]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Remove IntelFrameworkModulePkg
authorHao A Wu <hao.a.wu@intel.com>
Mon, 27 May 2019 06:19:41 +0000 (14:19 +0800)
committerHao A Wu <hao.a.wu@intel.com>
Wed, 3 Jul 2019 05:24:07 +0000 (13:24 +0800)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1605

Please note a subsequent commit will followed to update the information in
Maintainers.txt to reflect this package removal.

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Hao A Wu <hao.a.wu@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
346 files changed:
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaIo.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaIo.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/Fdc.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.inf [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPeiExtra.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.inf [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.inf [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.uni [deleted file]
IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.h [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverConfiguration.c [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverDiagnostics.c [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.h [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.uni [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeData.h [deleted file]
IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.c [deleted file]
IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.h [deleted file]
IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.uni [deleted file]
IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf [deleted file]
IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortExtra.uni [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosBlkIo.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosBlkIo.h [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosInt13.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxe.inf [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxe.uni [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/Edd.h [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/ComponentName.h [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.uni [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.h [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.uni [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16Extra.uni [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Misc.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Pxe.h [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/PxeUndi.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Snp16Dxe.inf [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideo.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideo.h [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideoDxe.uni [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideoDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VesaBiosExtensions.h [deleted file]
IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.nasm [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBda.c [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.uni [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBootSupport.c [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyCmos.c [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyIde.c [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyPci.c [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacySio.c [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/Thunk.c [deleted file]
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/X64/InterruptTable.nasm [deleted file]
IntelFrameworkModulePkg/Include/Guid/AcpiVariableCompatibility.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/BdsHii.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/BdsLibHii.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/BlockIoVendor.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/CapsuleDataFile.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/DataHubStatusCodeRecord.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/HdBootVariable.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/IntelFrameworkModulePkgTokenSpace.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/LastEnumLang.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/LegacyBios.h [deleted file]
IntelFrameworkModulePkg/Include/Guid/LegacyDevOrder.h [deleted file]
IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h [deleted file]
IntelFrameworkModulePkg/Include/Library/PlatformBdsLib.h [deleted file]
IntelFrameworkModulePkg/Include/Protocol/ExitPmAuth.h [deleted file]
IntelFrameworkModulePkg/Include/Protocol/IsaAcpi.h [deleted file]
IntelFrameworkModulePkg/Include/Protocol/IsaIo.h [deleted file]
IntelFrameworkModulePkg/Include/Protocol/OEMBadging.h [deleted file]
IntelFrameworkModulePkg/Include/Protocol/VgaMiniPort.h [deleted file]
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec [deleted file]
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc [deleted file]
IntelFrameworkModulePkg/IntelFrameworkModulePkg.uni [deleted file]
IntelFrameworkModulePkg/IntelFrameworkModulePkgExtra.uni [deleted file]
IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.c [deleted file]
IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.inf [deleted file]
IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.uni [deleted file]
IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf [deleted file]
IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.uni [deleted file]
IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/ReportStatusCodeLib.c [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/DevicePath.c [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.uni [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsStrings.uni [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/String.c [deleted file]
IntelFrameworkModulePkg/Library/GenericBdsLib/String.h [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.h [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.uni [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiStrings.uni [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiVfr.Vfr [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiVfr.h [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootManagerLib/InternalLegacyBm.h [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf [deleted file]
IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.uni [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LZMA-SDK-README.txt [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaArchCustomDecompressLib.inf [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaArchDecompressLib.uni [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLib.uni [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zVersion.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra86.c [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Compiler.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/CpuArch.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzHash.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.c [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Precomp.h [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/DOC/lzma-history.txt [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/DOC/lzma-sdk.txt [deleted file]
IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/UefiLzma.h [deleted file]
IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c [deleted file]
IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf [deleted file]
IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.uni [deleted file]
IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.c [deleted file]
IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.inf [deleted file]
IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.uni [deleted file]
IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.c [deleted file]
IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.inf [deleted file]
IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.uni [deleted file]
IntelFrameworkModulePkg/Library/PlatformBdsLibNull/BdsPlatform.c [deleted file]
IntelFrameworkModulePkg/Library/PlatformBdsLibNull/BdsPlatform.h [deleted file]
IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformBdsLib.uni [deleted file]
IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf [deleted file]
IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformData.c [deleted file]
IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/ReportStatusCodeLib.c [deleted file]
IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/ReportStatusCodeLibInternal.h [deleted file]
IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeReportStatusCodeLibFramework.inf [deleted file]
IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeReportStatusCodeLibFramework.uni [deleted file]
IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeSupport.c [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.h [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiVariableThunkPlatform.c [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.c [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.h [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportAcpiSupportProtocol.c [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Bm.vfr [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BmLib.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Bmstring.uni [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Data.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FE.vfr [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FileExplorer.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FormGuid.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManagerStrings.uni [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManagerVfr.Vfr [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManagerStrings.uni [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManagerVfr.Vfr [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManagerVfr.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DriverHealthVfr.Vfr [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPageStrings.uni [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPageVfr.Vfr [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/HwErrRecSupport.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/HwErrRecSupport.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/Language.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/Language.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/String.c [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/String.h [deleted file]
IntelFrameworkModulePkg/Universal/BdsDxe/Strings.uni [deleted file]
IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.c [deleted file]
IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.c [deleted file]
IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.h [deleted file]
IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIo.c [deleted file]
IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIo.h [deleted file]
IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/DataHubDxe/DataHub.c [deleted file]
IntelFrameworkModulePkg/Universal/DataHubDxe/DataHub.h [deleted file]
IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErr.c [deleted file]
IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/Ffs.c [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwPadFile.c [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVol.c [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolAttrib.c [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDriver.h [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolWrite.c [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/FlashUpdate.c [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/ParseUpdateProfile.c [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDispatcher.c [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriver.h [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateStrings.uni [deleted file]
IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegion.c [deleted file]
IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c [deleted file]
IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DataHubStatusCodeWorker.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.h [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxeExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.h [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.uni [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePeiExtra.uni [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/RtMemoryStatusCodeWorker.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/SerialStatusCodeWorker.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.h [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.uni [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxeExtra.uni [deleted file]

diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.c
deleted file mode 100644 (file)
index 9af9905..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/** @file\r
-  UEFI Component Name(2) protocol implementation for IsaBus driver.\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalIsaBus.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gIsaBusComponentName = {\r
-  IsaBusComponentNameGetDriverName,\r
-  IsaBusComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaBusComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaBusComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaBusComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaBusDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"ISA Bus Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mIsaBusDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gIsaBusComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_HANDLE                   ChildHandle  OPTIONAL,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **ControllerName\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.h
deleted file mode 100644 (file)
index 6202568..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/** @file\r
-  Header file for implementation of UEFI Component Name(2) protocol.\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _COMPONENT_NAME_H_\r
-#define _COMPONENT_NAME_H_\r
-\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gIsaBusComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gIsaBusComponentName2;\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_HANDLE                   ChildHandle  OPTIONAL,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **ControllerName\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h
deleted file mode 100644 (file)
index 9e6ecf3..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/** @file\r
-  The header file for ISA bus driver\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _INTERNAL_ISA_BUS_H_\r
-#define _INTERNAL_ISA_BUS_H_\r
-\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/ComponentName.h>\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/IsaAcpi.h>\r
-#include <Protocol/DriverBinding.h>\r
-#include <Protocol/GenericMemoryTest.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-#include "ComponentName.h"\r
-\r
-//\r
-// 8237 DMA registers\r
-//\r
-#define R_8237_DMA_BASE_CA_CH0                    0x00\r
-#define R_8237_DMA_BASE_CA_CH1                    0x02\r
-#define R_8237_DMA_BASE_CA_CH2                    0x04\r
-#define R_8237_DMA_BASE_CA_CH3                    0xd6\r
-#define R_8237_DMA_BASE_CA_CH5                    0xc4\r
-#define R_8237_DMA_BASE_CA_CH6                    0xc8\r
-#define R_8237_DMA_BASE_CA_CH7                    0xcc\r
-\r
-#define R_8237_DMA_BASE_CC_CH0                    0x01\r
-#define R_8237_DMA_BASE_CC_CH1                    0x03\r
-#define R_8237_DMA_BASE_CC_CH2                    0x05\r
-#define R_8237_DMA_BASE_CC_CH3                    0xd7\r
-#define R_8237_DMA_BASE_CC_CH5                    0xc6\r
-#define R_8237_DMA_BASE_CC_CH6                    0xca\r
-#define R_8237_DMA_BASE_CC_CH7                    0xce\r
-\r
-#define R_8237_DMA_MEM_LP_CH0                     0x87\r
-#define R_8237_DMA_MEM_LP_CH1                     0x83\r
-#define R_8237_DMA_MEM_LP_CH2                     0x81\r
-#define R_8237_DMA_MEM_LP_CH3                     0x82\r
-#define R_8237_DMA_MEM_LP_CH5                     0x8B\r
-#define R_8237_DMA_MEM_LP_CH6                     0x89\r
-#define R_8237_DMA_MEM_LP_CH7                     0x8A\r
-\r
-\r
-#define R_8237_DMA_COMMAND_CH0_3                  0x08\r
-#define R_8237_DMA_COMMAND_CH4_7                  0xd0\r
-#define   B_8237_DMA_COMMAND_GAP                  0x10\r
-#define   B_8237_DMA_COMMAND_CGE                  0x04\r
-\r
-\r
-#define R_8237_DMA_STA_CH0_3                      0xd8\r
-#define R_8237_DMA_STA_CH4_7                      0xd0\r
-\r
-#define R_8237_DMA_WRSMSK_CH0_3                   0x0a\r
-#define R_8237_DMA_WRSMSK_CH4_7                   0xd4\r
-#define   B_8237_DMA_WRSMSK_CMS                   0x04\r
-\r
-\r
-#define R_8237_DMA_CHMODE_CH0_3                   0x0b\r
-#define R_8237_DMA_CHMODE_CH4_7                   0xd6\r
-#define   V_8237_DMA_CHMODE_DEMAND                0x00\r
-#define   V_8237_DMA_CHMODE_SINGLE                0x40\r
-#define   V_8237_DMA_CHMODE_CASCADE               0xc0\r
-#define   B_8237_DMA_CHMODE_DECREMENT             0x20\r
-#define   B_8237_DMA_CHMODE_INCREMENT             0x00\r
-#define   B_8237_DMA_CHMODE_AE                    0x10\r
-#define   V_8237_DMA_CHMODE_VERIFY                0\r
-#define   V_8237_DMA_CHMODE_IO2MEM                0x04\r
-#define   V_8237_DMA_CHMODE_MEM2IO                0x08\r
-\r
-#define R_8237_DMA_CBPR_CH0_3                     0x0c\r
-#define R_8237_DMA_CBPR_CH4_7                     0xd8\r
-\r
-#define R_8237_DMA_MCR_CH0_3                      0x0d\r
-#define R_8237_DMA_MCR_CH4_7                      0xda\r
-\r
-#define R_8237_DMA_CLMSK_CH0_3                    0x0e\r
-#define R_8237_DMA_CLMSK_CH4_7                    0xdc\r
-\r
-#define R_8237_DMA_WRMSK_CH0_3                    0x0f\r
-#define R_8237_DMA_WRMSK_CH4_7                    0xde\r
-\r
-typedef enum {\r
-  IsaAccessTypeUnknown,\r
-  IsaAccessTypeIo,\r
-  IsaAccessTypeMem,\r
-  IsaAccessTypeMaxType\r
-} ISA_ACCESS_TYPE;\r
-\r
-//\r
-// 16 MB Memory Range\r
-//\r
-#define ISA_MAX_MEMORY_ADDRESS  0x1000000\r
-//\r
-// 64K I/O Range\r
-//\r
-#define ISA_MAX_IO_ADDRESS  0x10000\r
-\r
-typedef struct {\r
-  UINT8 Address;\r
-  UINT8 Page;\r
-  UINT8 Count;\r
-} EFI_ISA_DMA_REGISTERS;\r
-\r
-//\r
-// ISA I/O Device Structure\r
-//\r
-#define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')\r
-\r
-typedef struct {\r
-  UINT32                                    Signature;\r
-  EFI_HANDLE                                Handle;\r
-  EFI_ISA_IO_PROTOCOL                       IsaIo;\r
-  EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;\r
-  EFI_PCI_IO_PROTOCOL                       *PciIo;\r
-} ISA_IO_DEVICE;\r
-\r
-#define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)\r
-\r
-//\r
-// Mapping structure for performing ISA DMA to a buffer above 16 MB\r
-//\r
-typedef struct {\r
-  EFI_ISA_IO_PROTOCOL_OPERATION Operation;\r
-  UINTN                         NumberOfBytes;\r
-  UINTN                         NumberOfPages;\r
-  EFI_PHYSICAL_ADDRESS          HostAddress;\r
-  EFI_PHYSICAL_ADDRESS          MappedHostAddress;\r
-} ISA_MAP_INFO;\r
-\r
-//\r
-// EFI Driver Binding Protocol Interface Functions\r
-//\r
-\r
-/**\r
-  Tests to see if a controller can be managed by the ISA Bus Driver. If a child device is provided,\r
-  it further tests to see if this driver supports creating a handle for the specified child device.\r
-\r
-  Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\r
-  How the Start() function of a driver is implemented can affect how the Supported() function is implemented.\r
-\r
-  @param[in] This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] Controller           The handle of the controller to test.\r
-  @param[in] RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS             The device is supported by this driver.\r
-  @retval EFI_ALREADY_STARTED     The device is already being managed by this driver.\r
-  @retval EFI_ACCESS_DENIED       The device is already being managed by a different driver\r
-                                  or an application that requires exclusive access.\r
-  @retval EFI_UNSUPPORTED         The device is is not supported by this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  );\r
-\r
-/**\r
-  Start this driver on ControllerHandle.\r
-\r
-  Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\r
-  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been moved into this\r
-  common boot service. It is legal to call Start() from other locations, but the following calling\r
-  restrictions must be followed or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE.\r
-  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
-     EFI_DEVICE_PATH_PROTOCOL.\r
-  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
-     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
-                                   must support a protocol interface that supplies\r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-                                   This parameter is ignored by device drivers, and is optional for bus drivers.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
-                                   Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  );\r
-\r
-/**\r
-  Stop this driver on ControllerHandle.\r
-\r
-  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
-  As a result, much of the error checking on the parameters to Stop() has been moved\r
-  into this common boot service. It is legal to call Stop() from other locations,\r
-  but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
-     same driver's Start() function.\r
-  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
-     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
-     Start() function, and the Start() function must have called OpenProtocol() on\r
-     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-\r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
-                                support a bus specific I/O protocol for the driver\r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
-                                if NumberOfChildren is 0.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusControllerDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  * This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   * ChildHandleBuffer OPTIONAL\r
-  );\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-\r
-/**\r
-  Create EFI Handle for a ISA device found via ISA ACPI Protocol\r
-\r
-  @param[in] This                   The EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] Controller             The handle of ISA bus controller(PCI to ISA bridge)\r
-  @param[in] PciIo                  The Pointer to the PCI protocol\r
-  @param[in] ParentDevicePath       Device path of the ISA bus controller\r
-  @param[in] IsaDeviceResourceList  The resource list of the ISA device\r
-  @param[out] ChildDevicePath       The pointer to the child device.\r
-\r
-  @retval EFI_SUCCESS               The handle for the child device was created.\r
-  @retval EFI_OUT_OF_RESOURCES      The request could not be completed due to a lack of resources.\r
-  @retval EFI_DEVICE_ERROR          The handle for the child device can not be created.\r
-**/\r
-EFI_STATUS\r
-IsaCreateDevice (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_PCI_IO_PROTOCOL          *PciIo,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *ParentDevicePath,\r
-  IN EFI_ISA_ACPI_RESOURCE_LIST   *IsaDeviceResourceList,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL    **ChildDevicePath\r
-  );\r
-\r
-/**\r
-  Initializes an ISA I/O Instance\r
-\r
-  @param[in] IsaIoDevice            The iso device to be initialized.\r
-  @param[in] IsaDeviceResourceList  The resource list.\r
-\r
-**/\r
-VOID\r
-InitializeIsaIoInstance (\r
-  IN ISA_IO_DEVICE               *IsaIoDevice,\r
-  IN EFI_ISA_ACPI_RESOURCE_LIST  *IsaDevice\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaIo.h b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaIo.h
deleted file mode 100644 (file)
index 6a17dbe..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-/** @file\r
-  The header file for EFI_ISA_IO protocol implementation.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _INTERNAL_ISA_IO_H_\r
-#define _INTERNAL_ISA_IO_H_\r
-\r
-#include "InternalIsaBus.h"\r
-\r
-//\r
-// Bits definition of PcdIsaBusSupportedFeatures\r
-//\r
-#define PCD_ISA_BUS_SUPPORT_DMA                  BIT0\r
-#define PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA       BIT1\r
-#define PCD_ISA_BUS_SUPPORT_ISA_MEMORY           BIT2\r
-\r
-//\r
-// ISA I/O Support Function Prototypes\r
-//\r
-\r
-/**\r
-  Verifies access to an ISA device\r
-\r
-  @param[in] IsaIoDevice         The ISA device to be verified.\r
-  @param[in] Type                The Access type. The input must be either IsaAccessTypeMem or IsaAccessTypeIo.\r
-  @param[in] Width               The width of the memory operation.\r
-  @param[in] Count               The number of memory operations to perform.\r
-  @param[in] Offset              The offset in ISA memory space to start the memory operation.\r
-\r
-  @retval EFI_SUCCESS            Verify success.\r
-  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value.\r
-  @retval EFI_UNSUPPORTED        The device ont support the access type.\r
-**/\r
-EFI_STATUS\r
-IsaIoVerifyAccess (\r
-  IN ISA_IO_DEVICE              *IsaIoDevice,\r
-  IN ISA_ACCESS_TYPE            Type,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINTN                      Count,\r
-  IN UINT32                     Offset\r
-  );\r
-\r
-/**\r
-  Performs an ISA I/O Read Cycle\r
-\r
-  @param[in]  This              A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width             Specifies the width of the I/O operation.\r
-  @param[in]  Offset            The offset in ISA I/O space to start the I/O operation.\r
-  @param[in]  Count             The number of I/O operations to perform.\r
-  @param[out] Buffer            The destination buffer to store the results\r
-\r
-  @retval EFI_SUCCESS           The data was read from the device sucessfully.\r
-  @retval EFI_UNSUPPORTED       The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoIoRead (\r
-  IN  EFI_ISA_IO_PROTOCOL        *This,\r
-  IN  EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT32                     Offset,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Performs an ISA I/O Write Cycle\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Width               Specifies the width of the I/O operation.\r
-  @param[in] Offset              The offset in ISA I/O space to start the I/O operation.\r
-  @param[in] Count               The number of I/O operations to perform.\r
-  @param[in] Buffer              The source buffer to write data from\r
-\r
-  @retval EFI_SUCCESS            The data was writen to the device sucessfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoIoWrite (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     Offset,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Maps a memory region for DMA\r
-\r
-  @param This                    A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param Operation               Indicates the type of DMA (slave or bus master), and if\r
-                                 the DMA operation is going to read or write to system memory.\r
-  @param ChannelNumber           The slave channel number to use for this DMA operation.\r
-                                 If Operation and ChannelAttributes shows that this device\r
-                                 performs bus mastering DMA, then this field is ignored.\r
-                                 The legal range for this field is 0..7.\r
-  @param ChannelAttributes       The attributes of the DMA channel to use for this DMA operation\r
-  @param HostAddress             The system memory address to map to the device.\r
-  @param NumberOfBytes           On input the number of bytes to map.  On output the number\r
-                                 of bytes that were mapped.\r
-  @param DeviceAddress           The resulting map address for the bus master device to use\r
-                                 to access the hosts HostAddress.\r
-  @param Mapping                 A resulting value to pass to EFI_ISA_IO.Unmap().\r
-\r
-  @retval EFI_SUCCESS            The range was mapped for the returned NumberOfBytes.\r
-  @retval EFI_INVALID_PARAMETER  The Operation or HostAddress is undefined.\r
-  @retval EFI_UNSUPPORTED        The HostAddress can not be mapped as a common buffer.\r
-  @retval EFI_DEVICE_ERROR       The system hardware could not map the requested address.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMap (\r
-  IN     EFI_ISA_IO_PROTOCOL            *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     UINT8                          ChannelNumber  OPTIONAL,\r
-  IN     UINT32                         ChannelAttributes,\r
-  IN     VOID                           *HostAddress,\r
-  IN OUT UINTN                          *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
-  OUT    VOID                           **Mapping\r
-  );\r
-\r
-/**\r
-  Unmaps a memory region for DMA\r
-\r
-  @param[in] This           A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Mapping        The mapping value returned from EFI_ISA_IO.Map().\r
-\r
-  @retval EFI_SUCCESS       The range was unmapped.\r
-  @retval EFI_DEVICE_ERROR  The data was not committed to the target system memory.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoUnmap (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN VOID                 *Mapping\r
-  );\r
-\r
-/**\r
-  Flushes any posted write data to the system memory.\r
-\r
-  @param[in] This             A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-\r
-  @retval  EFI_SUCCESS        The buffers were flushed.\r
-  @retval  EFI_DEVICE_ERROR   The buffers were not flushed due to a hardware error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoFlush (\r
-  IN EFI_ISA_IO_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Writes I/O operation base address and count number to a 8 bit I/O Port.\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] AddrOffset          The address' offset.\r
-  @param[in] PageOffset          The page's offest.\r
-  @param[in] CountOffset         The count's offset.\r
-  @param[in] BaseAddress         The base address.\r
-  @param[in] Count               The number of I/O operations to perform.\r
-\r
-  @retval EFI_SUCCESS            Success.\r
-  @retval EFI_INVALID_PARAMETER  Parameter is invalid.\r
-  @retval EFI_UNSUPPORTED        The address range specified by these Offsets and Count is not valid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-WriteDmaPort (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINT32               AddrOffset,\r
-  IN UINT32               PageOffset,\r
-  IN UINT32               CountOffset,\r
-  IN UINT32               BaseAddress,\r
-  IN UINT16               Count\r
-  );\r
-\r
-/**\r
-  Writes an 8-bit I/O Port\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Offset              The offset in ISA IO space to start the IO operation.\r
-  @param[in] Value               The data to write port.\r
-\r
-  @retval EFI_SUCCESS            Success.\r
-  @retval EFI_INVALID_PARAMETER  Parameter is invalid.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Offset is not valid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-WritePort (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINT32               Offset,\r
-  IN UINT8                Value\r
-  );\r
-\r
-/**\r
-  Performs an ISA Memory Read Cycle\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width              Specifies the width of the memory operation.\r
-  @param[in]  Offset             The offset in ISA memory space to start the memory operation.\r
-  @param[in]  Count              The number of memory operations to perform.\r
-  @param[out] Buffer             The destination buffer to store the results\r
-\r
-  @retval EFI_SUCCESS            The data was read from the device successfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMemRead (\r
-  IN  EFI_ISA_IO_PROTOCOL        *This,\r
-  IN  EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT32                     Offset,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  );\r
-\r
-\r
-/**\r
-  Performs an ISA Memory Write Cycle\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Width               Specifies the width of the memory operation.\r
-  @param[in] Offset              The offset in ISA memory space to start the memory operation.\r
-  @param[in] Count               The number of memory operations to perform.\r
-  @param[in] Buffer              The source buffer to write data from\r
-\r
-  @retval EFI_SUCCESS            The data was written to the device sucessfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMemWrite (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     Offset,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Copy one region of ISA memory space to another region of ISA memory space on the ISA controller.\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width              Specifies the width of the memory copy operation.\r
-  @param[in]  DestOffset         The offset of the destination\r
-  @param[in]  SrcOffset          The offset of the source\r
-  @param[in]  Count              The number of memory copy  operations to perform\r
-\r
-  @retval EFI_SUCCESS            The data was copied sucessfully.\r
-  @retval EFI_UNSUPPORTED        The DestOffset or SrcOffset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoCopyMem (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     DestOffset,\r
-  IN UINT32                     SrcOffset,\r
-  IN UINTN                      Count\r
-  );\r
-\r
-/**\r
-  Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer mapping.\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Type               The type allocation to perform.\r
-  @param[in]  MemoryType         The type of memory to allocate.\r
-  @param[in]  Pages              The number of pages to allocate.\r
-  @param[out] HostAddress        A pointer to store the base address of the allocated range.\r
-  @param[in]  Attributes         The requested bit mask of attributes for the allocated range.\r
-\r
-  @retval EFI_SUCCESS            The requested memory pages were allocated.\r
-  @retval EFI_INVALID_PARAMETER  Type is invalid or MemoryType is invalid or HostAddress is NULL\r
-  @retval EFI_UNSUPPORTED        Attributes is unsupported or the memory range specified\r
-                                 by HostAddress, Pages, and Type is not available for common buffer use.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoAllocateBuffer (\r
-  IN  EFI_ISA_IO_PROTOCOL  *This,\r
-  IN  EFI_ALLOCATE_TYPE    Type,\r
-  IN  EFI_MEMORY_TYPE      MemoryType,\r
-  IN  UINTN                Pages,\r
-  OUT VOID                 **HostAddress,\r
-  IN  UINT64               Attributes\r
-  );\r
-\r
-/**\r
-  Frees memory that was allocated with EFI_ISA_IO.AllocateBuffer().\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Pages               The number of pages to free.\r
-  @param[in] HostAddress         The base address of the allocated range.\r
-\r
-  @retval EFI_SUCCESS            The requested memory pages were freed.\r
-  @retval EFI_INVALID_PARAMETER  The memory was not allocated with EFI_ISA_IO.AllocateBufer().\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoFreeBuffer (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINTN                Pages,\r
-  IN VOID                 *HostAddress\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.c b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.c
deleted file mode 100644 (file)
index 93097a8..0000000
+++ /dev/null
@@ -1,667 +0,0 @@
-/** @file\r
-  ISA Bus UEFI driver.\r
-\r
-  Discovers all the ISA Controllers and their resources by using the ISA ACPI\r
-  Protocol, produces an instance of the ISA I/O Protocol for every ISA\r
-  Controller found. This driver is designed to manage a PCI-to-ISA bridge Device\r
-  such as LPC bridge.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalIsaBus.h"\r
-\r
-//\r
-// ISA Bus Driver Global Variables\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver = {\r
-  IsaBusControllerDriverSupported,\r
-  IsaBusControllerDriverStart,\r
-  IsaBusControllerDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-/**\r
-  The main entry point for the ISA Bus driver.\r
-\r
-  @param[in] ImageHandle        The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable        A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS           The entry point is executed successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  There was not enough memory in pool to install all the protocols.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeIsaBus(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gIsaBusControllerDriver,\r
-             ImageHandle,\r
-             &gIsaBusComponentName,\r
-             &gIsaBusComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Tests to see if a controller can be managed by the ISA Bus Driver. If a child device is provided,\r
-  it further tests to see if this driver supports creating a handle for the specified child device.\r
-\r
-  Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\r
-  How the Start() function of a driver is implemented can affect how the Supported() function is implemented.\r
-\r
-  @param[in] This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] Controller           The handle of the controller to test.\r
-  @param[in] RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS             The device is supported by this driver.\r
-  @retval EFI_ALREADY_STARTED     The device is already being managed by this driver.\r
-  @retval EFI_ACCESS_DENIED       The device is already being managed by a different driver\r
-                                  or an application that requires exclusive access.\r
-  @retval EFI_UNSUPPORTED         The device is is not supported by this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
-  EFI_ISA_ACPI_PROTOCOL     *IsaAcpi;\r
-\r
-  //\r
-  // If RemainingDevicePath is not NULL, it should verify that the first device\r
-  // path node in RemainingDevicePath is an ACPI Device path node which is a\r
-  // legal Device Path Node for this bus driver's children.\r
-  //\r
-  if (RemainingDevicePath != NULL) {\r
-    if (RemainingDevicePath->Type != ACPI_DEVICE_PATH) {\r
-      return EFI_UNSUPPORTED;\r
-    } else if (RemainingDevicePath->SubType == ACPI_DP) {\r
-      if (DevicePathNodeLength (RemainingDevicePath) != sizeof (ACPI_HID_DEVICE_PATH)) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-    } else if (RemainingDevicePath->SubType == ACPI_EXTENDED_DP) {\r
-      if (DevicePathNodeLength (RemainingDevicePath) != sizeof (ACPI_EXTENDED_HID_DEVICE_PATH)) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-    } else {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-  //\r
-  // Try to open EFI DEVICE PATH protocol on the controller\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  //\r
-  // Although this driver creates all child handles at one time,\r
-  // but because all child handles may be not stopped at one time in EFI Driver Binding.Stop(),\r
-  // So it is allowed to create child handles again in successive calls to EFI Driver Binding.Start().\r
-  //\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  //\r
-  // Try to get Pci IO Protocol because it is assumed\r
-  // to have been opened by ISA ACPI driver\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  NULL,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Try to open the Isa Acpi protocol on the controller\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaAcpiProtocolGuid,\r
-                  (VOID **) &IsaAcpi,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Add more check to see if the child device is valid by calling IsaAcpi->DeviceEnumerate?\r
-  //\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaAcpiProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Start this driver on ControllerHandle.\r
-\r
-  Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\r
-  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been moved into this\r
-  common boot service. It is legal to call Start() from other locations, but the following calling\r
-  restrictions must be followed or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE.\r
-  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
-     EFI_DEVICE_PATH_PROTOCOL.\r
-  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
-     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
-                                   must support a protocol interface that supplies\r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-                                   This parameter is ignored by device drivers, and is optional for bus drivers.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
-                                   Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_PCI_IO_PROTOCOL                   *PciIo;\r
-  EFI_DEVICE_PATH_PROTOCOL              *ParentDevicePath;\r
-  EFI_ISA_ACPI_PROTOCOL                 *IsaAcpi;\r
-  EFI_ISA_ACPI_DEVICE_ID                *IsaDevice;\r
-  EFI_ISA_ACPI_RESOURCE_LIST            *ResourceList;\r
-  EFI_GENERIC_MEMORY_TEST_PROTOCOL      *GenMemoryTest;\r
-\r
-  //\r
-  // Local variables declaration for StatusCode reporting\r
-  //\r
-  EFI_DEVICE_PATH_PROTOCOL              *DevicePathData;\r
-\r
-  DevicePathData = NULL;\r
-\r
-  //\r
-  // Get Pci IO Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Open Device Path Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Open ISA Acpi Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaAcpiProtocolGuid,\r
-                  (VOID **) &IsaAcpi,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
-    //\r
-    // Close opened protocol\r
-    //\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-    return Status;\r
-  }\r
-  //\r
-  // The IsaBus driver will use memory below 16M, which is not tested yet,\r
-  // so call CompatibleRangeTest to test them. Since memory below 1M should\r
-  // be reserved to CSM, and 15M~16M might be reserved for Isa hole, test 1M\r
-  // ~15M here\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiGenericMemTestProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &GenMemoryTest\r
-                  );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = GenMemoryTest->CompatibleRangeTest (\r
-                              GenMemoryTest,\r
-                              0x100000,\r
-                              0xE00000\r
-                              );\r
-  }\r
-  //\r
-  // Report Status Code here since we will initialize the host controller\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    (EFI_IO_BUS_LPC | EFI_IOB_PC_INIT),\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // first init ISA interface\r
-  //\r
-  IsaAcpi->InterfaceInit (IsaAcpi);\r
-\r
-  //\r
-  // Report Status Code here since we will enable the host controller\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    (EFI_IO_BUS_LPC | EFI_IOB_PC_ENABLE),\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Create each ISA device handle in this ISA bus\r
-  //\r
-  IsaDevice = NULL;\r
-  do {\r
-    Status = IsaAcpi->DeviceEnumerate (IsaAcpi, &IsaDevice);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    //\r
-    // Get current resource of this ISA device\r
-    //\r
-    ResourceList  = NULL;\r
-    Status        = IsaAcpi->GetCurResource (IsaAcpi, IsaDevice, &ResourceList);\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Create handle for this ISA device\r
-    //\r
-    // If any child device handle was created in previous call to Start() and not stopped\r
-    // in previous call to Stop(), it will not be created again because the\r
-    // InstallMultipleProtocolInterfaces() boot service will reject same device path.\r
-    //\r
-    Status = IsaCreateDevice (\r
-               This,\r
-               Controller,\r
-               PciIo,\r
-               ParentDevicePath,\r
-               ResourceList,\r
-               &DevicePathData\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-    //\r
-    // Initialize ISA device\r
-    //\r
-    IsaAcpi->InitDevice (IsaAcpi, IsaDevice);\r
-\r
-    //\r
-    // Set resources for this ISA device\r
-    //\r
-    Status = IsaAcpi->SetResource (IsaAcpi, IsaDevice, ResourceList);\r
-\r
-    //\r
-    // Report Status Code here when failed to resource conflicts\r
-    //\r
-    if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {\r
-      //\r
-      // It's hard to tell which resource conflicts\r
-      //\r
-      REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-         EFI_ERROR_CODE,\r
-         (EFI_IO_BUS_LPC | EFI_IOB_EC_RESOURCE_CONFLICT),\r
-         DevicePathData\r
-         );\r
-\r
-    }\r
-    //\r
-    // Set power for this ISA device\r
-    //\r
-    IsaAcpi->SetPower (IsaAcpi, IsaDevice, TRUE);\r
-\r
-    //\r
-    // Enable this ISA device\r
-    //\r
-    IsaAcpi->EnableDevice (IsaAcpi, IsaDevice, TRUE);\r
-\r
-  } while (TRUE);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Stop this driver on ControllerHandle.\r
-\r
-  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
-  As a result, much of the error checking on the parameters to Stop() has been moved\r
-  into this common boot service. It is legal to call Stop() from other locations,\r
-  but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
-     same driver's Start() function.\r
-  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
-     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
-     Start() function, and the Start() function must have called OpenProtocol() on\r
-     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-\r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
-                                support a bus specific I/O protocol for the driver\r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
-                                if NumberOfChildren is 0.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaBusControllerDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  * This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   * ChildHandleBuffer OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  UINTN                               Index;\r
-  BOOLEAN                             AllChildrenStopped;\r
-  ISA_IO_DEVICE                       *IsaIoDevice;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-  EFI_PCI_IO_PROTOCOL                 *PciIo;\r
-\r
-  if (NumberOfChildren == 0) {\r
-    //\r
-    // Close the bus driver\r
-    //\r
-    Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    Controller\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiIsaAcpiProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    Controller\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Complete all outstanding transactions to Controller.\r
-  // Don't allow any new transaction to Controller to be started.\r
-  //\r
-  //\r
-  // Stop all the children\r
-  // Find all the ISA devices that were discovered on this PCI to ISA Bridge\r
-  // with the Start() function.\r
-  //\r
-  AllChildrenStopped = TRUE;\r
-\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-\r
-    Status = gBS->OpenProtocol (\r
-                    ChildHandleBuffer[Index],\r
-                    &gEfiIsaIoProtocolGuid,\r
-                    (VOID **) &IsaIo,\r
-                    This->DriverBindingHandle,\r
-                    Controller,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-\r
-      IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (IsaIo);\r
-\r
-      //\r
-      // Close the child handle\r
-      //\r
-\r
-      Status = gBS->CloseProtocol (\r
-                      Controller,\r
-                      &gEfiPciIoProtocolGuid,\r
-                      This->DriverBindingHandle,\r
-                      ChildHandleBuffer[Index]\r
-                      );\r
-      Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                      ChildHandleBuffer[Index],\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      IsaIoDevice->DevicePath,\r
-                      &gEfiIsaIoProtocolGuid,\r
-                      &IsaIoDevice->IsaIo,\r
-                      NULL\r
-                      );\r
-\r
-      if (!EFI_ERROR (Status)) {\r
-        FreePool (IsaIoDevice->DevicePath);\r
-        FreePool (IsaIoDevice);\r
-      } else {\r
-        //\r
-        // Re-open PCI IO Protocol on behalf of the child device\r
-        // because of failure of destroying the child device handle\r
-        //\r
-        gBS->OpenProtocol (\r
-               Controller,\r
-               &gEfiPciIoProtocolGuid,\r
-               (VOID **) &PciIo,\r
-               This->DriverBindingHandle,\r
-               ChildHandleBuffer[Index],\r
-               EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-               );\r
-      }\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      AllChildrenStopped = FALSE;\r
-    }\r
-  }\r
-\r
-  if (!AllChildrenStopped) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// Internal Function\r
-//\r
-\r
-/**\r
-  Create EFI Handle for a ISA device found via ISA ACPI Protocol\r
-\r
-  @param[in] This                   The EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] Controller             The handle of ISA bus controller(PCI to ISA bridge)\r
-  @param[in] PciIo                  The Pointer to the PCI protocol\r
-  @param[in] ParentDevicePath       Device path of the ISA bus controller\r
-  @param[in] IsaDeviceResourceList  The resource list of the ISA device\r
-  @param[out] ChildDevicePath       The pointer to the child device.\r
-\r
-  @retval EFI_SUCCESS               The handle for the child device was created.\r
-  @retval EFI_OUT_OF_RESOURCES      The request could not be completed due to a lack of resources.\r
-  @retval EFI_DEVICE_ERROR          The handle for the child device can not be created.\r
-**/\r
-EFI_STATUS\r
-IsaCreateDevice (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_PCI_IO_PROTOCOL          *PciIo,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *ParentDevicePath,\r
-  IN EFI_ISA_ACPI_RESOURCE_LIST   *IsaDeviceResourceList,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL    **ChildDevicePath\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-  EFI_DEV_PATH  Node;\r
-\r
-  //\r
-  // Initialize the PCI_IO_DEVICE structure\r
-  //\r
-  IsaIoDevice = AllocateZeroPool (sizeof (ISA_IO_DEVICE));\r
-  if (IsaIoDevice == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  IsaIoDevice->Signature  = ISA_IO_DEVICE_SIGNATURE;\r
-  IsaIoDevice->Handle     = NULL;\r
-  IsaIoDevice->PciIo      = PciIo;\r
-\r
-  //\r
-  // Initialize the ISA I/O instance structure\r
-  //\r
-  InitializeIsaIoInstance (IsaIoDevice, IsaDeviceResourceList);\r
-\r
-  //\r
-  // Build the child device path\r
-  //\r
-  Node.DevPath.Type     = ACPI_DEVICE_PATH;\r
-  Node.DevPath.SubType  = ACPI_DP;\r
-  SetDevicePathNodeLength (&Node.DevPath, sizeof (ACPI_HID_DEVICE_PATH));\r
-  Node.Acpi.HID = IsaDeviceResourceList->Device.HID;\r
-  Node.Acpi.UID = IsaDeviceResourceList->Device.UID;\r
-\r
-  IsaIoDevice->DevicePath = AppendDevicePathNode (\r
-                              ParentDevicePath,\r
-                              &Node.DevPath\r
-                              );\r
-\r
-  if (IsaIoDevice->DevicePath == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  *ChildDevicePath = IsaIoDevice->DevicePath;\r
-\r
-  //\r
-  // Create a child handle and install Device Path and ISA I/O protocols\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &IsaIoDevice->Handle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  IsaIoDevice->DevicePath,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  &IsaIoDevice->IsaIo,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  IsaIoDevice->Handle,\r
-                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-           IsaIoDevice->Handle,\r
-           &gEfiDevicePathProtocolGuid,\r
-           IsaIoDevice->DevicePath,\r
-           &gEfiIsaIoProtocolGuid,\r
-           &IsaIoDevice->IsaIo,\r
-           NULL\r
-           );\r
-  }\r
-\r
-Done:\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    if (IsaIoDevice->DevicePath != NULL) {\r
-      FreePool (IsaIoDevice->DevicePath);\r
-    }\r
-\r
-    FreePool (IsaIoDevice);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf
deleted file mode 100644 (file)
index 64a169d..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-## @file\r
-# Generates ISA I/O Protocols based on the ISA ACPI Protocol instances.\r
-#\r
-# Discovers all the ISA Controllers and their resources by using the ISA ACPI\r
-# Protocol, produces an instance of the ISA I/O Protocol for every ISA\r
-# Controller found. This driver is designed to manage a PCI-to-ISA bridge Device\r
-# such as an LPC bridge.\r
-#\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = IsaBusDxe\r
-  MODULE_UNI_FILE                = IsaBusDxe.uni\r
-  FILE_GUID                      = 240612B5-A063-11d4-9A3A-0090273FC14D\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializeIsaBus\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#  DRIVER_BINDING                = gIsaBusControllerDriver\r
-#  COMPONENT_NAME                = gIsaBusComponentName;\r
-#  COMPONENT_NAME2               = gIsaBusComponentName2;\r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  IsaIo.c\r
-  IsaBus.c\r
-  InternalIsaIo.h\r
-  InternalIsaBus.h\r
-  ComponentName.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  ReportStatusCodeLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  DevicePathLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-\r
-[Protocols]\r
-  gEfiIsaIoProtocolGuid                         ## BY_START\r
-  gEfiDevicePathProtocolGuid                    ## BY_START\r
-  gEfiIsaAcpiProtocolGuid                       ## TO_START\r
-  gEfiPciIoProtocolGuid                         ## TO_START\r
-  gEfiDevicePathProtocolGuid                    ## TO_START\r
-  gEfiGenericMemTestProtocolGuid                ## TO_START\r
-\r
-[Pcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSupportedFeatures  ## CONSUMES\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  IsaBusDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.uni
deleted file mode 100644 (file)
index 1497838..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// /** @file\r
-// Generates ISA I/O Protocols based on the ISA ACPI Protocol instances.\r
-//\r
-// Discovers all the ISA Controllers and their resources by using the ISA ACPI\r
-// Protocol, produces an instance of the ISA I/O Protocol for every ISA\r
-// Controller found. This driver is designed to manage a PCI-to-ISA bridge Device\r
-// such as an LPC bridge.\r
-//\r
-// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Generates ISA I/O Protocols based on the ISA ACPI Protocol instances"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Discovers all the ISA Controllers and their resources by using the ISA ACPI Protocol, and produces an instance of the ISA I/O Protocol for every ISA Controller found. This driver is designed to manage a PCI-to-ISA bridge Device such as an LPC bridge."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxeExtra.uni
deleted file mode 100644 (file)
index 0df6477..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// IsaBusDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"ISA Bus DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaIo.c b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaIo.c
deleted file mode 100644 (file)
index 5997bc6..0000000
+++ /dev/null
@@ -1,1457 +0,0 @@
-/** @file\r
-  The implementation for EFI_ISA_IO_PROTOCOL.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalIsaIo.h"\r
-\r
-//\r
-// Module Variables\r
-//\r
-EFI_ISA_IO_PROTOCOL mIsaIoInterface = {\r
-  {\r
-    IsaIoMemRead,\r
-    IsaIoMemWrite\r
-  },\r
-  {\r
-    IsaIoIoRead,\r
-    IsaIoIoWrite\r
-  },\r
-  IsaIoCopyMem,\r
-  IsaIoMap,\r
-  IsaIoUnmap,\r
-  IsaIoAllocateBuffer,\r
-  IsaIoFreeBuffer,\r
-  IsaIoFlush,\r
-  NULL,\r
-  0,\r
-  NULL\r
-};\r
-\r
-EFI_ISA_DMA_REGISTERS  mDmaRegisters[8] = {\r
-  {\r
-    0x00,\r
-    0x87,\r
-    0x01\r
-  },\r
-  {\r
-    0x02,\r
-    0x83,\r
-    0x03\r
-  },\r
-  {\r
-    0x04,\r
-    0x81,\r
-    0x05\r
-  },\r
-  {\r
-    0x06,\r
-    0x82,\r
-    0x07\r
-  },\r
-  {\r
-    0x00,\r
-    0x00,\r
-    0x00\r
-  },  // Channel 4 is invalid\r
-  {\r
-    0xC4,\r
-    0x8B,\r
-    0xC6\r
-  },\r
-  {\r
-    0xC8,\r
-    0x89,\r
-    0xCA\r
-  },\r
-  {\r
-    0xCC,\r
-    0x8A,\r
-    0xCE\r
-  },\r
-};\r
-\r
-/**\r
-  Initializes an ISA I/O Instance\r
-\r
-  @param[in] IsaIoDevice            The iso device to be initialized.\r
-  @param[in] IsaDeviceResourceList  The resource list.\r
-\r
-**/\r
-VOID\r
-InitializeIsaIoInstance (\r
-  IN ISA_IO_DEVICE               *IsaIoDevice,\r
-  IN EFI_ISA_ACPI_RESOURCE_LIST  *IsaDeviceResourceList\r
-  )\r
-{\r
-  //\r
-  // Use the ISA IO Protocol structure template to initialize the ISA IO instance\r
-  //\r
-  CopyMem (\r
-    &IsaIoDevice->IsaIo,\r
-    &mIsaIoInterface,\r
-    sizeof (EFI_ISA_IO_PROTOCOL)\r
-    );\r
-\r
-  IsaIoDevice->IsaIo.ResourceList = IsaDeviceResourceList;\r
-}\r
-\r
-/**\r
-  Performs an ISA I/O Read Cycle\r
-\r
-  @param[in]  This              A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width             Specifies the width of the I/O operation.\r
-  @param[in]  Offset            The offset in ISA I/O space to start the I/O operation.\r
-  @param[in]  Count             The number of I/O operations to perform.\r
-  @param[out] Buffer            The destination buffer to store the results\r
-\r
-  @retval EFI_SUCCESS           The data was read from the device sucessfully.\r
-  @retval EFI_UNSUPPORTED       The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoIoRead (\r
-  IN  EFI_ISA_IO_PROTOCOL        *This,\r
-  IN  EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT32                     Offset,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify Isa IO Access\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeIo,\r
-             Width,\r
-             Count,\r
-             Offset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->Io.Read (\r
-                                    IsaIoDevice->PciIo,\r
-                                    (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                    Offset,\r
-                                    Count,\r
-                                    Buffer\r
-                                    );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Performs an ISA I/O Write Cycle\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Width               Specifies the width of the I/O operation.\r
-  @param[in] Offset              The offset in ISA I/O space to start the I/O operation.\r
-  @param[in] Count               The number of I/O operations to perform.\r
-  @param[in] Buffer              The source buffer to write data from\r
-\r
-  @retval EFI_SUCCESS            The data was writen to the device sucessfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoIoWrite (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     Offset,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify Isa IO Access\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeIo,\r
-             Width,\r
-             Count,\r
-             Offset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->Io.Write (\r
-                                    IsaIoDevice->PciIo,\r
-                                    (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                    Offset,\r
-                                    Count,\r
-                                    Buffer\r
-                                    );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Writes an 8-bit I/O Port\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Offset              The offset in ISA IO space to start the IO operation.\r
-  @param[in] Value               The data to write port.\r
-\r
-  @retval EFI_SUCCESS            Success.\r
-  @retval EFI_INVALID_PARAMETER  Parameter is invalid.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Offset is not valid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-WritePort (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINT32               Offset,\r
-  IN UINT8                Value\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  Status = IsaIoDevice->PciIo->Io.Write (\r
-                                    IsaIoDevice->PciIo,\r
-                                    EfiPciIoWidthUint8,\r
-                                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                    Offset,\r
-                                    1,\r
-                                    &Value\r
-                                    );\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-    return Status;\r
-  }\r
-\r
-  gBS->Stall (50);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Writes I/O operation base address and count number to a 8 bit I/O Port.\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] AddrOffset          The address' offset.\r
-  @param[in] PageOffset          The page's offest.\r
-  @param[in] CountOffset         The count's offset.\r
-  @param[in] BaseAddress         The base address.\r
-  @param[in] Count               The number of I/O operations to perform.\r
-\r
-  @retval EFI_SUCCESS            Success.\r
-  @retval EFI_INVALID_PARAMETER  Parameter is invalid.\r
-  @retval EFI_UNSUPPORTED        The address range specified by these Offsets and Count is not valid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-WriteDmaPort (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINT32               AddrOffset,\r
-  IN UINT32               PageOffset,\r
-  IN UINT32               CountOffset,\r
-  IN UINT32               BaseAddress,\r
-  IN UINT16               Count\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = WritePort (This, AddrOffset, (UINT8) (BaseAddress & 0xff));\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, AddrOffset, (UINT8) ((BaseAddress >> 8) & 0xff));\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, PageOffset, (UINT8) ((BaseAddress >> 16) & 0xff));\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, CountOffset, (UINT8) (Count & 0xff));\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, CountOffset, (UINT8) ((Count >> 8) & 0xff));\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Unmaps a memory region for DMA\r
-\r
-  @param[in] This           A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Mapping        The mapping value returned from EFI_ISA_IO.Map().\r
-\r
-  @retval EFI_SUCCESS       The range was unmapped.\r
-  @retval EFI_DEVICE_ERROR  The data was not committed to the target system memory.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoUnmap (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN VOID                 *Mapping\r
-  )\r
-{\r
-  ISA_MAP_INFO  *IsaMapInfo;\r
-\r
-  //\r
-  // Check if DMA is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // See if the Map() operation associated with this Unmap() required a mapping\r
-  // buffer.If a mapping buffer was not required, then this function simply\r
-  // returns EFI_SUCCESS.\r
-  //\r
-  if (Mapping != NULL) {\r
-    //\r
-    // Get the MAP_INFO structure from Mapping\r
-    //\r
-    IsaMapInfo = (ISA_MAP_INFO *) Mapping;\r
-\r
-    //\r
-    // If this is a write operation from the Agent's point of view,\r
-    // then copy the contents of the mapped buffer into the real buffer\r
-    // so the processor can read the contents of the real buffer.\r
-    //\r
-    if (IsaMapInfo->Operation == EfiIsaIoOperationBusMasterWrite) {\r
-      CopyMem (\r
-        (VOID *) (UINTN) IsaMapInfo->HostAddress,\r
-        (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,\r
-        IsaMapInfo->NumberOfBytes\r
-        );\r
-    }\r
-    //\r
-    // Free the mapped buffer and the MAP_INFO structure.\r
-    //\r
-    gBS->FreePages (IsaMapInfo->MappedHostAddress, IsaMapInfo->NumberOfPages);\r
-    FreePool (IsaMapInfo);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Flushes any posted write data to the system memory.\r
-\r
-  @param[in] This             A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-\r
-  @retval  EFI_SUCCESS        The buffers were flushed.\r
-  @retval  EFI_DEVICE_ERROR   The buffers were not flushed due to a hardware error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoFlush (\r
-  IN EFI_ISA_IO_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  Status = IsaIoDevice->PciIo->Flush (IsaIoDevice->PciIo);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Verifies access to an ISA device\r
-\r
-  @param[in] IsaIoDevice         The ISA device to be verified.\r
-  @param[in] Type                The Access type. The input must be either IsaAccessTypeMem or IsaAccessTypeIo.\r
-  @param[in] Width               The width of the memory operation.\r
-  @param[in] Count               The number of memory operations to perform.\r
-  @param[in] Offset              The offset in ISA memory space to start the memory operation.\r
-\r
-  @retval EFI_SUCCESS            Verify success.\r
-  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value.\r
-  @retval EFI_UNSUPPORTED        The device ont support the access type.\r
-**/\r
-EFI_STATUS\r
-IsaIoVerifyAccess (\r
-  IN ISA_IO_DEVICE              *IsaIoDevice,\r
-  IN ISA_ACCESS_TYPE            Type,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINTN                      Count,\r
-  IN UINT32                     Offset\r
-  )\r
-{\r
-  EFI_ISA_ACPI_RESOURCE *Item;\r
-  EFI_STATUS            Status;\r
-\r
-  if ((UINT32)Width >= EfiIsaIoWidthMaximum ||\r
-      Width == EfiIsaIoWidthReserved ||\r
-      Width == EfiIsaIoWidthFifoReserved ||\r
-      Width == EfiIsaIoWidthFillReserved\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // If Width is EfiIsaIoWidthFifoUintX then convert to EfiIsaIoWidthUintX\r
-  // If Width is EfiIsaIoWidthFillUintX then convert to EfiIsaIoWidthUintX\r
-  //\r
-  if (Width >= EfiIsaIoWidthFifoUint8 && Width < EfiIsaIoWidthFifoReserved) {\r
-    Count = 1;\r
-  }\r
-\r
-  Width = (EFI_ISA_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-\r
-  Status  = EFI_UNSUPPORTED;\r
-  Item    = IsaIoDevice->IsaIo.ResourceList->ResourceItem;\r
-  while (Item->Type != EfiIsaAcpiResourceEndOfList) {\r
-    if ((Type == IsaAccessTypeMem && Item->Type == EfiIsaAcpiResourceMemory) ||\r
-        (Type == IsaAccessTypeIo && Item->Type == EfiIsaAcpiResourceIo)) {\r
-      if (Offset >= Item->StartRange && (Offset + Count * (UINT32)(1 << Width)) - 1 <= Item->EndRange) {\r
-        return EFI_SUCCESS;\r
-      }\r
-\r
-      if (Offset >= Item->StartRange && Offset <= Item->EndRange) {\r
-        Status = EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-\r
-    Item++;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Performs an ISA Memory Read Cycle\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width              Specifies the width of the memory operation.\r
-  @param[in]  Offset             The offset in ISA memory space to start the memory operation.\r
-  @param[in]  Count              The number of memory operations to perform.\r
-  @param[out] Buffer             The destination buffer to store the results\r
-\r
-  @retval EFI_SUCCESS            The data was read from the device successfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMemRead (\r
-  IN  EFI_ISA_IO_PROTOCOL        *This,\r
-  IN  EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT32                     Offset,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  //\r
-  // Check if ISA memory is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify the Isa Io Access\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeMem,\r
-             Width,\r
-             Count,\r
-             Offset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->Mem.Read (\r
-                                     IsaIoDevice->PciIo,\r
-                                     (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                     EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                     Offset,\r
-                                     Count,\r
-                                     Buffer\r
-                                     );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Performs an ISA Memory Write Cycle\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Width               Specifies the width of the memory operation.\r
-  @param[in] Offset              The offset in ISA memory space to start the memory operation.\r
-  @param[in] Count               The number of memory operations to perform.\r
-  @param[in] Buffer              The source buffer to write data from\r
-\r
-  @retval EFI_SUCCESS            The data was written to the device sucessfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMemWrite (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     Offset,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  //\r
-  // Check if ISA memory is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify Isa IO Access\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeMem,\r
-             Width,\r
-             Count,\r
-             Offset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->Mem.Write (\r
-                                     IsaIoDevice->PciIo,\r
-                                     (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                     EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                     Offset,\r
-                                     Count,\r
-                                     Buffer\r
-                                     );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Copy one region of ISA memory space to another region of ISA memory space on the ISA controller.\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width              Specifies the width of the memory copy operation.\r
-  @param[in]  DestOffset         The offset of the destination\r
-  @param[in]  SrcOffset          The offset of the source\r
-  @param[in]  Count              The number of memory copy  operations to perform\r
-\r
-  @retval EFI_SUCCESS            The data was copied sucessfully.\r
-  @retval EFI_UNSUPPORTED        The DestOffset or SrcOffset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoCopyMem (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     DestOffset,\r
-  IN UINT32                     SrcOffset,\r
-  IN UINTN                      Count\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  //\r
-  // Check if ISA memory is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify Isa IO Access for destination and source\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeMem,\r
-             Width,\r
-             Count,\r
-             DestOffset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeMem,\r
-             Width,\r
-             Count,\r
-             SrcOffset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->CopyMem (\r
-                                 IsaIoDevice->PciIo,\r
-                                 (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                 EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                 DestOffset,\r
-                                 EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                 SrcOffset,\r
-                                 Count\r
-                                 );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Maps a memory region for DMA, note this implementation\r
-  only supports slave read/write operation to save code size.\r
-\r
-  @param This                    A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param Operation               Indicates the type of DMA (slave or bus master), and if\r
-                                 the DMA operation is going to read or write to system memory.\r
-  @param ChannelNumber           The slave channel number to use for this DMA operation.\r
-                                 If Operation and ChannelAttributes shows that this device\r
-                                 performs bus mastering DMA, then this field is ignored.\r
-                                 The legal range for this field is 0..7.\r
-  @param ChannelAttributes       The attributes of the DMA channel to use for this DMA operation\r
-  @param HostAddress             The system memory address to map to the device.\r
-  @param NumberOfBytes           On input the number of bytes to map.  On output the number\r
-                                 of bytes that were mapped.\r
-  @param DeviceAddress           The resulting map address for the bus master device to use\r
-                                 to access the hosts HostAddress.\r
-  @param Mapping                 A resulting value to pass to EFI_ISA_IO.Unmap().\r
-\r
-  @retval EFI_SUCCESS            The range was mapped for the returned NumberOfBytes.\r
-  @retval EFI_INVALID_PARAMETER  The Operation or HostAddress is undefined.\r
-  @retval EFI_UNSUPPORTED        The HostAddress can not be mapped as a common buffer.\r
-  @retval EFI_DEVICE_ERROR       The system hardware could not map the requested address.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-IsaIoMapOnlySupportSlaveReadWrite (\r
-  IN     EFI_ISA_IO_PROTOCOL            *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     UINT8                          ChannelNumber  OPTIONAL,\r
-  IN     UINT32                         ChannelAttributes,\r
-  IN     VOID                           *HostAddress,\r
-  IN OUT UINTN                          *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
-  OUT    VOID                           **Mapping\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-  ISA_MAP_INFO          *IsaMapInfo;\r
-  UINT8                 DmaMode;\r
-  UINTN                 MaxNumberOfBytes;\r
-  UINT32                BaseAddress;\r
-  UINT16                Count;\r
-  UINT8                 DmaMask;\r
-  UINT8                 DmaClear;\r
-  UINT8                 DmaChannelMode;\r
-\r
-  if ((NULL == This) ||\r
-      (NULL == HostAddress) ||\r
-      (NULL == NumberOfBytes) ||\r
-      (NULL == DeviceAddress) ||\r
-      (NULL == Mapping)\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Initialize the return values to their defaults\r
-  //\r
-  *Mapping = NULL;\r
-\r
-  //\r
-  // Make sure the Operation parameter is valid.\r
-  // Light IsaIo only supports two operations.\r
-  //\r
-  if (!(Operation == EfiIsaIoOperationSlaveRead ||\r
-        Operation == EfiIsaIoOperationSlaveWrite)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (ChannelNumber >= 4) {\r
-    //\r
-    // The Light IsaIo doesn't support channelNumber larger than 4.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Map the HostAddress to a DeviceAddress.\r
-  //\r
-  PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;\r
-  if ((PhysicalAddress + *NumberOfBytes) > ISA_MAX_MEMORY_ADDRESS) {\r
-    //\r
-    // Common Buffer operations can not be remapped.  If the common buffer\r
-    // is above 16MB, then it is not possible to generate a mapping, so return\r
-    // an error.\r
-    //\r
-    if (Operation == EfiIsaIoOperationBusMasterCommonBuffer) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    //\r
-    // Allocate an ISA_MAP_INFO structure to remember the mapping when Unmap()\r
-    // is called later.\r
-    //\r
-    IsaMapInfo = AllocatePool (sizeof (ISA_MAP_INFO));\r
-    if (IsaMapInfo == NULL) {\r
-      *NumberOfBytes = 0;\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    //\r
-    // Return a pointer to the MAP_INFO structure in Mapping\r
-    //\r
-    *Mapping = IsaMapInfo;\r
-\r
-    //\r
-    // Initialize the MAP_INFO structure\r
-    //\r
-    IsaMapInfo->Operation         = Operation;\r
-    IsaMapInfo->NumberOfBytes     = *NumberOfBytes;\r
-    IsaMapInfo->NumberOfPages     = EFI_SIZE_TO_PAGES (*NumberOfBytes);\r
-    IsaMapInfo->HostAddress       = PhysicalAddress;\r
-    IsaMapInfo->MappedHostAddress = ISA_MAX_MEMORY_ADDRESS - 1;\r
-\r
-    //\r
-    // Allocate a buffer below 16MB to map the transfer to.\r
-    //\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiBootServicesData,\r
-                    IsaMapInfo->NumberOfPages,\r
-                    &IsaMapInfo->MappedHostAddress\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (IsaMapInfo);\r
-      *NumberOfBytes  = 0;\r
-      *Mapping        = NULL;\r
-      return Status;\r
-    }\r
-    //\r
-    // If this is a read operation from the DMA agents's point of view,\r
-    // then copy the contents of the real buffer into the mapped buffer\r
-    // so the DMA agent can read the contents of the real buffer.\r
-    //\r
-    if (Operation == EfiIsaIoOperationSlaveRead) {\r
-      CopyMem (\r
-        (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,\r
-        (VOID *) (UINTN) IsaMapInfo->HostAddress,\r
-        IsaMapInfo->NumberOfBytes\r
-        );\r
-    }\r
-    //\r
-    // The DeviceAddress is the address of the maped buffer below 16 MB\r
-    //\r
-    *DeviceAddress = IsaMapInfo->MappedHostAddress;\r
-  } else {\r
-    //\r
-    // The transfer is below 16 MB, so the DeviceAddress is simply the\r
-    // HostAddress\r
-    //\r
-    *DeviceAddress = PhysicalAddress;\r
-  }\r
-\r
-  //\r
-  // Figure out what to program into the DMA Channel Mode Register\r
-  //\r
-  DmaMode = (UINT8) (B_8237_DMA_CHMODE_INCREMENT | (ChannelNumber & 0x03));\r
-  if (Operation == EfiIsaIoOperationSlaveRead) {\r
-    DmaMode |= V_8237_DMA_CHMODE_MEM2IO;\r
-  } else {\r
-    DmaMode |= V_8237_DMA_CHMODE_IO2MEM;\r
-  }\r
-  //\r
-  // We only support EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE in simplified IsaIo\r
-  //\r
-  DmaMode |= V_8237_DMA_CHMODE_SINGLE;\r
-\r
-  //\r
-  // A Slave DMA transfer can not cross a 64K boundary.\r
-  // Compute *NumberOfBytes based on this restriction.\r
-  //\r
-  MaxNumberOfBytes = 0x10000 - ((UINT32) (*DeviceAddress) & 0xffff);\r
-  if (*NumberOfBytes > MaxNumberOfBytes) {\r
-    *NumberOfBytes = MaxNumberOfBytes;\r
-  }\r
-  //\r
-  // Compute the values to program into the BaseAddress and Count registers\r
-  // of the Slave DMA controller\r
-  //\r
-  BaseAddress = (UINT32) (*DeviceAddress);\r
-  Count       = (UINT16) (*NumberOfBytes - 1);\r
-  //\r
-  // Program the DMA Write Single Mask Register for ChannelNumber\r
-  // Clear the DMA Byte Pointer Register\r
-  //\r
-  DmaMask         = R_8237_DMA_WRSMSK_CH0_3;\r
-  DmaClear        = R_8237_DMA_CBPR_CH0_3;\r
-  DmaChannelMode  = R_8237_DMA_CHMODE_CH0_3;\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaMask,\r
-             (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaClear,\r
-             (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, DmaChannelMode, DmaMode);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WriteDmaPort (\r
-             This,\r
-             mDmaRegisters[ChannelNumber].Address,\r
-             mDmaRegisters[ChannelNumber].Page,\r
-             mDmaRegisters[ChannelNumber].Count,\r
-             BaseAddress,\r
-             Count\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaMask,\r
-             (UINT8) (ChannelNumber & 0x03)\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Maps a memory region for DMA. This implementation implement the\r
-  the full mapping support.\r
-\r
-  @param This                    A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param Operation               Indicates the type of DMA (slave or bus master), and if\r
-                                 the DMA operation is going to read or write to system memory.\r
-  @param ChannelNumber           The slave channel number to use for this DMA operation.\r
-                                 If Operation and ChannelAttributes shows that this device\r
-                                 performs bus mastering DMA, then this field is ignored.\r
-                                 The legal range for this field is 0..7.\r
-  @param ChannelAttributes       The attributes of the DMA channel to use for this DMA operation\r
-  @param HostAddress             The system memory address to map to the device.\r
-  @param NumberOfBytes           On input the number of bytes to map.  On output the number\r
-                                 of bytes that were mapped.\r
-  @param DeviceAddress           The resulting map address for the bus master device to use\r
-                                 to access the hosts HostAddress.\r
-  @param Mapping                 A resulting value to pass to EFI_ISA_IO.Unmap().\r
-\r
-  @retval EFI_SUCCESS           - The range was mapped for the returned NumberOfBytes.\r
-  @retval EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined.\r
-  @retval EFI_UNSUPPORTED       - The HostAddress can not be mapped as a common buffer.\r
-  @retval EFI_DEVICE_ERROR      - The system hardware could not map the requested address.\r
-  @retval EFI_OUT_OF_RESOURCES  - The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-IsaIoMapFullSupport (\r
-  IN     EFI_ISA_IO_PROTOCOL                                  *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_OPERATION                        Operation,\r
-  IN     UINT8                                                ChannelNumber         OPTIONAL,\r
-  IN     UINT32                                               ChannelAttributes,\r
-  IN     VOID                                                 *HostAddress,\r
-  IN OUT UINTN                                                *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS                                 *DeviceAddress,\r
-  OUT    VOID                                                 **Mapping\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  BOOLEAN               Master;\r
-  BOOLEAN               Read;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-  ISA_MAP_INFO          *IsaMapInfo;\r
-  UINT8                 DmaMode;\r
-  UINTN                 MaxNumberOfBytes;\r
-  UINT32                BaseAddress;\r
-  UINT16                Count;\r
-  UINT8                 DmaMask;\r
-  UINT8                 DmaClear;\r
-  UINT8                 DmaChannelMode;\r
-\r
-  if ((NULL == This) ||\r
-      (NULL == HostAddress) ||\r
-      (NULL == NumberOfBytes) ||\r
-      (NULL == DeviceAddress) ||\r
-      (NULL == Mapping)\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Initialize the return values to their defaults\r
-  //\r
-  *Mapping = NULL;\r
-\r
-  //\r
-  // Make sure the Operation parameter is valid\r
-  //\r
-  if ((UINT32)Operation >= EfiIsaIoOperationMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (ChannelNumber >= 8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // See if this is a Slave DMA Operation\r
-  //\r
-  Master  = TRUE;\r
-  Read    = FALSE;\r
-  if (Operation == EfiIsaIoOperationSlaveRead) {\r
-    Operation = EfiIsaIoOperationBusMasterRead;\r
-    Master    = FALSE;\r
-    Read      = TRUE;\r
-  }\r
-\r
-  if (Operation == EfiIsaIoOperationSlaveWrite) {\r
-    Operation = EfiIsaIoOperationBusMasterWrite;\r
-    Master    = FALSE;\r
-    Read      = FALSE;\r
-  }\r
-\r
-  if (!Master) {\r
-    //\r
-    // Make sure that ChannelNumber is a valid channel number\r
-    // Channel 4 is used to cascade, so it is illegal.\r
-    //\r
-    if (ChannelNumber == 4 || ChannelNumber > 7) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    //\r
-    // This implementation only support COMPATIBLE DMA Transfers\r
-    //\r
-    if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE) == 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if ((ChannelAttributes &\r
-         (EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A |\r
-          EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B |\r
-          EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C)) != 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (ChannelNumber < 4) {\r
-      //\r
-      // If this is Channel 0..3, then the width must be 8 bit\r
-      //\r
-      if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) == 0) ||\r
-          ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) != 0)\r
-          ) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    } else {\r
-      //\r
-      // If this is Channel 4..7, then the width must be 16 bit\r
-      //\r
-      if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) != 0) ||\r
-          ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) == 0)) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-    //\r
-    // Either Demand Mode or Single Mode must be selected, but not both\r
-    //\r
-    if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {\r
-      if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    } else {\r
-      if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) == 0) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Map the HostAddress to a DeviceAddress.\r
-  //\r
-  PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;\r
-  if ((PhysicalAddress +*NumberOfBytes) > ISA_MAX_MEMORY_ADDRESS) {\r
-    //\r
-    // Common Buffer operations can not be remapped.  If the common buffer\r
-    // is above 16MB, then it is not possible to generate a mapping, so return\r
-    // an error.\r
-    //\r
-    if (Operation == EfiIsaIoOperationBusMasterCommonBuffer) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    //\r
-    // Allocate an ISA_MAP_INFO structure to remember the mapping when Unmap()\r
-    // is called later.\r
-    //\r
-    IsaMapInfo = AllocatePool (sizeof (ISA_MAP_INFO));\r
-    if (IsaMapInfo == NULL) {\r
-      *NumberOfBytes = 0;\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    //\r
-    // Return a pointer to the MAP_INFO structure in Mapping\r
-    //\r
-    *Mapping = IsaMapInfo;\r
-\r
-    //\r
-    // Initialize the MAP_INFO structure\r
-    //\r
-    IsaMapInfo->Operation         = Operation;\r
-    IsaMapInfo->NumberOfBytes     = *NumberOfBytes;\r
-    IsaMapInfo->NumberOfPages     = EFI_SIZE_TO_PAGES (*NumberOfBytes);\r
-    IsaMapInfo->HostAddress       = PhysicalAddress;\r
-    IsaMapInfo->MappedHostAddress = ISA_MAX_MEMORY_ADDRESS - 1;\r
-\r
-    //\r
-    // Allocate a buffer below 16MB to map the transfer to.\r
-    //\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiBootServicesData,\r
-                    IsaMapInfo->NumberOfPages,\r
-                    &IsaMapInfo->MappedHostAddress\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (IsaMapInfo);\r
-      *NumberOfBytes  = 0;\r
-      *Mapping        = NULL;\r
-      return Status;\r
-    }\r
-    //\r
-    // If this is a read operation from the DMA agents's point of view,\r
-    // then copy the contents of the real buffer into the mapped buffer\r
-    // so the DMA agent can read the contents of the real buffer.\r
-    //\r
-    if (Operation == EfiIsaIoOperationBusMasterRead) {\r
-      CopyMem (\r
-        (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,\r
-        (VOID *) (UINTN) IsaMapInfo->HostAddress,\r
-        IsaMapInfo->NumberOfBytes\r
-        );\r
-    }\r
-    //\r
-    // The DeviceAddress is the address of the maped buffer below 16 MB\r
-    //\r
-    *DeviceAddress = IsaMapInfo->MappedHostAddress;\r
-  } else {\r
-    //\r
-    // The transfer is below 16 MB, so the DeviceAddress is simply the\r
-    // HostAddress\r
-    //\r
-    *DeviceAddress = PhysicalAddress;\r
-  }\r
-  //\r
-  // If this is a Bus Master operation then return\r
-  //\r
-  if (Master) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Figure out what to program into the DMA Channel Mode Register\r
-  //\r
-  DmaMode = (UINT8) (B_8237_DMA_CHMODE_INCREMENT | (ChannelNumber & 0x03));\r
-  if (Read) {\r
-    DmaMode |= V_8237_DMA_CHMODE_MEM2IO;\r
-  } else {\r
-    DmaMode |= V_8237_DMA_CHMODE_IO2MEM;\r
-  }\r
-\r
-  if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE) != 0) {\r
-    DmaMode |= B_8237_DMA_CHMODE_AE;\r
-  }\r
-\r
-  if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {\r
-    DmaMode |= V_8237_DMA_CHMODE_DEMAND;\r
-  }\r
-\r
-  if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {\r
-    DmaMode |= V_8237_DMA_CHMODE_SINGLE;\r
-  }\r
-  //\r
-  // A Slave DMA transfer can not cross a 64K boundary.\r
-  // Compute *NumberOfBytes based on this restriction.\r
-  //\r
-  MaxNumberOfBytes = 0x10000 - ((UINT32) (*DeviceAddress) & 0xffff);\r
-  if (*NumberOfBytes > MaxNumberOfBytes) {\r
-    *NumberOfBytes = MaxNumberOfBytes;\r
-  }\r
-  //\r
-  // Compute the values to program into the BaseAddress and Count registers\r
-  // of the Slave DMA controller\r
-  //\r
-  if (ChannelNumber < 4) {\r
-    BaseAddress = (UINT32) (*DeviceAddress);\r
-    Count       = (UINT16) (*NumberOfBytes - 1);\r
-  } else {\r
-    BaseAddress = (UINT32) (((UINT32) (*DeviceAddress) & 0xff0000) | (((UINT32) (*DeviceAddress) & 0xffff) >> 1));\r
-    Count       = (UINT16) ((*NumberOfBytes - 1) >> 1);\r
-  }\r
-  //\r
-  // Program the DMA Write Single Mask Register for ChannelNumber\r
-  // Clear the DMA Byte Pointer Register\r
-  //\r
-  if (ChannelNumber < 4) {\r
-    DmaMask         = R_8237_DMA_WRSMSK_CH0_3;\r
-    DmaClear        = R_8237_DMA_CBPR_CH0_3;\r
-    DmaChannelMode  = R_8237_DMA_CHMODE_CH0_3;\r
-  } else {\r
-    DmaMask         = R_8237_DMA_WRSMSK_CH4_7;\r
-    DmaClear        = R_8237_DMA_CBPR_CH4_7;\r
-    DmaChannelMode  = R_8237_DMA_CHMODE_CH4_7;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaMask,\r
-             (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaClear,\r
-             (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, DmaChannelMode, DmaMode);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WriteDmaPort (\r
-             This,\r
-             mDmaRegisters[ChannelNumber].Address,\r
-             mDmaRegisters[ChannelNumber].Page,\r
-             mDmaRegisters[ChannelNumber].Count,\r
-             BaseAddress,\r
-             Count\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaMask,\r
-             (UINT8) (ChannelNumber & 0x03)\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Maps a memory region for DMA\r
-\r
-  @param This                    A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param Operation               Indicates the type of DMA (slave or bus master), and if\r
-                                 the DMA operation is going to read or write to system memory.\r
-  @param ChannelNumber           The slave channel number to use for this DMA operation.\r
-                                 If Operation and ChannelAttributes shows that this device\r
-                                 performs bus mastering DMA, then this field is ignored.\r
-                                 The legal range for this field is 0..7.\r
-  @param ChannelAttributes       The attributes of the DMA channel to use for this DMA operation\r
-  @param HostAddress             The system memory address to map to the device.\r
-  @param NumberOfBytes           On input the number of bytes to map.  On output the number\r
-                                 of bytes that were mapped.\r
-  @param DeviceAddress           The resulting map address for the bus master device to use\r
-                                 to access the hosts HostAddress.\r
-  @param Mapping                 A resulting value to pass to EFI_ISA_IO.Unmap().\r
-\r
-  @retval EFI_SUCCESS            The range was mapped for the returned NumberOfBytes.\r
-  @retval EFI_INVALID_PARAMETER  The Operation or HostAddress is undefined.\r
-  @retval EFI_UNSUPPORTED        The HostAddress can not be mapped as a common buffer.\r
-  @retval EFI_DEVICE_ERROR       The system hardware could not map the requested address.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMap (\r
-  IN     EFI_ISA_IO_PROTOCOL            *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     UINT8                          ChannelNumber  OPTIONAL,\r
-  IN     UINT32                         ChannelAttributes,\r
-  IN     VOID                           *HostAddress,\r
-  IN OUT UINTN                          *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
-  OUT    VOID                           **Mapping\r
-  )\r
-{\r
-  //\r
-  // Check if DMA is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Set Feature Flag PcdIsaBusSupportBusMaster to FALSE to disable support for\r
-  // ISA Bus Master.\r
-  //\r
-  // So we just return EFI_UNSUPPORTED for these functions.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0) {\r
-    return IsaIoMapOnlySupportSlaveReadWrite (\r
-             This,\r
-             Operation,\r
-             ChannelNumber,\r
-             ChannelAttributes,\r
-             HostAddress,\r
-             NumberOfBytes,\r
-             DeviceAddress,\r
-             Mapping\r
-             );\r
-\r
-  } else {\r
-    return IsaIoMapFullSupport (\r
-             This,\r
-             Operation,\r
-             ChannelNumber,\r
-             ChannelAttributes,\r
-             HostAddress,\r
-             NumberOfBytes,\r
-             DeviceAddress,\r
-             Mapping\r
-             );\r
-  }\r
-}\r
-\r
-/**\r
-  Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer mapping.\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Type               The type allocation to perform.\r
-  @param[in]  MemoryType         The type of memory to allocate.\r
-  @param[in]  Pages              The number of pages to allocate.\r
-  @param[out] HostAddress        A pointer to store the base address of the allocated range.\r
-  @param[in]  Attributes         The requested bit mask of attributes for the allocated range.\r
-\r
-  @retval EFI_SUCCESS            The requested memory pages were allocated.\r
-  @retval EFI_INVALID_PARAMETER  Type is invalid or MemoryType is invalid or HostAddress is NULL\r
-  @retval EFI_UNSUPPORTED        Attributes is unsupported or the memory range specified\r
-                                 by HostAddress, Pages, and Type is not available for common buffer use.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoAllocateBuffer (\r
-  IN  EFI_ISA_IO_PROTOCOL  *This,\r
-  IN  EFI_ALLOCATE_TYPE    Type,\r
-  IN  EFI_MEMORY_TYPE      MemoryType,\r
-  IN  UINTN                Pages,\r
-  OUT VOID                 **HostAddress,\r
-  IN  UINT64               Attributes\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-\r
-  //\r
-  // Set Feature Flag PcdIsaBusOnlySupportSlaveDma to FALSE to disable support for\r
-  // ISA Bus Master.\r
-  // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.\r
-  //\r
-  if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||\r
-      ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (HostAddress == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((UINT32)Type >= MaxAllocateType) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // The only valid memory types are EfiBootServicesData and EfiRuntimeServicesData\r
-  //\r
-  if (MemoryType != EfiBootServicesData && MemoryType != EfiRuntimeServicesData) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Attributes & ~(EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED)) != 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) (ISA_MAX_MEMORY_ADDRESS - 1);\r
-  if (Type == AllocateAddress) {\r
-    if ((UINTN) (*HostAddress) >= ISA_MAX_MEMORY_ADDRESS) {\r
-      return EFI_UNSUPPORTED;\r
-    } else {\r
-      PhysicalAddress = (UINTN) (*HostAddress);\r
-    }\r
-  }\r
-\r
-  if (Type == AllocateAnyPages) {\r
-    Type = AllocateMaxAddress;\r
-  }\r
-\r
-  Status = gBS->AllocatePages (Type, MemoryType, Pages, &PhysicalAddress);\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-    return Status;\r
-  }\r
-\r
-  *HostAddress = (VOID *) (UINTN) PhysicalAddress;\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Frees memory that was allocated with EFI_ISA_IO.AllocateBuffer().\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Pages               The number of pages to free.\r
-  @param[in] HostAddress         The base address of the allocated range.\r
-\r
-  @retval EFI_SUCCESS            The requested memory pages were freed.\r
-  @retval EFI_INVALID_PARAMETER  The memory was not allocated with EFI_ISA_IO.AllocateBufer().\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoFreeBuffer (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINTN                Pages,\r
-  IN VOID                 *HostAddress\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Set Feature Flag PcdIsaBusOnlySupportSlaveDma to FALSE to disable support for\r
-  // ISA Bus Master.\r
-  // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.\r
-  //\r
-  if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||\r
-      ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = gBS->FreePages (\r
-                  (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress,\r
-                  Pages\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c
deleted file mode 100644 (file)
index 42ce990..0000000
+++ /dev/null
@@ -1,243 +0,0 @@
-/** @file\r
-  UEFI Component Name(2) protocol implementation for Isa Floppy driver.\r
-\r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IsaFloppy.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gIsaFloppyComponentName = {\r
-  IsaFloppyComponentNameGetDriverName,\r
-  IsaFloppyComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaFloppyComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaFloppyComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"ISA Floppy Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-  @param[out]  DriverName       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaFloppyComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mIsaFloppyDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gIsaFloppyComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-  @param[in]  ChildHandle       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-  @param[out]  ControllerName   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaFloppyComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_HANDLE                   ChildHandle  OPTIONAL,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS             Status;\r
-  EFI_BLOCK_IO_PROTOCOL  *BlkIo;\r
-  FDC_BLK_IO_DEV         *FdcDev;\r
-\r
-  if (Language == NULL || ControllerName == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // This is a device driver, so ChildHandle must be NULL.\r
-  //\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Check if this driver is currently managing ControllerHandle\r
-  //\r
-  Status = EfiTestManagedDevice (\r
-             ControllerHandle,\r
-             gFdcControllerDriver.DriverBindingHandle,\r
-             &gEfiIsaIoProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get the device context\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  (VOID **) &BlkIo,\r
-                  gFdcControllerDriver.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
-\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           FdcDev->ControllerNameTable,\r
-           ControllerName,\r
-           (BOOLEAN)(This == &gIsaFloppyComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Add the component name for the floppy device\r
-\r
-  @param[in]  FdcDev  A pointer to the FDC_BLK_IO_DEV instance.\r
-\r
-**/\r
-VOID\r
-AddName (\r
-  IN  FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  CHAR16  FloppyDriveName[FLOPPY_DRIVE_NAME_LEN + 1];\r
-\r
-  if (!(FeaturePcdGet(PcdComponentNameDisable) && FeaturePcdGet(PcdComponentName2Disable))) {\r
-    StrCpyS (FloppyDriveName, FLOPPY_DRIVE_NAME_LEN + 1, FLOPPY_DRIVE_NAME);\r
-    FloppyDriveName[FLOPPY_DRIVE_NAME_LEN - 1] = (CHAR16) (L'0' + FdcDev->Disk);\r
-\r
-    AddUnicodeString2 (\r
-      "eng",\r
-      gIsaFloppyComponentName.SupportedLanguages,\r
-      &FdcDev->ControllerNameTable,\r
-      FloppyDriveName,\r
-      TRUE\r
-      );\r
-    AddUnicodeString2 (\r
-      "en",\r
-      gIsaFloppyComponentName2.SupportedLanguages,\r
-      &FdcDev->ControllerNameTable,\r
-      FloppyDriveName,\r
-      FALSE\r
-      );\r
-  }\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h
deleted file mode 100644 (file)
index f0b6801..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/** @file\r
-  Header file for implementation of UEFI Component Name(2) protocol.\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _COMPONENT_NAME_H_\r
-#define _COMPONENT_NAME_H_\r
-\r
-#define FLOPPY_DRIVE_NAME      L"ISA Floppy Drive # "\r
-#define FLOPPY_DRIVE_NAME_LEN  ((sizeof (FLOPPY_DRIVE_NAME) / sizeof (CHAR16)) - 1)\r
-\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gIsaFloppyComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gIsaFloppyComponentName2;\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-  @param[out]  DriverName       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaFloppyComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-  @param[in]  ChildHandle       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-  @param[out]  ControllerName   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaFloppyComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_HANDLE                   ChildHandle  OPTIONAL,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **ControllerName\r
-  );\r
-\r
-\r
-/**\r
-  Add the component name for the floppy device\r
-\r
-  @param[in]  FdcDev  A pointer to the FDC_BLK_IO_DEV instance.\r
-\r
-**/\r
-VOID\r
-AddName (\r
-  IN  FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c
deleted file mode 100644 (file)
index 6d7edd6..0000000
+++ /dev/null
@@ -1,509 +0,0 @@
-/** @file\r
-  ISA Floppy Disk UEFI Driver conforming to the UEFI driver model\r
-\r
-  1. Support two types diskette drive\r
-     1.44M drive and 2.88M drive (and now only support 1.44M)\r
-  2. Support two diskette drives per floppy disk controller\r
-  3. Use DMA channel 2 to transfer data\r
-  4. Do not use interrupt\r
-  5. Support diskette change line signal and write protect\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IsaFloppy.h"\r
-\r
-LIST_ENTRY  mControllerHead = INITIALIZE_LIST_HEAD_VARIABLE (mControllerHead);\r
-\r
-//\r
-// ISA Floppy Driver Binding Protocol\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver = {\r
-  FdcControllerDriverSupported,\r
-  FdcControllerDriverStart,\r
-  FdcControllerDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-/**\r
-  The main Entry Point for this driver.\r
-\r
-  @param[in] ImageHandle  The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable  A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS     The entry point is executed successfully.\r
-  @retval other           Some error occurs when executing this entry point.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeIsaFloppy(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gFdcControllerDriver,\r
-             ImageHandle,\r
-             &gIsaFloppyComponentName,\r
-             &gIsaFloppyComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Test if the controller is a floppy disk drive device\r
-\r
-  @param[in] This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] Controller           The handle of the controller to test.\r
-  @param[in] RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS             The device is supported by this driver.\r
-  @retval EFI_ALREADY_STARTED     The device is already being managed by this driver.\r
-  @retval EFI_ACCESS_DENIED       The device is already being managed by a different driver\r
-                                  or an application that requires exclusive access.\r
-  @retval EFI_UNSUPPORTED         The device is is not supported by this driver.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_ISA_IO_PROTOCOL       *IsaIo;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
-\r
-  //\r
-  // Ignore the parameter RemainingDevicePath because this is a device driver.\r
-  //\r
-\r
-  //\r
-  // Open the device path protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  //\r
-  // Open the ISA I/O Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Use the ISA I/O Protocol to see if Controller is a floppy disk drive device\r
-  //\r
-  Status = EFI_SUCCESS;\r
-  if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {\r
-    Status = EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Close the ISA I/O Protocol\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Start this driver on Controller.\r
-\r
-  @param[in] This                  A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] ControllerHandle      The handle of the controller to start. This handle\r
-                                   must support a protocol interface that supplies\r
-                                   an I/O abstraction to the driver.\r
-  @param[in] RemainingDevicePath   A pointer to the remaining portion of a device path.\r
-                                   This parameter is ignored by device drivers, and is optional for bus drivers.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
-                                   Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  FDC_BLK_IO_DEV            *FdcDev;\r
-  EFI_ISA_IO_PROTOCOL       *IsaIo;\r
-  UINTN                     Index;\r
-  LIST_ENTRY                *List;\r
-  BOOLEAN                   Found;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
-\r
-  FdcDev  = NULL;\r
-  IsaIo   = NULL;\r
-\r
-  //\r
-  // Open the device path protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Report enable progress code\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_ENABLE,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Open the ISA I/O Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Allocate the floppy device's Device structure\r
-  //\r
-  FdcDev = AllocateZeroPool (sizeof (FDC_BLK_IO_DEV));\r
-  if (FdcDev == NULL) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Initialize the floppy device's device structure\r
-  //\r
-  FdcDev->Signature       = FDC_BLK_IO_DEV_SIGNATURE;\r
-  FdcDev->Handle          = Controller;\r
-  FdcDev->IsaIo           = IsaIo;\r
-  FdcDev->Disk            = (EFI_FDC_DISK) IsaIo->ResourceList->Device.UID;\r
-  FdcDev->Cache           = NULL;\r
-  FdcDev->Event           = NULL;\r
-  FdcDev->ControllerState = NULL;\r
-  FdcDev->DevicePath      = ParentDevicePath;\r
-\r
-  FdcDev->ControllerNameTable = NULL;\r
-  AddName (FdcDev);\r
-\r
-  //\r
-  // Look up the base address of the Floppy Disk Controller which controls this floppy device\r
-  //\r
-  for (Index = 0; FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {\r
-    if (FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {\r
-      FdcDev->BaseAddress = (UINT16) FdcDev->IsaIo->ResourceList->ResourceItem[Index].StartRange;\r
-    }\r
-  }\r
-  //\r
-  // Maintain the list of floppy disk controllers\r
-  //\r
-  Found = FALSE;\r
-  List  = mControllerHead.ForwardLink;\r
-  while (List != &mControllerHead) {\r
-    FdcDev->ControllerState = FLOPPY_CONTROLLER_FROM_LIST_ENTRY (List);\r
-    if (FdcDev->BaseAddress == FdcDev->ControllerState->BaseAddress) {\r
-      Found = TRUE;\r
-      break;\r
-    }\r
-\r
-    List = List->ForwardLink;\r
-  }\r
-\r
-  if (!Found) {\r
-    //\r
-    // A new floppy disk controller controlling this floppy disk drive is found\r
-    //\r
-    FdcDev->ControllerState = AllocatePool (sizeof (FLOPPY_CONTROLLER_CONTEXT));\r
-    if (FdcDev->ControllerState == NULL) {\r
-      goto Done;\r
-    }\r
-\r
-    FdcDev->ControllerState->Signature          = FLOPPY_CONTROLLER_CONTEXT_SIGNATURE;\r
-    FdcDev->ControllerState->FddResetPerformed  = FALSE;\r
-    FdcDev->ControllerState->NeedRecalibrate    = FALSE;\r
-    FdcDev->ControllerState->BaseAddress        = FdcDev->BaseAddress;\r
-    FdcDev->ControllerState->NumberOfDrive      = 0;\r
-\r
-    InsertTailList (&mControllerHead, &FdcDev->ControllerState->Link);\r
-  }\r
-  //\r
-  // Create a timer event for each floppy disk drive device.\r
-  // This timer event is used to control the motor on and off\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  FddTimerProc,\r
-                  FdcDev,\r
-                  &FdcDev->Event\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Reset the Floppy Disk Controller\r
-  //\r
-  if (!FdcDev->ControllerState->FddResetPerformed) {\r
-    FdcDev->ControllerState->FddResetPerformed  = TRUE;\r
-    FdcDev->ControllerState->FddResetStatus     = FddReset (FdcDev);\r
-  }\r
-\r
-  if (EFI_ERROR (FdcDev->ControllerState->FddResetStatus)) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_PRESENCE_DETECT,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Discover the Floppy Drive\r
-  //\r
-  Status = DiscoverFddDevice (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Done;\r
-  }\r
-  //\r
-  // Install protocol interfaces for the serial device.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  &FdcDev->BlkIo,\r
-                  NULL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    FdcDev->ControllerState->NumberOfDrive++;\r
-  }\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_CONTROLLER_ERROR,\r
-      ParentDevicePath\r
-      );\r
-\r
-    //\r
-    // If a floppy drive device structure was allocated, then free it\r
-    //\r
-    if (FdcDev != NULL) {\r
-      if (FdcDev->Event != NULL) {\r
-        //\r
-        // Close the event for turning the motor off\r
-        //\r
-        gBS->CloseEvent (FdcDev->Event);\r
-      }\r
-\r
-      FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
-      FreePool (FdcDev);\r
-    }\r
-\r
-    //\r
-    // Close the ISA I/O Protocol\r
-    //\r
-    if (IsaIo != NULL) {\r
-      gBS->CloseProtocol (\r
-             Controller,\r
-             &gEfiIsaIoProtocolGuid,\r
-             This->DriverBindingHandle,\r
-             Controller\r
-             );\r
-    }\r
-\r
-    //\r
-    // Close the device path protocol\r
-    //\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stop this driver on ControllerHandle.\r
-\r
-  @param[in] This               A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] ControllerHandle   A handle to the device being stopped. The handle must\r
-                                support a bus specific I/O protocol for the driver\r
-                                to use to stop the device.\r
-  @param[in] NumberOfChildren   The number of child device handles in ChildHandleBuffer.\r
-  @param[in] ChildHandleBuffer  An array of child handles to be freed. May be NULL\r
-                                if NumberOfChildren is 0.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
-  FDC_BLK_IO_DEV        *FdcDev;\r
-\r
-  //\r
-  // Ignore NumberOfChildren since this is a device driver\r
-  //\r
-\r
-  //\r
-  // Get the Block I/O Protocol on Controller\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  (VOID **) &BlkIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Get the floppy drive device's Device structure\r
-  //\r
-  FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
-\r
-  //\r
-  // Report disable progress code\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_DISABLE,\r
-    FdcDev->DevicePath\r
-    );\r
-\r
-  //\r
-  // Uninstall the Block I/O Protocol\r
-  //\r
-  Status = gBS->UninstallProtocolInterface (\r
-                  Controller,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  &FdcDev->BlkIo\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Close the event for turning the motor off\r
-  //\r
-  gBS->CloseEvent (FdcDev->Event);\r
-\r
-  //\r
-  // Turn the motor off on the floppy drive device\r
-  //\r
-  FddTimerProc (FdcDev->Event, FdcDev);\r
-\r
-  //\r
-  // Close the device path protocol\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  //\r
-  // Close the ISA I/O Protocol\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  //\r
-  // Free the controller list if needed\r
-  //\r
-  FdcDev->ControllerState->NumberOfDrive--;\r
-\r
-  //\r
-  // Free the cache if one was allocated\r
-  //\r
-  FdcFreeCache (FdcDev);\r
-\r
-  //\r
-  // Free the floppy drive device's device structure\r
-  //\r
-  FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
-  FreePool (FdcDev);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h
deleted file mode 100644 (file)
index 4d95b22..0000000
+++ /dev/null
@@ -1,1087 +0,0 @@
-/** @file\r
-  Include file for ISA Floppy Driver\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _ISA_FLOPPY_H_\r
-#define _ISA_FLOPPY_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-\r
-#include <Library/TimerLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-extern EFI_DRIVER_BINDING_PROTOCOL  gFdcControllerDriver;\r
-\r
-#define STALL_1_SECOND  1000000\r
-#define STALL_1_MSECOND 1000\r
-\r
-#define DATA_IN         1\r
-#define DATA_OUT        0\r
-#define READ            0\r
-#define WRITE           1\r
-\r
-//\r
-// Internal Data Structures\r
-//\r
-#define FDC_BLK_IO_DEV_SIGNATURE            SIGNATURE_32 ('F', 'B', 'I', 'O')\r
-#define FLOPPY_CONTROLLER_CONTEXT_SIGNATURE SIGNATURE_32 ('F', 'D', 'C', 'C')\r
-\r
-typedef enum {\r
-  FdcDisk0   = 0,\r
-  FdcDisk1   = 1,\r
-  FdcMaxDisk = 2\r
-} EFI_FDC_DISK;\r
-\r
-typedef struct {\r
-  UINT32          Signature;\r
-  LIST_ENTRY      Link;\r
-  BOOLEAN         FddResetPerformed;\r
-  EFI_STATUS      FddResetStatus;\r
-  BOOLEAN         NeedRecalibrate;\r
-  UINT8           NumberOfDrive;\r
-  UINT16          BaseAddress;\r
-} FLOPPY_CONTROLLER_CONTEXT;\r
-\r
-typedef struct {\r
-  UINTN                                     Signature;\r
-  EFI_HANDLE                                Handle;\r
-  EFI_BLOCK_IO_PROTOCOL                     BlkIo;\r
-  EFI_BLOCK_IO_MEDIA                        BlkMedia;\r
-\r
-  EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
-\r
-  UINT16                                    BaseAddress;\r
-\r
-  EFI_FDC_DISK                              Disk;\r
-  UINT8                                     PresentCylinderNumber;\r
-  UINT8                                     *Cache;\r
-\r
-  EFI_EVENT                                 Event;\r
-  EFI_UNICODE_STRING_TABLE                  *ControllerNameTable;\r
-  FLOPPY_CONTROLLER_CONTEXT                 *ControllerState;\r
-\r
-  EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;\r
-} FDC_BLK_IO_DEV;\r
-\r
-#include "ComponentName.h"\r
-\r
-#define FDD_BLK_IO_FROM_THIS(a) CR (a, FDC_BLK_IO_DEV, BlkIo, FDC_BLK_IO_DEV_SIGNATURE)\r
-#define FLOPPY_CONTROLLER_FROM_LIST_ENTRY(a) \\r
-          CR (a, \\r
-              FLOPPY_CONTROLLER_CONTEXT, \\r
-              Link, \\r
-              FLOPPY_CONTROLLER_CONTEXT_SIGNATURE \\r
-              )\r
-\r
-#define DISK_1440K_EOT            0x12\r
-#define DISK_1440K_GPL            0x1b\r
-#define DISK_1440K_DTL            0xff\r
-#define DISK_1440K_NUMBER         0x02\r
-#define DISK_1440K_MAXTRACKNUM    0x4f\r
-#define DISK_1440K_BYTEPERSECTOR  512\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-  UINT8 Cylinder;\r
-  UINT8 Head;\r
-  UINT8 Sector;\r
-  UINT8 Number;\r
-  UINT8 EndOfTrack;\r
-  UINT8 GapLength;\r
-  UINT8 DataLength;\r
-} FDD_COMMAND_PACKET1;\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-} FDD_COMMAND_PACKET2;\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 SrtHut;\r
-  UINT8 HltNd;\r
-} FDD_SPECIFY_CMD;\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-  UINT8 NewCylinder;\r
-} FDD_SEEK_CMD;\r
-\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-  UINT8 Cylinder;\r
-  UINT8 Head;\r
-  UINT8 Sector;\r
-  UINT8 EndOfTrack;\r
-  UINT8 GapLength;\r
-  UINT8 ScanTestPause;\r
-} FDD_SCAN_CMD;\r
-\r
-typedef struct {\r
-  UINT8 Status0;\r
-  UINT8 Status1;\r
-  UINT8 Status2;\r
-  UINT8 Cylinder;\r
-  UINT8 Head;\r
-  UINT8 Sector;\r
-  UINT8 Number;\r
-} FDD_RESULT_PACKET;\r
-\r
-//\r
-// FDC Registers\r
-//\r
-//\r
-// Digital Output Register address offset\r
-//\r
-#define FDC_REGISTER_DOR  2\r
-\r
-//\r
-// Main Status Register address offset\r
-//\r
-#define FDC_REGISTER_MSR  4\r
-\r
-//\r
-// Data Register address offset\r
-//\r
-#define FDC_REGISTER_DTR  5\r
-\r
-//\r
-// Configuration Control Register(data rate select) address offset\r
-//\r
-#define FDC_REGISTER_CCR  7\r
-\r
-//\r
-// Digital Input Register(diskchange) address offset\r
-//\r
-#define FDC_REGISTER_DIR  7\r
-\r
-\r
-//\r
-// FDC Register Bit Definitions\r
-//\r
-//\r
-// Digital Out Register(WO)\r
-//\r
-//\r
-// Select Drive: 0=A 1=B\r
-//\r
-#define SELECT_DRV  BIT0\r
-\r
-//\r
-// Reset FDC\r
-//\r
-#define RESET_FDC BIT2\r
-\r
-//\r
-// Enable Int & DMA\r
-//\r
-#define INT_DMA_ENABLE  BIT3\r
-\r
-//\r
-// Turn On Drive A Motor\r
-//\r
-#define DRVA_MOTOR_ON BIT4\r
-\r
-//\r
-// Turn On Drive B Motor\r
-//\r
-#define DRVB_MOTOR_ON BIT5\r
-\r
-//\r
-// Main Status Register(RO)\r
-//\r
-//\r
-// Drive A Busy\r
-//\r
-#define MSR_DAB BIT0\r
-\r
-//\r
-// Drive B Busy\r
-//\r
-#define MSR_DBB BIT1\r
-\r
-//\r
-// FDC Busy\r
-//\r
-#define MSR_CB  BIT4\r
-\r
-//\r
-// Non-DMA Mode\r
-//\r
-#define MSR_NDM BIT5\r
-\r
-//\r
-// Data Input/Output\r
-//\r
-#define MSR_DIO BIT6\r
-\r
-//\r
-// Request For Master\r
-//\r
-#define MSR_RQM BIT7\r
-\r
-//\r
-// Configuration Control Register(WO)\r
-//\r
-//\r
-// Data Rate select\r
-//\r
-#define CCR_DRC (BIT0 | BIT1)\r
-\r
-//\r
-// Digital Input Register(RO)\r
-//\r
-//\r
-// Disk change line\r
-//\r
-#define DIR_DCL BIT7\r
-//\r
-// #define CCR_DCL         BIT7      // Diskette change\r
-//\r
-// 500K\r
-//\r
-#define DRC_500KBS  0x0\r
-\r
-//\r
-// 300K\r
-//\r
-#define DRC_300KBS  0x01\r
-\r
-//\r
-// 250K\r
-//\r
-#define DRC_250KBS  0x02\r
-\r
-//\r
-// FDC Command Code\r
-//\r
-#define READ_DATA_CMD         0x06\r
-#define WRITE_DATA_CMD        0x05\r
-#define WRITE_DEL_DATA_CMD    0x09\r
-#define READ_DEL_DATA_CMD     0x0C\r
-#define READ_TRACK_CMD        0x02\r
-#define READ_ID_CMD           0x0A\r
-#define FORMAT_TRACK_CMD      0x0D\r
-#define SCAN_EQU_CMD          0x11\r
-#define SCAN_LOW_EQU_CMD      0x19\r
-#define SCAN_HIGH_EQU_CMD     0x1D\r
-#define SEEK_CMD              0x0F\r
-#define RECALIBRATE_CMD       0x07\r
-#define SENSE_INT_STATUS_CMD  0x08\r
-#define SPECIFY_CMD           0x03\r
-#define SENSE_DRV_STATUS_CMD  0x04\r
-\r
-//\r
-// CMD_MT: Multi_Track Selector\r
-// when set , this flag selects the multi-track operating mode.\r
-// In this mode, the FDC treats a complete cylinder under head0 and 1\r
-// as a single track\r
-//\r
-#define CMD_MT  BIT7\r
-\r
-//\r
-// CMD_MFM: MFM/FM Mode Selector\r
-// A one selects the double density(MFM) mode\r
-// A zero selects single density (FM) mode\r
-//\r
-#define CMD_MFM BIT6\r
-\r
-//\r
-// CMD_SK: Skip Flag\r
-// When set to 1, sectors containing a deleted data address mark will\r
-// automatically be skipped during the execution of Read Data.\r
-// When set to 0, the sector is read or written the same as the read and\r
-// write commands.\r
-//\r
-#define CMD_SK  BIT5\r
-\r
-//\r
-// FDC Status Register Bit Definitions\r
-//\r
-//\r
-// Status Register 0\r
-//\r
-//\r
-// Interrupt Code\r
-//\r
-#define STS0_IC (BIT7 | BIT6)\r
-\r
-//\r
-// Seek End: the FDC completed a seek or recalibrate command\r
-//\r
-#define STS0_SE BIT5\r
-\r
-//\r
-// Equipment Check\r
-//\r
-#define STS0_EC BIT4\r
-\r
-//\r
-// Not Ready(unused), this bit is always 0\r
-//\r
-#define STS0_NR BIT3\r
-\r
-//\r
-// Head Address: the current head address\r
-//\r
-#define STS0_HA BIT2\r
-\r
-//\r
-// STS0_US1 & STS0_US0: Drive Select(the current selected drive)\r
-//\r
-//\r
-// Unit Select1\r
-//\r
-#define STS0_US1  BIT1\r
-\r
-//\r
-// Unit Select0\r
-//\r
-#define STS0_US0  BIT0\r
-\r
-//\r
-// Status Register 1\r
-//\r
-//\r
-// End of Cylinder\r
-//\r
-#define STS1_EN BIT7\r
-\r
-//\r
-// BIT6 is unused\r
-//\r
-//\r
-// Data Error: The FDC detected a CRC error in either the ID field or\r
-// data field of a sector\r
-//\r
-#define STS1_DE BIT5\r
-\r
-//\r
-// Overrun/Underrun: Becomes set if FDC does not receive CPU or DMA service\r
-// within the required time interval\r
-//\r
-#define STS1_OR BIT4\r
-\r
-//\r
-// BIT3 is unused\r
-//\r
-//\r
-// No data\r
-//\r
-#define STS1_ND BIT2\r
-\r
-//\r
-// Not Writable\r
-//\r
-#define STS1_NW BIT1\r
-\r
-//\r
-// Missing Address Mark\r
-//\r
-#define STS1_MA BIT0\r
-\r
-//\r
-// Control Mark\r
-//\r
-#define STS2_CM BIT6\r
-\r
-//\r
-// Data Error in Data Field: The FDC detected a CRC error in the data field\r
-//\r
-#define STS2_DD BIT5\r
-\r
-//\r
-// Wrong Cylinder: The track address from sector ID field is different from\r
-// the track address maintained inside FDC\r
-//\r
-#define STS2_WC BIT4\r
-\r
-//\r
-// Bad Cylinder\r
-//\r
-#define STS2_BC BIT1\r
-\r
-//\r
-// Missing Address Mark in Data Field\r
-//\r
-#define STS2_MD BIT0\r
-\r
-//\r
-// Write Protected\r
-//\r
-#define STS3_WP BIT6\r
-\r
-//\r
-// Track 0\r
-//\r
-#define STS3_T0 BIT4\r
-\r
-//\r
-// Head Address\r
-//\r
-#define STS3_HD BIT2\r
-\r
-//\r
-// STS3_US1 & STS3_US0 : Drive Select\r
-//\r
-#define STS3_US1  BIT1\r
-#define STS3_US0  BIT0\r
-\r
-//\r
-// Status Register 0 Interrupt Code Description\r
-//\r
-//\r
-// Normal Termination of Command\r
-//\r
-#define IC_NT 0x0\r
-\r
-//\r
-// Abnormal Termination of Command\r
-//\r
-#define IC_AT 0x40\r
-\r
-//\r
-// Invalid Command\r
-//\r
-#define IC_IC 0x80\r
-\r
-//\r
-// Abnormal Termination caused by Polling\r
-//\r
-#define IC_ATRC 0xC0\r
-\r
-//\r
-// EFI Driver Binding Protocol Functions\r
-//\r
-\r
-/**\r
-  Test controller is a floppy disk drive device\r
-\r
-  @param[in] This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] Controller           The handle of the controller to test.\r
-  @param[in] RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS             The device is supported by this driver.\r
-  @retval EFI_ALREADY_STARTED     The device is already being managed by this driver.\r
-  @retval EFI_ACCESS_DENIED       The device is already being managed by a different driver\r
-                                  or an application that requires exclusive access.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Start this driver on Controller.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
-                                   must support a protocol interface that supplies\r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-                                   This parameter is ignored by device drivers, and is optional for bus drivers.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
-                                   Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Stop this driver on ControllerHandle.\r
-\r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
-                                support a bus specific I/O protocol for the driver\r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
-                                if NumberOfChildren is 0.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcControllerDriverStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN UINTN                        NumberOfChildren,\r
-  IN EFI_HANDLE                   *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// EFI Block I/O Protocol Functions\r
-//\r
-\r
-/**\r
-  Reset the Floppy Logic Drive, call the FddReset function.\r
-\r
-  @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-  @param ExtendedVerification BOOLEAN: Indicate that the driver may perform a more\r
-                    exhaustive verification operation of the device during\r
-                    reset, now this par is ignored in this driver\r
-  @retval  EFI_SUCCESS:      The Floppy Logic Drive is reset\r
-  @retval  EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly\r
-                      and can not be reset\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcReset (\r
-  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN BOOLEAN                ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Flush block via fdd controller.\r
-\r
-  @param  This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-  @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FddFlushBlocks (\r
-  IN EFI_BLOCK_IO_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Read the requested number of blocks from the device.\r
-\r
-  @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-  @param MediaId UINT32:    The media id that the read request is for\r
-  @param  Lba EFI_LBA:     The starting logic block address to read from on the device\r
-  @param  BufferSize UINTN:  The size of the Buffer in bytes\r
-  @param  Buffer VOID *:     A pointer to the destination buffer for the data\r
-\r
-  @retval  EFI_SUCCESS:     The data was read correctly from the device\r
-  @retval  EFI_DEVICE_ERROR:The device reported an error while attempting to perform\r
-                     the read operation\r
-  @retval  EFI_NO_MEDIA:    There is no media in the device\r
-  @retval  EFI_MEDIA_CHANGED:   The MediaId is not for the current media\r
-  @retval  EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the\r
-                         intrinsic block size of the device\r
-  @retval  EFI_INVALID_PARAMETER:The read request contains LBAs that are not valid,\r
-                          or the buffer is not on proper alignment\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FddReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                Lba,\r
-  IN  UINTN                  BufferSize,\r
-  OUT VOID                   *Buffer\r
-  );\r
-\r
-/**\r
-  Write a specified number of blocks to the device.\r
-\r
-  @param  This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
-  @param  MediaId UINT32:    The media id that the write request is for\r
-  @param  Lba EFI_LBA:     The starting logic block address to be written\r
-  @param  BufferSize UINTN:  The size in bytes in Buffer\r
-  @param  Buffer VOID *:     A pointer to the source buffer for the data\r
-\r
-  @retval  EFI_SUCCESS:     The data were written correctly to the device\r
-  @retval  EFI_WRITE_PROTECTED: The device can not be written to\r
-  @retval  EFI_NO_MEDIA:    There is no media in the device\r
-  @retval  EFI_MEDIA_CHANGED:   The MediaId is not for the current media\r
-  @retval  EFI_DEVICE_ERROR:  The device reported an error while attempting to perform\r
-                       the write operation\r
-  @retval  EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the\r
-                         intrinsic block size of the device\r
-  @retval  EFI_INVALID_PARAMETER:The write request contains LBAs that are not valid,\r
-                          or the buffer is not on proper alignment\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FddWriteBlocks (\r
-  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN UINT32                 MediaId,\r
-  IN EFI_LBA                Lba,\r
-  IN UINTN                  BufferSize,\r
-  IN VOID                   *Buffer\r
-  );\r
-\r
-//\r
-// Prototypes of internal functions\r
-//\r
-/**\r
-\r
-  Detect the floppy drive is presented or not.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
-  @retval EFI_SUCCESS    Drive is presented\r
-  @retval EFI_NOT_FOUND  Drive is not presented\r
-\r
-**/\r
-EFI_STATUS\r
-DiscoverFddDevice (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-\r
-  Do recalibrate  and see the drive is presented or not.\r
-  Set the media parameters.\r
-\r
-  @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
-  @return the drive is presented or not\r
-\r
-**/\r
-EFI_STATUS\r
-FddIdentify (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-\r
-  Reset the Floppy Logic Drive.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
-\r
-  @retval EFI_SUCCESS:    The Floppy Logic Drive is reset\r
-  @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and\r
-                      can not be reset\r
-\r
-**/\r
-EFI_STATUS\r
-FddReset (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-\r
-  Turn the drive's motor on.\r
-  The drive's motor must be on before any command can be executed.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
-\r
-  @retval  EFI_SUCCESS:       Turn the drive's motor on successfully\r
-  @retval  EFI_DEVICE_ERROR:    The drive is busy, so can not turn motor on\r
-  @retval  EFI_INVALID_PARAMETER: Fail to Set timer(Cancel timer)\r
-\r
-**/\r
-EFI_STATUS\r
-MotorOn (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-\r
-  Set a Timer and when Timer goes off, turn the motor off.\r
-\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
-\r
-  @retval  EFI_SUCCESS:       Set the Timer successfully\r
-  @retval  EFI_INVALID_PARAMETER: Fail to Set the timer\r
-\r
-**/\r
-EFI_STATUS\r
-MotorOff (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-  Detect the disk in the drive is changed or not.\r
-\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-\r
-  @retval  EFI_SUCCESS:    No disk media change\r
-  @retval  EFI_DEVICE_ERROR: Fail to do the recalibrate or seek operation\r
-  @retval  EFI_NO_MEDIA:   No disk in the drive\r
-  @retval  EFI_MEDIA_CHANGED:  There is a new disk in the drive\r
-**/\r
-EFI_STATUS\r
-DisketChanged (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-  Do the Specify command, this command sets DMA operation\r
-  and the initial values for each of the three internal\r
-  times: HUT, SRT and HLT.\r
-\r
-  @param FdcDev    Pointer to instance of FDC_BLK_IO_DEV\r
-\r
-  @retval  EFI_SUCCESS:    Execute the Specify command successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to execute the command\r
-\r
-**/\r
-EFI_STATUS\r
-Specify (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-  Set the head of floppy drive to track 0.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @retval EFI_SUCCESS:    Execute the Recalibrate operation successfully\r
-  @retval EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation\r
-\r
-**/\r
-EFI_STATUS\r
-Recalibrate (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-  Set the head of floppy drive to the new cylinder.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param  Lba EFI_LBA     : The logic block address want to seek\r
-\r
-  @retval  EFI_SUCCESS:    Execute the Seek operation successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to execute the Seek operation\r
-\r
-**/\r
-EFI_STATUS\r
-Seek (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         Lba\r
-  );\r
-\r
-/**\r
-  Do the Sense Interrupt Status command, this command resets the interrupt signal.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param  StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC\r
-  @param  PresentCylinderNumber  UINT8 *: Be used to save present cylinder number\r
-                                    read from FDC\r
-\r
-  @retval  EFI_SUCCESS:    Execute the Sense Interrupt Status command successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to execute the command\r
-\r
-**/\r
-EFI_STATUS\r
-SenseIntStatus (\r
-  IN     FDC_BLK_IO_DEV  *FdcDev,\r
-  IN OUT UINT8           *StatusRegister0,\r
-  IN OUT UINT8           *PresentCylinderNumber\r
-  );\r
-\r
-/**\r
-  Do the Sense Drive Status command.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param  Lba EFI_LBA     : Logic block address\r
-\r
-  @retval  EFI_SUCCESS:    Execute the Sense Drive Status command successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to execute the command\r
-  @retval  EFI_WRITE_PROTECTED:The disk is write protected\r
-\r
-**/\r
-EFI_STATUS\r
-SenseDrvStatus (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         Lba\r
-  );\r
-\r
-/**\r
-  Update the disk media properties and if necessary reinstall Block I/O interface.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-\r
-  @retval  EFI_SUCCESS:    Do the operation successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to the operation\r
-\r
-**/\r
-EFI_STATUS\r
-DetectMedia (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-  Set the data rate and so on.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-\r
-  @retval EFI_SUCCESS success to set the data rate\r
-**/\r
-EFI_STATUS\r
-Setup (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-/**\r
-  Read or Write a number of blocks in the same cylinder.\r
-\r
-  @param  FdcDev      A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param  HostAddress device address\r
-  @param  Lba         The starting logic block address to read from on the device\r
-  @param  NumberOfBlocks The number of block wanted to be read or write\r
-  @param  Read        Operation type: read or write\r
-\r
-  @retval EFI_SUCCESS Success operate\r
-\r
-**/\r
-EFI_STATUS\r
-ReadWriteDataSector (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN VOID            *HostAddress,\r
-  IN EFI_LBA         Lba,\r
-  IN UINTN           NumberOfBlocks,\r
-  IN BOOLEAN         Read\r
-  );\r
-\r
-/**\r
-  Fill in FDD command's parameter.\r
-\r
-  @param FdcDev   Pointer to instance of FDC_BLK_IO_DEV\r
-  @param Lba      The starting logic block address to read from on the device\r
-  @param Command  FDD command\r
-\r
-**/\r
-VOID\r
-FillPara (\r
-  IN FDC_BLK_IO_DEV       *FdcDev,\r
-  IN EFI_LBA              Lba,\r
-  IN FDD_COMMAND_PACKET1  *Command\r
-  );\r
-\r
-/**\r
-  Read result byte from Data Register of FDC.\r
-\r
-  @param FdcDev   Pointer to instance of FDC_BLK_IO_DEV\r
-  @param Pointer  Buffer to store the byte read from FDC\r
-\r
-  @retval EFI_SUCCESS       Read result byte from FDC successfully\r
-  @retval EFI_DEVICE_ERROR  The FDC is not ready to be read\r
-\r
-**/\r
-EFI_STATUS\r
-DataInByte (\r
-  IN  FDC_BLK_IO_DEV  *FdcDev,\r
-  OUT UINT8           *Pointer\r
-  );\r
-\r
-/**\r
-  Write command byte to Data Register of FDC.\r
-\r
-  @param FdcDev  Pointer to instance of FDC_BLK_IO_DEV\r
-  @param Pointer Be used to save command byte written to FDC\r
-\r
-  @retval  EFI_SUCCESS:    Write command byte to FDC successfully\r
-  @retval  EFI_DEVICE_ERROR: The FDC is not ready to be written\r
-\r
-**/\r
-EFI_STATUS\r
-DataOutByte (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT8           *Pointer\r
-  );\r
-\r
-/**\r
-  Detect the specified floppy logic drive is busy or not within a period of time.\r
-\r
-  @param FdcDev           Indicate it is drive A or drive B\r
-  @param Timeout          The time period for waiting\r
-\r
-  @retval EFI_SUCCESS:  The drive and command are not busy\r
-  @retval EFI_TIMEOUT:  The drive or command is still busy after a period time that\r
-                        set by Timeout\r
-\r
-**/\r
-EFI_STATUS\r
-FddWaitForBSYClear (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINTN           Timeout\r
-  );\r
-\r
-/**\r
-  Determine whether FDC is ready to write or read.\r
-\r
-  @param  FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
-  @param  Dio BOOLEAN:      Indicate the FDC is waiting to write or read\r
-  @param  Timeout           The time period for waiting\r
-\r
-  @retval EFI_SUCCESS:  FDC is ready to write or read\r
-  @retval EFI_NOT_READY:  FDC is not ready within the specified time period\r
-\r
-**/\r
-EFI_STATUS\r
-FddDRQReady (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN BOOLEAN         Dio,\r
-  IN UINTN           Timeout\r
-  );\r
-\r
-/**\r
-  Set FDC control structure's attribute according to result.\r
-\r
-  @param Result  Point to result structure\r
-  @param FdcDev  FDC control structure\r
-\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
-**/\r
-EFI_STATUS\r
-CheckResult (\r
-  IN     FDD_RESULT_PACKET  *Result,\r
-  IN OUT FDC_BLK_IO_DEV     *FdcDev\r
-  );\r
-\r
-/**\r
-  Check the drive status information.\r
-\r
-  @param StatusRegister3  the value of Status Register 3\r
-\r
-  @retval EFI_SUCCESS           The disk is not write protected\r
-  @retval EFI_WRITE_PROTECTED:  The disk is write protected\r
-\r
-**/\r
-EFI_STATUS\r
-CheckStatus3 (\r
-  IN UINT8 StatusRegister3\r
-  );\r
-\r
-/**\r
-  Calculate the number of block in the same cylinder according to Lba.\r
-\r
-  @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param Lba EFI_LBA:      The starting logic block address\r
-  @param NumberOfBlocks UINTN: The number of blocks\r
-\r
-  @return The number of blocks in the same cylinder which the starting\r
-        logic block address is Lba\r
-\r
-**/\r
-UINTN\r
-GetTransferBlockCount (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         Lba,\r
-  IN UINTN           NumberOfBlocks\r
-  );\r
-\r
-/**\r
-  When the Timer(2s) off, turn the drive's motor off.\r
-\r
-  @param Event EFI_EVENT: Event(the timer) whose notification function is being\r
-                     invoked\r
-  @param Context VOID *:  Pointer to the notification function's context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-FddTimerProc (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  );\r
-\r
-/**\r
-  Read I/O port for FDC.\r
-\r
-  @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param Offset The offset address of port\r
-\r
-**/\r
-UINT8\r
-FdcReadPort (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT32          Offset\r
-  );\r
-\r
-/**\r
-  Write I/O port for FDC.\r
-\r
-  @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
-  @param Offset The offset address of port\r
-  @param Data   Value written to port\r
-\r
-**/\r
-VOID\r
-FdcWritePort (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT32          Offset,\r
-  IN UINT8           Data\r
-  );\r
-\r
-/**\r
-  Read or Write a number of blocks to floppy device.\r
-\r
-  @param This     Pointer to instance of EFI_BLOCK_IO_PROTOCOL\r
-  @param MediaId  The media id of read/write request\r
-  @param Lba      The starting logic block address to read from on the device\r
-  @param BufferSize The size of the Buffer in bytes\r
-  @param Operation   - GC_TODO: add argument description\r
-  @param Buffer      - GC_TODO: add argument description\r
-\r
-  @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
-  @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_NO_MEDIA - GC_TODO: Add description for return value\r
-  @retval EFI_MEDIA_CHANGED - GC_TODO: Add description for return value\r
-  @retval EFI_WRITE_PROTECTED - GC_TODO: Add description for return value\r
-  @retval EFI_BAD_BUFFER_SIZE - GC_TODO: Add description for return value\r
-  @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
-  @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
-  @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
-**/\r
-EFI_STATUS\r
-FddReadWriteBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                Lba,\r
-  IN  UINTN                  BufferSize,\r
-  IN  BOOLEAN                Operation,\r
-  OUT VOID                   *Buffer\r
-  );\r
-\r
-/**\r
-  Common interface for free cache.\r
-\r
-  @param FdcDev  Pointer of FDC_BLK_IO_DEV instance\r
-\r
-**/\r
-VOID\r
-FdcFreeCache (\r
-  IN    FDC_BLK_IO_DEV  *FdcDev\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c
deleted file mode 100644 (file)
index 55bb68e..0000000
+++ /dev/null
@@ -1,369 +0,0 @@
-/** @file\r
-  Implementation of the EFI Block IO Protocol for ISA Floppy driver\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IsaFloppy.h"\r
-\r
-/**\r
-  Reset the Block Device.\r
-\r
-  @param  This                 Indicates a pointer to the calling context.\r
-  @param  ExtendedVerification Driver may perform diagnostics on reset.\r
-\r
-  @retval EFI_SUCCESS          The device was reset.\r
-  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
-                               not be reset.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcReset (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  BOOLEAN                ExtendedVerification\r
-  )\r
-{\r
-  FDC_BLK_IO_DEV  *FdcDev;\r
-\r
-  //\r
-  // Reset the Floppy Disk Controller\r
-  //\r
-  FdcDev = FDD_BLK_IO_FROM_THIS (This);\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_P_PC_RESET | EFI_PERIPHERAL_REMOVABLE_MEDIA,\r
-    FdcDev->DevicePath\r
-    );\r
-\r
-  return FddReset (FdcDev);\r
-}\r
-\r
-/**\r
-  Flush the Block Device.\r
-\r
-  @param  This              Indicates a pointer to the calling context.\r
-\r
-  @retval EFI_SUCCESS       All outstanding data was written to the device\r
-  @retval EFI_DEVICE_ERROR  The device reported an error while writting back the data\r
-  @retval EFI_NO_MEDIA      There is no media in the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FddFlushBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This\r
-  )\r
-{\r
-  //\r
-  // Not supported yet\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Common report status code interface.\r
-\r
-  @param This  Pointer of FDC_BLK_IO_DEV instance\r
-  @param Read  Read or write operation when error occurrs\r
-**/\r
-VOID\r
-FddReportStatus (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  BOOLEAN                Read\r
-  )\r
-{\r
-  FDC_BLK_IO_DEV  *FdcDev;\r
-\r
-  FdcDev = FDD_BLK_IO_FROM_THIS (This);\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_ERROR_CODE,\r
-    ((Read) ? EFI_P_EC_INPUT_ERROR : EFI_P_EC_OUTPUT_ERROR) | EFI_PERIPHERAL_REMOVABLE_MEDIA,\r
-    FdcDev->DevicePath\r
-    );\r
-}\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    Id of the media, changes every time the media is replaced.\r
-  @param  Lba        The starting Logical Block Address to read from\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
-                     responsible for either having implicit or explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FddReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                Lba,\r
-  IN  UINTN                  BufferSize,\r
-  OUT VOID                   *Buffer\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = FddReadWriteBlocks (This, MediaId, Lba, BufferSize, READ, Buffer);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    FddReportStatus (This, TRUE);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    The media ID that the write request is for.\r
-  @param  Lba        The starting logical block address to be written. The caller is\r
-                     responsible for writing to only legitimate locations.\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The data was written correctly to the device.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FddWriteBlocks (\r
-  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN UINT32                 MediaId,\r
-  IN EFI_LBA                Lba,\r
-  IN UINTN                  BufferSize,\r
-  IN VOID                   *Buffer\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = FddReadWriteBlocks (This, MediaId, Lba, BufferSize, WRITE, Buffer);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    FddReportStatus (This, FALSE);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Read or Write a number of blocks to floppy disk\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    Id of the media, changes every time the media is replaced.\r
-  @param  Lba        The starting Logical Block Address to read from\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Operation  Specifies the read or write operation.\r
-  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
-                     responsible for either having implicit or explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-\r
-**/\r
-EFI_STATUS\r
-FddReadWriteBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                Lba,\r
-  IN  UINTN                  BufferSize,\r
-  IN  BOOLEAN                Operation,\r
-  OUT VOID                   *Buffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_MEDIA  *Media;\r
-  FDC_BLK_IO_DEV      *FdcDev;\r
-  UINTN               BlockSize;\r
-  UINTN               NumberOfBlocks;\r
-  UINTN               BlockCount;\r
-  EFI_STATUS          Status;\r
-  EFI_LBA             Lba0;\r
-  UINT8               *Pointer;\r
-\r
-  //\r
-  // Get the intrinsic block size\r
-  //\r
-  Media     = This->Media;\r
-  BlockSize = Media->BlockSize;\r
-  FdcDev    = FDD_BLK_IO_FROM_THIS (This);\r
-\r
-  if (Operation == WRITE) {\r
-    if (Lba == 0) {\r
-      FdcFreeCache (FdcDev);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Set the drive motor on\r
-  //\r
-  Status = MotorOn (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Check to see if media can be detected\r
-  //\r
-  Status = DetectMedia (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    MotorOff (FdcDev);\r
-    FdcFreeCache (FdcDev);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Check to see if media is present\r
-  //\r
-  if (!(Media->MediaPresent)) {\r
-    MotorOff (FdcDev);\r
-    FdcFreeCache (FdcDev);\r
-    return EFI_NO_MEDIA;\r
-  }\r
-  //\r
-  // Check to see if media has been changed\r
-  //\r
-  if (MediaId != Media->MediaId) {\r
-    MotorOff (FdcDev);\r
-    FdcFreeCache (FdcDev);\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    MotorOff (FdcDev);\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Operation == WRITE) {\r
-    if (Media->ReadOnly) {\r
-      MotorOff (FdcDev);\r
-      return EFI_WRITE_PROTECTED;\r
-    }\r
-  }\r
-  //\r
-  // Check the parameters for this read/write operation\r
-  //\r
-  if (Buffer == NULL) {\r
-    MotorOff (FdcDev);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    MotorOff (FdcDev);\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    MotorOff (FdcDev);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (((BufferSize / BlockSize) + Lba - 1) > Media->LastBlock) {\r
-    MotorOff (FdcDev);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Operation == READ) {\r
-    //\r
-    // See if the data that is being read is already in the cache\r
-    //\r
-    if (FdcDev->Cache != NULL) {\r
-      if (Lba == 0 && BufferSize == BlockSize) {\r
-        MotorOff (FdcDev);\r
-        CopyMem ((UINT8 *) Buffer, (UINT8 *) FdcDev->Cache, BlockSize);\r
-        return EFI_SUCCESS;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Set up Floppy Disk Controller\r
-  //\r
-  Status = Setup (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    MotorOff (FdcDev);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  NumberOfBlocks  = BufferSize / BlockSize;\r
-  Lba0            = Lba;\r
-  Pointer         = Buffer;\r
-\r
-  //\r
-  // read blocks in the same cylinder.\r
-  // in a cylinder , there are 18 * 2 = 36 blocks\r
-  //\r
-  BlockCount = GetTransferBlockCount (FdcDev, Lba, NumberOfBlocks);\r
-  while ((BlockCount != 0) && !EFI_ERROR (Status)) {\r
-    Status = ReadWriteDataSector (FdcDev, Buffer, Lba, BlockCount, Operation);\r
-    if (EFI_ERROR (Status)) {\r
-      MotorOff (FdcDev);\r
-      FddReset (FdcDev);\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Lba += BlockCount;\r
-    NumberOfBlocks -= BlockCount;\r
-    Buffer      = (VOID *) ((UINTN) Buffer + BlockCount * BlockSize);\r
-    BlockCount  = GetTransferBlockCount (FdcDev, Lba, NumberOfBlocks);\r
-  }\r
-\r
-  Buffer = Pointer;\r
-\r
-  //\r
-  // Turn the motor off\r
-  //\r
-  MotorOff (FdcDev);\r
-\r
-  if (Operation == READ) {\r
-    //\r
-    // Cache the data read\r
-    //\r
-    if (Lba0 == 0 && FdcDev->Cache == NULL) {\r
-      FdcDev->Cache = AllocateCopyPool (BlockSize, Buffer);\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-/**\r
-  Free cache for a floppy disk.\r
-\r
-  @param FdcDev  A Pointer to FDC_BLK_IO_DEV instance\r
-\r
-**/\r
-VOID\r
-FdcFreeCache (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  if (FdcDev->Cache != NULL) {\r
-    FreePool (FdcDev->Cache);\r
-    FdcDev->Cache = NULL;\r
-  }\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c
deleted file mode 100644 (file)
index 423d5d7..0000000
+++ /dev/null
@@ -1,1392 +0,0 @@
-/** @file\r
-  Internal floppy disk controller programming functions for the floppy driver.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IsaFloppy.h"\r
-\r
-/**\r
-  Detect whether a floppy drive is present or not.\r
-\r
-  @param[in] FdcDev  A pointer to the FDC_BLK_IO_DEV\r
-\r
-  @retval EFI_SUCCESS    The floppy disk drive is present\r
-  @retval EFI_NOT_FOUND  The floppy disk drive is not present\r
-**/\r
-EFI_STATUS\r
-DiscoverFddDevice (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  FdcDev->BlkIo.Media = &FdcDev->BlkMedia;\r
-\r
-  Status = FddIdentify (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  FdcDev->BlkIo.Reset               = FdcReset;\r
-  FdcDev->BlkIo.FlushBlocks         = FddFlushBlocks;\r
-  FdcDev->BlkIo.ReadBlocks          = FddReadBlocks;\r
-  FdcDev->BlkIo.WriteBlocks         = FddWriteBlocks;\r
-  FdcDev->BlkMedia.LogicalPartition = FALSE;\r
-  FdcDev->BlkMedia.WriteCaching     = FALSE;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Do recalibrate and check if the drive is present or not\r
-  and set the media parameters if the driver is present.\r
-\r
-  @param[in] FdcDev  A pointer to the FDC_BLK_IO_DEV\r
-\r
-  @retval EFI_SUCCESS       The floppy disk drive is present\r
-  @retval EFI_DEVICE_ERROR  The floppy disk drive is not present\r
-**/\r
-EFI_STATUS\r
-FddIdentify (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Set Floppy Disk Controller's motor on\r
-  //\r
-  Status = MotorOn (FdcDev);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Status = Recalibrate (FdcDev);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    MotorOff (FdcDev);\r
-    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Set Media Parameter\r
-  //\r
-  FdcDev->BlkIo.Media->RemovableMedia = TRUE;\r
-  FdcDev->BlkIo.Media->MediaPresent   = TRUE;\r
-  FdcDev->BlkIo.Media->MediaId = 0;\r
-\r
-  //\r
-  // Check Media\r
-  //\r
-  Status = DisketChanged (FdcDev);\r
-\r
-  if (Status == EFI_NO_MEDIA) {\r
-    FdcDev->BlkIo.Media->MediaPresent = FALSE;\r
-  } else if ((Status != EFI_MEDIA_CHANGED) &&\r
-             (Status != EFI_SUCCESS)) {\r
-    MotorOff (FdcDev);\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Check Disk Write Protected\r
-  //\r
-  Status = SenseDrvStatus (FdcDev, 0);\r
-\r
-  if (Status == EFI_WRITE_PROTECTED) {\r
-    FdcDev->BlkIo.Media->ReadOnly = TRUE;\r
-  } else if (Status == EFI_SUCCESS) {\r
-    FdcDev->BlkIo.Media->ReadOnly = FALSE;\r
-  } else {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  MotorOff (FdcDev);\r
-\r
-  //\r
-  // Set Media Default Type\r
-  //\r
-  FdcDev->BlkIo.Media->BlockSize  = DISK_1440K_BYTEPERSECTOR;\r
-  FdcDev->BlkIo.Media->LastBlock  = DISK_1440K_EOT * 2 * (DISK_1440K_MAXTRACKNUM + 1) - 1;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Reset the Floppy Logic Drive.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV * : A pointer to the FDC_BLK_IO_DEV\r
-\r
-  @retval EFI_SUCCESS:    The Floppy Logic Drive is reset\r
-  @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and\r
-                      can not be reset\r
-\r
-**/\r
-EFI_STATUS\r
-FddReset (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  UINT8 Data;\r
-  UINT8 StatusRegister0;\r
-  UINT8 PresentCylinderNumber;\r
-  UINTN Index;\r
-\r
-  //\r
-  // Report reset progress code\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_RESET,\r
-    FdcDev->DevicePath\r
-    );\r
-\r
-  //\r
-  // Reset specified Floppy Logic Drive according to FdcDev -> Disk\r
-  // Set Digital Output Register(DOR) to do reset work\r
-  //   bit0 & bit1 of DOR : Drive Select\r
-  //   bit2 : Reset bit\r
-  //   bit3 : DMA and Int bit\r
-  // Reset : a "0" written to bit2 resets the FDC, this reset will remain\r
-  //         active until\r
-  //         a "1" is written to this bit.\r
-  // Reset step 1:\r
-  //         use bit0 & bit1 to  select the logic drive\r
-  //         write "0" to bit2\r
-  //\r
-  Data = 0x0;\r
-  Data = (UINT8) (Data | (SELECT_DRV & FdcDev->Disk));\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);\r
-\r
-  //\r
-  // wait some time,at least 120us\r
-  //\r
-  MicroSecondDelay (500);\r
-\r
-  //\r
-  // Reset step 2:\r
-  //   write "1" to bit2\r
-  //   write "1" to bit3 : enable DMA\r
-  //\r
-  Data |= 0x0C;\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);\r
-\r
-  //\r
-  // Experience value\r
-  //\r
-  MicroSecondDelay (2000);\r
-\r
-  //\r
-  // wait specified floppy logic drive is not busy\r
-  //\r
-  if (EFI_ERROR (FddWaitForBSYClear (FdcDev, 1))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Set the Transfer Data Rate\r
-  //\r
-  FdcWritePort (FdcDev, FDC_REGISTER_CCR, 0x0);\r
-\r
-  //\r
-  // Experience value\r
-  //\r
-  MicroSecondDelay (100);\r
-\r
-  //\r
-  // Issue Sense interrupt command for each drive (total 4 drives)\r
-  //\r
-  for (Index = 0; Index < 4; Index++) {\r
-    if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // issue Specify command\r
-  //\r
-  if (EFI_ERROR (Specify (FdcDev))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Turn the floppy disk drive's motor on.\r
-  The drive's motor must be on before any command can be executed.\r
-\r
-  @param[in] FdcDev  A pointer to the FDC_BLK_IO_DEV\r
-\r
-  @retval  EFI_SUCCESS            The drive's motor was turned on successfully\r
-  @retval  EFI_DEVICE_ERROR       The drive is busy, so can not turn motor on\r
-**/\r
-EFI_STATUS\r
-MotorOn (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       DorData;\r
-\r
-  //\r
-  // Control of the floppy drive motors is a big pain. If motor is off, you have\r
-  // to turn it on first. But you can not leave the motor on all the time, since\r
-  // that would wear out the disk. On the other hand, if you turn the motor off\r
-  // after each operation, the system performance will be awful. The compromise\r
-  // used in this driver is to leave the motor on for 2 seconds after\r
-  // each operation. If a new operation is started in that interval(2s),\r
-  // the motor need not be turned on again. If no new operation is started,\r
-  // a timer goes off and the motor is turned off\r
-  //\r
-  //\r
-  // Cancel the timer\r
-  //\r
-  Status = gBS->SetTimer (FdcDev->Event, TimerCancel, 0);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Get the motor status\r
-  //\r
-  DorData = FdcReadPort (FdcDev, FDC_REGISTER_DOR);\r
-\r
-  if (((FdcDev->Disk == FdcDisk0) && ((DorData & 0x10) == 0x10)) ||\r
-      ((FdcDev->Disk == FdcDisk1) && ((DorData & 0x21) == 0x21))\r
-      ) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // The drive's motor is off, so need turn it on\r
-  // first look at command and drive are busy or not\r
-  //\r
-  if (EFI_ERROR (FddWaitForBSYClear (FdcDev, 1))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // for drive A: 1CH, drive B: 2DH\r
-  //\r
-  DorData = 0x0C;\r
-  DorData = (UINT8) (DorData | (SELECT_DRV & FdcDev->Disk));\r
-  if (FdcDev->Disk == FdcDisk0) {\r
-    //\r
-    // drive A\r
-    //\r
-    DorData |= DRVA_MOTOR_ON;\r
-  } else {\r
-    //\r
-    // drive B\r
-    //\r
-    DorData |= DRVB_MOTOR_ON;\r
-  }\r
-\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, DorData);\r
-\r
-  //\r
-  // Experience value\r
-  //\r
-  MicroSecondDelay (4000);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Set a Timer and when Timer goes off, turn the motor off.\r
-\r
-  @param[in] FdcDev  A pointer to the FDC_BLK_IO_DEV\r
-\r
-  @retval  EFI_SUCCESS            Set the Timer successfully\r
-  @retval  EFI_INVALID_PARAMETER  Fail to Set the timer\r
-**/\r
-EFI_STATUS\r
-MotorOff (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  //\r
-  // Set the timer : 2s\r
-  //\r
-  return gBS->SetTimer (FdcDev->Event, TimerRelative, 20000000);\r
-}\r
-\r
-/**\r
-  Detect whether the disk in the drive is changed or not.\r
-\r
-  @param[in] FdcDev  A pointer to FDC_BLK_IO_DEV\r
-\r
-  @retval  EFI_SUCCESS        No disk media change\r
-  @retval  EFI_DEVICE_ERROR   Fail to do the recalibrate or seek operation\r
-  @retval  EFI_NO_MEDIA       No disk in the drive\r
-  @retval  EFI_MEDIA_CHANGED  There is a new disk in the drive\r
-**/\r
-EFI_STATUS\r
-DisketChanged (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Check change line\r
-  //\r
-  Data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
-\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  if ((Data & DIR_DCL) == 0x80) {\r
-    //\r
-    // disk change line is active\r
-    //\r
-    if (FdcDev->PresentCylinderNumber != 0) {\r
-      Status = Recalibrate (FdcDev);\r
-    } else {\r
-      Status = Seek (FdcDev, 0x30);\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-      return EFI_DEVICE_ERROR;\r
-      //\r
-      // Fail to do the seek or recalibrate operation\r
-      //\r
-    }\r
-\r
-    Data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);\r
-\r
-    //\r
-    // Io delay\r
-    //\r
-    MicroSecondDelay (50);\r
-\r
-    if ((Data & DIR_DCL) == 0x80) {\r
-      return EFI_NO_MEDIA;\r
-    }\r
-\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Do the Specify command, this command sets DMA operation\r
-  and the initial values for each of the three internal\r
-  times: HUT, SRT and HLT.\r
-\r
-  @param[in] FdcDev  Pointer to instance of FDC_BLK_IO_DEV\r
-\r
-  @retval EFI_SUCCESS       Execute the Specify command successfully\r
-  @retval EFI_DEVICE_ERROR  Fail to execute the command\r
-**/\r
-EFI_STATUS\r
-Specify (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  FDD_SPECIFY_CMD Command;\r
-  UINTN           Index;\r
-  UINT8           *CommandPointer;\r
-\r
-  ZeroMem (&Command, sizeof (FDD_SPECIFY_CMD));\r
-  Command.CommandCode = SPECIFY_CMD;\r
-  //\r
-  // set SRT, HUT\r
-  //\r
-  Command.SrtHut = 0xdf;\r
-  //\r
-  // 0xdf;\r
-  //\r
-  // set HLT and DMA\r
-  //\r
-  Command.HltNd   = 0x02;\r
-\r
-  CommandPointer  = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDD_SPECIFY_CMD); Index++) {\r
-    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Set the head of floppy drive to track 0.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
-  @retval EFI_SUCCESS:    Execute the Recalibrate operation successfully\r
-  @retval EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation\r
-\r
-**/\r
-EFI_STATUS\r
-Recalibrate (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  FDD_COMMAND_PACKET2 Command;\r
-  UINTN               Index;\r
-  UINT8               StatusRegister0;\r
-  UINT8               PresentCylinderNumber;\r
-  UINT8               *CommandPointer;\r
-  UINT8               Count;\r
-\r
-  Count = 2;\r
-\r
-  while (Count > 0) {\r
-    ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));\r
-    Command.CommandCode = RECALIBRATE_CMD;\r
-    //\r
-    // drive select\r
-    //\r
-    if (FdcDev->Disk == FdcDisk0) {\r
-      Command.DiskHeadSel = 0;\r
-      //\r
-      // 0\r
-      //\r
-    } else {\r
-      Command.DiskHeadSel = 1;\r
-      //\r
-      // 1\r
-      //\r
-    }\r
-\r
-    CommandPointer = (UINT8 *) (&Command);\r
-    for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET2); Index++) {\r
-      if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-    }\r
-    //\r
-    // Experience value\r
-    //\r
-    MicroSecondDelay (250000);\r
-    //\r
-    // need modify according to 1.44M or 2.88M\r
-    //\r
-    if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    if ((StatusRegister0 & 0xf0) == 0x20 && PresentCylinderNumber == 0) {\r
-      FdcDev->PresentCylinderNumber             = 0;\r
-      FdcDev->ControllerState->NeedRecalibrate  = FALSE;\r
-      return EFI_SUCCESS;\r
-    } else {\r
-      Count--;\r
-      if (Count == 0) {\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // end while\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Set the head of floppy drive to the new cylinder.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
-  @param  Lba EFI_LBA     : The logic block address want to seek\r
-\r
-  @retval  EFI_SUCCESS:    Execute the Seek operation successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to execute the Seek operation\r
-\r
-**/\r
-EFI_STATUS\r
-Seek (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         Lba\r
-  )\r
-{\r
-  FDD_SEEK_CMD  Command;\r
-  UINT8         EndOfTrack;\r
-  UINT8         Head;\r
-  UINT8         Cylinder;\r
-  UINT8         StatusRegister0;\r
-  UINT8         *CommandPointer;\r
-  UINT8         PresentCylinderNumber;\r
-  UINTN         Index;\r
-  UINT8         DelayTime;\r
-\r
-  if (FdcDev->ControllerState->NeedRecalibrate) {\r
-    if (EFI_ERROR (Recalibrate (FdcDev))) {\r
-      FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  EndOfTrack = DISK_1440K_EOT;\r
-  //\r
-  // Calculate cylinder based on Lba and EOT\r
-  //\r
-  Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);\r
-\r
-  //\r
-  // if the destination cylinder is the present cylinder, unnecessary to do the\r
-  // seek operation\r
-  //\r
-  if (FdcDev->PresentCylinderNumber == Cylinder) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Calculate the head : 0 or 1\r
-  //\r
-  Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
-\r
-  ZeroMem (&Command, sizeof (FDD_SEEK_CMD));\r
-  Command.CommandCode = SEEK_CMD;\r
-  if (FdcDev->Disk == FdcDisk0) {\r
-    Command.DiskHeadSel = 0;\r
-    //\r
-    // 0\r
-    //\r
-  } else {\r
-    Command.DiskHeadSel = 1;\r
-    //\r
-    // 1\r
-    //\r
-  }\r
-\r
-  Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));\r
-  Command.NewCylinder = Cylinder;\r
-\r
-  CommandPointer      = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDD_SEEK_CMD); Index++) {\r
-    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (100);\r
-\r
-  //\r
-  // Calculate waiting time\r
-  //\r
-  if (FdcDev->PresentCylinderNumber > Cylinder) {\r
-    DelayTime = (UINT8) (FdcDev->PresentCylinderNumber - Cylinder);\r
-  } else {\r
-    DelayTime = (UINT8) (Cylinder - FdcDev->PresentCylinderNumber);\r
-  }\r
-\r
-  MicroSecondDelay ((DelayTime + 1) * 4000);\r
-\r
-  if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if ((StatusRegister0 & 0xf0) == 0x20) {\r
-    FdcDev->PresentCylinderNumber = Command.NewCylinder;\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-}\r
-\r
-/**\r
-  Do the Sense Interrupt Status command, this command\r
-  resets the interrupt signal.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
-  @param  StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC\r
-  @param  PresentCylinderNumber  UINT8 *: Be used to save present cylinder number\r
-                                    read from FDC\r
-\r
-  @retval  EFI_SUCCESS:    Execute the Sense Interrupt Status command successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to execute the command\r
-\r
-**/\r
-EFI_STATUS\r
-SenseIntStatus (\r
-  IN     FDC_BLK_IO_DEV  *FdcDev,\r
-  IN OUT UINT8           *StatusRegister0,\r
-  IN OUT UINT8           *PresentCylinderNumber\r
-  )\r
-{\r
-  UINT8 Command;\r
-\r
-  Command = SENSE_INT_STATUS_CMD;\r
-  if (EFI_ERROR (DataOutByte (FdcDev, &Command))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (EFI_ERROR (DataInByte (FdcDev, StatusRegister0))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (EFI_ERROR (DataInByte (FdcDev, PresentCylinderNumber))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Do the Sense Drive Status command.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
-  @param  Lba EFI_LBA     : Logic block address\r
-\r
-  @retval  EFI_SUCCESS:    Execute the Sense Drive Status command successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to execute the command\r
-  @retval  EFI_WRITE_PROTECTED:The disk is write protected\r
-\r
-**/\r
-EFI_STATUS\r
-SenseDrvStatus (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN EFI_LBA         Lba\r
-  )\r
-{\r
-  FDD_COMMAND_PACKET2 Command;\r
-  UINT8               Head;\r
-  UINT8               EndOfTrack;\r
-  UINTN               Index;\r
-  UINT8               StatusRegister3;\r
-  UINT8               *CommandPointer;\r
-\r
-  //\r
-  // Sense Drive Status command obtains drive status information,\r
-  // it has not execution phase and goes directly to the result phase from the\r
-  // command phase, Status Register 3 contains the drive status information\r
-  //\r
-  ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));\r
-  Command.CommandCode = SENSE_DRV_STATUS_CMD;\r
-\r
-  if (FdcDev->Disk == FdcDisk0) {\r
-    Command.DiskHeadSel = 0;\r
-  } else {\r
-    Command.DiskHeadSel = 1;\r
-  }\r
-\r
-  EndOfTrack  = DISK_1440K_EOT;\r
-  Head        = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
-  Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));\r
-\r
-  CommandPointer = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET2); Index++) {\r
-    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  if (EFI_ERROR (DataInByte (FdcDev, &StatusRegister3))) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  //\r
-  // Check Status Register 3 to get drive status information\r
-  //\r
-  return CheckStatus3 (StatusRegister3);\r
-}\r
-\r
-/**\r
-  Update the disk media properties and if necessary reinstall Block I/O interface.\r
-\r
-  @param  FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
-\r
-  @retval  EFI_SUCCESS:    Do the operation successfully\r
-  @retval  EFI_DEVICE_ERROR: Fail to the operation\r
-\r
-**/\r
-EFI_STATUS\r
-DetectMedia (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  BOOLEAN     Reset;\r
-  BOOLEAN     ReadOnlyLastTime;\r
-  BOOLEAN     MediaPresentLastTime;\r
-\r
-  Reset                = FALSE;\r
-  ReadOnlyLastTime     = FdcDev->BlkIo.Media->ReadOnly;\r
-  MediaPresentLastTime = FdcDev->BlkIo.Media->MediaPresent;\r
-\r
-  //\r
-  // Check disk change\r
-  //\r
-  Status = DisketChanged (FdcDev);\r
-\r
-  if (Status == EFI_MEDIA_CHANGED) {\r
-    FdcDev->BlkIo.Media->MediaId++;\r
-    FdcDev->BlkIo.Media->MediaPresent = TRUE;\r
-    Reset = TRUE;\r
-  } else if (Status == EFI_NO_MEDIA) {\r
-    FdcDev->BlkIo.Media->MediaPresent = FALSE;\r
-  } else if (Status != EFI_SUCCESS) {\r
-    MotorOff (FdcDev);\r
-    return Status;\r
-    //\r
-    // EFI_DEVICE_ERROR\r
-    //\r
-  }\r
-\r
-  if (FdcDev->BlkIo.Media->MediaPresent) {\r
-    //\r
-    // Check disk write protected\r
-    //\r
-    Status = SenseDrvStatus (FdcDev, 0);\r
-    if (Status == EFI_WRITE_PROTECTED) {\r
-      FdcDev->BlkIo.Media->ReadOnly = TRUE;\r
-    } else {\r
-      FdcDev->BlkIo.Media->ReadOnly = FALSE;\r
-    }\r
-  }\r
-\r
-  if (FdcDev->BlkIo.Media->MediaPresent && (ReadOnlyLastTime != FdcDev->BlkIo.Media->ReadOnly)) {\r
-    Reset = TRUE;\r
-  }\r
-\r
-  if (MediaPresentLastTime != FdcDev->BlkIo.Media->MediaPresent) {\r
-    Reset = TRUE;\r
-  }\r
-\r
-  if (Reset) {\r
-    Status = gBS->ReinstallProtocolInterface (\r
-                    FdcDev->Handle,\r
-                    &gEfiBlockIoProtocolGuid,\r
-                    &FdcDev->BlkIo,\r
-                    &FdcDev->BlkIo\r
-                    );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Set the data rate and so on.\r
-\r
-  @param  FdcDev  A pointer to FDC_BLK_IO_DEV\r
-\r
-  @retval EFI_SUCCESS success to set the data rate\r
-**/\r
-EFI_STATUS\r
-Setup (\r
-  IN FDC_BLK_IO_DEV  *FdcDev\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Set data rate 500kbs\r
-  //\r
-  FdcWritePort (FdcDev, FDC_REGISTER_CCR, 0x0);\r
-\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  Status = Specify (FdcDev);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Read or Write a number of blocks in the same cylinder.\r
-\r
-  @param  FdcDev      A pointer to FDC_BLK_IO_DEV\r
-  @param  HostAddress device address\r
-  @param  Lba         The starting logic block address to read from on the device\r
-  @param  NumberOfBlocks The number of block wanted to be read or write\r
-  @param  Read        Operation type: read or write\r
-\r
-  @retval EFI_SUCCESS Success operate\r
-\r
-**/\r
-EFI_STATUS\r
-ReadWriteDataSector (\r
-  IN  FDC_BLK_IO_DEV  *FdcDev,\r
-  IN  VOID            *HostAddress,\r
-  IN  EFI_LBA         Lba,\r
-  IN  UINTN           NumberOfBlocks,\r
-  IN  BOOLEAN         Read\r
-  )\r
-{\r
-  EFI_STATUS                                    Status;\r
-  FDD_COMMAND_PACKET1                           Command;\r
-  FDD_RESULT_PACKET                             Result;\r
-  UINTN                                         Index;\r
-  UINTN                                         Times;\r
-  UINT8                                         *CommandPointer;\r
-\r
-  EFI_PHYSICAL_ADDRESS                          DeviceAddress;\r
-  EFI_ISA_IO_PROTOCOL                           *IsaIo;\r
-  UINTN                                         NumberofBytes;\r
-  VOID                                          *Mapping;\r
-  EFI_ISA_IO_PROTOCOL_OPERATION                 Operation;\r
-  EFI_STATUS                                    Status1;\r
-  UINT8                                         Channel;\r
-  EFI_ISA_ACPI_RESOURCE                         *ResourceItem;\r
-  UINT32                                        Attribute;\r
-\r
-  Status = Seek (FdcDev, Lba);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Map Dma\r
-  //\r
-  IsaIo         = FdcDev->IsaIo;\r
-  NumberofBytes = NumberOfBlocks * 512;\r
-  if (Read == READ) {\r
-    Operation = EfiIsaIoOperationSlaveWrite;\r
-  } else {\r
-    Operation = EfiIsaIoOperationSlaveRead;\r
-  }\r
-\r
-  ResourceItem  = IsaIo->ResourceList->ResourceItem;\r
-  Index         = 0;\r
-  while (ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList) {\r
-    if (ResourceItem[Index].Type == EfiIsaAcpiResourceDma) {\r
-      break;\r
-    }\r
-\r
-    Index++;\r
-  }\r
-\r
-  if (ResourceItem[Index].Type == EfiIsaAcpiResourceEndOfList) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Channel   = (UINT8) IsaIo->ResourceList->ResourceItem[Index].StartRange;\r
-  Attribute = IsaIo->ResourceList->ResourceItem[Index].Attribute;\r
-\r
-  Status1 = IsaIo->Map (\r
-                    IsaIo,\r
-                    Operation,\r
-                    Channel,\r
-                    Attribute,\r
-                    HostAddress,\r
-                    &NumberofBytes,\r
-                    &DeviceAddress,\r
-                    &Mapping\r
-                    );\r
-  if (EFI_ERROR (Status1)) {\r
-    return Status1;\r
-  }\r
-\r
-  //\r
-  // Allocate Read or Write command packet\r
-  //\r
-  ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET1));\r
-  if (Read == READ) {\r
-    Command.CommandCode = READ_DATA_CMD | CMD_MT | CMD_MFM | CMD_SK;\r
-  } else {\r
-    Command.CommandCode = WRITE_DATA_CMD | CMD_MT | CMD_MFM;\r
-  }\r
-\r
-  FillPara (FdcDev, Lba, &Command);\r
-\r
-  //\r
-  // Write command bytes to FDC\r
-  //\r
-  CommandPointer = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET1); Index++) {\r
-    if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // wait for some time\r
-  //\r
-  Times = (STALL_1_SECOND / 50) + 1;\r
-  do {\r
-    if ((FdcReadPort (FdcDev, FDC_REGISTER_MSR) & 0xc0) == 0xc0) {\r
-      break;\r
-    }\r
-\r
-    MicroSecondDelay (50);\r
-    Times = Times - 1;\r
-  } while (Times > 0);\r
-\r
-  if (Times == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-  //\r
-  // Read result bytes from FDC\r
-  //\r
-  CommandPointer = (UINT8 *) (&Result);\r
-  for (Index = 0; Index < sizeof (FDD_RESULT_PACKET); Index++) {\r
-    if (EFI_ERROR (DataInByte (FdcDev, CommandPointer++))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // Flush before Unmap\r
-  //\r
-  if (Read == READ) {\r
-    Status1 = IsaIo->Flush (IsaIo);\r
-    if (EFI_ERROR (Status1)) {\r
-      return Status1;\r
-    }\r
-  }\r
-  //\r
-  // Unmap Dma\r
-  //\r
-  Status1 = IsaIo->Unmap (IsaIo, Mapping);\r
-  if (EFI_ERROR (Status1)) {\r
-    return Status1;\r
-  }\r
-\r
-  return CheckResult (&Result, FdcDev);\r
-}\r
-\r
-/**\r
-  Fill in FDD command's parameter.\r
-\r
-  @param FdcDev   Pointer to instance of FDC_BLK_IO_DEV\r
-  @param Lba      The starting logic block address to read from on the device\r
-  @param Command  FDD command\r
-\r
-**/\r
-VOID\r
-FillPara (\r
-  IN  FDC_BLK_IO_DEV       *FdcDev,\r
-  IN  EFI_LBA              Lba,\r
-  IN  FDD_COMMAND_PACKET1  *Command\r
-  )\r
-{\r
-  UINT8 EndOfTrack;\r
-\r
-  //\r
-  // Get EndOfTrack from the Para table\r
-  //\r
-  EndOfTrack = DISK_1440K_EOT;\r
-\r
-  //\r
-  // Fill the command parameter\r
-  //\r
-  if (FdcDev->Disk == FdcDisk0) {\r
-    Command->DiskHeadSel = 0;\r
-  } else {\r
-    Command->DiskHeadSel = 1;\r
-  }\r
-\r
-  Command->Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);\r
-  Command->Head     = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
-  Command->Sector   = (UINT8) ((UINT8) ((UINTN) Lba % EndOfTrack) + 1);\r
-  Command->DiskHeadSel = (UINT8) (Command->DiskHeadSel | (Command->Head << 2));\r
-  Command->Number     = DISK_1440K_NUMBER;\r
-  Command->EndOfTrack = DISK_1440K_EOT;\r
-  Command->GapLength  = DISK_1440K_GPL;\r
-  Command->DataLength = DISK_1440K_DTL;\r
-}\r
-\r
-/**\r
-  Read result byte from Data Register of FDC.\r
-\r
-  @param FdcDev   Pointer to instance of FDC_BLK_IO_DEV\r
-  @param Pointer  Buffer to store the byte read from FDC\r
-\r
-  @retval EFI_SUCCESS       Read result byte from FDC successfully\r
-  @retval EFI_DEVICE_ERROR  The FDC is not ready to be read\r
-\r
-**/\r
-EFI_STATUS\r
-DataInByte (\r
-  IN  FDC_BLK_IO_DEV  *FdcDev,\r
-  OUT UINT8           *Pointer\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  //\r
-  // wait for 1ms and detect the FDC is ready to be read\r
-  //\r
-  if (EFI_ERROR (FddDRQReady (FdcDev, DATA_IN, 1))) {\r
-    return EFI_DEVICE_ERROR;\r
-    //\r
-    // is not ready\r
-    //\r
-  }\r
-\r
-  Data = FdcReadPort (FdcDev, FDC_REGISTER_DTR);\r
-\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  *Pointer = Data;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write command byte to Data Register of FDC.\r
-\r
-  @param FdcDev  Pointer to instance of FDC_BLK_IO_DEV\r
-  @param Pointer Be used to save command byte written to FDC\r
-\r
-  @retval  EFI_SUCCESS:    Write command byte to FDC successfully\r
-  @retval  EFI_DEVICE_ERROR: The FDC is not ready to be written\r
-\r
-**/\r
-EFI_STATUS\r
-DataOutByte (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT8           *Pointer\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  //\r
-  // wait for 1ms and detect the FDC is ready to be written\r
-  //\r
-  if (EFI_ERROR (FddDRQReady (FdcDev, DATA_OUT, 1))) {\r
-    //\r
-    // Not ready\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Data = *Pointer;\r
-\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DTR, Data);\r
-\r
-  //\r
-  // Io delay\r
-  //\r
-  MicroSecondDelay (50);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Detect the specified floppy logic drive is busy or not within a period of time.\r
-\r
-  @param FdcDev           Indicate it is drive A or drive B\r
-  @param Timeout          The time period for waiting\r
-\r
-  @retval EFI_SUCCESS:  The drive and command are not busy\r
-  @retval EFI_TIMEOUT:  The drive or command is still busy after a period time that\r
-                        set by Timeout\r
-\r
-**/\r
-EFI_STATUS\r
-FddWaitForBSYClear (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINTN           Timeout\r
-  )\r
-{\r
-  UINTN Delay;\r
-  UINT8 StatusRegister;\r
-  UINT8 Mask;\r
-\r
-  //\r
-  // How to determine drive and command are busy or not: by the bits of\r
-  // Main Status Register\r
-  // bit0: Drive 0 busy (drive A)\r
-  // bit1: Drive 1 busy (drive B)\r
-  // bit4: Command busy\r
-  //\r
-  //\r
-  // set mask: for drive A set bit0 & bit4; for drive B set bit1 & bit4\r
-  //\r
-  Mask  = (UINT8) ((FdcDev->Disk == FdcDisk0 ? MSR_DAB : MSR_DBB) | MSR_CB);\r
-\r
-  Delay = ((Timeout * STALL_1_MSECOND) / 50) + 1;\r
-  do {\r
-    StatusRegister = FdcReadPort (FdcDev, FDC_REGISTER_MSR);\r
-    if ((StatusRegister & Mask) == 0x00) {\r
-      break;\r
-      //\r
-      // not busy\r
-      //\r
-    }\r
-\r
-    MicroSecondDelay (50);\r
-    Delay = Delay - 1;\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Determine whether FDC is ready to write or read.\r
-\r
-  @param  FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
-  @param  Dio BOOLEAN:      Indicate the FDC is waiting to write or read\r
-  @param  Timeout           The time period for waiting\r
-\r
-  @retval EFI_SUCCESS:  FDC is ready to write or read\r
-  @retval EFI_NOT_READY:  FDC is not ready within the specified time period\r
-\r
-**/\r
-EFI_STATUS\r
-FddDRQReady (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN BOOLEAN         Dio,\r
-  IN UINTN           Timeout\r
-  )\r
-{\r
-  UINTN Delay;\r
-  UINT8 StatusRegister;\r
-  UINT8 DataInOut;\r
-\r
-  //\r
-  // Before writing to FDC or reading from FDC, the Host must examine\r
-  // the bit7(RQM) and bit6(DIO) of the Main Status Register.\r
-  // That is to say:\r
-  //  command bytes can not be written to Data Register\r
-  //  unless RQM is 1 and DIO is 0\r
-  //  result bytes can not be read from Data Register\r
-  //  unless RQM is 1 and DIO is 1\r
-  //\r
-  DataInOut = (UINT8) (Dio << 6);\r
-  //\r
-  // in order to compare bit6\r
-  //\r
-  Delay = ((Timeout * STALL_1_MSECOND) / 50) + 1;\r
-  do {\r
-    StatusRegister = FdcReadPort (FdcDev, FDC_REGISTER_MSR);\r
-    if ((StatusRegister & MSR_RQM) == MSR_RQM && (StatusRegister & MSR_DIO) == DataInOut) {\r
-      break;\r
-      //\r
-      // FDC is ready\r
-      //\r
-    }\r
-\r
-    MicroSecondDelay (50);\r
-    //\r
-    // Stall for 50 us\r
-    //\r
-    Delay = Delay - 1;\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_NOT_READY;\r
-    //\r
-    // FDC is not ready within the specified time period\r
-    //\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Set FDC control structure's attribute according to result.\r
-\r
-  @param Result  Point to result structure\r
-  @param FdcDev  FDC control structure\r
-\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
-  @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
-**/\r
-EFI_STATUS\r
-CheckResult (\r
-  IN     FDD_RESULT_PACKET  *Result,\r
-  IN OUT FDC_BLK_IO_DEV     *FdcDev\r
-  )\r
-{\r
-  //\r
-  // Check Status Register0\r
-  //\r
-  if ((Result->Status0 & STS0_IC) != IC_NT) {\r
-    if ((Result->Status0 & STS0_SE) == 0x20) {\r
-      //\r
-      // seek error\r
-      //\r
-      FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    }\r
-\r
-    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Check Status Register1\r
-  //\r
-  if ((Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) != 0) {\r
-    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Check Status Register2\r
-  //\r
-  if ((Result->Status2 & (STS2_CM | STS2_DD | STS2_WC | STS2_BC | STS2_MD)) != 0) {\r
-    FdcDev->ControllerState->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Check the drive status information.\r
-\r
-  @param StatusRegister3  the value of Status Register 3\r
-\r
-  @retval EFI_SUCCESS           The disk is not write protected\r
-  @retval EFI_WRITE_PROTECTED:  The disk is write protected\r
-\r
-**/\r
-EFI_STATUS\r
-CheckStatus3 (\r
-  IN UINT8 StatusRegister3\r
-  )\r
-{\r
-  if ((StatusRegister3 & STS3_WP) != 0) {\r
-    return EFI_WRITE_PROTECTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Calculate the number of block in the same cylinder according to LBA.\r
-\r
-  @param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV\r
-  @param LBA EFI_LBA:      The starting logic block address\r
-  @param NumberOfBlocks UINTN: The number of blocks\r
-\r
-  @return The number of blocks in the same cylinder which the starting\r
-        logic block address is LBA\r
-\r
-**/\r
-UINTN\r
-GetTransferBlockCount (\r
-  IN  FDC_BLK_IO_DEV  *FdcDev,\r
-  IN  EFI_LBA         LBA,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-  UINT8 EndOfTrack;\r
-  UINT8 Head;\r
-  UINT8 SectorsInTrack;\r
-\r
-  //\r
-  // Calculate the number of block in the same cylinder\r
-  //\r
-  EndOfTrack      = DISK_1440K_EOT;\r
-  Head            = (UINT8) ((UINTN) LBA / EndOfTrack % 2);\r
-\r
-  SectorsInTrack  = (UINT8) (EndOfTrack * (2 - Head) - (UINT8) ((UINTN) LBA % EndOfTrack));\r
-  if (SectorsInTrack < NumberOfBlocks) {\r
-    return SectorsInTrack;\r
-  } else {\r
-    return NumberOfBlocks;\r
-  }\r
-}\r
-\r
-/**\r
-  When the Timer(2s) off, turn the drive's motor off.\r
-\r
-  @param Event EFI_EVENT: Event(the timer) whose notification function is being\r
-                     invoked\r
-  @param Context VOID *:  Pointer to the notification function's context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-FddTimerProc (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-{\r
-  FDC_BLK_IO_DEV  *FdcDev;\r
-  UINT8           Data;\r
-\r
-  FdcDev = (FDC_BLK_IO_DEV *) Context;\r
-\r
-  //\r
-  // Get the motor status\r
-  //\r
-  Data = FdcReadPort (FdcDev, FDC_REGISTER_DOR);\r
-\r
-  if (((FdcDev->Disk == FdcDisk0) && ((Data & 0x10) != 0x10)) ||\r
-      ((FdcDev->Disk == FdcDisk1) && ((Data & 0x21) != 0x21))\r
-      ) {\r
-    return ;\r
-  }\r
-  //\r
-  // the motor is on, so need motor off\r
-  //\r
-  Data = 0x0C;\r
-  Data = (UINT8) (Data | (SELECT_DRV & FdcDev->Disk));\r
-  FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);\r
-  MicroSecondDelay (500);\r
-}\r
-\r
-/**\r
-  Read an I/O port of FDC.\r
-\r
-  @param[in] FdcDev  A pointer to FDC_BLK_IO_DEV.\r
-  @param[in] Offset  The address offset of the I/O port.\r
-\r
-  @retval  8-bit data read from the I/O port.\r
-**/\r
-UINT8\r
-FdcReadPort (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT32          Offset\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  Status = FdcDev->IsaIo->Io.Read (\r
-                            FdcDev->IsaIo,\r
-                            EfiIsaIoWidthUint8,\r
-                            FdcDev->BaseAddress + Offset,\r
-                            1,\r
-                            &Data\r
-                            );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Data;\r
-}\r
-\r
-/**\r
-  Write an I/O port of FDC.\r
-\r
-  @param[in] FdcDev  A pointer to FDC_BLK_IO_DEV\r
-  @param[in] Offset  The address offset of the I/O port\r
-  @param[in] Data    8-bit Value written to the I/O port\r
-**/\r
-VOID\r
-FdcWritePort (\r
-  IN FDC_BLK_IO_DEV  *FdcDev,\r
-  IN UINT32          Offset,\r
-  IN UINT8           Data\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = FdcDev->IsaIo->Io.Write (\r
-                            FdcDev->IsaIo,\r
-                            EfiIsaIoWidthUint8,\r
-                            FdcDev->BaseAddress + Offset,\r
-                            1,\r
-                            &Data\r
-                            );\r
-  ASSERT_EFI_ERROR (Status);\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf
deleted file mode 100644 (file)
index 9d20d85..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-## @file\r
-# Provides ISA Floppy Disk support.\r
-#\r
-# Provides ISA Floppy Disk UEFI Driver conforming to the UEFI driver model. The\r
-# driver provides support for two drives per controller, DMA channel 2, diskette\r
-# change line and write protect.  Currently only 1.44MB drives are supported.\r
-#\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = IsaFloppyDxe\r
-  MODULE_UNI_FILE                = IsaFloppyDxe.uni\r
-  FILE_GUID                      = 0abd8284-6da3-4616-971a-83a5148067ba\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializeIsaFloppy\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#  DRIVER_BINDING                = gFdcControllerDriver;\r
-#  COMPONENT_NAME                = gIsaFloppyComponentName;\r
-#  COMPONENT_NAME2               = gIsaFloppyComponentName2;\r
-#\r
-[Sources]\r
-  ComponentName.c\r
-  ComponentName.h\r
-  IsaFloppyCtrl.c\r
-  IsaFloppyBlock.c\r
-  IsaFloppy.c\r
-  IsaFloppy.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  ReportStatusCodeLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  UefiLib\r
-  BaseLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  TimerLib\r
-  PcdLib\r
-\r
-[Protocols]\r
-  gEfiIsaIoProtocolGuid                               ## TO_START\r
-  gEfiBlockIoProtocolGuid                             ## BY_START\r
-  gEfiDevicePathProtocolGuid                          ## TO_START\r
-\r
-[FeaturePcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable    ## CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable   ## CONSUMES\r
-\r
-#\r
-# [Event]\r
-#   ##\r
-#   # Floppy motor control timer event.\r
-#   #\r
-#   EVENT_TYPE_PERIODIC_TIMER   ## CONSUMES\r
-#\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  IsaFloppyDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.uni
deleted file mode 100644 (file)
index 32159dc..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// Provides ISA Floppy Disk support.\r
-//\r
-// Provides ISA Floppy Disk UEFI Driver conforming to the UEFI driver model. The\r
-// driver provides support for two drives per controller, DMA channel 2, diskette\r
-// change line and write protect.  Currently only 1.44MB drives are supported.\r
-//\r
-// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Provides ISA Floppy Disk support"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Provides ISA Floppy Disk UEFI Driver conforming to the UEFI driver model.  The driver provides support for two drives per controller, DMA channel 2, diskette change line and write protect.  Currently only 1.44MB drives are supported."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxeExtra.uni
deleted file mode 100644 (file)
index f1abfad..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// IsaFloppyDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"ISA Floppy DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/Fdc.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/Fdc.h
deleted file mode 100644 (file)
index a3f1ad7..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/** @file\r
-Definition of FDC registers and structures.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _PEI_RECOVERY_FDC_H_\r
-#define _PEI_RECOVERY_FDC_H_\r
-\r
-//\r
-// FDC Registers\r
-//\r
-#define FDC_REGISTER_DOR  2 //Digital Output Register\r
-#define FDC_REGISTER_MSR  4 //Main Status Register\r
-#define FDC_REGISTER_DTR  5 //Data Register\r
-#define FDC_REGISTER_CCR  7 //Configuration Control Register(data rate select)\r
-#define FDC_REGISTER_DIR  7 //Digital Input Register(diskchange)\r
-//\r
-// FDC Register Bit Definitions\r
-//\r
-//\r
-// Digital Out Register(WO)\r
-//\r
-#define SELECT_DRV      BIT0  // Select Drive: 0=A 1=B\r
-#define RESET_FDC       BIT2  // Reset FDC\r
-#define INT_DMA_ENABLE  BIT3  // Enable Int & DMA\r
-#define DRVA_MOTOR_ON   BIT4  // Turn On Drive A Motor\r
-#define DRVB_MOTOR_ON   BIT5  // Turn On Drive B Motor\r
-//\r
-// Main Status Register(RO)\r
-//\r
-#define MSR_DAB BIT0  // Drive A Busy\r
-#define MSR_DBB BIT1  // Drive B Busy\r
-#define MSR_CB  BIT4  // FDC Busy\r
-#define MSR_NDM BIT5  // Non-DMA Mode\r
-#define MSR_DIO BIT6  // Data Input/Output\r
-#define MSR_RQM BIT7  // Request For Master\r
-//\r
-// Configuration Control Register(WO)\r
-//\r
-#define CCR_DRC (BIT0 | BIT1) // Data Rate select\r
-//\r
-// Digital Input Register(RO)\r
-//\r
-#define DIR_DCL     BIT7  // Disk change line\r
-#define DRC_500KBS  0x0   // 500K\r
-#define DRC_300KBS  0x01  // 300K\r
-#define DRC_250KBS  0x02  // 250K\r
-//\r
-// FDC Command Code\r
-//\r
-#define READ_DATA_CMD         0x06\r
-#define SEEK_CMD              0x0F\r
-#define RECALIBRATE_CMD       0x07\r
-#define SENSE_INT_STATUS_CMD  0x08\r
-#define SPECIFY_CMD           0x03\r
-#define SENSE_DRV_STATUS_CMD  0x04\r
-\r
-///\r
-/// CMD_MT: Multi_Track Selector\r
-/// when set , this flag selects the multi-track operating mode.\r
-/// In this mode, the FDC treats a complete cylinder under head0 and 1 as a single track\r
-///\r
-#define CMD_MT  BIT7\r
-\r
-///\r
-/// CMD_MFM: MFM/FM Mode Selector\r
-/// A one selects the double density(MFM) mode\r
-/// A zero selects single density (FM) mode\r
-///\r
-#define CMD_MFM BIT6\r
-\r
-///\r
-/// CMD_SK: Skip Flag\r
-/// When set to 1, sectors containing a deleted data address mark will automatically be skipped\r
-/// during the execution of Read Data.\r
-/// When set to 0, the sector is read or written the same as the read and write commands.\r
-///\r
-#define CMD_SK  BIT5\r
-\r
-//\r
-// FDC Status Register Bit Definitions\r
-//\r
-//\r
-// Status Register 0\r
-//\r
-#define STS0_IC (BIT7 | BIT6) // Interrupt Code\r
-#define STS0_SE BIT5          // Seek End: the FDC completed a seek or recalibrate command\r
-#define STS0_EC BIT4          // Equipment Check\r
-#define STS0_NR BIT3          // Not Ready(unused), this bit is always 0\r
-#define STS0_HA BIT2          // Head Address: the current head address\r
-//\r
-// STS0_US1 & STS0_US0: Drive Select(the current selected drive)\r
-//\r
-#define STS0_US1  BIT1  // Unit Select1\r
-#define STS0_US0  BIT0  // Unit Select0\r
-//\r
-// Status Register 1\r
-//\r
-#define STS1_EN BIT7  // End of Cylinder\r
-//\r
-// BIT6 is unused\r
-//\r
-#define STS1_DE BIT5  // Data Error: The FDC detected a CRC error in either the ID field or data field of a sector\r
-#define STS1_OR BIT4  // Overrun/Underrun: Becomes set if FDC does not receive CPU or DMA service within the required time interval\r
-//\r
-// BIT3 is unused\r
-//\r
-#define STS1_ND BIT2  // No data\r
-#define STS1_NW BIT1  // Not Writable\r
-#define STS1_MA BIT0  // Missing Address Mark\r
-\r
-//\r
-// Status Register 2\r
-//\r
-// BIT7 is unused\r
-//\r
-#define STS2_CM BIT6  // Control Mark\r
-#define STS2_DD BIT5  // Data Error in Data Field: The FDC detected a CRC error in the data field\r
-#define STS2_WC BIT4  // Wrong Cylinder: The track address from sector ID field is different from the track address maintained inside FDC\r
-//\r
-// BIT3 is unused\r
-// BIT2 is unused\r
-//\r
-#define STS2_BC BIT1  // Bad Cylinder\r
-#define STS2_MD BIT0  // Missing Address Mark in DataField\r
-\r
-//\r
-// Status Register 3\r
-//\r
-// BIT7 is unused\r
-//\r
-#define STS3_WP BIT6  // Write Protected\r
-//\r
-// BIT5 is unused\r
-//\r
-#define STS3_T0 BIT4  // Track 0\r
-//\r
-// BIT3 is unused\r
-//\r
-#define STS3_HD BIT2  // Head Address\r
-//\r
-// STS3_US1 & STS3_US0 : Drive Select\r
-//\r
-#define STS3_US1  BIT1  // Unit Select1\r
-#define STS3_US0  BIT0  // Unit Select0\r
-\r
-//\r
-// Status Register 0 Interrupt Code Description\r
-//\r
-#define IC_NT   0x0   // Normal Termination of Command\r
-#define IC_AT   0x40  // Abnormal Termination of Command\r
-#define IC_IC   0x80  // Invalid Command\r
-#define IC_ATRC 0xC0  // Abnormal Termination caused by Polling\r
-\r
-///\r
-/// Table of parameters for diskette\r
-///\r
-typedef struct {\r
-  UINT8 EndOfTrack;          ///< End of track\r
-  UINT8 GapLength;           ///< Gap length\r
-  UINT8 DataLength;          ///< Data length\r
-  UINT8 Number;              ///< Number of bytes per sector\r
-  UINT8 MaxTrackNum;\r
-  UINT8 MotorStartTime;\r
-  UINT8 MotorOffTime;\r
-  UINT8 HeadSettlingTime;\r
-  UINT8 DataTransferRate;\r
-} DISKET_PARA_TABLE;\r
-\r
-///\r
-/// Structure for FDC Command Packet 1\r
-///\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-  UINT8 Cylinder;\r
-  UINT8 Head;\r
-  UINT8 Sector;\r
-  UINT8 Number;\r
-  UINT8 EndOfTrack;\r
-  UINT8 GapLength;\r
-  UINT8 DataLength;\r
-} FDC_COMMAND_PACKET1;\r
-\r
-///\r
-/// Structure for FDC Command Packet 2\r
-///\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-} FDC_COMMAND_PACKET2;\r
-\r
-///\r
-/// Structure for FDC Specify Command\r
-///\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 SrtHut;\r
-  UINT8 HltNd;\r
-} FDC_SPECIFY_CMD;\r
-\r
-///\r
-/// Structure for FDC Seek Command\r
-///\r
-typedef struct {\r
-  UINT8 CommandCode;\r
-  UINT8 DiskHeadSel;\r
-  UINT8 NewCylinder;\r
-} FDC_SEEK_CMD;\r
-\r
-///\r
-/// Structure for FDC Result Packet\r
-///\r
-typedef struct {\r
-  UINT8 Status0;\r
-  UINT8 Status1;\r
-  UINT8 Status2;\r
-  UINT8 CylinderNumber;\r
-  UINT8 HeaderAddress;\r
-  UINT8 Record;\r
-  UINT8 Number;\r
-} FDC_RESULT_PACKET;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c
deleted file mode 100644 (file)
index 9b571c1..0000000
+++ /dev/null
@@ -1,1752 +0,0 @@
-/** @file\r
-Floppy Peim to support Recovery function from Floppy device.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#include "FloppyPeim.h"\r
-\r
-\r
-PEI_DMA_TABLE      mRegisterTable[] = {\r
-  //\r
-  // DMA2: Clear Byte Ptr, Enable\r
-  //\r
-  {\r
-    R_8237_DMA_CBPR_CH4_7,\r
-    0\r
-  },\r
-  {\r
-    R_8237_DMA_COMMAND_CH4_7,\r
-    0\r
-  },\r
-  //\r
-  // DMA1: Clear Byte Ptr, Enable\r
-  //\r
-  {\r
-    R_8237_DMA_CBPR_CH0_3,\r
-    0\r
-  },\r
-  {\r
-    R_8237_DMA_COMMAND_CH0_3,\r
-    0\r
-  },\r
-  //\r
-  // Configure Channel 4 for Cascade Mode\r
-  // Clear DMA Request and enable DREQ\r
-  //\r
-  {\r
-    R_8237_DMA_CHMODE_CH4_7,\r
-    V_8237_DMA_CHMODE_CASCADE | 0\r
-  },\r
-  {\r
-    R_8237_DMA_STA_CH4_7,\r
-    0\r
-  },\r
-  {\r
-    R_8237_DMA_WRSMSK_CH4_7,\r
-    0\r
-  },\r
-  //\r
-  // Configure DMA1 (Channels 0-3) for Single Mode\r
-  // Clear DMA Request and enable DREQ\r
-  //\r
-  {\r
-    R_8237_DMA_CHMODE_CH0_3,\r
-    V_8237_DMA_CHMODE_SINGLE | 0\r
-  },\r
-  {\r
-    R_8237_DMA_STA_CH0_3,\r
-    0\r
-  },\r
-  {\r
-    R_8237_DMA_WRSMSK_CH0_3,\r
-    0\r
-  },\r
-  {\r
-    R_8237_DMA_CHMODE_CH0_3,\r
-    V_8237_DMA_CHMODE_SINGLE | 1\r
-  },\r
-  {\r
-    R_8237_DMA_STA_CH0_3,\r
-    1\r
-  },\r
-  {\r
-    R_8237_DMA_WRSMSK_CH0_3,\r
-    1\r
-  },\r
-  {\r
-    R_8237_DMA_CHMODE_CH0_3,\r
-    V_8237_DMA_CHMODE_SINGLE | 2\r
-  },\r
-  {\r
-    R_8237_DMA_STA_CH0_3,\r
-    2\r
-  },\r
-  {\r
-    R_8237_DMA_WRSMSK_CH0_3,\r
-    2\r
-  },\r
-  {\r
-    R_8237_DMA_CHMODE_CH0_3,\r
-    V_8237_DMA_CHMODE_SINGLE | 3\r
-  },\r
-  {\r
-    R_8237_DMA_STA_CH0_3,\r
-    3\r
-  },\r
-  {\r
-    R_8237_DMA_WRSMSK_CH0_3,\r
-    3\r
-  },\r
-  //\r
-  // Configure DMA2 (Channels 5-7) for Single Mode\r
-  // Clear DMA Request and enable DREQ\r
-  //\r
-  {\r
-    R_8237_DMA_CHMODE_CH4_7,\r
-    V_8237_DMA_CHMODE_SINGLE | 1\r
-  },\r
-  {\r
-    R_8237_DMA_STA_CH4_7,\r
-    1\r
-  },\r
-  {\r
-    R_8237_DMA_WRSMSK_CH4_7,\r
-    1\r
-  },\r
-  {\r
-    R_8237_DMA_CHMODE_CH4_7,\r
-    V_8237_DMA_CHMODE_SINGLE | 2\r
-  },\r
-  {\r
-    R_8237_DMA_STA_CH4_7,\r
-    2\r
-  },\r
-  {\r
-    R_8237_DMA_WRSMSK_CH4_7,\r
-    2\r
-  },\r
-  {\r
-    R_8237_DMA_CHMODE_CH4_7,\r
-    V_8237_DMA_CHMODE_SINGLE | 3\r
-  },\r
-  {\r
-    R_8237_DMA_STA_CH4_7,\r
-    3\r
-  },\r
-  {\r
-    R_8237_DMA_WRSMSK_CH4_7,\r
-    3\r
-  }\r
-};\r
-\r
-//\r
-// Table of diskette parameters of various diskette types\r
-//\r
-DISKET_PARA_TABLE  DiskPara[9] = {\r
-  {\r
-    0x09,\r
-    0x50,\r
-    0xff,\r
-    0x2,\r
-    0x27,\r
-    0x4,\r
-    0x25,\r
-    0x14,\r
-    0x80\r
-  },\r
-  {\r
-    0x09,\r
-    0x2a,\r
-    0xff,\r
-    0x2,\r
-    0x27,\r
-    0x4,\r
-    0x25,\r
-    0x0f,\r
-    0x40\r
-  },\r
-  {\r
-    0x0f,\r
-    0x54,\r
-    0xff,\r
-    0x2,\r
-    0x4f,\r
-    0x4,\r
-    0x25,\r
-    0x0f,\r
-    0x0\r
-  },\r
-  {\r
-    0x09,\r
-    0x50,\r
-    0xff,\r
-    0x2,\r
-    0x4f,\r
-    0x4,\r
-    0x25,\r
-    0x0f,\r
-    0x80\r
-  },\r
-  {\r
-    0x09,\r
-    0x2a,\r
-    0xff,\r
-    0x2,\r
-    0x4f,\r
-    0x4,\r
-    0x25,\r
-    0x0f,\r
-    0x80\r
-  },\r
-  {\r
-    0x12,\r
-    0x1b,\r
-    0xff,\r
-    0x2,\r
-    0x4f,\r
-    0x4,\r
-    0x25,\r
-    0x0f,\r
-    0x0\r
-  },\r
-  {\r
-    0x09,\r
-    0x2a,\r
-    0xff,\r
-    0x2,\r
-    0x4f,\r
-    0x4,\r
-    0x25,\r
-    0x0f,\r
-    0x80\r
-  },\r
-  {\r
-    0x12,\r
-    0x1b,\r
-    0xff,\r
-    0x2,\r
-    0x4f,\r
-    0x4,\r
-    0x25,\r
-    0x0f,\r
-    0x0\r
-  },\r
-  {\r
-    0x24,\r
-    0x1b,\r
-    0xff,\r
-    0x2,\r
-    0x4f,\r
-    0x4,\r
-    0x25,\r
-    0x0f,\r
-    0xc0\r
-  }\r
-};\r
-\r
-//\r
-// Byte per sector corresponding to various device types.\r
-//\r
-UINTN    BytePerSector[6] = { 0, 256, 512, 1024, 2048, 4096 };\r
-\r
-FDC_BLK_IO_DEV mBlockIoDevTemplate = {\r
-  FDC_BLK_IO_DEV_SIGNATURE,\r
-  {\r
-    FdcGetNumberOfBlockDevices,\r
-    FdcGetBlockDeviceMediaInfo,\r
-    FdcReadBlocks,\r
-  },\r
-  {\r
-    (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
-    &gEfiPeiVirtualBlockIoPpiGuid,\r
-    NULL\r
-  },\r
-  0,\r
-  {{0}}\r
-};\r
-\r
-/**\r
-  Wait and check if bits for DIO and RQM of FDC Main Status Register\r
-  indicates FDC is ready for read or write.\r
-\r
-  Before writing to FDC or reading from FDC, the Host must examine\r
-  the bit7(RQM) and bit6(DIO) of the Main Status Register.\r
-  That is to say:\r
-   Command bytes can not be written to Data Register unless RQM is 1 and DIO is 0.\r
-   Result bytes can not be read from Data Register unless RQM is 1 and DIO is 1.\r
-\r
-  @param  FdcBlkIoDev       Instance of FDC_BLK_IO_DEV.\r
-  @param  DataIn            Indicates data input or output.\r
-                            TRUE means input.\r
-                            FALSE means output.\r
-  @param  TimeoutInMseconds  Timeout value to wait.\r
-\r
-  @retval EFI_SUCCESS       FDC is ready.\r
-  @retval EFI_NOT_READY     FDC is not ready within the specified time period.\r
-\r
-**/\r
-EFI_STATUS\r
-FdcDRQReady (\r
-  IN FDC_BLK_IO_DEV   *FdcBlkIoDev,\r
-  IN BOOLEAN          DataIn,\r
-  IN UINTN            TimeoutInMseconds\r
-  )\r
-{\r
-  UINTN   Delay;\r
-  UINT8   StatusRegister;\r
-  UINT8   BitInOut;\r
-\r
-  //\r
-  // Check bit6 of Main Status Register.\r
-  //\r
-  BitInOut = 0;\r
-  if (DataIn) {\r
-    BitInOut = BIT6;\r
-  }\r
-\r
-  Delay = ((TimeoutInMseconds * STALL_1_MSECOND) / FDC_CHECK_INTERVAL) + 1;\r
-  do {\r
-    StatusRegister = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_MSR));\r
-    if ((StatusRegister & MSR_RQM) == MSR_RQM && (StatusRegister & MSR_DIO) == BitInOut) {\r
-      //\r
-      // FDC is ready\r
-      //\r
-      break;\r
-    }\r
-\r
-    MicroSecondDelay (FDC_SHORT_DELAY);\r
-  } while (--Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    //\r
-    // FDC is not ready within the specified time period\r
-    //\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Read a byte from FDC data register.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  Pointer          Pointer to buffer to hold data read from FDC.\r
-\r
-  @retval EFI_SUCCESS      Byte successfully read.\r
-  @retval EFI_DEVICE_ERROR FDC is not ready.\r
-\r
-**/\r
-EFI_STATUS\r
-DataInByte (\r
-  IN  FDC_BLK_IO_DEV   *FdcBlkIoDev,\r
-  OUT UINT8            *Pointer\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  //\r
-  // Wait for 1ms and detect the FDC is ready to be read\r
-  //\r
-  if (FdcDRQReady (FdcBlkIoDev, TRUE, 1) != EFI_SUCCESS) {\r
-    //\r
-    // FDC is not ready.\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Data = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DTR));\r
-  MicroSecondDelay (FDC_SHORT_DELAY);\r
-  *Pointer = Data;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write a byte to FDC data register.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  Pointer          Pointer to data to write.\r
-\r
-  @retval EFI_SUCCESS      Byte successfully written.\r
-  @retval EFI_DEVICE_ERROR FDC is not ready.\r
-\r
-**/\r
-EFI_STATUS\r
-DataOutByte (\r
-  IN FDC_BLK_IO_DEV   *FdcBlkIoDev,\r
-  IN UINT8            *Pointer\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  //\r
-  // Wait for 1ms and detect the FDC is ready to be written\r
-  //\r
-  if (FdcDRQReady (FdcBlkIoDev, FALSE, 1) != EFI_SUCCESS) {\r
-    //\r
-    // FDC is not ready.\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Data = *Pointer;\r
-  IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DTR), Data);\r
-  MicroSecondDelay (FDC_SHORT_DELAY);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Get Sts0 and Pcn status from FDC\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV\r
-  @param  Sts0             Value of Sts0\r
-  @param  Pcn              Value of Pcn\r
-\r
-  @retval EFI_SUCCESS      Successfully retrieved status value of Sts0 and Pcn.\r
-  @retval EFI_DEVICE_ERROR Fail to send SENSE_INT_STATUS_CMD.\r
-  @retval EFI_DEVICE_ERROR Fail to read Sts0.\r
-  @retval EFI_DEVICE_ERROR Fail to read Pcn.\r
-\r
-**/\r
-EFI_STATUS\r
-SenseIntStatus (\r
-  IN  FDC_BLK_IO_DEV   *FdcBlkIoDev,\r
-  OUT UINT8            *Sts0,\r
-  OUT UINT8            *Pcn\r
-  )\r
-{\r
-  UINT8 Command;\r
-\r
-  Command = SENSE_INT_STATUS_CMD;\r
-\r
-  if (DataOutByte (FdcBlkIoDev, &Command) != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (DataInByte (FdcBlkIoDev, Sts0) != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (DataInByte (FdcBlkIoDev, Pcn) != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Issue Specify command.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-\r
-  @retval EFI_SUCCESS      Specify command successfully issued.\r
-  @retval EFI_DEVICE_ERROR FDC device has errors.\r
-\r
-**/\r
-EFI_STATUS\r
-Specify (\r
-  IN FDC_BLK_IO_DEV   *FdcBlkIoDev\r
-  )\r
-{\r
-  FDC_SPECIFY_CMD Command;\r
-  UINTN           Index;\r
-  UINT8           *Pointer;\r
-\r
-  ZeroMem (&Command, sizeof (FDC_SPECIFY_CMD));\r
-  Command.CommandCode = SPECIFY_CMD;\r
-  //\r
-  // set SRT, HUT\r
-  //\r
-  Command.SrtHut = 0xdf;\r
-  //\r
-  // 0xdf;\r
-  // set HLT and DMA\r
-  //\r
-  Command.HltNd = 0x02;\r
-\r
-  Pointer            = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDC_SPECIFY_CMD); Index++) {\r
-    if (DataOutByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Wait until busy bit is cleared.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  DevPos           Position of FDC (Driver A or B)\r
-  @param  TimeoutInMseconds Timeout value to wait.\r
-\r
-  @retval EFI_SUCCESS      Busy bit has been cleared before timeout.\r
-  @retval EFI_TIMEOUT      Time goes out before busy bit is cleared.\r
-\r
-**/\r
-EFI_STATUS\r
-FdcWaitForBSYClear (\r
-  IN FDC_BLK_IO_DEV   *FdcBlkIoDev,\r
-  IN UINT8            DevPos,\r
-  IN UINTN            TimeoutInMseconds\r
-  )\r
-{\r
-  UINTN   Delay;\r
-  UINT8   StatusRegister;\r
-  UINT8   Mask;\r
-\r
-  //\r
-  // How to determine drive and command are busy or not: by the bits of Main Status Register\r
-  // bit0: Drive 0 busy (drive A)\r
-  // bit1: Drive 1 busy (drive B)\r
-  // bit4: Command busy\r
-  //\r
-  // set mask: for drive A set bit0 & bit4; for drive B set bit1 & bit4\r
-  //\r
-  Mask  = (UINT8) ((DevPos == 0 ? MSR_DAB : MSR_DBB) | MSR_CB);\r
-\r
-  Delay = ((TimeoutInMseconds * STALL_1_MSECOND) / FDC_CHECK_INTERVAL) + 1;\r
-\r
-  do {\r
-    StatusRegister = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_MSR));\r
-\r
-    if ((StatusRegister & Mask) == 0x00) {\r
-      //\r
-      // not busy\r
-      //\r
-      break;\r
-    }\r
-\r
-    MicroSecondDelay (FDC_SHORT_DELAY);\r
-  } while (--Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Reset FDC device.\r
-\r
-  @param  FdcBlkIoDev  Instance of FDC_BLK_IO_DEV\r
-  @param  DevPos       Index of FDC device.\r
-\r
-  @retval EFI_SUCCESS      FDC device successfully reset.\r
-  @retval EFI_DEVICE_ERROR Fail to reset FDC device.\r
-\r
-**/\r
-EFI_STATUS\r
-FdcReset (\r
-  IN FDC_BLK_IO_DEV   *FdcBlkIoDev,\r
-  IN UINT8            DevPos\r
-  )\r
-{\r
-  UINT8 Data;\r
-  UINT8 Sts0;\r
-  UINT8 Pcn;\r
-  UINTN Index;\r
-\r
-  //\r
-  // Reset specified Floppy Logic Drive according to Fdd -> Disk\r
-  // Set Digital Output Register(DOR) to do reset work\r
-  //    bit0 & bit1 of DOR : Drive Select\r
-  //    bit2 : Reset bit\r
-  //    bit3 : DMA and Int bit\r
-  // Reset : A "0" written to bit2 resets the FDC, this reset will remain active until\r
-  //       a "1" is written to this bit.\r
-  // Reset step 1:\r
-  //    use bit0 & bit1 to  select the logic drive\r
-  //    write "0" to bit2\r
-  //\r
-  Data = 0x0;\r
-  Data = (UINT8) (Data | (SELECT_DRV & DevPos));\r
-  IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DOR), Data);\r
-\r
-  //\r
-  // Wait some time, at least 120us.\r
-  //\r
-  MicroSecondDelay (FDC_RESET_DELAY);\r
-  //\r
-  // Reset step 2:\r
-  //    write "1" to bit2\r
-  //    write "1" to bit3 : enable DMA\r
-  //\r
-  Data |= 0x0C;\r
-  IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DOR), Data);\r
-\r
-  MicroSecondDelay (FDC_RESET_DELAY);\r
-\r
-  //\r
-  // Wait until specified floppy logic drive is not busy\r
-  //\r
-  if (FdcWaitForBSYClear (FdcBlkIoDev, DevPos, 1) != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Set the Transfer Data Rate\r
-  //\r
-  IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_CCR), 0x0);\r
-\r
-  MicroSecondDelay (FDC_MEDIUM_DELAY);\r
-\r
-  //\r
-  // Issue Sense interrupt command for each drive (totally 4 drives)\r
-  //\r
-  for (Index = 0; Index < 4; Index++) {\r
-    if (SenseIntStatus (FdcBlkIoDev, &Sts0, &Pcn) != EFI_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // Issue Specify command\r
-  //\r
-  if (Specify (FdcBlkIoDev) != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Turn on the motor of floppy drive.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  Info             Information of floppy device.\r
-\r
-  @retval EFI_SUCCESS      Motor is successfully turned on.\r
-  @retval EFI_SUCCESS      Motor is already on.\r
-  @retval EFI_DEVICE_ERROR Busy bit of FDC cannot be cleared.\r
-\r
-**/\r
-EFI_STATUS\r
-MotorOn (\r
-  IN FDC_BLK_IO_DEV             *FdcBlkIoDev,\r
-  IN OUT PEI_FLOPPY_DEVICE_INFO *Info\r
-  )\r
-{\r
-  UINT8 Data;\r
-  UINT8 DevPos;\r
-\r
-  //\r
-  // Control of the floppy drive motors is a big pain. If motor is off, you have to turn it\r
-  // on first. But you can not leave the motor on all the time, since that would wear out the\r
-  // disk. On the other hand, if you turn the motor off after each operation, the system performance\r
-  // will be awful. The compromise used in this driver is to leave the motor on for 2 seconds after\r
-  // each operation. If a new operation is started in that interval(2s), the motor need not be\r
-  // turned on again. If no new operation is started, a timer goes off and the motor is turned off.\r
-  //\r
-  DevPos = Info->DevPos;\r
-\r
-  //\r
-  // If the Motor is already on, just return EFI_SUCCESS.\r
-  //\r
-  if (Info->MotorOn) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // The drive's motor is off, so need turn it on.\r
-  // First check if command and drive are busy or not.\r
-  //\r
-  if (FdcWaitForBSYClear (FdcBlkIoDev, DevPos, 1) != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // for drive A: 1CH, drive B: 2DH\r
-  //\r
-  Data = 0x0C;\r
-  Data = (UINT8) (Data | (SELECT_DRV & DevPos));\r
-  if (DevPos == 0) {\r
-    Data |= DRVA_MOTOR_ON;\r
-  } else {\r
-    Data |= DRVB_MOTOR_ON;\r
-  }\r
-\r
-  Info->MotorOn = FALSE;\r
-\r
-  //\r
-  // Turn on the motor and wait for some time to ensure it takes effect.\r
-  //\r
-  IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DOR), Data);\r
-  MicroSecondDelay (FDC_LONG_DELAY);\r
-\r
-  Info->MotorOn = TRUE;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Turn off the motor of floppy drive.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  Info             Information of floppy device.\r
-\r
-**/\r
-VOID\r
-MotorOff (\r
-  IN FDC_BLK_IO_DEV             *FdcBlkIoDev,\r
-  IN OUT PEI_FLOPPY_DEVICE_INFO *Info\r
-  )\r
-{\r
-  UINT8 Data;\r
-  UINT8 DevPos;\r
-\r
-  DevPos = Info->DevPos;\r
-\r
-  if (!Info->MotorOn) {\r
-    return;\r
-  }\r
-  //\r
-  // The motor is on, so need motor off\r
-  //\r
-  Data = 0x0C;\r
-  Data = (UINT8) (Data | (SELECT_DRV & DevPos));\r
-\r
-  IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DOR), Data);\r
-  MicroSecondDelay (FDC_SHORT_DELAY);\r
-\r
-  Info->MotorOn = FALSE;\r
-}\r
-\r
-/**\r
-  Recalibrate the FDC device.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  Info             Information of floppy device.\r
-\r
-  @retval EFI_SUCCESS      FDC successfully recalibrated.\r
-  @retval EFI_DEVICE_ERROR Fail to send RECALIBRATE_CMD.\r
-  @retval EFI_DEVICE_ERROR Fail to get status value of Sts0 and Pcn.\r
-  @retval EFI_DEVICE_ERROR Fail to recalibrate FDC device.\r
-\r
-**/\r
-EFI_STATUS\r
-Recalibrate (\r
-  IN FDC_BLK_IO_DEV             *FdcBlkIoDev,\r
-  IN OUT PEI_FLOPPY_DEVICE_INFO *Info\r
-  )\r
-{\r
-  FDC_COMMAND_PACKET2 Command;\r
-  UINTN               Index;\r
-  UINT8               Sts0;\r
-  UINT8               Pcn;\r
-  UINT8               *Pointer;\r
-  UINT8               Count;\r
-  UINT8               DevPos;\r
-\r
-  DevPos  = Info->DevPos;\r
-\r
-  //\r
-  // We would try twice.\r
-  //\r
-  Count   = 2;\r
-  while (Count > 0) {\r
-    ZeroMem (&Command, sizeof (FDC_COMMAND_PACKET2));\r
-    Command.CommandCode = RECALIBRATE_CMD;\r
-    //\r
-    // drive select\r
-    //\r
-    if (DevPos == 0) {\r
-      Command.DiskHeadSel = 0;\r
-    } else {\r
-      Command.DiskHeadSel = 1;\r
-    }\r
-\r
-    Pointer = (UINT8 *) (&Command);\r
-    for (Index = 0; Index < sizeof (FDC_COMMAND_PACKET2); Index++) {\r
-      if (DataOutByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-    }\r
-\r
-    MicroSecondDelay (FDC_RECALIBRATE_DELAY);\r
-\r
-    if (SenseIntStatus (FdcBlkIoDev, &Sts0, &Pcn) != EFI_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    if ((Sts0 & 0xf0) == BIT5 && Pcn == 0) {\r
-      //\r
-      // Recalibration is successful.\r
-      //\r
-      Info->Pcn = 0;\r
-      Info->NeedRecalibrate = FALSE;\r
-\r
-      return EFI_SUCCESS;\r
-    } else {\r
-      //\r
-      // Recalibration is not successful. Try again.\r
-      // If trial is used out, return EFI_DEVICE_ERROR.\r
-      //\r
-      Count--;\r
-      if (Count == 0) {\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Seek for the cylinder according to given LBA.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  Info             Information of floppy device.\r
-  @param  Lba              LBA for which to seek for cylinder.\r
-\r
-  @retval EFI_SUCCESS      Successfully moved to the destination cylinder.\r
-  @retval EFI_SUCCESS      Destination cylinder is just the present cylinder.\r
-  @retval EFI_DEVICE_ERROR Fail to move to the destination cylinder.\r
-\r
-**/\r
-EFI_STATUS\r
-Seek (\r
-  IN     FDC_BLK_IO_DEV         *FdcBlkIoDev,\r
-  IN OUT PEI_FLOPPY_DEVICE_INFO *Info,\r
-  IN     EFI_PEI_LBA            Lba\r
-  )\r
-{\r
-  FDC_SEEK_CMD      Command;\r
-  DISKET_PARA_TABLE *Para;\r
-  UINT8             EndOfTrack;\r
-  UINT8             Head;\r
-  UINT8             Cylinder;\r
-  UINT8             Sts0;\r
-  UINT8             *Pointer;\r
-  UINT8             Pcn;\r
-  UINTN             Index;\r
-  UINT8             Gap;\r
-  UINT8             DevPos;\r
-\r
-  DevPos = Info->DevPos;\r
-  if (Info->NeedRecalibrate) {\r
-    if (Recalibrate (FdcBlkIoDev, Info) != EFI_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-    //\r
-    // Recalibrate Success\r
-    //\r
-    Info->NeedRecalibrate = FALSE;\r
-  }\r
-\r
-  //\r
-  // Get the base of disk parameter information corresponding to its type.\r
-  //\r
-  Para        = (DISKET_PARA_TABLE *) ((UINT8 *) DiskPara + sizeof (DISKET_PARA_TABLE) * Info->Type);\r
-  EndOfTrack  = Para->EndOfTrack;\r
-  //\r
-  // Calculate cylinder based on Lba and EOT\r
-  //\r
-  Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);\r
-\r
-  //\r
-  // If the dest cylinder is the present cylinder, unnecessary to do the seek operation\r
-  //\r
-  if (Info->Pcn == Cylinder) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Calculate the head : 0 or 1\r
-  //\r
-  Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
-\r
-  ZeroMem (&Command, sizeof (FDC_SEEK_CMD));\r
-  Command.CommandCode = SEEK_CMD;\r
-  if (DevPos == 0) {\r
-    Command.DiskHeadSel = 0;\r
-  } else {\r
-    Command.DiskHeadSel = 1;\r
-  }\r
-\r
-  //\r
-  // Send command to move to destination cylinder.\r
-  //\r
-  Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));\r
-  Command.NewCylinder = Cylinder;\r
-\r
-  Pointer = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDC_SEEK_CMD); Index++) {\r
-    if (DataOutByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  MicroSecondDelay (FDC_SHORT_DELAY);\r
-\r
-  //\r
-  // Calculate waiting time, which is proportional to the gap between destination\r
-  // cylinder and present cylinder.\r
-  //\r
-  if (Info->Pcn > Cylinder) {\r
-    Gap = (UINT8) (Info->Pcn - Cylinder);\r
-  } else {\r
-    Gap = (UINT8) (Cylinder - Info->Pcn);\r
-  }\r
-\r
-  MicroSecondDelay ((Gap + 1) * FDC_LONG_DELAY);\r
-\r
-  //\r
-  // Confirm if the new cylinder is the destination and status is correct.\r
-  //\r
-  if (SenseIntStatus (FdcBlkIoDev, &Sts0, &Pcn) != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if ((Sts0 & 0xf0) == BIT5) {\r
-    Info->Pcn             = Command.NewCylinder;\r
-    Info->NeedRecalibrate = FALSE;\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    Info->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-}\r
-\r
-/**\r
-  Check if diskette is changed.\r
-\r
-  @param  FdcBlkIoDev       Instance of FDC_BLK_IO_DEV\r
-  @param  Info              Information of floppy device.\r
-\r
-  @retval EFI_SUCCESS       Diskette is not changed.\r
-  @retval EFI_MEDIA_CHANGED Diskette is changed.\r
-  @retval EFI_NO_MEDIA      No diskette.\r
-  @retval EFI_DEVICE_ERROR  Fail to do the seek or recalibrate operation.\r
-\r
-**/\r
-EFI_STATUS\r
-DisketChanged (\r
-  IN FDC_BLK_IO_DEV             *FdcBlkIoDev,\r
-  IN OUT PEI_FLOPPY_DEVICE_INFO *Info\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Check change line\r
-  //\r
-  Data = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DIR));\r
-\r
-  MicroSecondDelay (FDC_SHORT_DELAY);\r
-\r
-  if ((Data & DIR_DCL) == DIR_DCL) {\r
-    if (Info->Pcn != 0) {\r
-      Status = Recalibrate (FdcBlkIoDev, Info);\r
-    } else {\r
-      Status = Seek (FdcBlkIoDev, Info, 0x30);\r
-    }\r
-\r
-    if (Status != EFI_SUCCESS) {\r
-      //\r
-      // Fail to do the seek or recalibrate operation\r
-      //\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Data = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DIR));\r
-\r
-    MicroSecondDelay (FDC_SHORT_DELAY);\r
-\r
-    if ((Data & DIR_DCL) == DIR_DCL) {\r
-      return EFI_NO_MEDIA;\r
-    }\r
-\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Detects if FDC device exists.\r
-\r
-  @param  FdcBlkIoDev  Instance of FDC_BLK_IO_DEV\r
-  @param  Info         Information of floppy device.\r
-  @param  MediaInfo    Information of floppy media.\r
-\r
-  @retval TRUE         FDC device exists and is working properly.\r
-  @retval FALSE        FDC device does not exist or cannot work properly.\r
-\r
-**/\r
-BOOLEAN\r
-DiscoverFdcDevice (\r
-  IN  FDC_BLK_IO_DEV             *FdcBlkIoDev,\r
-  IN  OUT PEI_FLOPPY_DEVICE_INFO *Info,\r
-  OUT EFI_PEI_BLOCK_IO_MEDIA     *MediaInfo\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  DISKET_PARA_TABLE *Para;\r
-\r
-  Status = MotorOn (FdcBlkIoDev, Info);\r
-  if (Status != EFI_SUCCESS) {\r
-    return FALSE;\r
-  }\r
-\r
-  Status = Recalibrate (FdcBlkIoDev, Info);\r
-\r
-  if (Status != EFI_SUCCESS) {\r
-    MotorOff (FdcBlkIoDev, Info);\r
-    return FALSE;\r
-  }\r
-  //\r
-  // Set Media Parameter\r
-  //\r
-  MediaInfo->DeviceType   = LegacyFloppy;\r
-  MediaInfo->MediaPresent = TRUE;\r
-\r
-  //\r
-  // Check Media\r
-  //\r
-  Status = DisketChanged (FdcBlkIoDev, Info);\r
-  if (Status == EFI_NO_MEDIA) {\r
-    //\r
-    // No diskette in floppy.\r
-    //\r
-    MediaInfo->MediaPresent = FALSE;\r
-  } else if (Status != EFI_MEDIA_CHANGED && Status != EFI_SUCCESS) {\r
-    //\r
-    // EFI_DEVICE_ERROR\r
-    //\r
-    MotorOff (FdcBlkIoDev, Info);\r
-    return FALSE;\r
-  }\r
-\r
-  MotorOff (FdcBlkIoDev, Info);\r
-\r
-  //\r
-  // Get the base of disk parameter information corresponding to its type.\r
-  //\r
-  Para                  = (DISKET_PARA_TABLE *) ((UINT8 *) DiskPara + sizeof (DISKET_PARA_TABLE) * Info->Type);\r
-\r
-  MediaInfo->BlockSize  = BytePerSector[Para->Number];\r
-  MediaInfo->LastBlock  = Para->EndOfTrack * 2 * (Para->MaxTrackNum + 1) - 1;\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Enumerate floppy device\r
-\r
-  @param  FdcBlkIoDev  Instance of floppy device controller\r
-\r
-  @return Number of FDC devices.\r
-\r
-**/\r
-UINT8\r
-FdcEnumeration (\r
-  IN FDC_BLK_IO_DEV   *FdcBlkIoDev\r
-  )\r
-{\r
-  UINT8                   DevPos;\r
-  UINT8                   DevNo;\r
-  EFI_PEI_BLOCK_IO_MEDIA  MediaInfo;\r
-  EFI_STATUS              Status;\r
-\r
-  DevNo = 0;\r
-\r
-  //\r
-  // DevPos=0 means Drive A, 1 means Drive B.\r
-  //\r
-  for (DevPos = 0; DevPos < 2; DevPos++) {\r
-    //\r
-    // Detecting device presence\r
-    //\r
-    REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_PERIPHERAL_REMOVABLE_MEDIA + EFI_P_PC_PRESENCE_DETECT);\r
-\r
-    //\r
-    // Reset FDC\r
-    //\r
-    Status = FdcReset (FdcBlkIoDev, DevPos);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    FdcBlkIoDev->DeviceInfo[DevPos].DevPos          = DevPos;\r
-    FdcBlkIoDev->DeviceInfo[DevPos].Pcn             = 0;\r
-    FdcBlkIoDev->DeviceInfo[DevPos].MotorOn         = FALSE;\r
-    FdcBlkIoDev->DeviceInfo[DevPos].NeedRecalibrate = TRUE;\r
-    FdcBlkIoDev->DeviceInfo[DevPos].Type            = FdcType1440K1440K;\r
-\r
-    //\r
-    // Discover FDC device\r
-    //\r
-    if (DiscoverFdcDevice (FdcBlkIoDev, &(FdcBlkIoDev->DeviceInfo[DevPos]), &MediaInfo)) {\r
-      FdcBlkIoDev->DeviceInfo[DevNo].DevPos           = DevPos;\r
-\r
-      FdcBlkIoDev->DeviceInfo[DevNo].Pcn              = FdcBlkIoDev->DeviceInfo[DevPos].Pcn;\r
-      FdcBlkIoDev->DeviceInfo[DevNo].MotorOn          = FdcBlkIoDev->DeviceInfo[DevPos].MotorOn;\r
-      FdcBlkIoDev->DeviceInfo[DevNo].NeedRecalibrate  = FdcBlkIoDev->DeviceInfo[DevPos].NeedRecalibrate;\r
-      FdcBlkIoDev->DeviceInfo[DevNo].Type             = FdcBlkIoDev->DeviceInfo[DevPos].Type;\r
-\r
-      CopyMem (\r
-        &(FdcBlkIoDev->DeviceInfo[DevNo].MediaInfo),\r
-        &MediaInfo,\r
-        sizeof (EFI_PEI_BLOCK_IO_MEDIA)\r
-        );\r
-\r
-      DevNo++;\r
-    } else {\r
-      //\r
-      // Assume controller error\r
-      //\r
-      REPORT_STATUS_CODE (\r
-        EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-        EFI_PERIPHERAL_REMOVABLE_MEDIA + EFI_P_EC_CONTROLLER_ERROR\r
-        );\r
-    }\r
-  }\r
-\r
-  FdcBlkIoDev->DeviceCount = DevNo;\r
-  return DevNo;\r
-}\r
-\r
-/**\r
-  Checks result reflected by FDC_RESULT_PACKET.\r
-\r
-  @param  Result           FDC_RESULT_PACKET read from FDC after certain operation.\r
-  @param  Info             Information of floppy device.\r
-\r
-  @retval EFI_SUCCESS      Result is healthy.\r
-  @retval EFI_DEVICE_ERROR Result is not healthy.\r
-\r
-**/\r
-EFI_STATUS\r
-CheckResult (\r
-  IN  FDC_RESULT_PACKET         *Result,\r
-  OUT PEI_FLOPPY_DEVICE_INFO    *Info\r
-  )\r
-{\r
-  if ((Result->Status0 & STS0_IC) != IC_NT) {\r
-    if ((Result->Status0 & STS0_SE) == BIT5) {\r
-      //\r
-      // Seek error\r
-      //\r
-      Info->NeedRecalibrate = TRUE;\r
-    }\r
-\r
-    Info->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Check Status Register1\r
-  //\r
-  if ((Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) != 0) {\r
-    Info->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Check Status Register2\r
-  //\r
-  if ((Result->Status2 & (STS2_CM | STS2_DD | STS2_WC | STS2_BC | STS2_MD)) != 0) {\r
-    Info->NeedRecalibrate = TRUE;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Fill parameters for command packet.\r
-\r
-  @param  Info    Information of floppy device.\r
-  @param  Lba     Logical block address.\r
-  @param  Command Command for which for fill parameters.\r
-\r
-**/\r
-VOID\r
-FillPara (\r
-  IN  PEI_FLOPPY_DEVICE_INFO *Info,\r
-  IN  EFI_PEI_LBA            Lba,\r
-  OUT FDC_COMMAND_PACKET1    *Command\r
-  )\r
-{\r
-  DISKET_PARA_TABLE *Para;\r
-  UINT8             EndOfTrack;\r
-  UINT8             DevPos;\r
-\r
-  DevPos      = Info->DevPos;\r
-\r
-  //\r
-  // Get the base of disk parameter information corresponding to its type.\r
-  //\r
-  Para        = (DISKET_PARA_TABLE *) ((UINT8 *) DiskPara + sizeof (DISKET_PARA_TABLE) * Info->Type);\r
-\r
-  EndOfTrack  = Para->EndOfTrack;\r
-\r
-  if (DevPos == 0) {\r
-    Command->DiskHeadSel = 0;\r
-  } else {\r
-    Command->DiskHeadSel = 1;\r
-  }\r
-\r
-  Command->Cylinder    = (UINT8) ((UINTN) Lba / EndOfTrack / 2);\r
-  Command->Head        = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
-  Command->Sector      = (UINT8) ((UINT8) ((UINTN) Lba % EndOfTrack) + 1);\r
-  Command->DiskHeadSel = (UINT8) (Command->DiskHeadSel | (Command->Head << 2));\r
-  Command->Number      = Para->Number;\r
-  Command->EndOfTrack  = Para->EndOfTrack;\r
-  Command->GapLength   = Para->GapLength;\r
-  Command->DataLength  = Para->DataLength;\r
-}\r
-\r
-/**\r
-  Setup specifed FDC device.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  DevPos           Index of FDC device.\r
-\r
-  @retval EFI_SUCCESS      FDC device successfully set up.\r
-  @retval EFI_DEVICE_ERROR FDC device has errors.\r
-\r
-**/\r
-EFI_STATUS\r
-Setup (\r
-  IN  FDC_BLK_IO_DEV  *FdcBlkIoDev,\r
-  IN  UINT8           DevPos\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_CCR), 0x0);\r
-\r
-  MicroSecondDelay (FDC_MEDIUM_DELAY);\r
-\r
-  Status = Specify (FdcBlkIoDev);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Setup DMA channels to read data.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  Buffer           Memory buffer for DMA transfer.\r
-  @param  BlockSize        the number of the bytes in one block.\r
-  @param  NumberOfBlocks   Number of blocks to read.\r
-\r
-**/\r
-VOID\r
-SetDMA (\r
-  IN FDC_BLK_IO_DEV   *FdcBlkIoDev,\r
-  IN VOID             *Buffer,\r
-  IN UINTN            BlockSize,\r
-  IN UINTN            NumberOfBlocks\r
-  )\r
-{\r
-  UINT8 Data;\r
-  UINTN Count;\r
-\r
-  //\r
-  // Mask DMA channel 2;\r
-  //\r
-  IoWrite8 (R_8237_DMA_WRSMSK_CH0_3, B_8237_DMA_WRSMSK_CMS | 2);\r
-\r
-  //\r
-  // Clear first/last flip flop\r
-  //\r
-  IoWrite8 (R_8237_DMA_CBPR_CH0_3, B_8237_DMA_WRSMSK_CMS | 2);\r
-\r
-  //\r
-  // Set mode\r
-  //\r
-  IoWrite8 (R_8237_DMA_CHMODE_CH0_3, V_8237_DMA_CHMODE_SINGLE | V_8237_DMA_CHMODE_IO2MEM | 2);\r
-\r
-  //\r
-  // Set base address and page register\r
-  //\r
-  Data = (UINT8) (UINTN) Buffer;\r
-  IoWrite8 (R_8237_DMA_BASE_CA_CH2, Data);\r
-  Data = (UINT8) ((UINTN) Buffer >> 8);\r
-  IoWrite8 (R_8237_DMA_BASE_CA_CH2, Data);\r
-\r
-  Data = (UINT8) ((UINTN) Buffer >> 16);\r
-  IoWrite8 (R_8237_DMA_MEM_LP_CH2, Data);\r
-\r
-  //\r
-  // Set count register\r
-  //\r
-  Count = BlockSize * NumberOfBlocks - 1;\r
-  Data  = (UINT8) (Count & 0xff);\r
-  IoWrite8 (R_8237_DMA_BASE_CC_CH2, Data);\r
-  Data = (UINT8) (Count >> 8);\r
-  IoWrite8 (R_8237_DMA_BASE_CC_CH2, Data);\r
-\r
-  //\r
-  // Clear channel 2 mask\r
-  //\r
-  IoWrite8 (R_8237_DMA_WRSMSK_CH0_3, 0x02);\r
-}\r
-\r
-\r
-/**\r
-  According to the block range specified by Lba and NumberOfBlocks, calculate\r
-  the number of blocks in the same sector, which can be transferred in a batch.\r
-\r
-  @param  Info           Information of floppy device.\r
-  @param  Lba            Start address of block range.\r
-  @param  NumberOfBlocks Number of blocks of the range.\r
-\r
-  @return Number of blocks in the same sector.\r
-\r
-**/\r
-UINTN\r
-GetTransferBlockCount (\r
-  IN  PEI_FLOPPY_DEVICE_INFO *Info,\r
-  IN  EFI_PEI_LBA            Lba,\r
-  IN  UINTN                  NumberOfBlocks\r
-  )\r
-{\r
-  DISKET_PARA_TABLE *Para;\r
-  UINT8             EndOfTrack;\r
-  UINT8             Head;\r
-  UINT8             SectorsInTrack;\r
-\r
-  //\r
-  // Get the base of disk parameter information corresponding to its type.\r
-  //\r
-  Para            = (DISKET_PARA_TABLE *) ((UINT8 *) DiskPara + sizeof (DISKET_PARA_TABLE) * Info->Type);\r
-\r
-  EndOfTrack      = Para->EndOfTrack;\r
-  Head            = (UINT8) ((UINTN) Lba / EndOfTrack % 2);\r
-\r
-  SectorsInTrack  = (UINT8) (EndOfTrack * (2 - Head) - (UINT8) ((UINTN) Lba % EndOfTrack));\r
-  if (SectorsInTrack < NumberOfBlocks) {\r
-    //\r
-    // Not all the block range locates in the same sector\r
-    //\r
-    return SectorsInTrack;\r
-  } else {\r
-    //\r
-    // All the block range is in the same sector.\r
-    //\r
-    return NumberOfBlocks;\r
-  }\r
-}\r
-\r
-/**\r
-  Read data sector from FDC device.\r
-\r
-  @param  FdcBlkIoDev      Instance of FDC_BLK_IO_DEV.\r
-  @param  Info             Information of floppy device.\r
-  @param  Buffer           Buffer to setup for DMA.\r
-  @param  Lba              The start address to read.\r
-  @param  NumberOfBlocks   Number of blocks to read.\r
-\r
-  @retval EFI_SUCCESS      Data successfully read out.\r
-  @retval EFI_DEVICE_ERROR FDC device has errors.\r
-  @retval EFI_TIMEOUT      Command does not take effect in time.\r
-\r
-**/\r
-EFI_STATUS\r
-ReadDataSector (\r
-  IN     FDC_BLK_IO_DEV         *FdcBlkIoDev,\r
-  IN OUT PEI_FLOPPY_DEVICE_INFO *Info,\r
-  IN     VOID                   *Buffer,\r
-  IN     EFI_PEI_LBA            Lba,\r
-  IN     UINTN                  NumberOfBlocks\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-  FDC_COMMAND_PACKET1 Command;\r
-  FDC_RESULT_PACKET   Result;\r
-  UINTN               Index;\r
-  UINTN               Times;\r
-  UINT8               *Pointer;\r
-\r
-  Status = Seek (FdcBlkIoDev, Info, Lba);\r
-  if (Status != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Set up DMA\r
-  //\r
-  SetDMA (FdcBlkIoDev, Buffer, Info->MediaInfo.BlockSize, NumberOfBlocks);\r
-\r
-  //\r
-  // Allocate Read command packet\r
-  //\r
-  ZeroMem (&Command, sizeof (FDC_COMMAND_PACKET1));\r
-  Command.CommandCode = READ_DATA_CMD | CMD_MT | CMD_MFM | CMD_SK;\r
-\r
-  //\r
-  // Fill parameters for command.\r
-  //\r
-  FillPara (Info, Lba, &Command);\r
-\r
-  //\r
-  // Write command bytes to FDC\r
-  //\r
-  Pointer = (UINT8 *) (&Command);\r
-  for (Index = 0; Index < sizeof (FDC_COMMAND_PACKET1); Index++) {\r
-    if (DataOutByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Wait for some time until command takes effect.\r
-  //\r
-  Times = (STALL_1_SECOND / FDC_CHECK_INTERVAL) + 1;\r
-  do {\r
-    if ((IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_MSR)) & 0xc0) == 0xc0) {\r
-      break;\r
-    }\r
-\r
-    MicroSecondDelay (FDC_SHORT_DELAY);\r
-  } while (--Times > 0);\r
-\r
-  if (Times == 0) {\r
-    //\r
-    // Command fails to take effect in time, return EFI_TIMEOUT.\r
-    //\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  //\r
-  // Read result bytes from FDC\r
-  //\r
-  Pointer = (UINT8 *) (&Result);\r
-  for (Index = 0; Index < sizeof (FDC_RESULT_PACKET); Index++) {\r
-    if (DataInByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  return CheckResult (&Result, Info);\r
-}\r
-\r
-/**\r
-  Gets the count of block I/O devices that one specific block driver detects.\r
-\r
-  This function is used for getting the count of block I/O devices that one\r
-  specific block driver detects.  To the PEI ATAPI driver, it returns the number\r
-  of all the detected ATAPI devices it detects during the enumeration process.\r
-  To the PEI legacy floppy driver, it returns the number of all the legacy\r
-  devices it finds during its enumeration process. If no device is detected,\r
-  then the function will return zero.\r
-\r
-  @param[in]  PeiServices          General-purpose services that are available\r
-                                   to every PEIM.\r
-  @param[in]  This                 Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI\r
-                                   instance.\r
-  @param[out] NumberBlockDevices   The number of block I/O devices discovered.\r
-\r
-  @retval     EFI_SUCCESS          Operation performed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcGetNumberOfBlockDevices (\r
-  IN   EFI_PEI_SERVICES                  **PeiServices,\r
-  IN   EFI_PEI_RECOVERY_BLOCK_IO_PPI     *This,\r
-  OUT  UINTN                             *NumberBlockDevices\r
-  )\r
-{\r
-  FDC_BLK_IO_DEV  *FdcBlkIoDev;\r
-\r
-  FdcBlkIoDev = NULL;\r
-\r
-  FdcBlkIoDev         = PEI_RECOVERY_FDC_FROM_BLKIO_THIS (This);\r
-\r
-  *NumberBlockDevices = FdcBlkIoDev->DeviceCount;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Gets a block device's media information.\r
-\r
-  This function will provide the caller with the specified block device's media\r
-  information. If the media changes, calling this function will update the media\r
-  information accordingly.\r
-\r
-  @param[in]  PeiServices   General-purpose services that are available to every\r
-                            PEIM\r
-  @param[in]  This          Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
-  @param[in]  DeviceIndex   Specifies the block device to which the function wants\r
-                            to talk. Because the driver that implements Block I/O\r
-                            PPIs will manage multiple block devices, the PPIs that\r
-                            want to talk to a single device must specify the\r
-                            device index that was assigned during the enumeration\r
-                            process. This index is a number from one to\r
-                            NumberBlockDevices.\r
-  @param[out] MediaInfo     The media information of the specified block media.\r
-                            The caller is responsible for the ownership of this\r
-                            data structure.\r
-\r
-  @retval EFI_SUCCESS        Media information about the specified block device\r
-                             was obtained successfully.\r
-  @retval EFI_DEVICE_ERROR   Cannot get the media information due to a hardware\r
-                             error.\r
-  @retval Others             Other failure occurs.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcGetBlockDeviceMediaInfo (\r
-  IN   EFI_PEI_SERVICES                     **PeiServices,\r
-  IN   EFI_PEI_RECOVERY_BLOCK_IO_PPI        *This,\r
-  IN   UINTN                                DeviceIndex,\r
-  OUT  EFI_PEI_BLOCK_IO_MEDIA               *MediaInfo\r
-  )\r
-{\r
-  UINTN           DeviceCount;\r
-  FDC_BLK_IO_DEV  *FdcBlkIoDev;\r
-  BOOLEAN         Healthy;\r
-  UINTN           Index;\r
-\r
-  FdcBlkIoDev = NULL;\r
-\r
-  if (This == NULL || MediaInfo == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  FdcBlkIoDev = PEI_RECOVERY_FDC_FROM_BLKIO_THIS (This);\r
-\r
-  DeviceCount = FdcBlkIoDev->DeviceCount;\r
-\r
-  //\r
-  // DeviceIndex is a value from 1 to NumberBlockDevices.\r
-  //\r
-  if ((DeviceIndex < 1) || (DeviceIndex > DeviceCount) || (DeviceIndex > 2)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Index = DeviceIndex - 1;\r
-  //\r
-  // Probe media and retrieve latest media information\r
-  //\r
-  Healthy = DiscoverFdcDevice (\r
-              FdcBlkIoDev,\r
-              &FdcBlkIoDev->DeviceInfo[Index],\r
-              MediaInfo\r
-              );\r
-\r
-  if (!Healthy) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  CopyMem (\r
-    &(FdcBlkIoDev->DeviceInfo[Index].MediaInfo),\r
-    MediaInfo,\r
-    sizeof (EFI_PEI_BLOCK_IO_MEDIA)\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Reads the requested number of blocks from the specified block device.\r
-\r
-  The function reads the requested number of blocks from the device. All the\r
-  blocks are read, or an error is returned. If there is no media in the device,\r
-  the function returns EFI_NO_MEDIA.\r
-\r
-  @param[in]  PeiServices   General-purpose services that are available to\r
-                            every PEIM.\r
-  @param[in]  This          Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
-  @param[in]  DeviceIndex   Specifies the block device to which the function wants\r
-                            to talk. Because the driver that implements Block I/O\r
-                            PPIs will manage multiple block devices, the PPIs that\r
-                            want to talk to a single device must specify the device\r
-                            index that was assigned during the enumeration process.\r
-                            This index is a number from one to NumberBlockDevices.\r
-  @param[in]  StartLBA      The starting logical block address (LBA) to read from\r
-                            on the device\r
-  @param[in]  BufferSize    The size of the Buffer in bytes. This number must be\r
-                            a multiple of the intrinsic block size of the device.\r
-  @param[out] Buffer        A pointer to the destination buffer for the data.\r
-                            The caller is responsible for the ownership of the\r
-                            buffer.\r
-\r
-  @retval EFI_SUCCESS             The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR        The device reported an error while attempting\r
-                                  to perform the read operation.\r
-  @retval EFI_INVALID_PARAMETER   The read request contains LBAs that are not\r
-                                  valid, or the buffer is not properly aligned.\r
-  @retval EFI_NO_MEDIA            There is no media in the device.\r
-  @retval EFI_BAD_BUFFER_SIZE     The BufferSize parameter is not a multiple of\r
-                                  the intrinsic block size of the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcReadBlocks (\r
-  IN   EFI_PEI_SERVICES                  **PeiServices,\r
-  IN   EFI_PEI_RECOVERY_BLOCK_IO_PPI     *This,\r
-  IN   UINTN                             DeviceIndex,\r
-  IN   EFI_PEI_LBA                       StartLBA,\r
-  IN   UINTN                             BufferSize,\r
-  OUT  VOID                              *Buffer\r
-  )\r
-{\r
-  EFI_PEI_BLOCK_IO_MEDIA MediaInfo;\r
-  EFI_STATUS            Status;\r
-  UINTN                 Count;\r
-  UINTN                 NumberOfBlocks;\r
-  UINTN                 BlockSize;\r
-  FDC_BLK_IO_DEV        *FdcBlkIoDev;\r
-  VOID                  *MemPage;\r
-\r
-  FdcBlkIoDev = NULL;\r
-  ZeroMem (&MediaInfo, sizeof (EFI_PEI_BLOCK_IO_MEDIA));\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  FdcBlkIoDev = PEI_RECOVERY_FDC_FROM_BLKIO_THIS (This);\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = FdcGetBlockDeviceMediaInfo (PeiServices, This, DeviceIndex, &MediaInfo);\r
-  if (Status != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (!MediaInfo.MediaPresent) {\r
-    return EFI_NO_MEDIA;\r
-  }\r
-\r
-  BlockSize = MediaInfo.BlockSize;\r
-\r
-  //\r
-  // If BufferSize cannot be divided by block size of FDC device,\r
-  // return EFI_BAD_BUFFER_SIZE.\r
-  //\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  NumberOfBlocks = BufferSize / BlockSize;\r
-\r
-  if ((StartLBA + NumberOfBlocks - 1) > FdcBlkIoDev->DeviceInfo[DeviceIndex - 1].MediaInfo.LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  MemPage = AllocatePages (EFI_SIZE_TO_PAGES (BufferSize));\r
-  if ((MemPage == NULL) || ((UINTN) MemPage >= ISA_MAX_MEMORY_ADDRESS)) {\r
-    //\r
-    // If fail to allocate memory under ISA_MAX_MEMORY_ADDRESS, designate the address space for DMA\r
-    //\r
-    MemPage = (VOID *) ((UINTN) (UINT32) 0x0f00000);\r
-  }\r
-  Status = MotorOn (FdcBlkIoDev, &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]));\r
-  if (Status != EFI_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Status = Setup (FdcBlkIoDev, FdcBlkIoDev->DeviceInfo[DeviceIndex - 1].DevPos);\r
-  if (Status != EFI_SUCCESS) {\r
-    MotorOff (FdcBlkIoDev, &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]));\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Read data in batches.\r
-  // Blocks in the same cylinder are read out in a batch.\r
-  //\r
-  while ((Count = GetTransferBlockCount (\r
-                    &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]),\r
-                    StartLBA,\r
-                    NumberOfBlocks\r
-                    )) != 0 && Status == EFI_SUCCESS) {\r
-    Status = ReadDataSector (\r
-               FdcBlkIoDev,\r
-               &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]),\r
-               MemPage,\r
-               StartLBA,\r
-               Count\r
-               );\r
-    CopyMem (Buffer, MemPage, BlockSize * Count);\r
-    StartLBA += Count;\r
-    NumberOfBlocks -= Count;\r
-    Buffer = (VOID *) ((UINTN) Buffer + Count * BlockSize);\r
-  }\r
-\r
-  MotorOff (FdcBlkIoDev, &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]));\r
-\r
-  switch (Status) {\r
-  case EFI_SUCCESS:\r
-    return EFI_SUCCESS;\r
-\r
-  default:\r
-    FdcReset (FdcBlkIoDev, FdcBlkIoDev->DeviceInfo[DeviceIndex - 1].DevPos);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-}\r
-\r
-/**\r
-  Initializes the floppy disk controller and installs FDC Block I/O PPI.\r
-\r
-  @param  FileHandle            Handle of the file being invoked.\r
-  @param  PeiServices           Describes the list of possible PEI Services.\r
-\r
-  @retval EFI_SUCCESS           Successfully initialized FDC and installed PPI.\r
-  @retval EFI_NOT_FOUND         Cannot find FDC device.\r
-  @retval EFI_OUT_OF_RESOURCES  Have no enough memory to create instance or descriptors.\r
-  @retval Other                 Fail to install FDC Block I/O PPI.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcPeimEntry (\r
-  IN  EFI_PEI_FILE_HANDLE         FileHandle,\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  FDC_BLK_IO_DEV        *FdcBlkIoDev;\r
-  UINTN                 DeviceCount;\r
-  UINT32                Index;\r
-\r
-  Status = PeiServicesRegisterForShadow (FileHandle);\r
-  if (!EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Allocate memory for instance of FDC_BLK_IO_DEV and copy initial value\r
-  // from template to it.\r
-  //\r
-  FdcBlkIoDev = AllocatePages (EFI_SIZE_TO_PAGES(sizeof (FDC_BLK_IO_DEV)));\r
-  if (FdcBlkIoDev == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (FdcBlkIoDev, &mBlockIoDevTemplate, sizeof (mBlockIoDevTemplate));\r
-\r
-  //\r
-  // Initialize DMA controller to enable all channels.\r
-  //\r
-  for (Index = 0; Index < sizeof (mRegisterTable) / sizeof (PEI_DMA_TABLE); Index++) {\r
-    IoWrite8 (mRegisterTable[Index].Register, mRegisterTable[Index].Value);\r
-  }\r
-  REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_PERIPHERAL_REMOVABLE_MEDIA + EFI_P_PC_INIT);\r
-\r
-  //\r
-  // Enumerate FDC devices.\r
-  //\r
-  DeviceCount = FdcEnumeration (FdcBlkIoDev);\r
-  if (DeviceCount == 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  FdcBlkIoDev->PpiDescriptor.Ppi = &FdcBlkIoDev->FdcBlkIo;\r
-\r
-  return PeiServicesInstallPpi (&FdcBlkIoDev->PpiDescriptor);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.h
deleted file mode 100644 (file)
index b0ad06c..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/** @file\r
-Private include file for IsaFloppyPei PEIM.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _RECOVERY_FLOPPY_H_\r
-#define _RECOVERY_FLOPPY_H_\r
-\r
-#include <Ppi/BlockIo.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-#include "Fdc.h"\r
-\r
-\r
-//\r
-// Some PC AT Compatible Device definitions\r
-//\r
-//\r
-// 8237 DMA registers\r
-//\r
-#define R_8237_DMA_BASE_CA_CH0                    0x00\r
-#define R_8237_DMA_BASE_CA_CH1                    0x02\r
-#define R_8237_DMA_BASE_CA_CH2                    0x04\r
-#define R_8237_DMA_BASE_CA_CH3                    0xd6\r
-#define R_8237_DMA_BASE_CA_CH5                    0xc4\r
-#define R_8237_DMA_BASE_CA_CH6                    0xc8\r
-#define R_8237_DMA_BASE_CA_CH7                    0xcc\r
-\r
-#define R_8237_DMA_BASE_CC_CH0                    0x01\r
-#define R_8237_DMA_BASE_CC_CH1                    0x03\r
-#define R_8237_DMA_BASE_CC_CH2                    0x05\r
-#define R_8237_DMA_BASE_CC_CH3                    0xd7\r
-#define R_8237_DMA_BASE_CC_CH5                    0xc6\r
-#define R_8237_DMA_BASE_CC_CH6                    0xca\r
-#define R_8237_DMA_BASE_CC_CH7                    0xce\r
-\r
-#define R_8237_DMA_MEM_LP_CH0                     0x87\r
-#define R_8237_DMA_MEM_LP_CH1                     0x83\r
-#define R_8237_DMA_MEM_LP_CH2                     0x81\r
-#define R_8237_DMA_MEM_LP_CH3                     0x82\r
-#define R_8237_DMA_MEM_LP_CH5                     0x8B\r
-#define R_8237_DMA_MEM_LP_CH6                     0x89\r
-#define R_8237_DMA_MEM_LP_CH7                     0x8A\r
-\r
-\r
-#define R_8237_DMA_COMMAND_CH0_3                  0x08\r
-#define R_8237_DMA_COMMAND_CH4_7                  0xd0\r
-#define   B_8237_DMA_COMMAND_GAP                  0x10\r
-#define   B_8237_DMA_COMMAND_CGE                  0x04\r
-\r
-\r
-#define R_8237_DMA_STA_CH0_3                      0x09\r
-#define R_8237_DMA_STA_CH4_7                      0xd2\r
-\r
-#define R_8237_DMA_WRSMSK_CH0_3                   0x0a\r
-#define R_8237_DMA_WRSMSK_CH4_7                   0xd4\r
-#define   B_8237_DMA_WRSMSK_CMS                   0x04\r
-\r
-\r
-#define R_8237_DMA_CHMODE_CH0_3                   0x0b\r
-#define R_8237_DMA_CHMODE_CH4_7                   0xd6\r
-#define   V_8237_DMA_CHMODE_DEMAND                0x00\r
-#define   V_8237_DMA_CHMODE_SINGLE                0x40\r
-#define   V_8237_DMA_CHMODE_CASCADE               0xc0\r
-#define   B_8237_DMA_CHMODE_DECREMENT             0x20\r
-#define   B_8237_DMA_CHMODE_INCREMENT             0x00\r
-#define   B_8237_DMA_CHMODE_AE                    0x10\r
-#define   V_8237_DMA_CHMODE_VERIFY                0\r
-#define   V_8237_DMA_CHMODE_IO2MEM                0x04\r
-#define   V_8237_DMA_CHMODE_MEM2IO                0x08\r
-\r
-#define R_8237_DMA_CBPR_CH0_3                     0x0c\r
-#define R_8237_DMA_CBPR_CH4_7                     0xd8\r
-\r
-#define R_8237_DMA_MCR_CH0_3                      0x0d\r
-#define R_8237_DMA_MCR_CH4_7                      0xda\r
-\r
-#define R_8237_DMA_CLMSK_CH0_3                    0x0e\r
-#define R_8237_DMA_CLMSK_CH4_7                    0xdc\r
-\r
-#define R_8237_DMA_WRMSK_CH0_3                    0x0f\r
-#define R_8237_DMA_WRMSK_CH4_7                    0xde\r
-\r
-///\r
-/// ISA memory range\r
-///\r
-#define ISA_MAX_MEMORY_ADDRESS  0x1000000\r
-\r
-//\r
-// Macro for time delay & interval\r
-//\r
-#define STALL_1_SECOND           1000000\r
-#define STALL_1_MSECOND          1000\r
-#define FDC_CHECK_INTERVAL       50\r
-\r
-#define FDC_SHORT_DELAY          50\r
-#define FDC_MEDIUM_DELAY         100\r
-#define FDC_LONG_DELAY           4000\r
-#define FDC_RESET_DELAY          2000\r
-#define FDC_RECALIBRATE_DELAY    250000\r
-\r
-typedef enum {\r
-  FdcType360K360K  = 0,\r
-  FdcType360K1200K,\r
-  FdcType1200K1200K,\r
-  FdcType720K720K,\r
-  FdcType720K1440K,\r
-  FdcType1440K1440K,\r
-  FdcType720K2880K,\r
-  FdcType1440K2880K,\r
-  FdcType2880K2880K\r
-} FDC_DISKET_TYPE;\r
-\r
-typedef struct {\r
-  UINT8 Register;\r
-  UINT8 Value;\r
-} PEI_DMA_TABLE;\r
-\r
-typedef struct {\r
-  UINT8                      DevPos;\r
-  UINT8                      Pcn;\r
-  BOOLEAN                    MotorOn;\r
-  BOOLEAN                    NeedRecalibrate;\r
-  FDC_DISKET_TYPE            Type;\r
-  EFI_PEI_BLOCK_IO_MEDIA     MediaInfo;\r
-} PEI_FLOPPY_DEVICE_INFO;\r
-\r
-#define FDC_BLK_IO_DEV_SIGNATURE  SIGNATURE_32 ('F', 'b', 'i', 'o')\r
-\r
-typedef struct {\r
-  UINTN                           Signature;\r
-  EFI_PEI_RECOVERY_BLOCK_IO_PPI   FdcBlkIo;\r
-  EFI_PEI_PPI_DESCRIPTOR          PpiDescriptor;\r
-  UINTN                           DeviceCount;\r
-  PEI_FLOPPY_DEVICE_INFO          DeviceInfo[2];\r
-} FDC_BLK_IO_DEV;\r
-\r
-#define PEI_RECOVERY_FDC_FROM_BLKIO_THIS(a) CR (a, FDC_BLK_IO_DEV, FdcBlkIo, FDC_BLK_IO_DEV_SIGNATURE)\r
-\r
-//\r
-// PEI Recovery Block I/O PPI\r
-//\r
-\r
-/**\r
-  Get the number of FDC devices.\r
-\r
-  This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.GetNumberOfBlockDevices.\r
-  It get the number of FDC devices in the system.\r
-\r
-  @param  PeiServices           An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
-  @param  This                  Pointer to this PPI instance.\r
-  @param  NumberBlockDevices    Pointer to the the number of FDC devices for output.\r
-\r
-  @retval EFI_SUCCESS           Number of FDC devices is retrieved successfully.\r
-  @retval EFI_INVALID_PARAMETER Parameter This is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcGetNumberOfBlockDevices (\r
-  IN   EFI_PEI_SERVICES                  **PeiServices,\r
-  IN   EFI_PEI_RECOVERY_BLOCK_IO_PPI     *This,\r
-  OUT  UINTN                             *NumberBlockDevices\r
-  );\r
-\r
-/**\r
-  Get the specified media information.\r
-\r
-  This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.GetBlockDeviceMediaInfo.\r
-  It gets the specified media information.\r
-\r
-  @param  PeiServices           An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
-  @param  This                  Pointer to this PPI instance.\r
-  @param  DeviceIndex           Index of FDC device to get information.\r
-  @param  MediaInfo             Pointer to the media info buffer for output.\r
-\r
-  @retval EFI_SUCCESS           Number of FDC devices is retrieved successfully.\r
-  @retval EFI_INVALID_PARAMETER Parameter This is NULL.\r
-  @retval EFI_INVALID_PARAMETER Parameter MediaInfo is NULL.\r
-  @retval EFI_INVALID_PARAMETER DeviceIndex is not valid.\r
-  @retval EFI_DEVICE_ERROR      FDC device does not exist or has errors.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcGetBlockDeviceMediaInfo (\r
-  IN   EFI_PEI_SERVICES                     **PeiServices,\r
-  IN   EFI_PEI_RECOVERY_BLOCK_IO_PPI        *This,\r
-  IN   UINTN                                DeviceIndex,\r
-  OUT  EFI_PEI_BLOCK_IO_MEDIA               *MediaInfo\r
-  );\r
-\r
-/**\r
-  Get the requested number of blocks from the specified FDC device.\r
-\r
-  This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.ReadBlocks.\r
-  It reads the requested number of blocks from the specified FDC device.\r
-\r
-  @param  PeiServices           An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
-  @param  This                  Pointer to this PPI instance.\r
-  @param  DeviceIndex           Index of FDC device to get information.\r
-  @param  StartLba              The start LBA to read from.\r
-  @param  BufferSize            The size of range to read.\r
-  @param  Buffer                Buffer to hold the data read from FDC.\r
-\r
-  @retval EFI_SUCCESS           Number of FDC devices is retrieved successfully.\r
-  @retval EFI_INVALID_PARAMETER Parameter This is NULL.\r
-  @retval EFI_INVALID_PARAMETER Parameter Buffer is NULL.\r
-  @retval EFI_INVALID_PARAMETER Parameter BufferSize cannot be divided by block size of FDC device.\r
-  @retval EFI_NO_MEDIA          No media present.\r
-  @retval EFI_DEVICE_ERROR      FDC device has error.\r
-  @retval Others                Fail to read blocks.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FdcReadBlocks (\r
-  IN   EFI_PEI_SERVICES                  **PeiServices,\r
-  IN   EFI_PEI_RECOVERY_BLOCK_IO_PPI     *This,\r
-  IN   UINTN                             DeviceIndex,\r
-  IN   EFI_PEI_LBA                       StartLba,\r
-  IN   UINTN                             BufferSize,\r
-  OUT  VOID                              *Buffer\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.inf
deleted file mode 100644 (file)
index 7b5970d..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-## @file\r
-# ISA Floppy PEIM to support recovery boot via floppy disk.\r
-#\r
-# This module detects and supports ISA Floppy drives. If a drive is discovered\r
-# the PEIM will install the BlockIo PPI. This module is only dispatched if it\r
-# is in the Recovery Boot mode.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-################################################################################\r
-#\r
-# Defines Section - statements that will be processed to create a Makefile.\r
-#\r
-################################################################################\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = IsaFloppyPei\r
-  MODULE_UNI_FILE                = IsaFloppyPei.uni\r
-  FILE_GUID                      = 7F6E0A24-DBFD-43df-9755-0292D7D3DD48\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = FdcPeimEntry\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC (EBC is for build only)\r
-#\r
-\r
-[Sources]\r
-  FloppyPeim.c\r
-  FloppyPeim.h\r
-  Fdc.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  IoLib\r
-  TimerLib\r
-  ReportStatusCodeLib\r
-  BaseMemoryLib\r
-  PeiServicesLib\r
-  PeimEntryPoint\r
-  DebugLib\r
-  MemoryAllocationLib\r
-  PcdLib\r
-\r
-[Ppis]\r
-  gEfiPeiVirtualBlockIoPpiGuid    ## PRODUCES\r
-\r
-[Pcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdFdcBaseAddress   ## CONSUMES\r
-\r
-[Depex]\r
-  gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiBootInRecoveryModePpiGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  IsaFloppyPeiExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.uni
deleted file mode 100644 (file)
index eff9741..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// ISA Floppy PEIM to support recovery boot via floppy disk.\r
-//\r
-// This module detects and supports ISA Floppy drives. If a drive is discovered\r
-// the PEIM will install the BlockIo PPI. This module is only dispatched if it\r
-// is in the Recovery Boot mode.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "ISA Floppy PEIM to support recovery boot via floppy disk"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This module detects and supports ISA Floppy drives. If a drive is discovered the PEIM will install the BlockIo PPI. This module is only dispatched if it is in the Recovery Boot mode."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPeiExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPeiExtra.uni
deleted file mode 100644 (file)
index a1f93d3..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// IsaFloppyPei Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"ISA Floppy PEI Module"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.c
deleted file mode 100644 (file)
index 405f183..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/** @file\r
-  UEFI Component Name(2) protocol implementation for Isa driver.\r
-\r
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IsaDriver.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gIsaIoComponentName = {\r
-  IsaIoComponentNameGetDriverName,\r
-  IsaIoComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaIoComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaIoComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaIoComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaIoDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"ISA IO Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mIsaIoDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gIsaIoComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_HANDLE                   ChildHandle  OPTIONAL,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **ControllerName\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.h
deleted file mode 100644 (file)
index aae0db8..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/** @file\r
-  Header file for implementation of UEFI Component Name(2) protocol.\r
-\r
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _COMPONENT_NAME_H_\r
-#define _COMPONENT_NAME_H_\r
-\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gIsaIoComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gIsaIoComponentName2;\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_HANDLE                   ChildHandle  OPTIONAL,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **ControllerName\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.c b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.c
deleted file mode 100644 (file)
index 9a72469..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-/** @file\r
-  IsaIo UEFI driver.\r
-\r
-  Produce an instance of the ISA I/O Protocol for every SIO controller.\r
-\r
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IsaDriver.h"\r
-\r
-//\r
-// IsaIo Driver Global Variables\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gIsaIoDriver = {\r
-  IsaIoDriverSupported,\r
-  IsaIoDriverStart,\r
-  IsaIoDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-/**\r
-  The main entry point for the IsaIo driver.\r
-\r
-  @param[in] ImageHandle        The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable        A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS           The entry point is executed successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  There was not enough memory in pool to install all the protocols.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeIsaIo (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gIsaIoDriver,\r
-             ImageHandle,\r
-             &gIsaIoComponentName,\r
-             &gIsaIoComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Tests to see if a controller can be managed by the IsaIo driver.\r
-\r
-  @param[in] This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] Controller           The handle of the controller to test.\r
-  @param[in] RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS             The device is supported by this driver.\r
-  @retval EFI_ALREADY_STARTED     The device is already being managed by this driver.\r
-  @retval EFI_ACCESS_DENIED       The device is already being managed by a different driver\r
-                                  or an application that requires exclusive access.\r
-  @retval EFI_UNSUPPORTED         The device is is not supported by this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_SIO_PROTOCOL          *Sio;\r
-  EFI_HANDLE                PciHandle;\r
-\r
-  //\r
-  // Try to open EFI DEVICE PATH protocol on the controller\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Get the PciIo protocol from its parent controller.\r
-    //\r
-    Status = gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &DevicePath, &PciHandle);\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Try to open the Super IO protocol on the controller\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiSioProtocolGuid,\r
-                  (VOID **) &Sio,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiSioProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Start this driver on ControllerHandle.\r
-\r
-  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been moved into this\r
-  common boot service. It is legal to call Start() from other locations, but the following calling\r
-  restrictions must be followed or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE.\r
-  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
-     EFI_DEVICE_PATH_PROTOCOL.\r
-  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
-     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
-                                   must support a protocol interface that supplies\r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-                                   This parameter is ignored by device drivers, and is optional for bus drivers.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
-                                   Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_PCI_IO_PROTOCOL                   *PciIo;\r
-  EFI_DEVICE_PATH_PROTOCOL              *DevicePath;\r
-  EFI_HANDLE                            PciHandle;\r
-  EFI_SIO_PROTOCOL                      *Sio;\r
-  ACPI_RESOURCE_HEADER_PTR              Resources;\r
-  EFI_DEVICE_PATH_PROTOCOL              *TempDevicePath;\r
-  ISA_IO_DEVICE                         *IsaIoDevice;\r
-\r
-  PciIo = NULL;\r
-  Sio   = NULL;\r
-\r
-  //\r
-  // Open Device Path Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get the PciIo protocol from its parent controller.\r
-  //\r
-  TempDevicePath = DevicePath;\r
-  Status = gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &TempDevicePath, &PciHandle);\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = gBS->HandleProtocol (PciHandle, &gEfiPciIoProtocolGuid, (VOID **) &PciIo);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Open Super IO Protocol\r
-    //\r
-    Status = gBS->OpenProtocol (\r
-                    Controller,\r
-                    &gEfiSioProtocolGuid,\r
-                    (VOID **) &Sio,\r
-                    This->DriverBindingHandle,\r
-                    Controller,\r
-                    EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                    );\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Fail due to LocateDevicePath(...) or OpenProtocol(Sio, BY_DRIVER)\r
-    //\r
-    return Status;\r
-  }\r
-\r
-  Status = Sio->GetResources (Sio, &Resources);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  IsaIoDevice = AllocatePool (sizeof (ISA_IO_DEVICE));\r
-  ASSERT (IsaIoDevice != NULL);\r
-\r
-  IsaIoDevice->Signature = ISA_IO_DEVICE_SIGNATURE;\r
-  IsaIoDevice->PciIo     = PciIo;\r
-\r
-  //\r
-  // Initialize the ISA I/O instance structure\r
-  //\r
-  InitializeIsaIoInstance (IsaIoDevice, DevicePath, Resources);\r
-\r
-  //\r
-  // Install the ISA I/O protocol on the Controller handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  &IsaIoDevice->IsaIo,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Stop this driver on ControllerHandle.\r
-\r
-  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
-  As a result, much of the error checking on the parameters to Stop() has been moved\r
-  into this common boot service. It is legal to call Stop() from other locations,\r
-  but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
-     same driver's Start() function.\r
-  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
-     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
-     Start() function, and the Start() function must have called OpenProtocol() on\r
-     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-\r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
-                                support a bus specific I/O protocol for the driver\r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
-                                if NumberOfChildren is 0.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  * This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   * ChildHandleBuffer OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  ISA_IO_DEVICE                       *IsaIoDevice;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (IsaIo);\r
-\r
-  Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  &IsaIoDevice->IsaIo,\r
-                  NULL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiSioProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    Controller\r
-                    );\r
-    FreePool (IsaIoDevice->IsaIo.ResourceList);\r
-    FreePool (IsaIoDevice);\r
-  }\r
-\r
-   return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.h b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.h
deleted file mode 100644 (file)
index 88de62b..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/** @file\r
-  The header file for ISA driver\r
-\r
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _ISA_DRIVER_H_\r
-#define _ISA_DRIVER_H_\r
-\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/SuperIo.h>\r
-#include <Protocol/ComponentName.h>\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/DriverBinding.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <IndustryStandard/Acpi.h>\r
-\r
-#include "ComponentName.h"\r
-\r
-//\r
-// 8237 DMA registers\r
-//\r
-#define R_8237_DMA_BASE_CA_CH0                    0x00\r
-#define R_8237_DMA_BASE_CA_CH1                    0x02\r
-#define R_8237_DMA_BASE_CA_CH2                    0x04\r
-#define R_8237_DMA_BASE_CA_CH3                    0xd6\r
-#define R_8237_DMA_BASE_CA_CH5                    0xc4\r
-#define R_8237_DMA_BASE_CA_CH6                    0xc8\r
-#define R_8237_DMA_BASE_CA_CH7                    0xcc\r
-\r
-#define R_8237_DMA_BASE_CC_CH0                    0x01\r
-#define R_8237_DMA_BASE_CC_CH1                    0x03\r
-#define R_8237_DMA_BASE_CC_CH2                    0x05\r
-#define R_8237_DMA_BASE_CC_CH3                    0xd7\r
-#define R_8237_DMA_BASE_CC_CH5                    0xc6\r
-#define R_8237_DMA_BASE_CC_CH6                    0xca\r
-#define R_8237_DMA_BASE_CC_CH7                    0xce\r
-\r
-#define R_8237_DMA_MEM_LP_CH0                     0x87\r
-#define R_8237_DMA_MEM_LP_CH1                     0x83\r
-#define R_8237_DMA_MEM_LP_CH2                     0x81\r
-#define R_8237_DMA_MEM_LP_CH3                     0x82\r
-#define R_8237_DMA_MEM_LP_CH5                     0x8B\r
-#define R_8237_DMA_MEM_LP_CH6                     0x89\r
-#define R_8237_DMA_MEM_LP_CH7                     0x8A\r
-\r
-\r
-#define R_8237_DMA_COMMAND_CH0_3                  0x08\r
-#define R_8237_DMA_COMMAND_CH4_7                  0xd0\r
-#define   B_8237_DMA_COMMAND_GAP                  0x10\r
-#define   B_8237_DMA_COMMAND_CGE                  0x04\r
-\r
-\r
-#define R_8237_DMA_STA_CH0_3                      0xd8\r
-#define R_8237_DMA_STA_CH4_7                      0xd0\r
-\r
-#define R_8237_DMA_WRSMSK_CH0_3                   0x0a\r
-#define R_8237_DMA_WRSMSK_CH4_7                   0xd4\r
-#define   B_8237_DMA_WRSMSK_CMS                   0x04\r
-\r
-\r
-#define R_8237_DMA_CHMODE_CH0_3                   0x0b\r
-#define R_8237_DMA_CHMODE_CH4_7                   0xd6\r
-#define   V_8237_DMA_CHMODE_DEMAND                0x00\r
-#define   V_8237_DMA_CHMODE_SINGLE                0x40\r
-#define   V_8237_DMA_CHMODE_CASCADE               0xc0\r
-#define   B_8237_DMA_CHMODE_DECREMENT             0x20\r
-#define   B_8237_DMA_CHMODE_INCREMENT             0x00\r
-#define   B_8237_DMA_CHMODE_AE                    0x10\r
-#define   V_8237_DMA_CHMODE_VERIFY                0\r
-#define   V_8237_DMA_CHMODE_IO2MEM                0x04\r
-#define   V_8237_DMA_CHMODE_MEM2IO                0x08\r
-\r
-#define R_8237_DMA_CBPR_CH0_3                     0x0c\r
-#define R_8237_DMA_CBPR_CH4_7                     0xd8\r
-\r
-#define R_8237_DMA_MCR_CH0_3                      0x0d\r
-#define R_8237_DMA_MCR_CH4_7                      0xda\r
-\r
-#define R_8237_DMA_CLMSK_CH0_3                    0x0e\r
-#define R_8237_DMA_CLMSK_CH4_7                    0xdc\r
-\r
-#define R_8237_DMA_WRMSK_CH0_3                    0x0f\r
-#define R_8237_DMA_WRMSK_CH4_7                    0xde\r
-\r
-typedef enum {\r
-  IsaAccessTypeUnknown,\r
-  IsaAccessTypeIo,\r
-  IsaAccessTypeMem,\r
-  IsaAccessTypeMaxType\r
-} ISA_ACCESS_TYPE;\r
-\r
-typedef struct {\r
-  UINT8 Address;\r
-  UINT8 Page;\r
-  UINT8 Count;\r
-} EFI_ISA_DMA_REGISTERS;\r
-\r
-//\r
-// ISA I/O Device Structure\r
-//\r
-#define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')\r
-\r
-typedef struct {\r
-  UINT32                                    Signature;\r
-  EFI_HANDLE                                Handle;\r
-  EFI_ISA_IO_PROTOCOL                       IsaIo;\r
-  EFI_PCI_IO_PROTOCOL                       *PciIo;\r
-} ISA_IO_DEVICE;\r
-\r
-#define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)\r
-\r
-//\r
-// Mapping structure for performing ISA DMA to a buffer above 16 MB\r
-//\r
-typedef struct {\r
-  EFI_ISA_IO_PROTOCOL_OPERATION Operation;\r
-  UINTN                         NumberOfBytes;\r
-  UINTN                         NumberOfPages;\r
-  EFI_PHYSICAL_ADDRESS          HostAddress;\r
-  EFI_PHYSICAL_ADDRESS          MappedHostAddress;\r
-} ISA_MAP_INFO;\r
-\r
-//\r
-// EFI Driver Binding Protocol Interface Functions\r
-//\r
-\r
-/**\r
-  Tests to see if a controller can be managed by the ISA Driver.\r
-\r
-  How the Start() function of a driver is implemented can affect how the Supported() function is implemented.\r
-\r
-  @param[in] This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in] Controller           The handle of the controller to test.\r
-  @param[in] RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS             The device is supported by this driver.\r
-  @retval EFI_ALREADY_STARTED     The device is already being managed by this driver.\r
-  @retval EFI_ACCESS_DENIED       The device is already being managed by a different driver\r
-                                  or an application that requires exclusive access.\r
-  @retval EFI_UNSUPPORTED         The device is is not supported by this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  );\r
-\r
-/**\r
-  Start this driver on ControllerHandle.\r
-\r
-  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been moved into this\r
-  common boot service. It is legal to call Start() from other locations, but the following calling\r
-  restrictions must be followed or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE.\r
-  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
-     EFI_DEVICE_PATH_PROTOCOL.\r
-  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
-     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
-                                   must support a protocol interface that supplies\r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-                                   This parameter is ignored by device drivers, and is optional for bus drivers.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
-                                   Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  );\r
-\r
-/**\r
-  Stop this driver on ControllerHandle.\r
-\r
-  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
-  As a result, much of the error checking on the parameters to Stop() has been moved\r
-  into this common boot service. It is legal to call Stop() from other locations,\r
-  but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
-     same driver's Start() function.\r
-  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
-     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
-     Start() function, and the Start() function must have called OpenProtocol() on\r
-     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-\r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
-                                support a bus specific I/O protocol for the driver\r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
-                                if NumberOfChildren is 0.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  * This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   * ChildHandleBuffer OPTIONAL\r
-  );\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-\r
-/**\r
-  Initializes an ISA I/O Instance\r
-\r
-  @param[in] IsaIoDevice            The isa device to be initialized.\r
-  @param[in] DevicePath             The device path of the isa device.\r
-  @param[in] Resources              The ACPI resource list.\r
-\r
-**/\r
-VOID\r
-InitializeIsaIoInstance (\r
-  IN ISA_IO_DEVICE               *IsaIoDevice,\r
-  IN EFI_DEVICE_PATH_PROTOCOL    *DevicePath,\r
-  IN ACPI_RESOURCE_HEADER_PTR    Resources\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.c b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.c
deleted file mode 100644 (file)
index 17ce13e..0000000
+++ /dev/null
@@ -1,1797 +0,0 @@
-/** @file\r
-  The implementation for EFI_ISA_IO_PROTOCOL.\r
-\r
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IsaIo.h"\r
-\r
-//\r
-// Module Variables\r
-//\r
-EFI_ISA_IO_PROTOCOL mIsaIoInterface = {\r
-  {\r
-    IsaIoMemRead,\r
-    IsaIoMemWrite\r
-  },\r
-  {\r
-    IsaIoIoRead,\r
-    IsaIoIoWrite\r
-  },\r
-  IsaIoCopyMem,\r
-  IsaIoMap,\r
-  IsaIoUnmap,\r
-  IsaIoAllocateBuffer,\r
-  IsaIoFreeBuffer,\r
-  IsaIoFlush,\r
-  NULL,\r
-  0,\r
-  NULL\r
-};\r
-\r
-EFI_ISA_DMA_REGISTERS  mDmaRegisters[8] = {\r
-  {\r
-    0x00,\r
-    0x87,\r
-    0x01\r
-  },\r
-  {\r
-    0x02,\r
-    0x83,\r
-    0x03\r
-  },\r
-  {\r
-    0x04,\r
-    0x81,\r
-    0x05\r
-  },\r
-  {\r
-    0x06,\r
-    0x82,\r
-    0x07\r
-  },\r
-  {\r
-    0x00,\r
-    0x00,\r
-    0x00\r
-  },  // Channel 4 is invalid\r
-  {\r
-    0xC4,\r
-    0x8B,\r
-    0xC6\r
-  },\r
-  {\r
-    0xC8,\r
-    0x89,\r
-    0xCA\r
-  },\r
-  {\r
-    0xCC,\r
-    0x8A,\r
-    0xCE\r
-  },\r
-};\r
-\r
-/**\r
-  Verifies access to an ISA device\r
-\r
-  @param[in] IsaIoDevice         The ISA device to be verified.\r
-  @param[in] Type                The Access type. The input must be either IsaAccessTypeMem or IsaAccessTypeIo.\r
-  @param[in] Width               The width of the memory operation.\r
-  @param[in] Count               The number of memory operations to perform.\r
-  @param[in] Offset              The offset in ISA memory space to start the memory operation.\r
-\r
-  @retval EFI_SUCCESS            Verify success.\r
-  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value.\r
-  @retval EFI_UNSUPPORTED        The device ont support the access type.\r
-**/\r
-EFI_STATUS\r
-IsaIoVerifyAccess (\r
-  IN ISA_IO_DEVICE              *IsaIoDevice,\r
-  IN ISA_ACCESS_TYPE            Type,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINTN                      Count,\r
-  IN UINT32                     Offset\r
-  )\r
-{\r
-  EFI_ISA_ACPI_RESOURCE *Item;\r
-  EFI_STATUS            Status;\r
-\r
-  if ((UINT32)Width >= EfiIsaIoWidthMaximum ||\r
-      Width == EfiIsaIoWidthReserved ||\r
-      Width == EfiIsaIoWidthFifoReserved ||\r
-      Width == EfiIsaIoWidthFillReserved\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // If Width is EfiIsaIoWidthFifoUintX then convert to EfiIsaIoWidthUintX\r
-  // If Width is EfiIsaIoWidthFillUintX then convert to EfiIsaIoWidthUintX\r
-  //\r
-  if (Width >= EfiIsaIoWidthFifoUint8 && Width < EfiIsaIoWidthFifoReserved) {\r
-    Count = 1;\r
-  }\r
-\r
-  Width = (EFI_ISA_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-\r
-  Status  = EFI_UNSUPPORTED;\r
-  Item    = IsaIoDevice->IsaIo.ResourceList->ResourceItem;\r
-  while (Item->Type != EfiIsaAcpiResourceEndOfList) {\r
-    if ((Type == IsaAccessTypeMem && Item->Type == EfiIsaAcpiResourceMemory) ||\r
-        (Type == IsaAccessTypeIo && Item->Type == EfiIsaAcpiResourceIo)) {\r
-      if (Offset >= Item->StartRange && (Offset + Count * (UINT32)(1 << Width)) - 1 <= Item->EndRange) {\r
-        return EFI_SUCCESS;\r
-      }\r
-\r
-      if (Offset >= Item->StartRange && Offset <= Item->EndRange) {\r
-        Status = EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-\r
-    Item++;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Convert the IO Information in ACPI descriptor to IO ISA Attribute.\r
-\r
-  @param[in] Information   The IO Information in ACPI descriptor\r
-\r
-  @return UINT32           The IO ISA Attribute\r
-**/\r
-UINT32\r
-IsaIoAttribute (\r
-  IN UINT8                            Information\r
-  )\r
-{\r
-  UINT32             Attribute;\r
-\r
-  Attribute = 0;\r
-\r
-  switch (Information & EFI_ACPI_IO_DECODE_MASK) {\r
-    case EFI_ACPI_IO_DECODE_16_BIT:\r
-      Attribute |= EFI_ISA_ACPI_IO_DECODE_16_BITS;\r
-      break;\r
-\r
-    case EFI_ACPI_IO_DECODE_10_BIT:\r
-      Attribute |= EFI_ISA_ACPI_IO_DECODE_10_BITS;\r
-      break;\r
-  }\r
-\r
-  return Attribute;\r
-}\r
-\r
-/**\r
-  Convert the IRQ Information in ACPI descriptor to IRQ ISA Attribute.\r
-\r
-  @param[in] Information   The IRQ Information in ACPI descriptor\r
-\r
-  @return UINT32           The IRQ ISA Attribute\r
-**/\r
-UINT32\r
-IsaIrqAttribute (\r
-  IN UINT8                            Information\r
-  )\r
-{\r
-  UINT32             Attribute;\r
-\r
-  Attribute = 0;\r
-\r
-  if ((Information & EFI_ACPI_IRQ_POLARITY_MASK) == EFI_ACPI_IRQ_HIGH_TRUE) {\r
-    if ((Information & EFI_ACPI_IRQ_MODE) == EFI_ACPI_IRQ_LEVEL_TRIGGERED) {\r
-      Attribute = EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_LEVEL_SENSITIVE;\r
-    } else {\r
-      Attribute = EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_EDGE_SENSITIVE;\r
-    }\r
-  } else {\r
-    if ((Information & EFI_ACPI_IRQ_MODE) == EFI_ACPI_IRQ_LEVEL_TRIGGERED) {\r
-      Attribute = EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_LEVEL_SENSITIVE;\r
-    } else {\r
-      Attribute = EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_EDGE_SENSITIVE;\r
-    }\r
-  }\r
-  return Attribute;\r
-}\r
-\r
-/**\r
-  Convert the Memory Information in ACPI descriptor to Memory ISA Attribute.\r
-\r
-  @param[in] Information   The Memory Information in ACPI descriptor\r
-\r
-  @return UINT32           The Memory ISA Attribute\r
-**/\r
-UINT32\r
-IsaMemoryAttribute (\r
-  IN UINT8                            Information\r
-  )\r
-{\r
-  UINT32             Attribute;\r
-\r
-  Attribute = 0;\r
-\r
-  switch (Information & EFI_ACPI_MEMORY_WRITE_STATUS_MASK) {\r
-    case EFI_ACPI_MEMORY_WRITABLE:\r
-      Attribute |= EFI_ISA_ACPI_MEMORY_WRITEABLE;\r
-      break;\r
-  }\r
-\r
-  return Attribute;\r
-}\r
-\r
-/**\r
-  Convert the DMA Information in ACPI descriptor to DMA ISA Attribute.\r
-\r
-  @param[in] Information   The DMA Information in ACPI descriptor\r
-\r
-  @return UINT32           The DMA ISA Attribute\r
-**/\r
-UINT32\r
-IsaDmaAttribute (\r
-  IN UINT8                            Information\r
-  )\r
-{\r
-  UINT32             Attribute;\r
-\r
-  Attribute = EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE;\r
-\r
-  switch (Information & EFI_ACPI_DMA_SPEED_TYPE_MASK) {\r
-    case EFI_ACPI_DMA_SPEED_TYPE_COMPATIBILITY:\r
-      Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE;\r
-      break;\r
-    case EFI_ACPI_DMA_SPEED_TYPE_A:\r
-      Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A;\r
-      break;\r
-    case EFI_ACPI_DMA_SPEED_TYPE_B:\r
-      Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B;\r
-      break;\r
-    case EFI_ACPI_DMA_SPEED_TYPE_F:\r
-      Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C;\r
-      break;\r
-  }\r
-\r
-  switch (Information & EFI_ACPI_DMA_TRANSFER_TYPE_MASK) {\r
-    case EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT:\r
-      Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8;\r
-      break;\r
-    case EFI_ACPI_DMA_TRANSFER_TYPE_16_BIT:\r
-      Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16;\r
-      break;\r
-  }\r
-\r
-  return Attribute;\r
-}\r
-\r
-/**\r
-  Convert the ACPI resource descriptor to ISA resource descriptor.\r
-\r
-  @param[in]  AcpiResource          Pointer to the ACPI resource descriptor\r
-  @param[out] IsaResource           The optional pointer to the buffer to\r
-                                    store the converted ISA resource descriptor\r
-\r
-  @return     UINTN                 Number of ISA resource descriptor needed\r
-**/\r
-UINTN\r
-AcpiResourceToIsaResource (\r
-  IN  ACPI_RESOURCE_HEADER_PTR        AcpiResource,\r
-  OUT EFI_ISA_ACPI_RESOURCE           *IsaResource   OPTIONAL\r
-  )\r
-{\r
-  UINT32                                        Index;\r
-  UINTN                                         Count;\r
-  UINT32                                        LastIndex;\r
-  EFI_ACPI_IO_PORT_DESCRIPTOR                   *Io;\r
-  EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR    *FixedIo;\r
-  EFI_ACPI_IRQ_DESCRIPTOR                       *Irq;\r
-  EFI_ACPI_DMA_DESCRIPTOR                       *Dma;\r
-  EFI_ACPI_32_BIT_MEMORY_RANGE_DESCRIPTOR       *Memory;\r
-  EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR *FixedMemory;\r
-\r
-  Count     = 0;\r
-  LastIndex = 0;\r
-\r
-  switch (AcpiResource.SmallHeader->Byte) {\r
-    case ACPI_DMA_DESCRIPTOR:\r
-      Dma = (EFI_ACPI_DMA_DESCRIPTOR *) AcpiResource.SmallHeader;\r
-      for (Index = 0; Index < sizeof (Dma->ChannelMask) * 8; Index++) {\r
-        if (Dma->ChannelMask & (1 << Index)) {\r
-          if ((Count > 0) && (LastIndex + 1 == Index)) {\r
-            if (IsaResource != NULL) {\r
-              IsaResource[Count - 1].EndRange ++;\r
-            }\r
-          } else {\r
-            if (IsaResource != NULL) {\r
-              IsaResource[Count].Type       = EfiIsaAcpiResourceDma;\r
-              IsaResource[Count].Attribute  = IsaDmaAttribute (Dma->Information);\r
-              IsaResource[Count].StartRange = Index;\r
-              IsaResource[Count].EndRange   = Index;\r
-            }\r
-            Count ++;\r
-          }\r
-\r
-          LastIndex = Index;\r
-        }\r
-      }\r
-      break;\r
-\r
-    case ACPI_IO_PORT_DESCRIPTOR:\r
-      Io = (EFI_ACPI_IO_PORT_DESCRIPTOR *) AcpiResource.SmallHeader;\r
-      if (Io->Length != 0) {\r
-        if (IsaResource != NULL) {\r
-          IsaResource[Count].Type       = EfiIsaAcpiResourceIo;\r
-          IsaResource[Count].Attribute  = IsaIoAttribute (Io->Information);\r
-          IsaResource[Count].StartRange = Io->BaseAddressMin;\r
-          IsaResource[Count].EndRange   = Io->BaseAddressMin + Io->Length - 1;\r
-        }\r
-        Count ++;\r
-      }\r
-      break;\r
-\r
-    case ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR:\r
-      FixedIo = (EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *) AcpiResource.SmallHeader;\r
-      if (FixedIo->Length != 0) {\r
-        if (IsaResource != NULL) {\r
-          IsaResource[Count].Type       = EfiIsaAcpiResourceIo;\r
-          IsaResource[Count].Attribute  = EFI_ISA_ACPI_IO_DECODE_10_BITS;\r
-          IsaResource[Count].StartRange = FixedIo->BaseAddress;\r
-          IsaResource[Count].EndRange   = FixedIo->BaseAddress + FixedIo->Length - 1;\r
-        }\r
-        Count ++;\r
-      }\r
-      break;\r
-\r
-    case ACPI_IRQ_DESCRIPTOR:\r
-    case ACPI_IRQ_NOFLAG_DESCRIPTOR:\r
-      Irq = (EFI_ACPI_IRQ_DESCRIPTOR *) AcpiResource.SmallHeader;\r
-      for (Index = 0; Index < sizeof (Irq->Mask) * 8; Index++) {\r
-        if (Irq->Mask & (1 << Index)) {\r
-          if ((Count > 0) && (LastIndex + 1 == Index)) {\r
-            if (IsaResource != NULL) {\r
-              IsaResource[Count - 1].EndRange ++;\r
-            }\r
-          } else {\r
-            if (IsaResource != NULL) {\r
-              IsaResource[Count].Type       = EfiIsaAcpiResourceInterrupt;\r
-              if (AcpiResource.SmallHeader->Byte == ACPI_IRQ_DESCRIPTOR) {\r
-                IsaResource[Count].Attribute = IsaIrqAttribute (Irq->Information);\r
-              } else {\r
-                IsaResource[Count].Attribute  = EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_EDGE_SENSITIVE;\r
-              }\r
-              IsaResource[Count].StartRange = Index;\r
-              IsaResource[Count].EndRange   = Index;\r
-            }\r
-            Count++;\r
-          }\r
-\r
-          LastIndex = Index;\r
-        }\r
-      }\r
-      break;\r
-\r
-    case ACPI_32_BIT_MEMORY_RANGE_DESCRIPTOR:\r
-      Memory = (EFI_ACPI_32_BIT_MEMORY_RANGE_DESCRIPTOR *) AcpiResource.LargeHeader;\r
-      if (Memory->Length != 0) {\r
-        if (IsaResource != NULL) {\r
-          IsaResource[Count].Type       = EfiIsaAcpiResourceMemory;\r
-          IsaResource[Count].Attribute  = IsaMemoryAttribute (Memory->Information);\r
-          IsaResource[Count].StartRange = Memory->BaseAddressMin;\r
-          IsaResource[Count].EndRange   = Memory->BaseAddressMin + Memory->Length - 1;\r
-        }\r
-        Count ++;\r
-      }\r
-      break;\r
-\r
-    case ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR:\r
-      FixedMemory = (EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR *) AcpiResource.LargeHeader;\r
-      if (FixedMemory->Length != 0) {\r
-        if (IsaResource != NULL) {\r
-          IsaResource[Count].Type       = EfiIsaAcpiResourceMemory;\r
-          IsaResource[Count].Attribute  = IsaMemoryAttribute (FixedMemory->Information);\r
-          IsaResource[Count].StartRange = FixedMemory->BaseAddress;\r
-          IsaResource[Count].EndRange   = FixedMemory->BaseAddress + FixedMemory->Length - 1;\r
-        }\r
-        Count ++;\r
-      }\r
-      break;\r
-\r
-    case ACPI_END_TAG_DESCRIPTOR:\r
-      if (IsaResource != NULL) {\r
-        IsaResource[Count].Type       = EfiIsaAcpiResourceEndOfList;\r
-        IsaResource[Count].Attribute  = 0;\r
-        IsaResource[Count].StartRange = 0;\r
-        IsaResource[Count].EndRange   = 0;\r
-      }\r
-      Count ++;\r
-      break;\r
-  }\r
-\r
-  return Count;\r
-}\r
-\r
-/**\r
-  Initializes an ISA I/O Instance\r
-\r
-  @param[in] IsaIoDevice            The isa device to be initialized.\r
-  @param[in] DevicePath             The device path of the isa device.\r
-  @param[in] Resources              The ACPI resource list.\r
-\r
-**/\r
-VOID\r
-InitializeIsaIoInstance (\r
-  IN ISA_IO_DEVICE               *IsaIoDevice,\r
-  IN EFI_DEVICE_PATH_PROTOCOL    *DevicePath,\r
-  IN ACPI_RESOURCE_HEADER_PTR    Resources\r
-  )\r
-{\r
-  UINTN                                       Index;\r
-  ACPI_HID_DEVICE_PATH                        *AcpiNode;\r
-  ACPI_RESOURCE_HEADER_PTR                    ResourcePtr;\r
-\r
-  //\r
-  // Use the ISA IO Protocol structure template to initialize the ISA IO instance\r
-  //\r
-  CopyMem (\r
-    &IsaIoDevice->IsaIo,\r
-    &mIsaIoInterface,\r
-    sizeof (EFI_ISA_IO_PROTOCOL)\r
-    );\r
-\r
-  //\r
-  // Count the resources including the ACPI End Tag\r
-  //\r
-  ResourcePtr = Resources;\r
-  Index       = 0;\r
-  while (ResourcePtr.SmallHeader->Byte != ACPI_END_TAG_DESCRIPTOR) {\r
-\r
-    Index += AcpiResourceToIsaResource (ResourcePtr, NULL);\r
-\r
-    if (ResourcePtr.SmallHeader->Bits.Type == 0) {\r
-      ResourcePtr.SmallHeader = (ACPI_SMALL_RESOURCE_HEADER *) ((UINT8 *) ResourcePtr.SmallHeader\r
-                              + ResourcePtr.SmallHeader->Bits.Length\r
-                              + sizeof (*ResourcePtr.SmallHeader));\r
-    } else {\r
-      ResourcePtr.LargeHeader = (ACPI_LARGE_RESOURCE_HEADER *) ((UINT8 *) ResourcePtr.LargeHeader\r
-                              + ResourcePtr.LargeHeader->Length\r
-                              + sizeof (*ResourcePtr.LargeHeader));\r
-    }\r
-\r
-  }\r
-  //\r
-  // Get the Isa Resource count for ACPI End Tag\r
-  //\r
-  Index += AcpiResourceToIsaResource (ResourcePtr, NULL);\r
-\r
-  //\r
-  // Initialize the ResourceList\r
-  //\r
-  IsaIoDevice->IsaIo.ResourceList = AllocatePool (sizeof (EFI_ISA_ACPI_RESOURCE_LIST) + Index * sizeof (EFI_ISA_ACPI_RESOURCE));\r
-  ASSERT (IsaIoDevice->IsaIo.ResourceList != NULL);\r
-  IsaIoDevice->IsaIo.ResourceList->ResourceItem = (EFI_ISA_ACPI_RESOURCE *) (IsaIoDevice->IsaIo.ResourceList + 1);\r
-\r
-  AcpiNode = (ACPI_HID_DEVICE_PATH *) ((UINT8 *) DevicePath + GetDevicePathSize (DevicePath) - END_DEVICE_PATH_LENGTH - sizeof (ACPI_HID_DEVICE_PATH));\r
-  IsaIoDevice->IsaIo.ResourceList->Device.HID = AcpiNode->HID;\r
-  IsaIoDevice->IsaIo.ResourceList->Device.UID = AcpiNode->UID;\r
-\r
-  ResourcePtr = Resources;\r
-  Index       = 0;\r
-  while (ResourcePtr.SmallHeader->Byte != ACPI_END_TAG_DESCRIPTOR) {\r
-\r
-    Index += AcpiResourceToIsaResource (ResourcePtr, &IsaIoDevice->IsaIo.ResourceList->ResourceItem[Index]);\r
-\r
-    if (ResourcePtr.SmallHeader->Bits.Type == 0) {\r
-      ResourcePtr.SmallHeader = (ACPI_SMALL_RESOURCE_HEADER *) ((UINT8 *) ResourcePtr.SmallHeader\r
-                              + ResourcePtr.SmallHeader->Bits.Length\r
-                              + sizeof (*ResourcePtr.SmallHeader));\r
-    } else {\r
-      ResourcePtr.LargeHeader = (ACPI_LARGE_RESOURCE_HEADER *) ((UINT8 *) ResourcePtr.LargeHeader\r
-                              + ResourcePtr.LargeHeader->Length\r
-                              + sizeof (*ResourcePtr.LargeHeader));\r
-    }\r
-  }\r
-\r
-  //\r
-  // Convert the ACPI End Tag\r
-  //\r
-  AcpiResourceToIsaResource (ResourcePtr, &IsaIoDevice->IsaIo.ResourceList->ResourceItem[Index]);\r
-}\r
-\r
-/**\r
-  Performs an ISA I/O Read Cycle\r
-\r
-  @param[in]  This              A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width             Specifies the width of the I/O operation.\r
-  @param[in]  Offset            The offset in ISA I/O space to start the I/O operation.\r
-  @param[in]  Count             The number of I/O operations to perform.\r
-  @param[out] Buffer            The destination buffer to store the results\r
-\r
-  @retval EFI_SUCCESS           The data was read from the device sucessfully.\r
-  @retval EFI_UNSUPPORTED       The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoIoRead (\r
-  IN  EFI_ISA_IO_PROTOCOL        *This,\r
-  IN  EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT32                     Offset,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify Isa IO Access\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeIo,\r
-             Width,\r
-             Count,\r
-             Offset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->Io.Read (\r
-                                    IsaIoDevice->PciIo,\r
-                                    (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                    Offset,\r
-                                    Count,\r
-                                    Buffer\r
-                                    );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Performs an ISA I/O Write Cycle\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Width               Specifies the width of the I/O operation.\r
-  @param[in] Offset              The offset in ISA I/O space to start the I/O operation.\r
-  @param[in] Count               The number of I/O operations to perform.\r
-  @param[in] Buffer              The source buffer to write data from\r
-\r
-  @retval EFI_SUCCESS            The data was writen to the device sucessfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoIoWrite (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     Offset,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify Isa IO Access\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeIo,\r
-             Width,\r
-             Count,\r
-             Offset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->Io.Write (\r
-                                    IsaIoDevice->PciIo,\r
-                                    (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                    Offset,\r
-                                    Count,\r
-                                    Buffer\r
-                                    );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Writes an 8-bit I/O Port\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Offset              The offset in ISA IO space to start the IO operation.\r
-  @param[in] Value               The data to write port.\r
-\r
-  @retval EFI_SUCCESS            Success.\r
-  @retval EFI_INVALID_PARAMETER  Parameter is invalid.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Offset is not valid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-WritePort (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINT32               Offset,\r
-  IN UINT8                Value\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  Status = IsaIoDevice->PciIo->Io.Write (\r
-                                    IsaIoDevice->PciIo,\r
-                                    EfiPciIoWidthUint8,\r
-                                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                    Offset,\r
-                                    1,\r
-                                    &Value\r
-                                    );\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Wait for 50 microseconds to take affect.\r
-  //\r
-  gBS->Stall (50);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Writes I/O operation base address and count number to a 8 bit I/O Port.\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] AddrOffset          The address' offset.\r
-  @param[in] PageOffset          The page's offest.\r
-  @param[in] CountOffset         The count's offset.\r
-  @param[in] BaseAddress         The base address.\r
-  @param[in] Count               The number of I/O operations to perform.\r
-\r
-  @retval EFI_SUCCESS            Success.\r
-  @retval EFI_INVALID_PARAMETER  Parameter is invalid.\r
-  @retval EFI_UNSUPPORTED        The address range specified by these Offsets and Count is not valid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-WriteDmaPort (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINT32               AddrOffset,\r
-  IN UINT32               PageOffset,\r
-  IN UINT32               CountOffset,\r
-  IN UINT32               BaseAddress,\r
-  IN UINT16               Count\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = WritePort (This, AddrOffset, (UINT8) (BaseAddress & 0xff));\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, AddrOffset, (UINT8) ((BaseAddress >> 8) & 0xff));\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, PageOffset, (UINT8) ((BaseAddress >> 16) & 0xff));\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, CountOffset, (UINT8) (Count & 0xff));\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, CountOffset, (UINT8) ((Count >> 8) & 0xff));\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Unmaps a memory region for DMA\r
-\r
-  @param[in] This           A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Mapping        The mapping value returned from EFI_ISA_IO.Map().\r
-\r
-  @retval EFI_SUCCESS       The range was unmapped.\r
-  @retval EFI_DEVICE_ERROR  The data was not committed to the target system memory.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoUnmap (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN VOID                 *Mapping\r
-  )\r
-{\r
-  ISA_MAP_INFO  *IsaMapInfo;\r
-\r
-  //\r
-  // Check if DMA is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // See if the Map() operation associated with this Unmap() required a mapping\r
-  // buffer.If a mapping buffer was not required, then this function simply\r
-  // returns EFI_SUCCESS.\r
-  //\r
-  if (Mapping != NULL) {\r
-    //\r
-    // Get the MAP_INFO structure from Mapping\r
-    //\r
-    IsaMapInfo = (ISA_MAP_INFO *) Mapping;\r
-\r
-    //\r
-    // If this is a write operation from the Agent's point of view,\r
-    // then copy the contents of the mapped buffer into the real buffer\r
-    // so the processor can read the contents of the real buffer.\r
-    //\r
-    if (IsaMapInfo->Operation == EfiIsaIoOperationBusMasterWrite) {\r
-      CopyMem (\r
-        (VOID *) (UINTN) IsaMapInfo->HostAddress,\r
-        (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,\r
-        IsaMapInfo->NumberOfBytes\r
-        );\r
-    }\r
-    //\r
-    // Free the mapped buffer and the MAP_INFO structure.\r
-    //\r
-    gBS->FreePages (IsaMapInfo->MappedHostAddress, IsaMapInfo->NumberOfPages);\r
-    FreePool (IsaMapInfo);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Flushes any posted write data to the system memory.\r
-\r
-  @param[in] This             A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-\r
-  @retval  EFI_SUCCESS        The buffers were flushed.\r
-  @retval  EFI_DEVICE_ERROR   The buffers were not flushed due to a hardware error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoFlush (\r
-  IN EFI_ISA_IO_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  Status = IsaIoDevice->PciIo->Flush (IsaIoDevice->PciIo);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Performs an ISA Memory Read Cycle\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width              Specifies the width of the memory operation.\r
-  @param[in]  Offset             The offset in ISA memory space to start the memory operation.\r
-  @param[in]  Count              The number of memory operations to perform.\r
-  @param[out] Buffer             The destination buffer to store the results\r
-\r
-  @retval EFI_SUCCESS            The data was read from the device successfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMemRead (\r
-  IN  EFI_ISA_IO_PROTOCOL        *This,\r
-  IN  EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT32                     Offset,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  //\r
-  // Check if ISA memory is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify the Isa Io Access\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeMem,\r
-             Width,\r
-             Count,\r
-             Offset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->Mem.Read (\r
-                                     IsaIoDevice->PciIo,\r
-                                     (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                     EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                     Offset,\r
-                                     Count,\r
-                                     Buffer\r
-                                     );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Performs an ISA Memory Write Cycle\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Width               Specifies the width of the memory operation.\r
-  @param[in] Offset              The offset in ISA memory space to start the memory operation.\r
-  @param[in] Count               The number of memory operations to perform.\r
-  @param[in] Buffer              The source buffer to write data from\r
-\r
-  @retval EFI_SUCCESS            The data was written to the device sucessfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMemWrite (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     Offset,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  //\r
-  // Check if ISA memory is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify Isa IO Access\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeMem,\r
-             Width,\r
-             Count,\r
-             Offset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->Mem.Write (\r
-                                     IsaIoDevice->PciIo,\r
-                                     (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                     EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                     Offset,\r
-                                     Count,\r
-                                     Buffer\r
-                                     );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Copy one region of ISA memory space to another region of ISA memory space on the ISA controller.\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width              Specifies the width of the memory copy operation.\r
-  @param[in]  DestOffset         The offset of the destination\r
-  @param[in]  SrcOffset          The offset of the source\r
-  @param[in]  Count              The number of memory copy  operations to perform\r
-\r
-  @retval EFI_SUCCESS            The data was copied sucessfully.\r
-  @retval EFI_UNSUPPORTED        The DestOffset or SrcOffset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoCopyMem (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     DestOffset,\r
-  IN UINT32                     SrcOffset,\r
-  IN UINTN                      Count\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  ISA_IO_DEVICE *IsaIoDevice;\r
-\r
-  //\r
-  // Check if ISA memory is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);\r
-\r
-  //\r
-  // Verify Isa IO Access for destination and source\r
-  //\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeMem,\r
-             Width,\r
-             Count,\r
-             DestOffset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoVerifyAccess (\r
-             IsaIoDevice,\r
-             IsaAccessTypeMem,\r
-             Width,\r
-             Count,\r
-             SrcOffset\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IsaIoDevice->PciIo->CopyMem (\r
-                                 IsaIoDevice->PciIo,\r
-                                 (EFI_PCI_IO_PROTOCOL_WIDTH) Width,\r
-                                 EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                 DestOffset,\r
-                                 EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                 SrcOffset,\r
-                                 Count\r
-                                 );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Maps a memory region for DMA, note this implementation\r
-  only supports slave read/write operation to save code size.\r
-\r
-  @param This                    A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param Operation               Indicates the type of DMA (slave or bus master), and if\r
-                                 the DMA operation is going to read or write to system memory.\r
-  @param ChannelNumber           The slave channel number to use for this DMA operation.\r
-                                 If Operation and ChannelAttributes shows that this device\r
-                                 performs bus mastering DMA, then this field is ignored.\r
-                                 The legal range for this field is 0..7.\r
-  @param ChannelAttributes       The attributes of the DMA channel to use for this DMA operation\r
-  @param HostAddress             The system memory address to map to the device.\r
-  @param NumberOfBytes           On input the number of bytes to map.  On output the number\r
-                                 of bytes that were mapped.\r
-  @param DeviceAddress           The resulting map address for the bus master device to use\r
-                                 to access the hosts HostAddress.\r
-  @param Mapping                 A resulting value to pass to EFI_ISA_IO.Unmap().\r
-\r
-  @retval EFI_SUCCESS            The range was mapped for the returned NumberOfBytes.\r
-  @retval EFI_INVALID_PARAMETER  The Operation or HostAddress is undefined.\r
-  @retval EFI_UNSUPPORTED        The HostAddress can not be mapped as a common buffer.\r
-  @retval EFI_DEVICE_ERROR       The system hardware could not map the requested address.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-IsaIoMapOnlySupportSlaveReadWrite (\r
-  IN     EFI_ISA_IO_PROTOCOL            *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     UINT8                          ChannelNumber  OPTIONAL,\r
-  IN     UINT32                         ChannelAttributes,\r
-  IN     VOID                           *HostAddress,\r
-  IN OUT UINTN                          *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
-  OUT    VOID                           **Mapping\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-  ISA_MAP_INFO          *IsaMapInfo;\r
-  UINT8                 DmaMode;\r
-  UINTN                 MaxNumberOfBytes;\r
-  UINT32                BaseAddress;\r
-  UINT16                Count;\r
-  UINT8                 DmaMask;\r
-  UINT8                 DmaClear;\r
-  UINT8                 DmaChannelMode;\r
-\r
-  if ((NULL == This) ||\r
-      (NULL == HostAddress) ||\r
-      (NULL == NumberOfBytes) ||\r
-      (NULL == DeviceAddress) ||\r
-      (NULL == Mapping)\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Initialize the return values to their defaults\r
-  //\r
-  *Mapping = NULL;\r
-\r
-  //\r
-  // Make sure the Operation parameter is valid.\r
-  // Light IsaIo only supports two operations.\r
-  //\r
-  if (!(Operation == EfiIsaIoOperationSlaveRead ||\r
-        Operation == EfiIsaIoOperationSlaveWrite)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (ChannelNumber >= 4) {\r
-    //\r
-    // The Light IsaIo doesn't support channelNumber larger than 4.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Map the HostAddress to a DeviceAddress.\r
-  //\r
-  PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;\r
-  if ((PhysicalAddress + *NumberOfBytes) > BASE_16MB) {\r
-    //\r
-    // Common Buffer operations can not be remapped.  If the common buffer\r
-    // is above 16MB, then it is not possible to generate a mapping, so return\r
-    // an error.\r
-    //\r
-    if (Operation == EfiIsaIoOperationBusMasterCommonBuffer) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    //\r
-    // Allocate an ISA_MAP_INFO structure to remember the mapping when Unmap()\r
-    // is called later.\r
-    //\r
-    IsaMapInfo = AllocatePool (sizeof (ISA_MAP_INFO));\r
-    if (IsaMapInfo == NULL) {\r
-      *NumberOfBytes = 0;\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    //\r
-    // Return a pointer to the MAP_INFO structure in Mapping\r
-    //\r
-    *Mapping = IsaMapInfo;\r
-\r
-    //\r
-    // Initialize the MAP_INFO structure\r
-    //\r
-    IsaMapInfo->Operation         = Operation;\r
-    IsaMapInfo->NumberOfBytes     = *NumberOfBytes;\r
-    IsaMapInfo->NumberOfPages     = EFI_SIZE_TO_PAGES (*NumberOfBytes);\r
-    IsaMapInfo->HostAddress       = PhysicalAddress;\r
-    IsaMapInfo->MappedHostAddress = BASE_16MB - 1;\r
-\r
-    //\r
-    // Allocate a buffer below 16MB to map the transfer to.\r
-    //\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiBootServicesData,\r
-                    IsaMapInfo->NumberOfPages,\r
-                    &IsaMapInfo->MappedHostAddress\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (IsaMapInfo);\r
-      *NumberOfBytes  = 0;\r
-      *Mapping        = NULL;\r
-      return Status;\r
-    }\r
-    //\r
-    // If this is a read operation from the DMA agents's point of view,\r
-    // then copy the contents of the real buffer into the mapped buffer\r
-    // so the DMA agent can read the contents of the real buffer.\r
-    //\r
-    if (Operation == EfiIsaIoOperationSlaveRead) {\r
-      CopyMem (\r
-        (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,\r
-        (VOID *) (UINTN) IsaMapInfo->HostAddress,\r
-        IsaMapInfo->NumberOfBytes\r
-        );\r
-    }\r
-    //\r
-    // The DeviceAddress is the address of the maped buffer below 16 MB\r
-    //\r
-    *DeviceAddress = IsaMapInfo->MappedHostAddress;\r
-  } else {\r
-    //\r
-    // The transfer is below 16 MB, so the DeviceAddress is simply the\r
-    // HostAddress\r
-    //\r
-    *DeviceAddress = PhysicalAddress;\r
-  }\r
-\r
-  //\r
-  // Figure out what to program into the DMA Channel Mode Register\r
-  //\r
-  DmaMode = (UINT8) (B_8237_DMA_CHMODE_INCREMENT | (ChannelNumber & 0x03));\r
-  if (Operation == EfiIsaIoOperationSlaveRead) {\r
-    DmaMode |= V_8237_DMA_CHMODE_MEM2IO;\r
-  } else {\r
-    DmaMode |= V_8237_DMA_CHMODE_IO2MEM;\r
-  }\r
-  //\r
-  // We only support EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE in simplified IsaIo\r
-  //\r
-  DmaMode |= V_8237_DMA_CHMODE_SINGLE;\r
-\r
-  //\r
-  // A Slave DMA transfer can not cross a 64K boundary.\r
-  // Compute *NumberOfBytes based on this restriction.\r
-  //\r
-  MaxNumberOfBytes = 0x10000 - ((UINT32) (*DeviceAddress) & 0xffff);\r
-  if (*NumberOfBytes > MaxNumberOfBytes) {\r
-    *NumberOfBytes = MaxNumberOfBytes;\r
-  }\r
-  //\r
-  // Compute the values to program into the BaseAddress and Count registers\r
-  // of the Slave DMA controller\r
-  //\r
-  BaseAddress = (UINT32) (*DeviceAddress);\r
-  Count       = (UINT16) (*NumberOfBytes - 1);\r
-  //\r
-  // Program the DMA Write Single Mask Register for ChannelNumber\r
-  // Clear the DMA Byte Pointer Register\r
-  //\r
-  DmaMask         = R_8237_DMA_WRSMSK_CH0_3;\r
-  DmaClear        = R_8237_DMA_CBPR_CH0_3;\r
-  DmaChannelMode  = R_8237_DMA_CHMODE_CH0_3;\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaMask,\r
-             (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaClear,\r
-             (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, DmaChannelMode, DmaMode);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WriteDmaPort (\r
-             This,\r
-             mDmaRegisters[ChannelNumber].Address,\r
-             mDmaRegisters[ChannelNumber].Page,\r
-             mDmaRegisters[ChannelNumber].Count,\r
-             BaseAddress,\r
-             Count\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaMask,\r
-             (UINT8) (ChannelNumber & 0x03)\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Maps a memory region for DMA. This implementation implement the\r
-  the full mapping support.\r
-\r
-  @param This                    A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param Operation               Indicates the type of DMA (slave or bus master), and if\r
-                                 the DMA operation is going to read or write to system memory.\r
-  @param ChannelNumber           The slave channel number to use for this DMA operation.\r
-                                 If Operation and ChannelAttributes shows that this device\r
-                                 performs bus mastering DMA, then this field is ignored.\r
-                                 The legal range for this field is 0..7.\r
-  @param ChannelAttributes       The attributes of the DMA channel to use for this DMA operation\r
-  @param HostAddress             The system memory address to map to the device.\r
-  @param NumberOfBytes           On input the number of bytes to map.  On output the number\r
-                                 of bytes that were mapped.\r
-  @param DeviceAddress           The resulting map address for the bus master device to use\r
-                                 to access the hosts HostAddress.\r
-  @param Mapping                 A resulting value to pass to EFI_ISA_IO.Unmap().\r
-\r
-  @retval EFI_SUCCESS           - The range was mapped for the returned NumberOfBytes.\r
-  @retval EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined.\r
-  @retval EFI_UNSUPPORTED       - The HostAddress can not be mapped as a common buffer.\r
-  @retval EFI_DEVICE_ERROR      - The system hardware could not map the requested address.\r
-  @retval EFI_OUT_OF_RESOURCES  - The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-IsaIoMapFullSupport (\r
-  IN     EFI_ISA_IO_PROTOCOL                                  *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_OPERATION                        Operation,\r
-  IN     UINT8                                                ChannelNumber         OPTIONAL,\r
-  IN     UINT32                                               ChannelAttributes,\r
-  IN     VOID                                                 *HostAddress,\r
-  IN OUT UINTN                                                *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS                                 *DeviceAddress,\r
-  OUT    VOID                                                 **Mapping\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  BOOLEAN               Master;\r
-  BOOLEAN               Read;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-  ISA_MAP_INFO          *IsaMapInfo;\r
-  UINT8                 DmaMode;\r
-  UINTN                 MaxNumberOfBytes;\r
-  UINT32                BaseAddress;\r
-  UINT16                Count;\r
-  UINT8                 DmaMask;\r
-  UINT8                 DmaClear;\r
-  UINT8                 DmaChannelMode;\r
-\r
-  if ((NULL == This) ||\r
-      (NULL == HostAddress) ||\r
-      (NULL == NumberOfBytes) ||\r
-      (NULL == DeviceAddress) ||\r
-      (NULL == Mapping)\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Initialize the return values to their defaults\r
-  //\r
-  *Mapping = NULL;\r
-\r
-  //\r
-  // Make sure the Operation parameter is valid\r
-  //\r
-  if ((UINT32)Operation >= EfiIsaIoOperationMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (ChannelNumber >= 8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // See if this is a Slave DMA Operation\r
-  //\r
-  Master  = TRUE;\r
-  Read    = FALSE;\r
-  if (Operation == EfiIsaIoOperationSlaveRead) {\r
-    Operation = EfiIsaIoOperationBusMasterRead;\r
-    Master    = FALSE;\r
-    Read      = TRUE;\r
-  }\r
-\r
-  if (Operation == EfiIsaIoOperationSlaveWrite) {\r
-    Operation = EfiIsaIoOperationBusMasterWrite;\r
-    Master    = FALSE;\r
-    Read      = FALSE;\r
-  }\r
-\r
-  if (!Master) {\r
-    //\r
-    // Make sure that ChannelNumber is a valid channel number\r
-    // Channel 4 is used to cascade, so it is illegal.\r
-    //\r
-    if (ChannelNumber == 4 || ChannelNumber > 7) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    //\r
-    // This implementation only support COMPATIBLE DMA Transfers\r
-    //\r
-    if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE) == 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if ((ChannelAttributes &\r
-         (EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A |\r
-          EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B |\r
-          EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C)) != 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (ChannelNumber < 4) {\r
-      //\r
-      // If this is Channel 0..3, then the width must be 8 bit\r
-      //\r
-      if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) == 0) ||\r
-          ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) != 0)\r
-          ) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    } else {\r
-      //\r
-      // If this is Channel 4..7, then the width must be 16 bit\r
-      //\r
-      if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) != 0) ||\r
-          ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) == 0)) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-    //\r
-    // Either Demand Mode or Single Mode must be selected, but not both\r
-    //\r
-    if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {\r
-      if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    } else {\r
-      if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) == 0) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Map the HostAddress to a DeviceAddress.\r
-  //\r
-  PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;\r
-  if ((PhysicalAddress +*NumberOfBytes) > BASE_16MB) {\r
-    //\r
-    // Common Buffer operations can not be remapped.  If the common buffer\r
-    // is above 16MB, then it is not possible to generate a mapping, so return\r
-    // an error.\r
-    //\r
-    if (Operation == EfiIsaIoOperationBusMasterCommonBuffer) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    //\r
-    // Allocate an ISA_MAP_INFO structure to remember the mapping when Unmap()\r
-    // is called later.\r
-    //\r
-    IsaMapInfo = AllocatePool (sizeof (ISA_MAP_INFO));\r
-    if (IsaMapInfo == NULL) {\r
-      *NumberOfBytes = 0;\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    //\r
-    // Return a pointer to the MAP_INFO structure in Mapping\r
-    //\r
-    *Mapping = IsaMapInfo;\r
-\r
-    //\r
-    // Initialize the MAP_INFO structure\r
-    //\r
-    IsaMapInfo->Operation         = Operation;\r
-    IsaMapInfo->NumberOfBytes     = *NumberOfBytes;\r
-    IsaMapInfo->NumberOfPages     = EFI_SIZE_TO_PAGES (*NumberOfBytes);\r
-    IsaMapInfo->HostAddress       = PhysicalAddress;\r
-    IsaMapInfo->MappedHostAddress = BASE_16MB - 1;\r
-\r
-    //\r
-    // Allocate a buffer below 16MB to map the transfer to.\r
-    //\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiBootServicesData,\r
-                    IsaMapInfo->NumberOfPages,\r
-                    &IsaMapInfo->MappedHostAddress\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (IsaMapInfo);\r
-      *NumberOfBytes  = 0;\r
-      *Mapping        = NULL;\r
-      return Status;\r
-    }\r
-    //\r
-    // If this is a read operation from the DMA agents's point of view,\r
-    // then copy the contents of the real buffer into the mapped buffer\r
-    // so the DMA agent can read the contents of the real buffer.\r
-    //\r
-    if (Operation == EfiIsaIoOperationBusMasterRead) {\r
-      CopyMem (\r
-        (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,\r
-        (VOID *) (UINTN) IsaMapInfo->HostAddress,\r
-        IsaMapInfo->NumberOfBytes\r
-        );\r
-    }\r
-    //\r
-    // The DeviceAddress is the address of the maped buffer below 16 MB\r
-    //\r
-    *DeviceAddress = IsaMapInfo->MappedHostAddress;\r
-  } else {\r
-    //\r
-    // The transfer is below 16 MB, so the DeviceAddress is simply the\r
-    // HostAddress\r
-    //\r
-    *DeviceAddress = PhysicalAddress;\r
-  }\r
-  //\r
-  // If this is a Bus Master operation then return\r
-  //\r
-  if (Master) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Figure out what to program into the DMA Channel Mode Register\r
-  //\r
-  DmaMode = (UINT8) (B_8237_DMA_CHMODE_INCREMENT | (ChannelNumber & 0x03));\r
-  if (Read) {\r
-    DmaMode |= V_8237_DMA_CHMODE_MEM2IO;\r
-  } else {\r
-    DmaMode |= V_8237_DMA_CHMODE_IO2MEM;\r
-  }\r
-\r
-  if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE) != 0) {\r
-    DmaMode |= B_8237_DMA_CHMODE_AE;\r
-  }\r
-\r
-  if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {\r
-    DmaMode |= V_8237_DMA_CHMODE_DEMAND;\r
-  }\r
-\r
-  if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {\r
-    DmaMode |= V_8237_DMA_CHMODE_SINGLE;\r
-  }\r
-  //\r
-  // A Slave DMA transfer can not cross a 64K boundary.\r
-  // Compute *NumberOfBytes based on this restriction.\r
-  //\r
-  MaxNumberOfBytes = 0x10000 - ((UINT32) (*DeviceAddress) & 0xffff);\r
-  if (*NumberOfBytes > MaxNumberOfBytes) {\r
-    *NumberOfBytes = MaxNumberOfBytes;\r
-  }\r
-  //\r
-  // Compute the values to program into the BaseAddress and Count registers\r
-  // of the Slave DMA controller\r
-  //\r
-  if (ChannelNumber < 4) {\r
-    BaseAddress = (UINT32) (*DeviceAddress);\r
-    Count       = (UINT16) (*NumberOfBytes - 1);\r
-  } else {\r
-    BaseAddress = (UINT32) (((UINT32) (*DeviceAddress) & 0xff0000) | (((UINT32) (*DeviceAddress) & 0xffff) >> 1));\r
-    Count       = (UINT16) ((*NumberOfBytes - 1) >> 1);\r
-  }\r
-  //\r
-  // Program the DMA Write Single Mask Register for ChannelNumber\r
-  // Clear the DMA Byte Pointer Register\r
-  //\r
-  if (ChannelNumber < 4) {\r
-    DmaMask         = R_8237_DMA_WRSMSK_CH0_3;\r
-    DmaClear        = R_8237_DMA_CBPR_CH0_3;\r
-    DmaChannelMode  = R_8237_DMA_CHMODE_CH0_3;\r
-  } else {\r
-    DmaMask         = R_8237_DMA_WRSMSK_CH4_7;\r
-    DmaClear        = R_8237_DMA_CBPR_CH4_7;\r
-    DmaChannelMode  = R_8237_DMA_CHMODE_CH4_7;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaMask,\r
-             (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaClear,\r
-             (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (This, DmaChannelMode, DmaMode);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WriteDmaPort (\r
-             This,\r
-             mDmaRegisters[ChannelNumber].Address,\r
-             mDmaRegisters[ChannelNumber].Page,\r
-             mDmaRegisters[ChannelNumber].Count,\r
-             BaseAddress,\r
-             Count\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = WritePort (\r
-             This,\r
-             DmaMask,\r
-             (UINT8) (ChannelNumber & 0x03)\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Maps a memory region for DMA\r
-\r
-  @param This                    A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param Operation               Indicates the type of DMA (slave or bus master), and if\r
-                                 the DMA operation is going to read or write to system memory.\r
-  @param ChannelNumber           The slave channel number to use for this DMA operation.\r
-                                 If Operation and ChannelAttributes shows that this device\r
-                                 performs bus mastering DMA, then this field is ignored.\r
-                                 The legal range for this field is 0..7.\r
-  @param ChannelAttributes       The attributes of the DMA channel to use for this DMA operation\r
-  @param HostAddress             The system memory address to map to the device.\r
-  @param NumberOfBytes           On input the number of bytes to map.  On output the number\r
-                                 of bytes that were mapped.\r
-  @param DeviceAddress           The resulting map address for the bus master device to use\r
-                                 to access the hosts HostAddress.\r
-  @param Mapping                 A resulting value to pass to EFI_ISA_IO.Unmap().\r
-\r
-  @retval EFI_SUCCESS            The range was mapped for the returned NumberOfBytes.\r
-  @retval EFI_INVALID_PARAMETER  The Operation or HostAddress is undefined.\r
-  @retval EFI_UNSUPPORTED        The HostAddress can not be mapped as a common buffer.\r
-  @retval EFI_DEVICE_ERROR       The system hardware could not map the requested address.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMap (\r
-  IN     EFI_ISA_IO_PROTOCOL            *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     UINT8                          ChannelNumber  OPTIONAL,\r
-  IN     UINT32                         ChannelAttributes,\r
-  IN     VOID                           *HostAddress,\r
-  IN OUT UINTN                          *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
-  OUT    VOID                           **Mapping\r
-  )\r
-{\r
-  //\r
-  // Check if DMA is supported.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Set Feature Flag PcdIsaBusSupportBusMaster to FALSE to disable support for\r
-  // ISA Bus Master.\r
-  //\r
-  // So we just return EFI_UNSUPPORTED for these functions.\r
-  //\r
-  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0) {\r
-    return IsaIoMapOnlySupportSlaveReadWrite (\r
-             This,\r
-             Operation,\r
-             ChannelNumber,\r
-             ChannelAttributes,\r
-             HostAddress,\r
-             NumberOfBytes,\r
-             DeviceAddress,\r
-             Mapping\r
-             );\r
-\r
-  } else {\r
-    return IsaIoMapFullSupport (\r
-             This,\r
-             Operation,\r
-             ChannelNumber,\r
-             ChannelAttributes,\r
-             HostAddress,\r
-             NumberOfBytes,\r
-             DeviceAddress,\r
-             Mapping\r
-             );\r
-  }\r
-}\r
-\r
-/**\r
-  Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer mapping.\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Type               The type allocation to perform.\r
-  @param[in]  MemoryType         The type of memory to allocate.\r
-  @param[in]  Pages              The number of pages to allocate.\r
-  @param[out] HostAddress        A pointer to store the base address of the allocated range.\r
-  @param[in]  Attributes         The requested bit mask of attributes for the allocated range.\r
-\r
-  @retval EFI_SUCCESS            The requested memory pages were allocated.\r
-  @retval EFI_INVALID_PARAMETER  Type is invalid or MemoryType is invalid or HostAddress is NULL\r
-  @retval EFI_UNSUPPORTED        Attributes is unsupported or the memory range specified\r
-                                 by HostAddress, Pages, and Type is not available for common buffer use.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoAllocateBuffer (\r
-  IN  EFI_ISA_IO_PROTOCOL  *This,\r
-  IN  EFI_ALLOCATE_TYPE    Type,\r
-  IN  EFI_MEMORY_TYPE      MemoryType,\r
-  IN  UINTN                Pages,\r
-  OUT VOID                 **HostAddress,\r
-  IN  UINT64               Attributes\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-\r
-  //\r
-  // Set Feature Flag PcdIsaBusOnlySupportSlaveDma to FALSE to disable support for\r
-  // ISA Bus Master.\r
-  // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.\r
-  //\r
-  if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||\r
-      ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (HostAddress == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((UINT32)Type >= MaxAllocateType) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // The only valid memory types are EfiBootServicesData and EfiRuntimeServicesData\r
-  //\r
-  if (MemoryType != EfiBootServicesData && MemoryType != EfiRuntimeServicesData) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Attributes & ~(EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED)) != 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) (BASE_16MB - 1);\r
-  if (Type == AllocateAddress) {\r
-    if ((UINTN) (*HostAddress) >= BASE_16MB) {\r
-      return EFI_UNSUPPORTED;\r
-    } else {\r
-      PhysicalAddress = (UINTN) (*HostAddress);\r
-    }\r
-  }\r
-\r
-  if (Type == AllocateAnyPages) {\r
-    Type = AllocateMaxAddress;\r
-  }\r
-\r
-  Status = gBS->AllocatePages (Type, MemoryType, Pages, &PhysicalAddress);\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-    return Status;\r
-  }\r
-\r
-  *HostAddress = (VOID *) (UINTN) PhysicalAddress;\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Frees memory that was allocated with EFI_ISA_IO.AllocateBuffer().\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Pages               The number of pages to free.\r
-  @param[in] HostAddress         The base address of the allocated range.\r
-\r
-  @retval EFI_SUCCESS            The requested memory pages were freed.\r
-  @retval EFI_INVALID_PARAMETER  The memory was not allocated with EFI_ISA_IO.AllocateBufer().\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoFreeBuffer (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINTN                Pages,\r
-  IN VOID                 *HostAddress\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Set Feature Flag PcdIsaBusOnlySupportSlaveDma to FALSE to disable support for\r
-  // ISA Bus Master.\r
-  // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.\r
-  //\r
-  if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||\r
-      ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = gBS->FreePages (\r
-                  (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress,\r
-                  Pages\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.h b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.h
deleted file mode 100644 (file)
index 8b8b132..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-/** @file\r
-  The header file for EFI_ISA_IO protocol implementation.\r
-\r
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _ISA_IO_H_\r
-#define _ISA_IO_H_\r
-\r
-#include "IsaDriver.h"\r
-\r
-//\r
-// Bits definition of PcdIsaBusSupportedFeatures\r
-//\r
-#define PCD_ISA_BUS_SUPPORT_DMA                  BIT0\r
-#define PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA       BIT1\r
-#define PCD_ISA_BUS_SUPPORT_ISA_MEMORY           BIT2\r
-\r
-//\r
-// ISA I/O Support Function Prototypes\r
-//\r
-\r
-/**\r
-  Verifies access to an ISA device\r
-\r
-  @param[in] IsaIoDevice         The ISA device to be verified.\r
-  @param[in] Type                The Access type. The input must be either IsaAccessTypeMem or IsaAccessTypeIo.\r
-  @param[in] Width               The width of the memory operation.\r
-  @param[in] Count               The number of memory operations to perform.\r
-  @param[in] Offset              The offset in ISA memory space to start the memory operation.\r
-\r
-  @retval EFI_SUCCESS            Verify success.\r
-  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value.\r
-  @retval EFI_UNSUPPORTED        The device ont support the access type.\r
-**/\r
-EFI_STATUS\r
-IsaIoVerifyAccess (\r
-  IN ISA_IO_DEVICE              *IsaIoDevice,\r
-  IN ISA_ACCESS_TYPE            Type,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINTN                      Count,\r
-  IN UINT32                     Offset\r
-  );\r
-\r
-/**\r
-  Performs an ISA I/O Read Cycle\r
-\r
-  @param[in]  This              A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width             Specifies the width of the I/O operation.\r
-  @param[in]  Offset            The offset in ISA I/O space to start the I/O operation.\r
-  @param[in]  Count             The number of I/O operations to perform.\r
-  @param[out] Buffer            The destination buffer to store the results\r
-\r
-  @retval EFI_SUCCESS           The data was read from the device sucessfully.\r
-  @retval EFI_UNSUPPORTED       The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoIoRead (\r
-  IN  EFI_ISA_IO_PROTOCOL        *This,\r
-  IN  EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT32                     Offset,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Performs an ISA I/O Write Cycle\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Width               Specifies the width of the I/O operation.\r
-  @param[in] Offset              The offset in ISA I/O space to start the I/O operation.\r
-  @param[in] Count               The number of I/O operations to perform.\r
-  @param[in] Buffer              The source buffer to write data from\r
-\r
-  @retval EFI_SUCCESS            The data was writen to the device sucessfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoIoWrite (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     Offset,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Maps a memory region for DMA\r
-\r
-  @param This                    A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param Operation               Indicates the type of DMA (slave or bus master), and if\r
-                                 the DMA operation is going to read or write to system memory.\r
-  @param ChannelNumber           The slave channel number to use for this DMA operation.\r
-                                 If Operation and ChannelAttributes shows that this device\r
-                                 performs bus mastering DMA, then this field is ignored.\r
-                                 The legal range for this field is 0..7.\r
-  @param ChannelAttributes       The attributes of the DMA channel to use for this DMA operation\r
-  @param HostAddress             The system memory address to map to the device.\r
-  @param NumberOfBytes           On input the number of bytes to map.  On output the number\r
-                                 of bytes that were mapped.\r
-  @param DeviceAddress           The resulting map address for the bus master device to use\r
-                                 to access the hosts HostAddress.\r
-  @param Mapping                 A resulting value to pass to EFI_ISA_IO.Unmap().\r
-\r
-  @retval EFI_SUCCESS            The range was mapped for the returned NumberOfBytes.\r
-  @retval EFI_INVALID_PARAMETER  The Operation or HostAddress is undefined.\r
-  @retval EFI_UNSUPPORTED        The HostAddress can not be mapped as a common buffer.\r
-  @retval EFI_DEVICE_ERROR       The system hardware could not map the requested address.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMap (\r
-  IN     EFI_ISA_IO_PROTOCOL            *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     UINT8                          ChannelNumber  OPTIONAL,\r
-  IN     UINT32                         ChannelAttributes,\r
-  IN     VOID                           *HostAddress,\r
-  IN OUT UINTN                          *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
-  OUT    VOID                           **Mapping\r
-  );\r
-\r
-/**\r
-  Unmaps a memory region for DMA\r
-\r
-  @param[in] This           A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Mapping        The mapping value returned from EFI_ISA_IO.Map().\r
-\r
-  @retval EFI_SUCCESS       The range was unmapped.\r
-  @retval EFI_DEVICE_ERROR  The data was not committed to the target system memory.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoUnmap (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN VOID                 *Mapping\r
-  );\r
-\r
-/**\r
-  Flushes any posted write data to the system memory.\r
-\r
-  @param[in] This             A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-\r
-  @retval  EFI_SUCCESS        The buffers were flushed.\r
-  @retval  EFI_DEVICE_ERROR   The buffers were not flushed due to a hardware error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoFlush (\r
-  IN EFI_ISA_IO_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Writes I/O operation base address and count number to a 8 bit I/O Port.\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] AddrOffset          The address' offset.\r
-  @param[in] PageOffset          The page's offest.\r
-  @param[in] CountOffset         The count's offset.\r
-  @param[in] BaseAddress         The base address.\r
-  @param[in] Count               The number of I/O operations to perform.\r
-\r
-  @retval EFI_SUCCESS            Success.\r
-  @retval EFI_INVALID_PARAMETER  Parameter is invalid.\r
-  @retval EFI_UNSUPPORTED        The address range specified by these Offsets and Count is not valid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-WriteDmaPort (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINT32               AddrOffset,\r
-  IN UINT32               PageOffset,\r
-  IN UINT32               CountOffset,\r
-  IN UINT32               BaseAddress,\r
-  IN UINT16               Count\r
-  );\r
-\r
-/**\r
-  Writes an 8-bit I/O Port\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Offset              The offset in ISA IO space to start the IO operation.\r
-  @param[in] Value               The data to write port.\r
-\r
-  @retval EFI_SUCCESS            Success.\r
-  @retval EFI_INVALID_PARAMETER  Parameter is invalid.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Offset is not valid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-WritePort (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINT32               Offset,\r
-  IN UINT8                Value\r
-  );\r
-\r
-/**\r
-  Performs an ISA Memory Read Cycle\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width              Specifies the width of the memory operation.\r
-  @param[in]  Offset             The offset in ISA memory space to start the memory operation.\r
-  @param[in]  Count              The number of memory operations to perform.\r
-  @param[out] Buffer             The destination buffer to store the results\r
-\r
-  @retval EFI_SUCCESS            The data was read from the device successfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMemRead (\r
-  IN  EFI_ISA_IO_PROTOCOL        *This,\r
-  IN  EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT32                     Offset,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  );\r
-\r
-\r
-/**\r
-  Performs an ISA Memory Write Cycle\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Width               Specifies the width of the memory operation.\r
-  @param[in] Offset              The offset in ISA memory space to start the memory operation.\r
-  @param[in] Count               The number of memory operations to perform.\r
-  @param[in] Buffer              The source buffer to write data from\r
-\r
-  @retval EFI_SUCCESS            The data was written to the device sucessfully.\r
-  @retval EFI_UNSUPPORTED        The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoMemWrite (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     Offset,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Copy one region of ISA memory space to another region of ISA memory space on the ISA controller.\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Width              Specifies the width of the memory copy operation.\r
-  @param[in]  DestOffset         The offset of the destination\r
-  @param[in]  SrcOffset          The offset of the source\r
-  @param[in]  Count              The number of memory copy  operations to perform\r
-\r
-  @retval EFI_SUCCESS            The data was copied sucessfully.\r
-  @retval EFI_UNSUPPORTED        The DestOffset or SrcOffset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoCopyMem (\r
-  IN EFI_ISA_IO_PROTOCOL        *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT32                     DestOffset,\r
-  IN UINT32                     SrcOffset,\r
-  IN UINTN                      Count\r
-  );\r
-\r
-/**\r
-  Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer mapping.\r
-\r
-  @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Type               The type allocation to perform.\r
-  @param[in]  MemoryType         The type of memory to allocate.\r
-  @param[in]  Pages              The number of pages to allocate.\r
-  @param[out] HostAddress        A pointer to store the base address of the allocated range.\r
-  @param[in]  Attributes         The requested bit mask of attributes for the allocated range.\r
-\r
-  @retval EFI_SUCCESS            The requested memory pages were allocated.\r
-  @retval EFI_INVALID_PARAMETER  Type is invalid or MemoryType is invalid or HostAddress is NULL\r
-  @retval EFI_UNSUPPORTED        Attributes is unsupported or the memory range specified\r
-                                 by HostAddress, Pages, and Type is not available for common buffer use.\r
-  @retval EFI_OUT_OF_RESOURCES   The memory pages could not be allocated.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoAllocateBuffer (\r
-  IN  EFI_ISA_IO_PROTOCOL  *This,\r
-  IN  EFI_ALLOCATE_TYPE    Type,\r
-  IN  EFI_MEMORY_TYPE      MemoryType,\r
-  IN  UINTN                Pages,\r
-  OUT VOID                 **HostAddress,\r
-  IN  UINT64               Attributes\r
-  );\r
-\r
-/**\r
-  Frees memory that was allocated with EFI_ISA_IO.AllocateBuffer().\r
-\r
-  @param[in] This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Pages               The number of pages to free.\r
-  @param[in] HostAddress         The base address of the allocated range.\r
-\r
-  @retval EFI_SUCCESS            The requested memory pages were freed.\r
-  @retval EFI_INVALID_PARAMETER  The memory was not allocated with EFI_ISA_IO.AllocateBufer().\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaIoFreeBuffer (\r
-  IN EFI_ISA_IO_PROTOCOL  *This,\r
-  IN UINTN                Pages,\r
-  IN VOID                 *HostAddress\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.inf
deleted file mode 100644 (file)
index 7e88588..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-## @file\r
-# Produces an instance of the ISA I/O Protocol for every SIO controller.\r
-#\r
-# Produces an instance of the ISA I/O Protocol for every SIO controller. The ISA\r
-# I/O protocols are installed based off of the information provided by each\r
-# instance of the SIO Protocol found.\r
-#\r
-# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = IsaIoDxe\r
-  MODULE_UNI_FILE                = IsaIoDxe.uni\r
-  FILE_GUID                      = 61AD3083-DCAD-4850-A50C-73B23B3B14F9\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializeIsaIo\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#  DRIVER_BINDING                = gIsaIoDriver\r
-#  COMPONENT_NAME                = gIsaIoComponentName;\r
-#  COMPONENT_NAME2               = gIsaIoComponentName2;\r
-#\r
-\r
-[Sources]\r
-  ComponentName.h\r
-  ComponentName.c\r
-  IsaIo.h\r
-  IsaIo.c\r
-  IsaDriver.h\r
-  IsaDriver.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  ReportStatusCodeLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  DevicePathLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-\r
-[Protocols]\r
-  gEfiIsaIoProtocolGuid                         ## BY_START\r
-  gEfiSioProtocolGuid                           ## TO_START\r
-  gEfiPciIoProtocolGuid                         ## TO_START\r
-  gEfiDevicePathProtocolGuid                    ## TO_START\r
-\r
-[Pcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSupportedFeatures  ## CONSUMES\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  IsaIoDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.uni
deleted file mode 100644 (file)
index 5967a0e..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// Produces an instance of the ISA I/O Protocol for every SIO controller.\r
-//\r
-// Produces an instance of the ISA I/O Protocol for every SIO controller. The ISA\r
-// I/O protocols are installed based off of the information provided by each\r
-// instance of the SIO Protocol found.\r
-//\r
-// Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Produces an instance of the ISA I/O Protocol for every SIO controller"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Produces an instance of the ISA I/O Protocol for every SIO controller. The ISA I/O protocols are installed based off of the information provided by each instance of the SIO Protocol found."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxeExtra.uni
deleted file mode 100644 (file)
index 575a5d6..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// IsaIoDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"ISA I/O DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c
deleted file mode 100644 (file)
index 7697aa7..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-/** @file\r
-  UEFI Component Name and Name2 protocol for Isa serial driver.\r
-\r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Serial.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gIsaSerialComponentName = {\r
-  IsaSerialComponentNameGetDriverName,\r
-  IsaSerialComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaSerialComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaSerialComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaSerialComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaSerialDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"ISA Serial Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 mSerialPortName[] = L"ISA Serial Port # ";\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mIsaSerialDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gIsaSerialComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_SERIAL_IO_PROTOCOL    *SerialIo;\r
-  SERIAL_DEV                *SerialDevice;\r
-  EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
-\r
-  //\r
-  // Make sure this driver is currently managing ControllerHandle\r
-  //\r
-  Status = EfiTestManagedDevice (\r
-             ControllerHandle,\r
-             gSerialControllerDriver.DriverBindingHandle,\r
-             &gEfiIsaIoProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  ControllerNameTable = NULL;\r
-  if (ChildHandle != NULL) {\r
-    Status = EfiTestChildHandle (\r
-               ControllerHandle,\r
-               ChildHandle,\r
-               &gEfiIsaIoProtocolGuid\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    //\r
-    // Get the Serial I/O Protocol from the child handle\r
-    //\r
-    Status = gBS->OpenProtocol (\r
-                    ChildHandle,\r
-                    &gEfiSerialIoProtocolGuid,\r
-                    (VOID **) &SerialIo,\r
-                    gSerialControllerDriver.DriverBindingHandle,\r
-                    ChildHandle,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    //\r
-    // Get the Serial Controller's Device structure\r
-    //\r
-    SerialDevice = SERIAL_DEV_FROM_THIS (SerialIo);\r
-    ControllerNameTable = SerialDevice->ControllerNameTable;\r
-  }\r
-\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           ControllerNameTable,\r
-           ControllerName,\r
-           (BOOLEAN)(This == &gIsaSerialComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Add the ISO639-2 and RFC4646 component name both for the Serial IO device\r
-\r
-  @param SerialDevice     A pointer to the SERIAL_DEV instance.\r
-\r
-  @param IsaIo            A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-\r
-**/\r
-VOID\r
-AddName (\r
-  IN  SERIAL_DEV                               *SerialDevice,\r
-  IN  EFI_ISA_IO_PROTOCOL                      *IsaIo\r
-  )\r
-{\r
-  mSerialPortName[(sizeof (mSerialPortName) / 2) - 2] = (CHAR16) (L'0' + (UINT8) IsaIo->ResourceList->Device.UID);\r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gIsaSerialComponentName.SupportedLanguages,\r
-    &SerialDevice->ControllerNameTable,\r
-    mSerialPortName,\r
-    TRUE\r
-    );\r
-  AddUnicodeString2 (\r
-    "en",\r
-    gIsaSerialComponentName2.SupportedLanguages,\r
-    &SerialDevice->ControllerNameTable,\r
-    mSerialPortName,\r
-    FALSE\r
-    );\r
-\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
deleted file mode 100644 (file)
index 040dbef..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-## @file\r
-# Serial driver for standard UARTS on an ISA bus.\r
-#\r
-# Produces the Serial I/O protocol for standard UARTS using ISA I/O. This driver\r
-# supports the 8250, 16450, 16550 and 16550A UART types.\r
-#\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = IsaSerialDxe\r
-  MODULE_UNI_FILE                = IsaSerialDxe.uni\r
-  FILE_GUID                      = 93B80003-9FB3-11d4-9A3A-0090273FC14D\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializeIsaSerial\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-#  DRIVER_BINDING                =  gSerialControllerDriver\r
-#  COMPONENT_NAME                =  gIsaSerialComponentName\r
-#  COMPONENT_NAME2               =  gIsaSerialComponentName2\r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  Serial.h\r
-  Serial.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  ReportStatusCodeLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  DevicePathLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-\r
-[Guids]\r
-  gEfiUartDevicePathGuid                        ## SOMETIMES_CONSUMES   ## GUID\r
-\r
-[Protocols]\r
-  gEfiIsaIoProtocolGuid                         ## TO_START\r
-  gEfiDevicePathProtocolGuid                    ## TO_START\r
-  gEfiSerialIoProtocolGuid                      ## BY_START\r
-  gEfiDevicePathProtocolGuid                    ## BY_START\r
-\r
-[FeaturePcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSerialUseHalfHandshake|FALSE   ## CONSUMES\r
-\r
-[Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200    ## CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8         ## CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1           ## CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1         ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200 ## CONSUMES\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  IsaSerialDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.uni
deleted file mode 100644 (file)
index d4edb7c..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// /** @file\r
-// Serial driver for standard UARTS on an ISA bus.\r
-//\r
-// Produces the Serial I/O protocol for standard UARTS using ISA I/O. This driver\r
-// supports the 8250, 16450, 16550 and 16550A UART types.\r
-//\r
-// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Serial driver for standard UARTS on an ISA bus"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Produces the Serial I/O protocol for standard UARTS using ISA I/O. This driver supports the 8250, 16450, 16550 and 16550A UART types."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxeExtra.uni
deleted file mode 100644 (file)
index 3be5c6b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// IsaSerialDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"ISA UART Serial Bus DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
deleted file mode 100644 (file)
index d31e6b0..0000000
+++ /dev/null
@@ -1,2032 +0,0 @@
-/** @file\r
-  Serial driver for standard UARTS on an ISA bus.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Serial.h"\r
-\r
-//\r
-// ISA Serial Driver Global Variables\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver = {\r
-  SerialControllerDriverSupported,\r
-  SerialControllerDriverStart,\r
-  SerialControllerDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-SERIAL_DEV  gSerialDevTempate = {\r
-  SERIAL_DEV_SIGNATURE,\r
-  NULL,\r
-  { // SerialIo\r
-    SERIAL_IO_INTERFACE_REVISION,\r
-    IsaSerialReset,\r
-    IsaSerialSetAttributes,\r
-    IsaSerialSetControl,\r
-    IsaSerialGetControl,\r
-    IsaSerialWrite,\r
-    IsaSerialRead,\r
-    NULL\r
-  },\r
-  { // SerialMode\r
-    SERIAL_PORT_SUPPORT_CONTROL_MASK,\r
-    SERIAL_PORT_DEFAULT_TIMEOUT,\r
-    0,\r
-    SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH,\r
-    0,\r
-    0,\r
-    0\r
-  },\r
-  NULL,\r
-  NULL,\r
-  { // UartDevicePath\r
-    {\r
-      MESSAGING_DEVICE_PATH,\r
-      MSG_UART_DP,\r
-      {\r
-        (UINT8) (sizeof (UART_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    0,\r
-    0,\r
-    0,\r
-    0,\r
-    0\r
-  },\r
-  NULL,\r
-  0,    //BaseAddress\r
-  {\r
-    0,\r
-    0,\r
-    SERIAL_MAX_BUFFER_SIZE,\r
-    { 0 }\r
-  },\r
-  {\r
-    0,\r
-    0,\r
-    SERIAL_MAX_BUFFER_SIZE,\r
-    { 0 }\r
-  },\r
-  FALSE,\r
-  FALSE,\r
-  Uart16550A,\r
-  NULL\r
-};\r
-\r
-/**\r
-  Check the device path node whether it's the Flow Control node or not.\r
-\r
-  @param[in] FlowControl    The device path node to be checked.\r
-\r
-  @retval TRUE              It's the Flow Control node.\r
-  @retval FALSE             It's not.\r
-\r
-**/\r
-BOOLEAN\r
-IsUartFlowControlNode (\r
-  IN UART_FLOW_CONTROL_DEVICE_PATH *FlowControl\r
-  )\r
-{\r
-  return (BOOLEAN) (\r
-           (DevicePathType (FlowControl) == MESSAGING_DEVICE_PATH) &&\r
-           (DevicePathSubType (FlowControl) == MSG_VENDOR_DP) &&\r
-           (CompareGuid (&FlowControl->Guid, &gEfiUartDevicePathGuid))\r
-           );\r
-}\r
-\r
-/**\r
-  Check the device path node whether it contains Flow Control node or not.\r
-\r
-  @param[in] DevicePath     The device path to be checked.\r
-\r
-  @retval TRUE              It contains the Flow Control node.\r
-  @retval FALSE             It doesn't.\r
-\r
-**/\r
-BOOLEAN\r
-ContainsFlowControl (\r
-  IN EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
-  )\r
-{\r
-  while (!IsDevicePathEnd (DevicePath)) {\r
-    if (IsUartFlowControlNode ((UART_FLOW_CONTROL_DEVICE_PATH *) DevicePath)) {\r
-      return TRUE;\r
-    }\r
-    DevicePath = NextDevicePathNode (DevicePath);\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  The user Entry Point for module IsaSerial. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeIsaSerial (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gSerialControllerDriver,\r
-             ImageHandle,\r
-             &gIsaSerialComponentName,\r
-             &gIsaSerialComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Initialize UART default setting in gSerialDevTempate\r
-  //\r
-  gSerialDevTempate.SerialMode.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);\r
-  gSerialDevTempate.SerialMode.DataBits = PcdGet8 (PcdUartDefaultDataBits);\r
-  gSerialDevTempate.SerialMode.Parity   = PcdGet8 (PcdUartDefaultParity);\r
-  gSerialDevTempate.SerialMode.StopBits = PcdGet8 (PcdUartDefaultStopBits);\r
-  gSerialDevTempate.UartDevicePath.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);\r
-  gSerialDevTempate.UartDevicePath.DataBits = PcdGet8 (PcdUartDefaultDataBits);\r
-  gSerialDevTempate.UartDevicePath.Parity   = PcdGet8 (PcdUartDefaultParity);\r
-  gSerialDevTempate.UartDevicePath.StopBits = PcdGet8 (PcdUartDefaultStopBits);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Check to see if this driver supports the given controller\r
-\r
-  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  Controller           The handle of the controller to test.\r
-  @param  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @return EFI_SUCCESS          This driver can support the given controller\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-\r
-{\r
-  EFI_STATUS                                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL                  *ParentDevicePath;\r
-  EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
-  UART_DEVICE_PATH                          *UartNode;\r
-  EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;\r
-  UART_FLOW_CONTROL_DEVICE_PATH             *FlowControlNode;\r
-  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY       *OpenInfoBuffer;\r
-  UINTN                                     EntryCount;\r
-  UINTN                                     Index;\r
-  BOOLEAN                                   HasFlowControl;\r
-\r
-  //\r
-  // Check RemainingDevicePath validation\r
-  //\r
-  if (RemainingDevicePath != NULL) {\r
-    //\r
-    // Check if RemainingDevicePath is the End of Device Path Node,\r
-    // if yes, go on checking other conditions\r
-    //\r
-    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
-      //\r
-      // If RemainingDevicePath isn't the End of Device Path Node,\r
-      // check its validation\r
-      //\r
-      Status = EFI_UNSUPPORTED;\r
-\r
-      UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;\r
-      if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||\r
-          UartNode->Header.SubType != MSG_UART_DP ||\r
-          sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UartNode)\r
-                                        ) {\r
-        goto Error;\r
-      }\r
-\r
-      if (UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
-        goto Error;\r
-      }\r
-\r
-      if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {\r
-        goto Error;\r
-      }\r
-\r
-      if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {\r
-        goto Error;\r
-      }\r
-\r
-      if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {\r
-        goto Error;\r
-      }\r
-\r
-      if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {\r
-        goto Error;\r
-      }\r
-\r
-      if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {\r
-        goto Error;\r
-      }\r
-\r
-      FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (UartNode);\r
-      if (IsUartFlowControlNode (FlowControlNode)) {\r
-        //\r
-        // If the second node is Flow Control Node,\r
-        //   return error when it request other than hardware flow control.\r
-        //\r
-        if ((ReadUnaligned32 (&FlowControlNode->FlowControlMap) & ~UART_FLOW_CONTROL_HARDWARE) != 0) {\r
-          goto Error;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {\r
-      //\r
-      // If RemainingDevicePath is NULL or is the End of Device Path Node\r
-      //\r
-      return EFI_SUCCESS;\r
-    }\r
-    //\r
-    // When the driver has produced device path with flow control node but RemainingDevicePath only contains UART node,\r
-    //   return unsupported, and vice versa.\r
-    //\r
-    Status = gBS->OpenProtocolInformation (\r
-                    Controller,\r
-                    &gEfiIsaIoProtocolGuid,\r
-                    &OpenInfoBuffer,\r
-                    &EntryCount\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    for (Index = 0; Index < EntryCount; Index++) {\r
-      if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
-        Status = gBS->OpenProtocol (\r
-                        OpenInfoBuffer[Index].ControllerHandle,\r
-                        &gEfiDevicePathProtocolGuid,\r
-                        (VOID **) &DevicePath,\r
-                        This->DriverBindingHandle,\r
-                        Controller,\r
-                        EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                        );\r
-        if (!EFI_ERROR (Status)) {\r
-          HasFlowControl = ContainsFlowControl (RemainingDevicePath);\r
-          if (HasFlowControl ^ ContainsFlowControl (DevicePath)) {\r
-            Status = EFI_UNSUPPORTED;\r
-          }\r
-        }\r
-        break;\r
-      }\r
-    }\r
-    FreePool (OpenInfoBuffer);\r
-    return Status;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  //\r
-  // Open the EFI Device Path protocol needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Use the ISA I/O Protocol to see if Controller is standard ISA UART that\r
-  // can be managed by this driver.\r
-  //\r
-  Status = EFI_SUCCESS;\r
-  if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x501)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Error;\r
-  }\r
-\r
-Error:\r
-  //\r
-  // Close protocol, don't use device path protocol in the Support() function\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Start to management the controller passed in\r
-\r
-  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  Controller           The handle of the controller to test.\r
-  @param  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @return EFI_SUCCESS   Driver is started successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-  SERIAL_DEV                          *SerialDevice;\r
-  UINTN                               Index;\r
-  EFI_DEVICE_PATH_PROTOCOL            *ParentDevicePath;\r
-  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
-  UINTN                               EntryCount;\r
-  EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
-  UART_DEVICE_PATH                    *Uart;\r
-  UINT32                              FlowControlMap;\r
-  UART_FLOW_CONTROL_DEVICE_PATH       *FlowControl;\r
-  EFI_DEVICE_PATH_PROTOCOL            *TempDevicePath;\r
-  UINT32                              Control;\r
-\r
-  SerialDevice = NULL;\r
-  //\r
-  // Get the Parent Device Path\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Report status code enable the serial\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_P_PC_ENABLE | EFI_PERIPHERAL_SERIAL_PORT,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Grab the IO abstraction we need to get any work done\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
-    goto Error;\r
-  }\r
-\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-\r
-    if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {\r
-      //\r
-      // If RemainingDevicePath is NULL or is the End of Device Path Node\r
-      //\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    //\r
-    // Make sure a child handle does not already exist.  This driver can only\r
-    // produce one child per serial port.\r
-    //\r
-    Status = gBS->OpenProtocolInformation (\r
-                    Controller,\r
-                    &gEfiIsaIoProtocolGuid,\r
-                    &OpenInfoBuffer,\r
-                    &EntryCount\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    Status = EFI_ALREADY_STARTED;\r
-    for (Index = 0; Index < EntryCount; Index++) {\r
-      if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
-        Status = gBS->OpenProtocol (\r
-                        OpenInfoBuffer[Index].ControllerHandle,\r
-                        &gEfiSerialIoProtocolGuid,\r
-                        (VOID **) &SerialIo,\r
-                        This->DriverBindingHandle,\r
-                        Controller,\r
-                        EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                        );\r
-        if (!EFI_ERROR (Status)) {\r
-          Uart   = (UART_DEVICE_PATH *) RemainingDevicePath;\r
-          Status = SerialIo->SetAttributes (\r
-                               SerialIo,\r
-                               Uart->BaudRate,\r
-                               SerialIo->Mode->ReceiveFifoDepth,\r
-                               SerialIo->Mode->Timeout,\r
-                               (EFI_PARITY_TYPE) Uart->Parity,\r
-                               Uart->DataBits,\r
-                               (EFI_STOP_BITS_TYPE) Uart->StopBits\r
-                               );\r
-\r
-          FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Uart);\r
-          if (!EFI_ERROR (Status) && IsUartFlowControlNode (FlowControl)) {\r
-            Status = SerialIo->GetControl (SerialIo, &Control);\r
-            if (!EFI_ERROR (Status)) {\r
-              if (ReadUnaligned32 (&FlowControl->FlowControlMap) == UART_FLOW_CONTROL_HARDWARE) {\r
-                Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;\r
-              } else {\r
-                Control &= ~EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;\r
-              }\r
-              //\r
-              // Clear the bits that are not allowed to pass to SetControl\r
-              //\r
-              Control &= (EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |\r
-                          EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |\r
-                          EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE);\r
-              Status = SerialIo->SetControl (SerialIo, Control);\r
-            }\r
-          }\r
-        }\r
-        break;\r
-      }\r
-    }\r
-\r
-    FreePool (OpenInfoBuffer);\r
-    return Status;\r
-  }\r
-\r
-  if (RemainingDevicePath != NULL) {\r
-    if (IsDevicePathEnd (RemainingDevicePath)) {\r
-      //\r
-      // If RemainingDevicePath is the End of Device Path Node,\r
-      // skip enumerate any device and return EFI_SUCESSS\r
-      //\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Initialize the serial device instance\r
-  //\r
-  SerialDevice = AllocateCopyPool (sizeof (SERIAL_DEV), &gSerialDevTempate);\r
-  if (SerialDevice == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Error;\r
-  }\r
-\r
-  SerialDevice->SerialIo.Mode       = &(SerialDevice->SerialMode);\r
-  SerialDevice->IsaIo               = IsaIo;\r
-  SerialDevice->ParentDevicePath    = ParentDevicePath;\r
-  FlowControl                       = NULL;\r
-  FlowControlMap                    = 0;\r
-\r
-  //\r
-  // Check if RemainingDevicePath is NULL,\r
-  // if yes, use the values from the gSerialDevTempate as no remaining device path was\r
-  // passed in.\r
-  //\r
-  if (RemainingDevicePath != NULL) {\r
-    //\r
-    // If RemainingDevicePath isn't NULL,\r
-    // match the configuration of the RemainingDevicePath. IsHandleSupported()\r
-    // already checked to make sure the RemainingDevicePath contains settings\r
-    // that we can support.\r
-    //\r
-    CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
-    FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (RemainingDevicePath);\r
-    if (IsUartFlowControlNode (FlowControl)) {\r
-      FlowControlMap = ReadUnaligned32 (&FlowControl->FlowControlMap);\r
-    } else {\r
-      FlowControl    = NULL;\r
-    }\r
-  }\r
-\r
-  AddName (SerialDevice, IsaIo);\r
-\r
-  for (Index = 0; SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {\r
-    if (SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {\r
-      SerialDevice->BaseAddress = (UINT16) SerialDevice->IsaIo->ResourceList->ResourceItem[Index].StartRange;\r
-    }\r
-  }\r
-\r
-  SerialDevice->HardwareFlowControl = (BOOLEAN) (FlowControlMap == UART_FLOW_CONTROL_HARDWARE);\r
-\r
-  //\r
-  // Report status code the serial present\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_P_PC_PRESENCE_DETECT | EFI_PERIPHERAL_SERIAL_PORT,\r
-    ParentDevicePath\r
-    );\r
-\r
-  if (!IsaSerialPortPresent (SerialDevice)) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE,\r
-      EFI_P_EC_NOT_DETECTED | EFI_PERIPHERAL_SERIAL_PORT,\r
-      ParentDevicePath\r
-      );\r
-    goto Error;\r
-  }\r
-\r
-  //\r
-  // Build the device path by appending the UART node to the ParentDevicePath.\r
-  // The Uart setings are zero here, since  SetAttribute() will update them to match\r
-  // the default setings.\r
-  //\r
-  SerialDevice->DevicePath = AppendDevicePathNode (\r
-                               ParentDevicePath,\r
-                               (EFI_DEVICE_PATH_PROTOCOL *) &SerialDevice->UartDevicePath\r
-                               );\r
-  //\r
-  // Only produce the Flow Control node when remaining device path has it\r
-  //\r
-  if (FlowControl != NULL) {\r
-    TempDevicePath = SerialDevice->DevicePath;\r
-    if (TempDevicePath != NULL) {\r
-      SerialDevice->DevicePath = AppendDevicePathNode (\r
-                                   TempDevicePath,\r
-                                   (EFI_DEVICE_PATH_PROTOCOL *) FlowControl\r
-                                   );\r
-      FreePool (TempDevicePath);\r
-    }\r
-  }\r
-  if (SerialDevice->DevicePath == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Error;\r
-  }\r
-\r
-  //\r
-  // Fill in Serial I/O Mode structure based on either the RemainingDevicePath or defaults.\r
-  //\r
-  SerialDevice->SerialMode.BaudRate         = SerialDevice->UartDevicePath.BaudRate;\r
-  SerialDevice->SerialMode.DataBits         = SerialDevice->UartDevicePath.DataBits;\r
-  SerialDevice->SerialMode.Parity           = SerialDevice->UartDevicePath.Parity;\r
-  SerialDevice->SerialMode.StopBits         = SerialDevice->UartDevicePath.StopBits;\r
-\r
-  //\r
-  // Issue a reset to initialize the COM port\r
-  //\r
-  Status = SerialDevice->SerialIo.Reset (&SerialDevice->SerialIo);\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE,\r
-      EFI_P_EC_CONTROLLER_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
-      ParentDevicePath\r
-      );\r
-    goto Error;\r
-  }\r
-  //\r
-  // Install protocol interfaces for the serial device.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &SerialDevice->Handle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  SerialDevice->DevicePath,\r
-                  &gEfiSerialIoProtocolGuid,\r
-                  &SerialDevice->SerialIo,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-  //\r
-  // Open For Child Device\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  SerialDevice->Handle,\r
-                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                  );\r
-\r
-Error:\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiIsaIoProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-    if (SerialDevice != NULL) {\r
-      if (SerialDevice->DevicePath != NULL) {\r
-        gBS->FreePool (SerialDevice->DevicePath);\r
-      }\r
-\r
-      FreeUnicodeStringTable (SerialDevice->ControllerNameTable);\r
-      gBS->FreePool (SerialDevice);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Disconnect this driver with the controller, uninstall related protocol instance\r
-\r
-  @param  This                  A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  Controller            The handle of the controller to test.\r
-  @param  NumberOfChildren      Number of child device.\r
-  @param  ChildHandleBuffer     A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS           Operation successfully\r
-  @retval EFI_DEVICE_ERROR      Cannot stop the driver successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialControllerDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN  EFI_HANDLE                     Controller,\r
-  IN  UINTN                          NumberOfChildren,\r
-  IN  EFI_HANDLE                     *ChildHandleBuffer\r
-  )\r
-\r
-{\r
-  EFI_STATUS                          Status;\r
-  UINTN                               Index;\r
-  BOOLEAN                             AllChildrenStopped;\r
-  EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
-  SERIAL_DEV                          *SerialDevice;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-  EFI_DEVICE_PATH_PROTOCOL            *DevicePath;\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath\r
-                  );\r
-\r
-  //\r
-  // Report the status code disable the serial\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_P_PC_DISABLE | EFI_PERIPHERAL_SERIAL_PORT,\r
-    DevicePath\r
-    );\r
-\r
-  //\r
-  // Complete all outstanding transactions to Controller.\r
-  // Don't allow any new transaction to Controller to be started.\r
-  //\r
-  if (NumberOfChildren == 0) {\r
-    //\r
-    // Close the bus driver\r
-    //\r
-    Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiIsaIoProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    Controller\r
-                    );\r
-\r
-    Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    Controller\r
-                    );\r
-    return Status;\r
-  }\r
-\r
-  AllChildrenStopped = TRUE;\r
-\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-\r
-    Status = gBS->OpenProtocol (\r
-                    ChildHandleBuffer[Index],\r
-                    &gEfiSerialIoProtocolGuid,\r
-                    (VOID **) &SerialIo,\r
-                    This->DriverBindingHandle,\r
-                    Controller,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-\r
-      SerialDevice = SERIAL_DEV_FROM_THIS (SerialIo);\r
-\r
-      Status = gBS->CloseProtocol (\r
-                      Controller,\r
-                      &gEfiIsaIoProtocolGuid,\r
-                      This->DriverBindingHandle,\r
-                      ChildHandleBuffer[Index]\r
-                      );\r
-\r
-      Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                      ChildHandleBuffer[Index],\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      SerialDevice->DevicePath,\r
-                      &gEfiSerialIoProtocolGuid,\r
-                      &SerialDevice->SerialIo,\r
-                      NULL\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        gBS->OpenProtocol (\r
-               Controller,\r
-               &gEfiIsaIoProtocolGuid,\r
-               (VOID **) &IsaIo,\r
-               This->DriverBindingHandle,\r
-               ChildHandleBuffer[Index],\r
-               EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-               );\r
-      } else {\r
-        if (SerialDevice->DevicePath != NULL) {\r
-          gBS->FreePool (SerialDevice->DevicePath);\r
-        }\r
-\r
-        FreeUnicodeStringTable (SerialDevice->ControllerNameTable);\r
-        gBS->FreePool (SerialDevice);\r
-      }\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      AllChildrenStopped = FALSE;\r
-    }\r
-  }\r
-\r
-  if (!AllChildrenStopped) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Detect whether specific FIFO is full or not.\r
-\r
-  @param Fifo    A pointer to the Data Structure SERIAL_DEV_FIFO\r
-\r
-  @return whether specific FIFO is full or not\r
-\r
-**/\r
-BOOLEAN\r
-IsaSerialFifoFull (\r
-  IN SERIAL_DEV_FIFO *Fifo\r
-  )\r
-\r
-{\r
-  if (Fifo->Surplus == 0) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Detect whether specific FIFO is empty or not.\r
-\r
-  @param  Fifo    A pointer to the Data Structure SERIAL_DEV_FIFO\r
-\r
-  @return whether specific FIFO is empty or not\r
-\r
-**/\r
-BOOLEAN\r
-IsaSerialFifoEmpty (\r
-  IN SERIAL_DEV_FIFO *Fifo\r
-  )\r
-\r
-{\r
-  if (Fifo->Surplus == SERIAL_MAX_BUFFER_SIZE) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Add data to specific FIFO.\r
-\r
-  @param Fifo                  A pointer to the Data Structure SERIAL_DEV_FIFO\r
-  @param Data                  the data added to FIFO\r
-\r
-  @retval EFI_SUCCESS           Add data to specific FIFO successfully\r
-  @retval EFI_OUT_OF_RESOURCE   Failed to add data because FIFO is already full\r
-\r
-**/\r
-EFI_STATUS\r
-IsaSerialFifoAdd (\r
-  IN SERIAL_DEV_FIFO *Fifo,\r
-  IN UINT8           Data\r
-  )\r
-\r
-{\r
-  //\r
-  // if FIFO full can not add data\r
-  //\r
-  if (IsaSerialFifoFull (Fifo)) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // FIFO is not full can add data\r
-  //\r
-  Fifo->Data[Fifo->Last] = Data;\r
-  Fifo->Surplus--;\r
-  Fifo->Last++;\r
-  if (Fifo->Last == SERIAL_MAX_BUFFER_SIZE) {\r
-    Fifo->Last = 0;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Remove data from specific FIFO.\r
-\r
-  @param Fifo                  A pointer to the Data Structure SERIAL_DEV_FIFO\r
-  @param Data                  the data removed from FIFO\r
-\r
-  @retval EFI_SUCCESS           Remove data from specific FIFO successfully\r
-  @retval EFI_OUT_OF_RESOURCE   Failed to remove data because FIFO is empty\r
-\r
-**/\r
-EFI_STATUS\r
-IsaSerialFifoRemove (\r
-  IN  SERIAL_DEV_FIFO *Fifo,\r
-  OUT UINT8           *Data\r
-  )\r
-\r
-{\r
-  //\r
-  // if FIFO is empty, no data can remove\r
-  //\r
-  if (IsaSerialFifoEmpty (Fifo)) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // FIFO is not empty, can remove data\r
-  //\r
-  *Data = Fifo->Data[Fifo->First];\r
-  Fifo->Surplus++;\r
-  Fifo->First++;\r
-  if (Fifo->First == SERIAL_MAX_BUFFER_SIZE) {\r
-    Fifo->First = 0;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Reads and writes all avaliable data.\r
-\r
-  @param SerialDevice           The device to flush\r
-\r
-  @retval EFI_SUCCESS           Data was read/written successfully.\r
-  @retval EFI_OUT_OF_RESOURCE   Failed because software receive FIFO is full.  Note, when\r
-                                this happens, pending writes are not done.\r
-\r
-**/\r
-EFI_STATUS\r
-IsaSerialReceiveTransmit (\r
-  IN SERIAL_DEV *SerialDevice\r
-  )\r
-\r
-{\r
-  SERIAL_PORT_LSR Lsr;\r
-  UINT8           Data;\r
-  BOOLEAN         ReceiveFifoFull;\r
-  SERIAL_PORT_MSR Msr;\r
-  SERIAL_PORT_MCR Mcr;\r
-  UINTN           TimeOut;\r
-\r
-  Data = 0;\r
-\r
-  //\r
-  // Begin the read or write\r
-  //\r
-  if (SerialDevice->SoftwareLoopbackEnable) {\r
-    do {\r
-      ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);\r
-      if (!IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
-        IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
-        if (ReceiveFifoFull) {\r
-          return EFI_OUT_OF_RESOURCES;\r
-        }\r
-\r
-        IsaSerialFifoAdd (&SerialDevice->Receive, Data);\r
-      }\r
-    } while (!IsaSerialFifoEmpty (&SerialDevice->Transmit));\r
-  } else {\r
-    ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);\r
-    //\r
-    // For full handshake flow control, tell the peer to send data\r
-    // if receive buffer is available.\r
-    //\r
-    if (SerialDevice->HardwareFlowControl &&\r
-        !FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)&&\r
-        !ReceiveFifoFull\r
-        ) {\r
-      Mcr.Data     = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-      Mcr.Bits.Rts = 1;\r
-      WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
-    }\r
-    do {\r
-      Lsr.Data = READ_LSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-\r
-      //\r
-      // Flush incomming data to prevent a an overrun during a long write\r
-      //\r
-      if ((Lsr.Bits.Dr == 1) && !ReceiveFifoFull) {\r
-        ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);\r
-        if (!ReceiveFifoFull) {\r
-          if (Lsr.Bits.FIFOe == 1 || Lsr.Bits.Oe == 1 || Lsr.Bits.Pe == 1 || Lsr.Bits.Fe == 1 || Lsr.Bits.Bi == 1) {\r
-            REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-              EFI_ERROR_CODE,\r
-              EFI_P_EC_INPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
-              SerialDevice->DevicePath\r
-              );\r
-            if (Lsr.Bits.FIFOe == 1 || Lsr.Bits.Pe == 1|| Lsr.Bits.Fe == 1 || Lsr.Bits.Bi == 1) {\r
-              Data = READ_RBR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-              continue;\r
-            }\r
-          }\r
-\r
-          Data = READ_RBR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-\r
-          IsaSerialFifoAdd (&SerialDevice->Receive, Data);\r
-\r
-          //\r
-          // For full handshake flow control, if receive buffer full\r
-          // tell the peer to stop sending data.\r
-          //\r
-          if (SerialDevice->HardwareFlowControl &&\r
-              !FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)   &&\r
-              IsaSerialFifoFull (&SerialDevice->Receive)\r
-              ) {\r
-            Mcr.Data     = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-            Mcr.Bits.Rts = 0;\r
-            WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
-          }\r
-\r
-\r
-          continue;\r
-        } else {\r
-          REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-            EFI_PROGRESS_CODE,\r
-            EFI_P_SERIAL_PORT_PC_CLEAR_BUFFER | EFI_PERIPHERAL_SERIAL_PORT,\r
-            SerialDevice->DevicePath\r
-            );\r
-        }\r
-      }\r
-      //\r
-      // Do the write\r
-      //\r
-      if (Lsr.Bits.Thre == 1 && !IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
-        //\r
-        // Make sure the transmit data will not be missed\r
-        //\r
-        if (SerialDevice->HardwareFlowControl) {\r
-          //\r
-          // For half handshake flow control assert RTS before sending.\r
-          //\r
-          if (FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)) {\r
-            Mcr.Data     = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-            Mcr.Bits.Rts= 0;\r
-            WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
-          }\r
-          //\r
-          // Wait for CTS\r
-          //\r
-          TimeOut   = 0;\r
-          Msr.Data  = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-          while ((Msr.Bits.Dcd == 1) && ((Msr.Bits.Cts == 0) ^ FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake))) {\r
-            gBS->Stall (TIMEOUT_STALL_INTERVAL);\r
-            TimeOut++;\r
-            if (TimeOut > 5) {\r
-              break;\r
-            }\r
-\r
-            Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-          }\r
-\r
-          if ((Msr.Bits.Dcd == 0) || ((Msr.Bits.Cts == 1) ^ FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake))) {\r
-            IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
-            WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);\r
-          }\r
-\r
-          //\r
-          // For half handshake flow control, tell DCE we are done.\r
-          //\r
-          if (FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)) {\r
-            Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-            Mcr.Bits.Rts = 1;\r
-            WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
-          }\r
-        } else {\r
-          IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
-          WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);\r
-        }\r
-      }\r
-    } while (Lsr.Bits.Thre == 1 && !IsaSerialFifoEmpty (&SerialDevice->Transmit));\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// Interface Functions\r
-//\r
-/**\r
-  Reset serial device.\r
-\r
-  @param This               Pointer to EFI_SERIAL_IO_PROTOCOL\r
-\r
-  @retval EFI_SUCCESS        Reset successfully\r
-  @retval EFI_DEVICE_ERROR   Failed to reset\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialReset (\r
-  IN EFI_SERIAL_IO_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS      Status;\r
-  SERIAL_DEV      *SerialDevice;\r
-  SERIAL_PORT_LCR Lcr;\r
-  SERIAL_PORT_IER Ier;\r
-  SERIAL_PORT_MCR Mcr;\r
-  SERIAL_PORT_FCR Fcr;\r
-  EFI_TPL         Tpl;\r
-  UINT32          Control;\r
-\r
-  SerialDevice = SERIAL_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Report the status code reset the serial\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_P_PC_RESET | EFI_PERIPHERAL_SERIAL_PORT,\r
-    SerialDevice->DevicePath\r
-    );\r
-\r
-  Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // Make sure DLAB is 0.\r
-  //\r
-  Lcr.Data      = READ_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Lcr.Bits.DLab = 0;\r
-  WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);\r
-\r
-  //\r
-  // Turn off all interrupts\r
-  //\r
-  Ier.Data        = READ_IER (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Ier.Bits.Ravie  = 0;\r
-  Ier.Bits.Theie  = 0;\r
-  Ier.Bits.Rie    = 0;\r
-  Ier.Bits.Mie    = 0;\r
-  WRITE_IER (SerialDevice->IsaIo, SerialDevice->BaseAddress, Ier.Data);\r
-\r
-  //\r
-  // Disable the FIFO.\r
-  //\r
-  Fcr.Bits.TrFIFOE = 0;\r
-  WRITE_FCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Fcr.Data);\r
-\r
-  //\r
-  // Turn off loopback and disable device interrupt.\r
-  //\r
-  Mcr.Data      = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Mcr.Bits.Out1 = 0;\r
-  Mcr.Bits.Out2 = 0;\r
-  Mcr.Bits.Lme  = 0;\r
-  WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
-\r
-  //\r
-  // Clear the scratch pad register\r
-  //\r
-  WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0);\r
-\r
-  //\r
-  // Go set the current attributes\r
-  //\r
-  Status = This->SetAttributes (\r
-                   This,\r
-                   This->Mode->BaudRate,\r
-                   This->Mode->ReceiveFifoDepth,\r
-                   This->Mode->Timeout,\r
-                   (EFI_PARITY_TYPE) This->Mode->Parity,\r
-                   (UINT8) This->Mode->DataBits,\r
-                   (EFI_STOP_BITS_TYPE) This->Mode->StopBits\r
-                   );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->RestoreTPL (Tpl);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Go set the current control bits\r
-  //\r
-  Control = 0;\r
-  if (SerialDevice->HardwareFlowControl) {\r
-    Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;\r
-  }\r
-  if (SerialDevice->SoftwareLoopbackEnable) {\r
-    Control |= EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE;\r
-  }\r
-  Status = This->SetControl (\r
-                   This,\r
-                   Control\r
-                   );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->RestoreTPL (Tpl);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // for 16550A enable FIFO, 16550 disable FIFO\r
-  //\r
-  Fcr.Bits.TrFIFOE  = 1;\r
-  Fcr.Bits.ResetRF  = 1;\r
-  Fcr.Bits.ResetTF  = 1;\r
-  WRITE_FCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Fcr.Data);\r
-\r
-  //\r
-  // Reset the software FIFO\r
-  //\r
-  SerialDevice->Receive.First     = 0;\r
-  SerialDevice->Receive.Last      = 0;\r
-  SerialDevice->Receive.Surplus   = SERIAL_MAX_BUFFER_SIZE;\r
-  SerialDevice->Transmit.First    = 0;\r
-  SerialDevice->Transmit.Last     = 0;\r
-  SerialDevice->Transmit.Surplus  = SERIAL_MAX_BUFFER_SIZE;\r
-\r
-  gBS->RestoreTPL (Tpl);\r
-\r
-  //\r
-  // Device reset is complete\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Set new attributes to a serial device.\r
-\r
-  @param This                     Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param  BaudRate                 The baudrate of the serial device\r
-  @param  ReceiveFifoDepth         The depth of receive FIFO buffer\r
-  @param  Timeout                  The request timeout for a single char\r
-  @param  Parity                   The type of parity used in serial device\r
-  @param  DataBits                 Number of databits used in serial device\r
-  @param  StopBits                 Number of stopbits used in serial device\r
-\r
-  @retval  EFI_SUCCESS              The new attributes were set\r
-  @retval  EFI_INVALID_PARAMETERS   One or more attributes have an unsupported value\r
-  @retval  EFI_UNSUPPORTED          Data Bits can not set to 5 or 6\r
-  @retval  EFI_DEVICE_ERROR         The serial device is not functioning correctly (no return)\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialSetAttributes (\r
-  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
-  IN UINT64                  BaudRate,\r
-  IN UINT32                  ReceiveFifoDepth,\r
-  IN UINT32                  Timeout,\r
-  IN EFI_PARITY_TYPE         Parity,\r
-  IN UINT8                   DataBits,\r
-  IN EFI_STOP_BITS_TYPE      StopBits\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  SERIAL_DEV                *SerialDevice;\r
-  UINT32                    Divisor;\r
-  UINT32                    Remained;\r
-  SERIAL_PORT_LCR           Lcr;\r
-  UART_DEVICE_PATH          *Uart;\r
-  EFI_TPL                   Tpl;\r
-\r
-  SerialDevice = SERIAL_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Check for default settings and fill in actual values.\r
-  //\r
-  if (BaudRate == 0) {\r
-    BaudRate = PcdGet64 (PcdUartDefaultBaudRate);\r
-  }\r
-\r
-  if (ReceiveFifoDepth == 0) {\r
-    ReceiveFifoDepth = SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH;\r
-  }\r
-\r
-  if (Timeout == 0) {\r
-    Timeout = SERIAL_PORT_DEFAULT_TIMEOUT;\r
-  }\r
-\r
-  if (Parity == DefaultParity) {\r
-    Parity = (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity);\r
-  }\r
-\r
-  if (DataBits == 0) {\r
-    DataBits = PcdGet8 (PcdUartDefaultDataBits);\r
-  }\r
-\r
-  if (StopBits == DefaultStopBits) {\r
-    StopBits = (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits);\r
-  }\r
-  //\r
-  // 5 and 6 data bits can not be verified on a 16550A UART\r
-  // Return EFI_INVALID_PARAMETER if an attempt is made to use these settings.\r
-  //\r
-  if ((DataBits == 5) || (DataBits == 6)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Make sure all parameters are valid\r
-  //\r
-  if ((BaudRate > SERIAL_PORT_MAX_BAUD_RATE) || (BaudRate < SERIAL_PORT_MIN_BAUD_RATE)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // 50,75,110,134,150,300,600,1200,1800,2000,2400,3600,4800,7200,9600,19200,\r
-  // 38400,57600,115200\r
-  //\r
-  if (BaudRate < 75) {\r
-    BaudRate = 50;\r
-  } else if (BaudRate < 110) {\r
-    BaudRate = 75;\r
-  } else if (BaudRate < 134) {\r
-    BaudRate = 110;\r
-  } else if (BaudRate < 150) {\r
-    BaudRate = 134;\r
-  } else if (BaudRate < 300) {\r
-    BaudRate = 150;\r
-  } else if (BaudRate < 600) {\r
-    BaudRate = 300;\r
-  } else if (BaudRate < 1200) {\r
-    BaudRate = 600;\r
-  } else if (BaudRate < 1800) {\r
-    BaudRate = 1200;\r
-  } else if (BaudRate < 2000) {\r
-    BaudRate = 1800;\r
-  } else if (BaudRate < 2400) {\r
-    BaudRate = 2000;\r
-  } else if (BaudRate < 3600) {\r
-    BaudRate = 2400;\r
-  } else if (BaudRate < 4800) {\r
-    BaudRate = 3600;\r
-  } else if (BaudRate < 7200) {\r
-    BaudRate = 4800;\r
-  } else if (BaudRate < 9600) {\r
-    BaudRate = 7200;\r
-  } else if (BaudRate < 19200) {\r
-    BaudRate = 9600;\r
-  } else if (BaudRate < 38400) {\r
-    BaudRate = 19200;\r
-  } else if (BaudRate < 57600) {\r
-    BaudRate = 38400;\r
-  } else if (BaudRate < 115200) {\r
-    BaudRate = 57600;\r
-  } else if (BaudRate <= SERIAL_PORT_MAX_BAUD_RATE) {\r
-    BaudRate = 115200;\r
-  }\r
-\r
-  if ((ReceiveFifoDepth < 1) || (ReceiveFifoDepth > SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Timeout < SERIAL_PORT_MIN_TIMEOUT) || (Timeout > SERIAL_PORT_MAX_TIMEOUT)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Parity < NoParity) || (Parity > SpaceParity)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((DataBits < 5) || (DataBits > 8)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((StopBits < OneStopBit) || (StopBits > TwoStopBits)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // for DataBits = 6,7,8, StopBits can not set OneFiveStopBits\r
-  //\r
-  if ((DataBits >= 6) && (DataBits <= 8) && (StopBits == OneFiveStopBits)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Compute divisor use to program the baud rate using a round determination\r
-  //\r
-  Divisor = (UINT32) DivU64x32Remainder (\r
-                       PcdGet32 (PcdSerialClockRate),\r
-                       ((UINT32) BaudRate * 16),\r
-                       &Remained\r
-                       );\r
-  if (Remained >= ((UINT32) BaudRate * 8)) {\r
-    Divisor += 1;\r
-  }\r
-\r
-  if ((Divisor == 0) || ((Divisor & 0xffff0000) != 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // Compute the actual baud rate that the serial port will be programmed for.\r
-  //\r
-  BaudRate = PcdGet32 (PcdSerialClockRate) / Divisor / 16;\r
-\r
-  //\r
-  // Put serial port on Divisor Latch Mode\r
-  //\r
-  Lcr.Data      = READ_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Lcr.Bits.DLab = 1;\r
-  WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);\r
-\r
-  //\r
-  // Write the divisor to the serial port\r
-  //\r
-  WRITE_DLL (SerialDevice->IsaIo, SerialDevice->BaseAddress, (UINT8) (Divisor & 0xff));\r
-  WRITE_DLM (SerialDevice->IsaIo, SerialDevice->BaseAddress, (UINT8) ((Divisor >> 8) & 0xff));\r
-\r
-  //\r
-  // Put serial port back in normal mode and set remaining attributes.\r
-  //\r
-  Lcr.Bits.DLab = 0;\r
-\r
-  switch (Parity) {\r
-  case NoParity:\r
-    Lcr.Bits.ParEn    = 0;\r
-    Lcr.Bits.EvenPar  = 0;\r
-    Lcr.Bits.SticPar  = 0;\r
-    break;\r
-\r
-  case EvenParity:\r
-    Lcr.Bits.ParEn    = 1;\r
-    Lcr.Bits.EvenPar  = 1;\r
-    Lcr.Bits.SticPar  = 0;\r
-    break;\r
-\r
-  case OddParity:\r
-    Lcr.Bits.ParEn    = 1;\r
-    Lcr.Bits.EvenPar  = 0;\r
-    Lcr.Bits.SticPar  = 0;\r
-    break;\r
-\r
-  case SpaceParity:\r
-    Lcr.Bits.ParEn    = 1;\r
-    Lcr.Bits.EvenPar  = 1;\r
-    Lcr.Bits.SticPar  = 1;\r
-    break;\r
-\r
-  case MarkParity:\r
-    Lcr.Bits.ParEn    = 1;\r
-    Lcr.Bits.EvenPar  = 0;\r
-    Lcr.Bits.SticPar  = 1;\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  switch (StopBits) {\r
-  case OneStopBit:\r
-    Lcr.Bits.StopB = 0;\r
-    break;\r
-\r
-  case OneFiveStopBits:\r
-  case TwoStopBits:\r
-    Lcr.Bits.StopB = 1;\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-  //\r
-  // DataBits\r
-  //\r
-  Lcr.Bits.SerialDB = (UINT8) ((DataBits - 5) & 0x03);\r
-  WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);\r
-\r
-  //\r
-  // Set the Serial I/O mode\r
-  //\r
-  This->Mode->BaudRate          = BaudRate;\r
-  This->Mode->ReceiveFifoDepth  = ReceiveFifoDepth;\r
-  This->Mode->Timeout           = Timeout;\r
-  This->Mode->Parity            = Parity;\r
-  This->Mode->DataBits          = DataBits;\r
-  This->Mode->StopBits          = StopBits;\r
-\r
-  //\r
-  // See if Device Path Node has actually changed\r
-  //\r
-  if (SerialDevice->UartDevicePath.BaudRate == BaudRate &&\r
-      SerialDevice->UartDevicePath.DataBits == DataBits &&\r
-      SerialDevice->UartDevicePath.Parity == Parity &&\r
-      SerialDevice->UartDevicePath.StopBits == StopBits\r
-      ) {\r
-    gBS->RestoreTPL (Tpl);\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Update the device path\r
-  //\r
-  SerialDevice->UartDevicePath.BaudRate = BaudRate;\r
-  SerialDevice->UartDevicePath.DataBits = DataBits;\r
-  SerialDevice->UartDevicePath.Parity   = (UINT8) Parity;\r
-  SerialDevice->UartDevicePath.StopBits = (UINT8) StopBits;\r
-\r
-  Status = EFI_SUCCESS;\r
-  if (SerialDevice->Handle != NULL) {\r
-    Uart = (UART_DEVICE_PATH *) (\r
-             (UINTN) SerialDevice->DevicePath\r
-             + GetDevicePathSize (SerialDevice->ParentDevicePath)\r
-             - END_DEVICE_PATH_LENGTH\r
-             );\r
-    CopyMem (Uart, &SerialDevice->UartDevicePath, sizeof (UART_DEVICE_PATH));\r
-    Status = gBS->ReinstallProtocolInterface (\r
-                    SerialDevice->Handle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    SerialDevice->DevicePath,\r
-                    SerialDevice->DevicePath\r
-                    );\r
-  }\r
-\r
-  gBS->RestoreTPL (Tpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Set Control Bits.\r
-\r
-  @param This              Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param Control           Control bits that can be settable\r
-\r
-  @retval EFI_SUCCESS       New Control bits were set successfully\r
-  @retval EFI_UNSUPPORTED   The Control bits wanted to set are not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialSetControl (\r
-  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
-  IN UINT32                  Control\r
-  )\r
-{\r
-  SERIAL_DEV                    *SerialDevice;\r
-  SERIAL_PORT_MCR               Mcr;\r
-  EFI_TPL                       Tpl;\r
-  UART_FLOW_CONTROL_DEVICE_PATH *FlowControl;\r
-  EFI_STATUS                    Status;\r
-\r
-  //\r
-  // The control bits that can be set are :\r
-  //     EFI_SERIAL_DATA_TERMINAL_READY: 0x0001  // WO\r
-  //     EFI_SERIAL_REQUEST_TO_SEND: 0x0002  // WO\r
-  //     EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE: 0x1000  // RW\r
-  //     EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE: 0x2000  // RW\r
-  //     EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE: 0x4000 // RW\r
-  //\r
-  SerialDevice = SERIAL_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // first determine the parameter is invalid\r
-  //\r
-  if ((Control & (~(EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |\r
-                    EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |\r
-                    EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) != 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Mcr.Bits.DtrC = 0;\r
-  Mcr.Bits.Rts = 0;\r
-  Mcr.Bits.Lme = 0;\r
-  SerialDevice->SoftwareLoopbackEnable = FALSE;\r
-  SerialDevice->HardwareFlowControl = FALSE;\r
-\r
-  if ((Control & EFI_SERIAL_DATA_TERMINAL_READY) == EFI_SERIAL_DATA_TERMINAL_READY) {\r
-    Mcr.Bits.DtrC = 1;\r
-  }\r
-\r
-  if ((Control & EFI_SERIAL_REQUEST_TO_SEND) == EFI_SERIAL_REQUEST_TO_SEND) {\r
-    Mcr.Bits.Rts = 1;\r
-  }\r
-\r
-  if ((Control & EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE) == EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE) {\r
-    Mcr.Bits.Lme = 1;\r
-  }\r
-\r
-  if ((Control & EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) == EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) {\r
-    SerialDevice->HardwareFlowControl = TRUE;\r
-  }\r
-\r
-  WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
-\r
-  if ((Control & EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) == EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) {\r
-    SerialDevice->SoftwareLoopbackEnable = TRUE;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-  if (SerialDevice->Handle != NULL) {\r
-    FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) (\r
-                    (UINTN) SerialDevice->DevicePath\r
-                    + GetDevicePathSize (SerialDevice->ParentDevicePath)\r
-                    - END_DEVICE_PATH_LENGTH\r
-                    + sizeof (UART_DEVICE_PATH)\r
-                    );\r
-    if (IsUartFlowControlNode (FlowControl) &&\r
-        ((ReadUnaligned32 (&FlowControl->FlowControlMap) == UART_FLOW_CONTROL_HARDWARE) ^ SerialDevice->HardwareFlowControl)) {\r
-      //\r
-      // Flow Control setting is changed, need to reinstall device path protocol\r
-      //\r
-      WriteUnaligned32 (&FlowControl->FlowControlMap, SerialDevice->HardwareFlowControl ? UART_FLOW_CONTROL_HARDWARE : 0);\r
-      Status = gBS->ReinstallProtocolInterface (\r
-                      SerialDevice->Handle,\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      SerialDevice->DevicePath,\r
-                      SerialDevice->DevicePath\r
-                      );\r
-    }\r
-  }\r
-\r
-  gBS->RestoreTPL (Tpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Get ControlBits.\r
-\r
-  @param This          Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param Control       Control signals of the serial device\r
-\r
-  @retval EFI_SUCCESS   Get Control signals successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialGetControl (\r
-  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
-  OUT UINT32                 *Control\r
-  )\r
-{\r
-  SERIAL_DEV      *SerialDevice;\r
-  SERIAL_PORT_MSR Msr;\r
-  SERIAL_PORT_MCR Mcr;\r
-  EFI_TPL         Tpl;\r
-\r
-  Tpl           = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  SerialDevice  = SERIAL_DEV_FROM_THIS (This);\r
-\r
-  *Control      = 0;\r
-\r
-  //\r
-  // Read the Modem Status Register\r
-  //\r
-  Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-\r
-  if (Msr.Bits.Cts == 1) {\r
-    *Control |= EFI_SERIAL_CLEAR_TO_SEND;\r
-  }\r
-\r
-  if (Msr.Bits.Dsr == 1) {\r
-    *Control |= EFI_SERIAL_DATA_SET_READY;\r
-  }\r
-\r
-  if (Msr.Bits.Ri == 1) {\r
-    *Control |= EFI_SERIAL_RING_INDICATE;\r
-  }\r
-\r
-  if (Msr.Bits.Dcd == 1) {\r
-    *Control |= EFI_SERIAL_CARRIER_DETECT;\r
-  }\r
-  //\r
-  // Read the Modem Control Register\r
-  //\r
-  Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-\r
-  if (Mcr.Bits.DtrC == 1) {\r
-    *Control |= EFI_SERIAL_DATA_TERMINAL_READY;\r
-  }\r
-\r
-  if (Mcr.Bits.Rts == 1) {\r
-    *Control |= EFI_SERIAL_REQUEST_TO_SEND;\r
-  }\r
-\r
-  if (Mcr.Bits.Lme == 1) {\r
-    *Control |= EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE;\r
-  }\r
-\r
-  if (SerialDevice->HardwareFlowControl) {\r
-    *Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;\r
-  }\r
-  //\r
-  // See if the Transmit FIFO is empty\r
-  //\r
-  IsaSerialReceiveTransmit (SerialDevice);\r
-\r
-  if (IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
-    *Control |= EFI_SERIAL_OUTPUT_BUFFER_EMPTY;\r
-  }\r
-  //\r
-  // See if the Receive FIFO is empty.\r
-  //\r
-  IsaSerialReceiveTransmit (SerialDevice);\r
-\r
-  if (IsaSerialFifoEmpty (&SerialDevice->Receive)) {\r
-    *Control |= EFI_SERIAL_INPUT_BUFFER_EMPTY;\r
-  }\r
-\r
-  if (SerialDevice->SoftwareLoopbackEnable) {\r
-    *Control |= EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE;\r
-  }\r
-\r
-  gBS->RestoreTPL (Tpl);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write the specified number of bytes to serial device.\r
-\r
-  @param This               Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param  BufferSize         On input the size of Buffer, on output the amount of\r
-                       data actually written\r
-  @param  Buffer             The buffer of data to write\r
-\r
-  @retval EFI_SUCCESS        The data were written successfully\r
-  @retval EFI_DEVICE_ERROR   The device reported an error\r
-  @retval EFI_TIMEOUT        The write operation was stopped due to timeout\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialWrite (\r
-  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
-  IN OUT UINTN               *BufferSize,\r
-  IN VOID                    *Buffer\r
-  )\r
-{\r
-  SERIAL_DEV  *SerialDevice;\r
-  UINT8       *CharBuffer;\r
-  UINT32      Index;\r
-  UINTN       Elapsed;\r
-  UINTN       ActualWrite;\r
-  EFI_TPL     Tpl;\r
-  UINTN       Timeout;\r
-  UINTN       BitsPerCharacter;\r
-\r
-  SerialDevice  = SERIAL_DEV_FROM_THIS (This);\r
-  Elapsed       = 0;\r
-  ActualWrite   = 0;\r
-\r
-  if (*BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE,\r
-      EFI_P_EC_OUTPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
-      SerialDevice->DevicePath\r
-      );\r
-\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Tpl         = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  CharBuffer  = (UINT8 *) Buffer;\r
-\r
-  //\r
-  // Compute the number of bits in a single character.  This is a start bit,\r
-  // followed by the number of data bits, followed by the number of stop bits.\r
-  // The number of stop bits is specified by an enumeration that includes\r
-  // support for 1.5 stop bits.  Treat 1.5 stop bits as 2 stop bits.\r
-  //\r
-  BitsPerCharacter =\r
-    1 +\r
-    This->Mode->DataBits +\r
-    ((This->Mode->StopBits == TwoStopBits) ? 2 : This->Mode->StopBits);\r
-\r
-  //\r
-  // Compute the timeout in microseconds to wait for a single byte to be\r
-  // transmitted.  The Mode structure contans a Timeout field that is the\r
-  // maximum time to transmit or receive a character.  However, many UARTs\r
-  // have a FIFO for transmits, so the time required to add one new character\r
-  // to the transmit FIFO may be the time required to flush a full FIFO.  If\r
-  // the Timeout in the Mode structure is smaller than the time required to\r
-  // flush a full FIFO at the current baud rate, then use a timeout value that\r
-  // is required to flush a full transmit FIFO.\r
-  //\r
-  Timeout = MAX (\r
-              This->Mode->Timeout,\r
-              (UINTN)DivU64x64Remainder (\r
-                BitsPerCharacter * (SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH + 1) * 1000000,\r
-                This->Mode->BaudRate,\r
-                NULL\r
-                )\r
-              );\r
-\r
-  for (Index = 0; Index < *BufferSize; Index++) {\r
-    IsaSerialFifoAdd (&SerialDevice->Transmit, CharBuffer[Index]);\r
-\r
-    while (IsaSerialReceiveTransmit (SerialDevice) != EFI_SUCCESS || !IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
-      //\r
-      //  Unsuccessful write so check if timeout has expired, if not,\r
-      //  stall for a bit, increment time elapsed, and try again\r
-      //\r
-      if (Elapsed >= Timeout) {\r
-        *BufferSize = ActualWrite;\r
-        gBS->RestoreTPL (Tpl);\r
-        return EFI_TIMEOUT;\r
-      }\r
-\r
-      gBS->Stall (TIMEOUT_STALL_INTERVAL);\r
-\r
-      Elapsed += TIMEOUT_STALL_INTERVAL;\r
-    }\r
-\r
-    ActualWrite++;\r
-    //\r
-    //  Successful write so reset timeout\r
-    //\r
-    Elapsed = 0;\r
-  }\r
-\r
-  gBS->RestoreTPL (Tpl);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Read the specified number of bytes from serial device.\r
-\r
-  @param This               Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param BufferSize         On input the size of Buffer, on output the amount of\r
-                            data returned in buffer\r
-  @param Buffer             The buffer to return the data into\r
-\r
-  @retval EFI_SUCCESS        The data were read successfully\r
-  @retval EFI_DEVICE_ERROR   The device reported an error\r
-  @retval EFI_TIMEOUT        The read operation was stopped due to timeout\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialRead (\r
-  IN EFI_SERIAL_IO_PROTOCOL  *This,\r
-  IN OUT UINTN               *BufferSize,\r
-  OUT VOID                   *Buffer\r
-  )\r
-{\r
-  SERIAL_DEV  *SerialDevice;\r
-  UINT32      Index;\r
-  UINT8       *CharBuffer;\r
-  UINTN       Elapsed;\r
-  EFI_STATUS  Status;\r
-  EFI_TPL     Tpl;\r
-\r
-  SerialDevice  = SERIAL_DEV_FROM_THIS (This);\r
-  Elapsed       = 0;\r
-\r
-  if (*BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Tpl     = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  Status  = IsaSerialReceiveTransmit (SerialDevice);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    *BufferSize = 0;\r
-\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE,\r
-      EFI_P_EC_INPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
-      SerialDevice->DevicePath\r
-      );\r
-\r
-    gBS->RestoreTPL (Tpl);\r
-\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  CharBuffer = (UINT8 *) Buffer;\r
-  for (Index = 0; Index < *BufferSize; Index++) {\r
-    while (IsaSerialFifoRemove (&SerialDevice->Receive, &(CharBuffer[Index])) != EFI_SUCCESS) {\r
-      //\r
-      //  Unsuccessful read so check if timeout has expired, if not,\r
-      //  stall for a bit, increment time elapsed, and try again\r
-      //  Need this time out to get conspliter to work.\r
-      //\r
-      if (Elapsed >= This->Mode->Timeout) {\r
-        *BufferSize = Index;\r
-        gBS->RestoreTPL (Tpl);\r
-        return EFI_TIMEOUT;\r
-      }\r
-\r
-      gBS->Stall (TIMEOUT_STALL_INTERVAL);\r
-      Elapsed += TIMEOUT_STALL_INTERVAL;\r
-\r
-      Status = IsaSerialReceiveTransmit (SerialDevice);\r
-      if (Status == EFI_DEVICE_ERROR) {\r
-        *BufferSize = Index;\r
-        gBS->RestoreTPL (Tpl);\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-    }\r
-    //\r
-    //  Successful read so reset timeout\r
-    //\r
-    Elapsed = 0;\r
-  }\r
-\r
-  IsaSerialReceiveTransmit (SerialDevice);\r
-\r
-  gBS->RestoreTPL (Tpl);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Use scratchpad register to test if this serial port is present.\r
-\r
-  @param SerialDevice   Pointer to serial device structure\r
-\r
-  @return if this serial port is present\r
-**/\r
-BOOLEAN\r
-IsaSerialPortPresent (\r
-  IN SERIAL_DEV *SerialDevice\r
-  )\r
-\r
-{\r
-  UINT8   Temp;\r
-  BOOLEAN Status;\r
-\r
-  Status = TRUE;\r
-\r
-  //\r
-  // Save SCR reg\r
-  //\r
-  Temp = READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0xAA);\r
-\r
-  if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0xAA) {\r
-    Status = FALSE;\r
-  }\r
-\r
-  WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0x55);\r
-\r
-  if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0x55) {\r
-    Status = FALSE;\r
-  }\r
-  //\r
-  // Restore SCR\r
-  //\r
-  WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Temp);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Use IsaIo protocol to read serial port.\r
-\r
-  @param IsaIo         Pointer to EFI_ISA_IO_PROTOCOL instance\r
-  @param BaseAddress   Serial port register group base address\r
-  @param Offset        Offset in register group\r
-\r
-  @return Data read from serial port\r
-\r
-**/\r
-UINT8\r
-IsaSerialReadPort (\r
-  IN EFI_ISA_IO_PROTOCOL                   *IsaIo,\r
-  IN UINT16                                BaseAddress,\r
-  IN UINT32                                Offset\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  //\r
-  // Use IsaIo to access IO\r
-  //\r
-  IsaIo->Io.Read (\r
-             IsaIo,\r
-             EfiIsaIoWidthUint8,\r
-             BaseAddress + Offset,\r
-             1,\r
-             &Data\r
-             );\r
-  return Data;\r
-}\r
-\r
-/**\r
-  Use IsaIo protocol to write serial port.\r
-\r
-  @param  IsaIo         Pointer to EFI_ISA_IO_PROTOCOL instance\r
-  @param  BaseAddress   Serial port register group base address\r
-  @param  Offset        Offset in register group\r
-  @param  Data          data which is to be written to some serial port register\r
-\r
-**/\r
-VOID\r
-IsaSerialWritePort (\r
-  IN EFI_ISA_IO_PROTOCOL                 *IsaIo,\r
-  IN UINT16                              BaseAddress,\r
-  IN UINT32                              Offset,\r
-  IN UINT8                               Data\r
-  )\r
-{\r
-  //\r
-  // Use IsaIo to access IO\r
-  //\r
-  IsaIo->Io.Write (\r
-             IsaIo,\r
-             EfiIsaIoWidthUint8,\r
-             BaseAddress + Offset,\r
-             1,\r
-             &Data\r
-             );\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
deleted file mode 100644 (file)
index a2b91d8..0000000
+++ /dev/null
@@ -1,836 +0,0 @@
-/** @file\r
-  Include for Serial Driver\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _SERIAL_H_\r
-#define _SERIAL_H_\r
-\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/SerialIo.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-//\r
-// Driver Binding Externs\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL  gSerialControllerDriver;\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gIsaSerialComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gIsaSerialComponentName2;\r
-\r
-//\r
-// Internal Data Structures\r
-//\r
-#define SERIAL_DEV_SIGNATURE    SIGNATURE_32 ('s', 'e', 'r', 'd')\r
-#define SERIAL_MAX_BUFFER_SIZE  16\r
-#define TIMEOUT_STALL_INTERVAL  10\r
-\r
-//\r
-//  Name:   SERIAL_DEV_FIFO\r
-//  Purpose:  To define Receive FIFO and Transmit FIFO\r
-//  Context:  Used by serial data transmit and receive\r
-//  Fields:\r
-//      First UINT32: The index of the first data in array Data[]\r
-//      Last  UINT32: The index, which you can put a new data into array Data[]\r
-//      Surplus UINT32: Identify how many data you can put into array Data[]\r
-//      Data[]  UINT8 : An array, which used to store data\r
-//\r
-typedef struct {\r
-  UINT32  First;\r
-  UINT32  Last;\r
-  UINT32  Surplus;\r
-  UINT8   Data[SERIAL_MAX_BUFFER_SIZE];\r
-} SERIAL_DEV_FIFO;\r
-\r
-typedef enum {\r
-  Uart8250  = 0,\r
-  Uart16450 = 1,\r
-  Uart16550 = 2,\r
-  Uart16550A= 3\r
-} EFI_UART_TYPE;\r
-\r
-//\r
-//  Name:   SERIAL_DEV\r
-//  Purpose:  To provide device specific information\r
-//  Context:\r
-//  Fields:\r
-//      Signature UINTN: The identity of the serial device\r
-//      SerialIo  SERIAL_IO_PROTOCOL: Serial I/O protocol interface\r
-//      SerialMode  SERIAL_IO_MODE:\r
-//      DevicePath  EFI_DEVICE_PATH_PROTOCOL *: Device path of the serial device\r
-//      Handle      EFI_HANDLE: The handle instance attached to serial device\r
-//      BaseAddress UINT16: The base address of specific serial device\r
-//      Receive     SERIAL_DEV_FIFO: The FIFO used to store data,\r
-//                  which is received by UART\r
-//      Transmit    SERIAL_DEV_FIFO: The FIFO used to store data,\r
-//                  which you want to transmit by UART\r
-//      SoftwareLoopbackEnable BOOLEAN:\r
-//      Type    EFI_UART_TYPE: Specify the UART type of certain serial device\r
-//\r
-typedef struct {\r
-  UINTN                                  Signature;\r
-\r
-  EFI_HANDLE                             Handle;\r
-  EFI_SERIAL_IO_PROTOCOL                 SerialIo;\r
-  EFI_SERIAL_IO_MODE                     SerialMode;\r
-  EFI_DEVICE_PATH_PROTOCOL               *DevicePath;\r
-\r
-  EFI_DEVICE_PATH_PROTOCOL               *ParentDevicePath;\r
-  UART_DEVICE_PATH                       UartDevicePath;\r
-  EFI_ISA_IO_PROTOCOL                    *IsaIo;\r
-\r
-  UINT16                                 BaseAddress;\r
-  SERIAL_DEV_FIFO                        Receive;\r
-  SERIAL_DEV_FIFO                        Transmit;\r
-  BOOLEAN                                SoftwareLoopbackEnable;\r
-  BOOLEAN                                HardwareFlowControl;\r
-  EFI_UART_TYPE                          Type;\r
-  EFI_UNICODE_STRING_TABLE               *ControllerNameTable;\r
-} SERIAL_DEV;\r
-\r
-#define SERIAL_DEV_FROM_THIS(a) CR (a, SERIAL_DEV, SerialIo, SERIAL_DEV_SIGNATURE)\r
-\r
-//\r
-// Serial Driver Defaults\r
-//\r
-#define SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH  1\r
-#define SERIAL_PORT_DEFAULT_TIMEOUT             1000000\r
-#define SERIAL_PORT_SUPPORT_CONTROL_MASK        (EFI_SERIAL_CLEAR_TO_SEND                | \\r
-                                                 EFI_SERIAL_DATA_SET_READY               | \\r
-                                                 EFI_SERIAL_RING_INDICATE                | \\r
-                                                 EFI_SERIAL_CARRIER_DETECT               | \\r
-                                                 EFI_SERIAL_REQUEST_TO_SEND              | \\r
-                                                 EFI_SERIAL_DATA_TERMINAL_READY          | \\r
-                                                 EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE     | \\r
-                                                 EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE     | \\r
-                                                 EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE | \\r
-                                                 EFI_SERIAL_OUTPUT_BUFFER_EMPTY          | \\r
-                                                 EFI_SERIAL_INPUT_BUFFER_EMPTY)\r
-\r
-//\r
-// 115200 baud with rounding errors\r
-//\r
-#define SERIAL_PORT_MAX_BAUD_RATE           115400\r
-#define SERIAL_PORT_MIN_BAUD_RATE           50\r
-\r
-#define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH  16\r
-#define SERIAL_PORT_MIN_TIMEOUT             1         // 1 uS\r
-#define SERIAL_PORT_MAX_TIMEOUT             100000000 // 100 seconds\r
-//\r
-// UART Registers\r
-//\r
-#define SERIAL_REGISTER_THR 0 // WO   Transmit Holding Register\r
-#define SERIAL_REGISTER_RBR 0 // RO   Receive Buffer Register\r
-#define SERIAL_REGISTER_DLL 0 // R/W  Divisor Latch LSB\r
-#define SERIAL_REGISTER_DLM 1 // R/W  Divisor Latch MSB\r
-#define SERIAL_REGISTER_IER 1 // R/W  Interrupt Enable Register\r
-#define SERIAL_REGISTER_IIR 2 // RO   Interrupt Identification Register\r
-#define SERIAL_REGISTER_FCR 2 // WO   FIFO Cotrol Register\r
-#define SERIAL_REGISTER_LCR 3 // R/W  Line Control Register\r
-#define SERIAL_REGISTER_MCR 4 // R/W  Modem Control Register\r
-#define SERIAL_REGISTER_LSR 5 // R/W  Line Status Register\r
-#define SERIAL_REGISTER_MSR 6 // R/W  Modem Status Register\r
-#define SERIAL_REGISTER_SCR 7 // R/W  Scratch Pad Register\r
-#pragma pack(1)\r
-//\r
-//  Name:   SERIAL_PORT_IER_BITS\r
-//  Purpose:  Define each bit in Interrupt Enable Register\r
-//  Context:\r
-//  Fields:\r
-//     Ravie  Bit0: Receiver Data Available Interrupt Enable\r
-//     Theie  Bit1: Transmistter Holding Register Empty Interrupt Enable\r
-//     Rie      Bit2: Receiver Interrupt Enable\r
-//     Mie      Bit3: Modem Interrupt Enable\r
-//     Reserved Bit4-Bit7: Reserved\r
-//\r
-typedef struct {\r
-  UINT8 Ravie : 1;\r
-  UINT8 Theie : 1;\r
-  UINT8 Rie : 1;\r
-  UINT8 Mie : 1;\r
-  UINT8 Reserved : 4;\r
-} SERIAL_PORT_IER_BITS;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_IER\r
-//  Purpose:\r
-//  Context:\r
-//  Fields:\r
-//      Bits    SERIAL_PORT_IER_BITS:  Bits of the IER\r
-//      Data    UINT8: the value of the IER\r
-//\r
-typedef union {\r
-  SERIAL_PORT_IER_BITS  Bits;\r
-  UINT8                 Data;\r
-} SERIAL_PORT_IER;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_FCR_BITS\r
-//  Purpose:  Define each bit in FIFO Control Register\r
-//  Context:\r
-//  Fields:\r
-//      TrFIFOE    Bit0: Transmit and Receive FIFO Enable\r
-//      ResetRF    Bit1: Reset Reciever FIFO\r
-//      ResetTF    Bit2: Reset Transmistter FIFO\r
-//      Dms        Bit3: DMA Mode Select\r
-//      Reserved   Bit4-Bit5: Reserved\r
-//      Rtb        Bit6-Bit7: Receive Trigger Bits\r
-//\r
-typedef struct {\r
-  UINT8 TrFIFOE : 1;\r
-  UINT8 ResetRF : 1;\r
-  UINT8 ResetTF : 1;\r
-  UINT8 Dms : 1;\r
-  UINT8 Reserved : 2;\r
-  UINT8 Rtb : 2;\r
-} SERIAL_PORT_FCR_BITS;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_FCR\r
-//  Purpose:\r
-//  Context:\r
-//  Fields:\r
-//      Bits    SERIAL_PORT_FCR_BITS:  Bits of the FCR\r
-//      Data    UINT8: the value of the FCR\r
-//\r
-typedef union {\r
-  SERIAL_PORT_FCR_BITS  Bits;\r
-  UINT8                 Data;\r
-} SERIAL_PORT_FCR;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_LCR_BITS\r
-//  Purpose:  Define each bit in Line Control Register\r
-//  Context:\r
-//  Fields:\r
-//      SerialDB  Bit0-Bit1: Number of Serial Data Bits\r
-//      StopB     Bit2: Number of Stop Bits\r
-//      ParEn     Bit3: Parity Enable\r
-//      EvenPar   Bit4: Even Parity Select\r
-//      SticPar   Bit5: Sticky Parity\r
-//      BrCon     Bit6: Break Control\r
-//      DLab      Bit7: Divisor Latch Access Bit\r
-//\r
-typedef struct {\r
-  UINT8 SerialDB : 2;\r
-  UINT8 StopB : 1;\r
-  UINT8 ParEn : 1;\r
-  UINT8 EvenPar : 1;\r
-  UINT8 SticPar : 1;\r
-  UINT8 BrCon : 1;\r
-  UINT8 DLab : 1;\r
-} SERIAL_PORT_LCR_BITS;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_LCR\r
-//  Purpose:\r
-//  Context:\r
-//  Fields:\r
-//      Bits    SERIAL_PORT_LCR_BITS:  Bits of the LCR\r
-//      Data    UINT8: the value of the LCR\r
-//\r
-typedef union {\r
-  SERIAL_PORT_LCR_BITS  Bits;\r
-  UINT8                 Data;\r
-} SERIAL_PORT_LCR;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_MCR_BITS\r
-//  Purpose:  Define each bit in Modem Control Register\r
-//  Context:\r
-//  Fields:\r
-//      DtrC     Bit0: Data Terminal Ready Control\r
-//      Rts      Bit1: Request To Send Control\r
-//      Out1     Bit2: Output1\r
-//      Out2     Bit3: Output2, used to disable interrupt\r
-//      Lme;     Bit4: Loopback Mode Enable\r
-//      Reserved Bit5-Bit7: Reserved\r
-//\r
-typedef struct {\r
-  UINT8 DtrC : 1;\r
-  UINT8 Rts : 1;\r
-  UINT8 Out1 : 1;\r
-  UINT8 Out2 : 1;\r
-  UINT8 Lme : 1;\r
-  UINT8 Reserved : 3;\r
-} SERIAL_PORT_MCR_BITS;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_MCR\r
-//  Purpose:\r
-//  Context:\r
-//  Fields:\r
-//      Bits    SERIAL_PORT_MCR_BITS:  Bits of the MCR\r
-//      Data    UINT8: the value of the MCR\r
-//\r
-typedef union {\r
-  SERIAL_PORT_MCR_BITS  Bits;\r
-  UINT8                 Data;\r
-} SERIAL_PORT_MCR;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_LSR_BITS\r
-//  Purpose:  Define each bit in Line Status Register\r
-//  Context:\r
-//  Fields:\r
-//      Dr    Bit0: Receiver Data Ready Status\r
-//      Oe    Bit1: Overrun Error Status\r
-//      Pe    Bit2: Parity Error Status\r
-//      Fe    Bit3: Framing Error Status\r
-//      Bi    Bit4: Break Interrupt Status\r
-//      Thre  Bit5: Transmistter Holding Register Status\r
-//      Temt  Bit6: Transmitter Empty Status\r
-//      FIFOe Bit7: FIFO Error Status\r
-//\r
-typedef struct {\r
-  UINT8 Dr : 1;\r
-  UINT8 Oe : 1;\r
-  UINT8 Pe : 1;\r
-  UINT8 Fe : 1;\r
-  UINT8 Bi : 1;\r
-  UINT8 Thre : 1;\r
-  UINT8 Temt : 1;\r
-  UINT8 FIFOe : 1;\r
-} SERIAL_PORT_LSR_BITS;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_LSR\r
-//  Purpose:\r
-//  Context:\r
-//  Fields:\r
-//      Bits    SERIAL_PORT_LSR_BITS:  Bits of the LSR\r
-//      Data    UINT8: the value of the LSR\r
-//\r
-typedef union {\r
-  SERIAL_PORT_LSR_BITS  Bits;\r
-  UINT8                 Data;\r
-} SERIAL_PORT_LSR;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_MSR_BITS\r
-//  Purpose:  Define each bit in Modem Status Register\r
-//  Context:\r
-//  Fields:\r
-//      DeltaCTS      Bit0: Delta Clear To Send Status\r
-//      DeltaDSR        Bit1: Delta Data Set Ready Status\r
-//      TrailingEdgeRI  Bit2: Trailing Edge of Ring Indicator Status\r
-//      DeltaDCD        Bit3: Delta Data Carrier Detect Status\r
-//      Cts             Bit4: Clear To Send Status\r
-//      Dsr             Bit5: Data Set Ready Status\r
-//      Ri              Bit6: Ring Indicator Status\r
-//      Dcd             Bit7: Data Carrier Detect Status\r
-//\r
-typedef struct {\r
-  UINT8 DeltaCTS : 1;\r
-  UINT8 DeltaDSR : 1;\r
-  UINT8 TrailingEdgeRI : 1;\r
-  UINT8 DeltaDCD : 1;\r
-  UINT8 Cts : 1;\r
-  UINT8 Dsr : 1;\r
-  UINT8 Ri : 1;\r
-  UINT8 Dcd : 1;\r
-} SERIAL_PORT_MSR_BITS;\r
-\r
-//\r
-//  Name:   SERIAL_PORT_MSR\r
-//  Purpose:\r
-//  Context:\r
-//  Fields:\r
-//      Bits    SERIAL_PORT_MSR_BITS:  Bits of the MSR\r
-//      Data    UINT8: the value of the MSR\r
-//\r
-typedef union {\r
-  SERIAL_PORT_MSR_BITS  Bits;\r
-  UINT8                 Data;\r
-} SERIAL_PORT_MSR;\r
-\r
-#pragma pack()\r
-//\r
-// Define serial register I/O macros\r
-//\r
-#define READ_RBR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_RBR)\r
-#define READ_DLL(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLL)\r
-#define READ_DLM(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLM)\r
-#define READ_IER(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_IER)\r
-#define READ_IIR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_IIR)\r
-#define READ_LCR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_LCR)\r
-#define READ_MCR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_MCR)\r
-#define READ_LSR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_LSR)\r
-#define READ_MSR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_MSR)\r
-#define READ_SCR(IO, B)     IsaSerialReadPort (IO, B, SERIAL_REGISTER_SCR)\r
-\r
-#define WRITE_THR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_THR, D)\r
-#define WRITE_DLL(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLL, D)\r
-#define WRITE_DLM(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLM, D)\r
-#define WRITE_IER(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_IER, D)\r
-#define WRITE_FCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_FCR, D)\r
-#define WRITE_LCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LCR, D)\r
-#define WRITE_MCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MCR, D)\r
-#define WRITE_LSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LSR, D)\r
-#define WRITE_MSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MSR, D)\r
-#define WRITE_SCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_SCR, D)\r
-\r
-//\r
-// Prototypes\r
-// Driver model protocol interface\r
-//\r
-/**\r
-  Check to see if this driver supports the given controller\r
-\r
-  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  Controller           The handle of the controller to test.\r
-  @param  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @return EFI_SUCCESS          This driver can support the given controller\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Start to management the controller passed in\r
-\r
-  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  Controller           The handle of the controller to test.\r
-  @param  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @return EFI_SUCCESS          Driver is started successfully\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Disconnect this driver with the controller, uninstall related protocol instance\r
-\r
-  @param  This                  A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  Controller            The handle of the controller to test.\r
-  @param  NumberOfChildren      Number of child device.\r
-  @param  ChildHandleBuffer     A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS           Operation successfully\r
-  @retval EFI_DEVICE_ERROR      Cannot stop the driver successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialControllerDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
-  IN  EFI_HANDLE                    Controller,\r
-  IN  UINTN                         NumberOfChildren,\r
-  IN  EFI_HANDLE                    *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// Serial I/O Protocol Interface\r
-//\r
-/**\r
-  Reset serial device.\r
-\r
-  @param This               Pointer to EFI_SERIAL_IO_PROTOCOL\r
-\r
-  @retval EFI_SUCCESS        Reset successfully\r
-  @retval EFI_DEVICE_ERROR   Failed to reset\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialReset (\r
-  IN EFI_SERIAL_IO_PROTOCOL         *This\r
-  );\r
-\r
-/**\r
-  Set new attributes to a serial device.\r
-\r
-  @param This                     Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param  BaudRate                 The baudrate of the serial device\r
-  @param  ReceiveFifoDepth         The depth of receive FIFO buffer\r
-  @param  Timeout                  The request timeout for a single char\r
-  @param  Parity                   The type of parity used in serial device\r
-  @param  DataBits                 Number of databits used in serial device\r
-  @param  StopBits                 Number of stopbits used in serial device\r
-\r
-  @retval  EFI_SUCCESS              The new attributes were set\r
-  @retval  EFI_INVALID_PARAMETERS   One or more attributes have an unsupported value\r
-  @retval  EFI_UNSUPPORTED          Data Bits can not set to 5 or 6\r
-  @retval  EFI_DEVICE_ERROR         The serial device is not functioning correctly (no return)\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialSetAttributes (\r
-  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
-  IN UINT64                         BaudRate,\r
-  IN UINT32                         ReceiveFifoDepth,\r
-  IN UINT32                         Timeout,\r
-  IN EFI_PARITY_TYPE                Parity,\r
-  IN UINT8                          DataBits,\r
-  IN EFI_STOP_BITS_TYPE             StopBits\r
-  );\r
-\r
-/**\r
-  Set Control Bits.\r
-\r
-  @param This              Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param Control           Control bits that can be settable\r
-\r
-  @retval EFI_SUCCESS       New Control bits were set successfully\r
-  @retval EFI_UNSUPPORTED   The Control bits wanted to set are not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialSetControl (\r
-  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
-  IN UINT32                         Control\r
-  );\r
-\r
-/**\r
-  Get ControlBits.\r
-\r
-  @param This          Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param Control       Control signals of the serial device\r
-\r
-  @retval EFI_SUCCESS   Get Control signals successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialGetControl (\r
-  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
-  OUT UINT32                        *Control\r
-  );\r
-\r
-/**\r
-  Write the specified number of bytes to serial device.\r
-\r
-  @param This                Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param  BufferSize         On input the size of Buffer, on output the amount of\r
-                             data actually written\r
-  @param  Buffer             The buffer of data to write\r
-\r
-  @retval EFI_SUCCESS        The data were written successfully\r
-  @retval EFI_DEVICE_ERROR   The device reported an error\r
-  @retval EFI_TIMEOUT        The write operation was stopped due to timeout\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialWrite (\r
-  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
-  IN OUT UINTN                      *BufferSize,\r
-  IN VOID                           *Buffer\r
-  );\r
-\r
-/**\r
-  Read the specified number of bytes from serial device.\r
-\r
-  @param This               Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param BufferSize         On input the size of Buffer, on output the amount of\r
-                            data returned in buffer\r
-  @param Buffer             The buffer to return the data into\r
-\r
-  @retval EFI_SUCCESS        The data were read successfully\r
-  @retval EFI_DEVICE_ERROR   The device reported an error\r
-  @retval EFI_TIMEOUT        The read operation was stopped due to timeout\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialRead (\r
-  IN EFI_SERIAL_IO_PROTOCOL         *This,\r
-  IN OUT UINTN                      *BufferSize,\r
-  OUT VOID                          *Buffer\r
-  );\r
-\r
-//\r
-// Internal Functions\r
-//\r
-/**\r
-  Use scratchpad register to test if this serial port is present.\r
-\r
-  @param SerialDevice   Pointer to serial device structure\r
-\r
-  @return if this serial port is present\r
-**/\r
-BOOLEAN\r
-IsaSerialPortPresent (\r
-  IN SERIAL_DEV                     *SerialDevice\r
-  );\r
-\r
-/**\r
-  Detect whether specific FIFO is full or not.\r
-\r
-  @param Fifo    A pointer to the Data Structure SERIAL_DEV_FIFO\r
-\r
-  @return whether specific FIFO is full or not\r
-\r
-**/\r
-BOOLEAN\r
-IsaSerialFifoFull (\r
-  IN SERIAL_DEV_FIFO                *Fifo\r
-  );\r
-\r
-/**\r
-  Detect whether specific FIFO is empty or not.\r
-\r
-  @param  Fifo    A pointer to the Data Structure SERIAL_DEV_FIFO\r
-\r
-  @return whether specific FIFO is empty or not\r
-\r
-**/\r
-BOOLEAN\r
-IsaSerialFifoEmpty (\r
-  IN SERIAL_DEV_FIFO                *Fifo\r
-  );\r
-\r
-/**\r
-  Add data to specific FIFO.\r
-\r
-  @param Fifo                  A pointer to the Data Structure SERIAL_DEV_FIFO\r
-  @param Data                  the data added to FIFO\r
-\r
-  @retval EFI_SUCCESS           Add data to specific FIFO successfully\r
-  @retval EFI_OUT_OF_RESOURCE   Failed to add data because FIFO is already full\r
-\r
-**/\r
-EFI_STATUS\r
-IsaSerialFifoAdd (\r
-  IN SERIAL_DEV_FIFO                *Fifo,\r
-  IN UINT8                          Data\r
-  );\r
-\r
-/**\r
-  Remove data from specific FIFO.\r
-\r
-  @param Fifo                  A pointer to the Data Structure SERIAL_DEV_FIFO\r
-  @param Data                  the data removed from FIFO\r
-\r
-  @retval EFI_SUCCESS           Remove data from specific FIFO successfully\r
-  @retval EFI_OUT_OF_RESOURCE   Failed to remove data because FIFO is empty\r
-\r
-**/\r
-EFI_STATUS\r
-IsaSerialFifoRemove (\r
-  IN  SERIAL_DEV_FIFO               *Fifo,\r
-  OUT UINT8                         *Data\r
-  );\r
-\r
-/**\r
-  Reads and writes all avaliable data.\r
-\r
-  @param SerialDevice           The device to flush\r
-\r
-  @retval EFI_SUCCESS           Data was read/written successfully.\r
-  @retval EFI_OUT_OF_RESOURCE   Failed because software receive FIFO is full.  Note, when\r
-                                this happens, pending writes are not done.\r
-\r
-**/\r
-EFI_STATUS\r
-IsaSerialReceiveTransmit (\r
-  IN SERIAL_DEV                     *SerialDevice\r
-  );\r
-\r
-/**\r
-  Use IsaIo protocol to read serial port.\r
-\r
-  @param IsaIo         Pointer to EFI_ISA_IO_PROTOCOL instance\r
-  @param BaseAddress   Serial port register group base address\r
-  @param Offset        Offset in register group\r
-\r
-  @return Data read from serial port\r
-\r
-**/\r
-UINT8\r
-IsaSerialReadPort (\r
-  IN EFI_ISA_IO_PROTOCOL                    *IsaIo,\r
-  IN UINT16                                 BaseAddress,\r
-  IN UINT32                                 Offset\r
-  );\r
-\r
-/**\r
-  Use IsaIo protocol to write serial port.\r
-\r
-  @param  IsaIo         Pointer to EFI_ISA_IO_PROTOCOL instance\r
-  @param  BaseAddress   Serial port register group base address\r
-  @param  Offset        Offset in register group\r
-  @param  Data          data which is to be written to some serial port register\r
-\r
-**/\r
-VOID\r
-IsaSerialWritePort (\r
-  IN EFI_ISA_IO_PROTOCOL                    *IsaIo,\r
-  IN UINT16                                 BaseAddress,\r
-  IN UINT32                                 Offset,\r
-  IN UINT8                                  Data\r
-  );\r
-\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSerialComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-/**\r
-  Add the component name for the serial io device\r
-\r
-  @param SerialDevice     A pointer to the SERIAL_DEV instance.\r
-\r
-  @param IsaIo            A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-\r
-**/\r
-VOID\r
-AddName (\r
-  IN  SERIAL_DEV                                   *SerialDevice,\r
-  IN  EFI_ISA_IO_PROTOCOL                          *IsaIo\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c
deleted file mode 100644 (file)
index e6f1bca..0000000
+++ /dev/null
@@ -1,366 +0,0 @@
-/** @file\r
-  Routines related Component Name protocol.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ps2Keyboard.h"\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2KeyboardComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2KeyboardComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gPs2KeyboardComponentName = {\r
-  Ps2KeyboardComponentNameGetDriverName,\r
-  Ps2KeyboardComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2KeyboardComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2KeyboardComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"PS/2 Keyboard Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2KeyboardComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mPs2KeyboardDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gPs2KeyboardComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2KeyboardComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS                                  Status;\r
-  EFI_SIMPLE_TEXT_INPUT_PROTOCOL              *ConIn;\r
-  KEYBOARD_CONSOLE_IN_DEV                     *ConsoleIn;\r
-  EFI_ISA_IO_PROTOCOL                         *IsaIoProtocol;\r
-\r
-  //\r
-  // This is a device driver, so ChildHandle must be NULL.\r
-  //\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Check Controller's handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIoProtocol,\r
-                  gKeyboardControllerDriver.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           ControllerHandle,\r
-           &gEfiIsaIoProtocolGuid,\r
-           gKeyboardControllerDriver.DriverBindingHandle,\r
-           ControllerHandle\r
-           );\r
-\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (Status != EFI_ALREADY_STARTED) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Get the device context\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiSimpleTextInProtocolGuid,\r
-                  (VOID **) &ConIn,\r
-                  gKeyboardControllerDriver.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);\r
-\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           ConsoleIn->ControllerNameTable,\r
-           ControllerName,\r
-           (BOOLEAN)(This == &gPs2KeyboardComponentName)\r
-           );\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
deleted file mode 100644 (file)
index bc1655e..0000000
+++ /dev/null
@@ -1,1900 +0,0 @@
-/** @file\r
-  Routines that access 8042 keyboard controller\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ps2Keyboard.h"\r
-\r
-struct {\r
-  UINT8   ScanCode;             ///< follows value defined in Scan Code Set1\r
-  UINT16  EfiScanCode;\r
-  CHAR16  UnicodeChar;\r
-  CHAR16  ShiftUnicodeChar;\r
-}\r
-ConvertKeyboardScanCodeToEfiKey[] = {\r
-\r
-  {\r
-    0x01,  //   Escape\r
-    SCAN_ESC,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x02,\r
-    SCAN_NULL,\r
-    L'1',\r
-    L'!'\r
-  },\r
-  {\r
-    0x03,\r
-    SCAN_NULL,\r
-    L'2',\r
-    L'@'\r
-  },\r
-  {\r
-    0x04,\r
-    SCAN_NULL,\r
-    L'3',\r
-    L'#'\r
-  },\r
-  {\r
-    0x05,\r
-    SCAN_NULL,\r
-    L'4',\r
-    L'$'\r
-  },\r
-  {\r
-    0x06,\r
-    SCAN_NULL,\r
-    L'5',\r
-    L'%'\r
-  },\r
-  {\r
-    0x07,\r
-    SCAN_NULL,\r
-    L'6',\r
-    L'^'\r
-  },\r
-  {\r
-    0x08,\r
-    SCAN_NULL,\r
-    L'7',\r
-    L'&'\r
-  },\r
-  {\r
-    0x09,\r
-    SCAN_NULL,\r
-    L'8',\r
-    L'*'\r
-  },\r
-  {\r
-    0x0A,\r
-    SCAN_NULL,\r
-    L'9',\r
-    L'('\r
-  },\r
-  {\r
-    0x0B,\r
-    SCAN_NULL,\r
-    L'0',\r
-    L')'\r
-  },\r
-  {\r
-    0x0C,\r
-    SCAN_NULL,\r
-    L'-',\r
-    L'_'\r
-  },\r
-  {\r
-    0x0D,\r
-    SCAN_NULL,\r
-    L'=',\r
-    L'+'\r
-  },\r
-  {\r
-    0x0E, //  BackSpace\r
-    SCAN_NULL,\r
-    0x0008,\r
-    0x0008\r
-  },\r
-  {\r
-    0x0F, //  Tab\r
-    SCAN_NULL,\r
-    0x0009,\r
-    0x0009\r
-  },\r
-  {\r
-    0x10,\r
-    SCAN_NULL,\r
-    L'q',\r
-    L'Q'\r
-  },\r
-  {\r
-    0x11,\r
-    SCAN_NULL,\r
-    L'w',\r
-    L'W'\r
-  },\r
-  {\r
-    0x12,\r
-    SCAN_NULL,\r
-    L'e',\r
-    L'E'\r
-  },\r
-  {\r
-    0x13,\r
-    SCAN_NULL,\r
-    L'r',\r
-    L'R'\r
-  },\r
-  {\r
-    0x14,\r
-    SCAN_NULL,\r
-    L't',\r
-    L'T'\r
-  },\r
-  {\r
-    0x15,\r
-    SCAN_NULL,\r
-    L'y',\r
-    L'Y'\r
-  },\r
-  {\r
-    0x16,\r
-    SCAN_NULL,\r
-    L'u',\r
-    L'U'\r
-  },\r
-  {\r
-    0x17,\r
-    SCAN_NULL,\r
-    L'i',\r
-    L'I'\r
-  },\r
-  {\r
-    0x18,\r
-    SCAN_NULL,\r
-    L'o',\r
-    L'O'\r
-  },\r
-  {\r
-    0x19,\r
-    SCAN_NULL,\r
-    L'p',\r
-    L'P'\r
-  },\r
-  {\r
-    0x1a,\r
-    SCAN_NULL,\r
-    L'[',\r
-    L'{'\r
-  },\r
-  {\r
-    0x1b,\r
-    SCAN_NULL,\r
-    L']',\r
-    L'}'\r
-  },\r
-  {\r
-    0x1c, //   Enter\r
-    SCAN_NULL,\r
-    0x000d,\r
-    0x000d\r
-  },\r
-  {\r
-    0x1d,\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x1e,\r
-    SCAN_NULL,\r
-    L'a',\r
-    L'A'\r
-  },\r
-  {\r
-    0x1f,\r
-    SCAN_NULL,\r
-    L's',\r
-    L'S'\r
-  },\r
-  {\r
-    0x20,\r
-    SCAN_NULL,\r
-    L'd',\r
-    L'D'\r
-  },\r
-  {\r
-    0x21,\r
-    SCAN_NULL,\r
-    L'f',\r
-    L'F'\r
-  },\r
-  {\r
-    0x22,\r
-    SCAN_NULL,\r
-    L'g',\r
-    L'G'\r
-  },\r
-  {\r
-    0x23,\r
-    SCAN_NULL,\r
-    L'h',\r
-    L'H'\r
-  },\r
-  {\r
-    0x24,\r
-    SCAN_NULL,\r
-    L'j',\r
-    L'J'\r
-  },\r
-  {\r
-    0x25,\r
-    SCAN_NULL,\r
-    L'k',\r
-    L'K'\r
-  },\r
-  {\r
-    0x26,\r
-    SCAN_NULL,\r
-    L'l',\r
-    L'L'\r
-  },\r
-  {\r
-    0x27,\r
-    SCAN_NULL,\r
-    L';',\r
-    L':'\r
-  },\r
-  {\r
-    0x28,\r
-    SCAN_NULL,\r
-    L'\'',\r
-    L'"'\r
-  },\r
-  {\r
-    0x29,\r
-    SCAN_NULL,\r
-    L'`',\r
-    L'~'\r
-  },\r
-  {\r
-    0x2a, //   Left Shift\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x2b,\r
-    SCAN_NULL,\r
-    L'\\',\r
-    L'|'\r
-  },\r
-  {\r
-    0x2c,\r
-    SCAN_NULL,\r
-    L'z',\r
-    L'Z'\r
-  },\r
-  {\r
-    0x2d,\r
-    SCAN_NULL,\r
-    L'x',\r
-    L'X'\r
-  },\r
-  {\r
-    0x2e,\r
-    SCAN_NULL,\r
-    L'c',\r
-    L'C'\r
-  },\r
-  {\r
-    0x2f,\r
-    SCAN_NULL,\r
-    L'v',\r
-    L'V'\r
-  },\r
-  {\r
-    0x30,\r
-    SCAN_NULL,\r
-    L'b',\r
-    L'B'\r
-  },\r
-  {\r
-    0x31,\r
-    SCAN_NULL,\r
-    L'n',\r
-    L'N'\r
-  },\r
-  {\r
-    0x32,\r
-    SCAN_NULL,\r
-    L'm',\r
-    L'M'\r
-  },\r
-  {\r
-    0x33,\r
-    SCAN_NULL,\r
-    L',',\r
-    L'<'\r
-  },\r
-  {\r
-    0x34,\r
-    SCAN_NULL,\r
-    L'.',\r
-    L'>'\r
-  },\r
-  {\r
-    0x35,\r
-    SCAN_NULL,\r
-    L'/',\r
-    L'?'\r
-  },\r
-  {\r
-    0x36, //Right Shift\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x37, // Numeric Keypad *\r
-    SCAN_NULL,\r
-    L'*',\r
-    L'*'\r
-  },\r
-  {\r
-    0x38,  //Left Alt/Extended Right Alt\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x39,\r
-    SCAN_NULL,\r
-    L' ',\r
-    L' '\r
-  },\r
-  {\r
-    0x3A, //CapsLock\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x3B,\r
-    SCAN_F1,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x3C,\r
-    SCAN_F2,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x3D,\r
-    SCAN_F3,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x3E,\r
-    SCAN_F4,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x3F,\r
-    SCAN_F5,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x40,\r
-    SCAN_F6,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x41,\r
-    SCAN_F7,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x42,\r
-    SCAN_F8,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x43,\r
-    SCAN_F9,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x44,\r
-    SCAN_F10,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x45, // NumLock\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x46, //  ScrollLock\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x47,\r
-    SCAN_HOME,\r
-    L'7',\r
-    L'7'\r
-  },\r
-  {\r
-    0x48,\r
-    SCAN_UP,\r
-    L'8',\r
-    L'8'\r
-  },\r
-  {\r
-    0x49,\r
-    SCAN_PAGE_UP,\r
-    L'9',\r
-    L'9'\r
-  },\r
-  {\r
-    0x4a,\r
-    SCAN_NULL,\r
-    L'-',\r
-    L'-'\r
-  },\r
-  {\r
-    0x4b,\r
-    SCAN_LEFT,\r
-    L'4',\r
-    L'4'\r
-  },\r
-  {\r
-    0x4c, //  Numeric Keypad 5\r
-    SCAN_NULL,\r
-    L'5',\r
-    L'5'\r
-  },\r
-  {\r
-    0x4d,\r
-    SCAN_RIGHT,\r
-    L'6',\r
-    L'6'\r
-  },\r
-  {\r
-    0x4e,\r
-    SCAN_NULL,\r
-    L'+',\r
-    L'+'\r
-  },\r
-  {\r
-    0x4f,\r
-    SCAN_END,\r
-    L'1',\r
-    L'1'\r
-  },\r
-  {\r
-    0x50,\r
-    SCAN_DOWN,\r
-    L'2',\r
-    L'2'\r
-  },\r
-  {\r
-    0x51,\r
-    SCAN_PAGE_DOWN,\r
-    L'3',\r
-    L'3'\r
-  },\r
-  {\r
-    0x52,\r
-    SCAN_INSERT,\r
-    L'0',\r
-    L'0'\r
-  },\r
-  {\r
-    0x53,\r
-    SCAN_DELETE,\r
-    L'.',\r
-    L'.'\r
-  },\r
-  {\r
-    0x57,\r
-    SCAN_F11,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x58,\r
-    SCAN_F12,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x5B,  //Left LOGO\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x5C,  //Right LOGO\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    0x5D,  //Menu key\r
-    SCAN_NULL,\r
-    0x0000,\r
-    0x0000\r
-  },\r
-  {\r
-    TABLE_END,\r
-    TABLE_END,\r
-    SCAN_NULL,\r
-    SCAN_NULL\r
-  },\r
-};\r
-\r
-//\r
-// The WaitForValue time out\r
-//\r
-UINTN  mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;\r
-\r
-BOOLEAN          mEnableMouseInterface;\r
-\r
-\r
-\r
-/**\r
-  Return the count of scancode in the queue.\r
-\r
-  @param Queue     Pointer to instance of SCAN_CODE_QUEUE.\r
-\r
-  @return          Count of the scancode.\r
-**/\r
-UINTN\r
-GetScancodeBufCount (\r
-  IN SCAN_CODE_QUEUE       *Queue\r
-  )\r
-{\r
-  if (Queue->Head <= Queue->Tail) {\r
-    return Queue->Tail - Queue->Head;\r
-  } else {\r
-    return Queue->Tail + KEYBOARD_SCAN_CODE_MAX_COUNT - Queue->Head;\r
-  }\r
-}\r
-\r
-/**\r
-  Read several bytes from the scancode buffer without removing them.\r
-  This function is called to see if there are enough bytes of scancode\r
-  representing a single key.\r
-\r
-  @param Queue     Pointer to instance of SCAN_CODE_QUEUE.\r
-  @param Count     Number of bytes to be read\r
-  @param Buf       Store the results\r
-\r
-  @retval EFI_SUCCESS   success to scan the keyboard code\r
-  @retval EFI_NOT_READY invalid parameter\r
-**/\r
-EFI_STATUS\r
-GetScancodeBufHead (\r
-  IN  SCAN_CODE_QUEUE        *Queue,\r
-  IN  UINTN                  Count,\r
-  OUT UINT8                  *Buf\r
-  )\r
-{\r
-  UINTN                      Index;\r
-  UINTN                      Pos;\r
-\r
-  //\r
-  // check the valid range of parameter 'Count'\r
-  //\r
-  if (GetScancodeBufCount (Queue) < Count) {\r
-    return EFI_NOT_READY;\r
-  }\r
-  //\r
-  // retrieve the values\r
-  //\r
-  for (Index = 0, Pos = Queue->Head; Index < Count; Index++, Pos = (Pos + 1) % KEYBOARD_SCAN_CODE_MAX_COUNT) {\r
-    Buf[Index] = Queue->Buffer[Pos];\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  Read & remove several bytes from the scancode buffer.\r
-  This function is usually called after GetScancodeBufHead()\r
-\r
-  @param Queue     Pointer to instance of SCAN_CODE_QUEUE.\r
-  @param Count     Number of bytes to be read\r
-  @param Buf       Store the results\r
-\r
-  @retval EFI_SUCCESS success to scan the keyboard code\r
-  @retval EFI_NOT_READY invalid parameter\r
-**/\r
-EFI_STATUS\r
-PopScancodeBufHead (\r
-  IN  SCAN_CODE_QUEUE       *Queue,\r
-  IN  UINTN                 Count,\r
-  OUT UINT8                 *Buf OPTIONAL\r
-  )\r
-{\r
-  UINTN                     Index;\r
-\r
-  //\r
-  // Check the valid range of parameter 'Count'\r
-  //\r
-  if (GetScancodeBufCount (Queue) < Count) {\r
-    return EFI_NOT_READY;\r
-  }\r
-  //\r
-  // Retrieve and remove the values\r
-  //\r
-  for (Index = 0; Index < Count; Index++, Queue->Head = (Queue->Head + 1) % KEYBOARD_SCAN_CODE_MAX_COUNT) {\r
-    if (Buf != NULL) {\r
-      Buf[Index] = Queue->Buffer[Queue->Head];\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Push one byte to the scancode buffer.\r
-\r
-  @param Queue     Pointer to instance of SCAN_CODE_QUEUE.\r
-  @param Scancode  The byte to push.\r
-**/\r
-VOID\r
-PushScancodeBufTail (\r
-  IN  SCAN_CODE_QUEUE       *Queue,\r
-  IN  UINT8                 Scancode\r
-  )\r
-{\r
-  if (GetScancodeBufCount (Queue) == KEYBOARD_SCAN_CODE_MAX_COUNT - 1) {\r
-    PopScancodeBufHead (Queue, 1, NULL);\r
-  }\r
-\r
-  Queue->Buffer[Queue->Tail] = Scancode;\r
-  Queue->Tail = (Queue->Tail + 1) % KEYBOARD_SCAN_CODE_MAX_COUNT;\r
-}\r
-\r
-/**\r
-  Read data register .\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-\r
-  @return return the value\r
-\r
-**/\r
-UINT8\r
-KeyReadDataRegister (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  )\r
-\r
-{\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-  UINT8                               Data;\r
-\r
-  //\r
-  // Use IsaIo protocol to perform IO operations\r
-  //\r
-  IsaIo = ConsoleIn->IsaIo;\r
-\r
-  IsaIo->Io.Read (\r
-              IsaIo,\r
-              EfiIsaIoWidthUint8,\r
-              ConsoleIn->DataRegisterAddress,\r
-              1,\r
-              &Data\r
-              );\r
-\r
-  return Data;\r
-}\r
-\r
-/**\r
-  Write data register.\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-  @param Data      value wanted to be written\r
-\r
-**/\r
-VOID\r
-KeyWriteDataRegister (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  IN UINT8                   Data\r
-  )\r
-{\r
-  ConsoleIn->IsaIo->Io.Write (\r
-                         ConsoleIn->IsaIo,\r
-                         EfiIsaIoWidthUint8,\r
-                         ConsoleIn->DataRegisterAddress,\r
-                         1,\r
-                         &Data\r
-                         );\r
-}\r
-\r
-/**\r
-  Read status register.\r
-\r
-  @param ConsoleIn  Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-\r
-  @return value in status register\r
-\r
-**/\r
-UINT8\r
-KeyReadStatusRegister (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  )\r
-{\r
-  UINT8                               Data;\r
-  ConsoleIn->IsaIo->Io.Read (\r
-                         ConsoleIn->IsaIo,\r
-                         EfiIsaIoWidthUint8,\r
-                         ConsoleIn->StatusRegisterAddress,\r
-                         1,\r
-                         &Data\r
-                         );\r
-  return Data;\r
-}\r
-\r
-/**\r
-  Write command register .\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-  @param Data      The value wanted to be written\r
-\r
-**/\r
-VOID\r
-KeyWriteCommandRegister (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  IN UINT8                   Data\r
-  )\r
-{\r
-  ConsoleIn->IsaIo->Io.Write (\r
-                         ConsoleIn->IsaIo,\r
-                         EfiIsaIoWidthUint8,\r
-                         ConsoleIn->CommandRegisterAddress,\r
-                         1,\r
-                         &Data\r
-                         );\r
-}\r
-\r
-/**\r
-  Display error message.\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-  @param ErrMsg    Unicode string of error message\r
-\r
-**/\r
-VOID\r
-KeyboardError (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  IN CHAR16                  *ErrMsg\r
-  )\r
-{\r
-  ConsoleIn->KeyboardErr = TRUE;\r
-}\r
-\r
-/**\r
-  Timer event handler: read a series of scancodes from 8042\r
-  and put them into memory scancode buffer.\r
-  it read as much scancodes to either fill\r
-  the memory buffer or empty the keyboard buffer.\r
-  It is registered as running under TPL_NOTIFY\r
-\r
-  @param Event       The timer event\r
-  @param Context     A KEYBOARD_CONSOLE_IN_DEV pointer\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyboardTimerHandler (\r
-  IN EFI_EVENT    Event,\r
-  IN VOID         *Context\r
-  )\r
-\r
-{\r
-  UINT8                   Data;\r
-  EFI_TPL                 OldTpl;\r
-  KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r
-\r
-  ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  if (((KEYBOARD_CONSOLE_IN_DEV *) Context)->KeyboardErr) {\r
-    //\r
-    // Leave critical section and return\r
-    //\r
-    gBS->RestoreTPL (OldTpl);\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // To let KB driver support Hot plug, here should skip the 'resend' command  for the case that\r
-  // KB is not connected to system. If KB is not connected to system, driver will find there's something\r
-  // error in the following code and wait for the input buffer empty, this waiting time shoulb be short enough since\r
-  // this is a NOTIFY TPL period function, or the system performance will degrade hardly when KB is not connected.\r
-  // Just skip the 'resend' process simply.\r
-  //\r
-\r
-  while ((KeyReadStatusRegister (ConsoleIn) & (KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT|KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA)) ==\r
-      KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA\r
-     ) {\r
-    //\r
-    // Read one byte of the scan code and store it into the memory buffer\r
-    //\r
-    Data = KeyReadDataRegister (ConsoleIn);\r
-    PushScancodeBufTail (&ConsoleIn->ScancodeQueue, Data);\r
-  }\r
-  KeyGetchar (ConsoleIn);\r
-\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-}\r
-\r
-/**\r
-  Read key value .\r
-\r
-  @param ConsoleIn - Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-  @param Data      - Pointer to outof buffer for keeping key value\r
-\r
-  @retval EFI_TIMEOUT Status resigter time out\r
-  @retval EFI_SUCCESS Success to read keyboard\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardRead (\r
-  IN KEYBOARD_CONSOLE_IN_DEV  *ConsoleIn,\r
-  OUT UINT8                   *Data\r
-  )\r
-\r
-{\r
-  UINT32  TimeOut;\r
-  UINT32  RegFilled;\r
-\r
-  TimeOut   = 0;\r
-  RegFilled = 0;\r
-\r
-  //\r
-  // wait till output buffer full then perform the read\r
-  //\r
-  for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-    if (KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA) {\r
-      RegFilled = 1;\r
-      *Data     = KeyReadDataRegister (ConsoleIn);\r
-      break;\r
-    }\r
-\r
-    MicroSecondDelay (30);\r
-  }\r
-\r
-  if (RegFilled == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  write key to keyboard\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-  @param Data      value wanted to be written\r
-\r
-  @retval EFI_TIMEOUT   The input buffer register is full for putting new value util timeout\r
-  @retval EFI_SUCCESS   The new value is sucess put into input buffer register.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardWrite (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  IN UINT8                   Data\r
-  )\r
-{\r
-  UINT32  TimeOut;\r
-  UINT32  RegEmptied;\r
-\r
-  TimeOut     = 0;\r
-  RegEmptied  = 0;\r
-\r
-  //\r
-  // wait for input buffer empty\r
-  //\r
-  for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-    if ((KeyReadStatusRegister (ConsoleIn) & 0x02) == 0) {\r
-      RegEmptied = 1;\r
-      break;\r
-    }\r
-\r
-    MicroSecondDelay (30);\r
-  }\r
-\r
-  if (RegEmptied == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-  //\r
-  // Write it\r
-  //\r
-  KeyWriteDataRegister (ConsoleIn, Data);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Issue keyboard command.\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-  @param Data      The buff holding the command\r
-\r
-  @retval EFI_TIMEOUT Keyboard is not ready to issuing\r
-  @retval EFI_SUCCESS Success to issue keyboard command\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardCommand (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  IN UINT8                   Data\r
-  )\r
-{\r
-  UINT32  TimeOut;\r
-  UINT32  RegEmptied;\r
-\r
-  TimeOut     = 0;\r
-  RegEmptied  = 0;\r
-\r
-  //\r
-  // Wait For Input Buffer Empty\r
-  //\r
-  for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-    if ((KeyReadStatusRegister (ConsoleIn) & 0x02) == 0) {\r
-      RegEmptied = 1;\r
-      break;\r
-    }\r
-\r
-    MicroSecondDelay (30);\r
-  }\r
-\r
-  if (RegEmptied == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-  //\r
-  // issue the command\r
-  //\r
-  KeyWriteCommandRegister (ConsoleIn, Data);\r
-\r
-  //\r
-  // Wait For Input Buffer Empty again\r
-  //\r
-  RegEmptied = 0;\r
-  for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-    if ((KeyReadStatusRegister (ConsoleIn) & 0x02) == 0) {\r
-      RegEmptied = 1;\r
-      break;\r
-    }\r
-\r
-    MicroSecondDelay (30);\r
-  }\r
-\r
-  if (RegEmptied == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  wait for a specific value to be presented on\r
-  8042 Data register by keyboard and then read it,\r
-  used in keyboard commands ack\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-  @param Value     the value wanted to be waited.\r
-\r
-  @retval EFI_TIMEOUT Fail to get specific value in given time\r
-  @retval EFI_SUCCESS Success to get specific value in given time.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardWaitForValue (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  IN UINT8                   Value\r
-  )\r
-{\r
-  UINT8   Data;\r
-  UINT32  TimeOut;\r
-  UINT32  SumTimeOut;\r
-  UINT32  GotIt;\r
-\r
-  GotIt       = 0;\r
-  TimeOut     = 0;\r
-  SumTimeOut  = 0;\r
-\r
-  //\r
-  // Make sure the initial value of 'Data' is different from 'Value'\r
-  //\r
-  Data = 0;\r
-  if (Data == Value) {\r
-    Data = 1;\r
-  }\r
-  //\r
-  // Read from 8042 (multiple times if needed)\r
-  // until the expected value appears\r
-  // use SumTimeOut to control the iteration\r
-  //\r
-  while (1) {\r
-    //\r
-    // Perform a read\r
-    //\r
-    for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-      if (KeyReadStatusRegister (ConsoleIn) & 0x01) {\r
-        Data = KeyReadDataRegister (ConsoleIn);\r
-        break;\r
-      }\r
-\r
-      MicroSecondDelay (30);\r
-    }\r
-\r
-    SumTimeOut += TimeOut;\r
-\r
-    if (Data == Value) {\r
-      GotIt = 1;\r
-      break;\r
-    }\r
-\r
-    if (SumTimeOut >= mWaitForValueTimeOut) {\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Check results\r
-  //\r
-  if (GotIt == 1) {\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-}\r
-\r
-/**\r
-  Show keyboard status lights according to\r
-  indicators in ConsoleIn.\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-\r
-  @return status of updating keyboard register\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateStatusLights (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Command;\r
-\r
-  //\r
-  // Send keyboard command\r
-  //\r
-  Status = KeyboardWrite (ConsoleIn, 0xed);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  KeyboardWaitForValue (ConsoleIn, 0xfa);\r
-\r
-  //\r
-  // Light configuration\r
-  //\r
-  Command = 0;\r
-  if (ConsoleIn->CapsLock) {\r
-    Command |= 4;\r
-  }\r
-\r
-  if (ConsoleIn->NumLock) {\r
-    Command |= 2;\r
-  }\r
-\r
-  if (ConsoleIn->ScrollLock) {\r
-    Command |= 1;\r
-  }\r
-\r
-  Status = KeyboardWrite (ConsoleIn, Command);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  KeyboardWaitForValue (ConsoleIn, 0xfa);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Initialize the key state.\r
-\r
-  @param  ConsoleIn     The KEYBOARD_CONSOLE_IN_DEV instance.\r
-  @param  KeyState      A pointer to receive the key state information.\r
-**/\r
-VOID\r
-InitializeKeyState (\r
-  IN  KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  OUT EFI_KEY_STATE           *KeyState\r
-  )\r
-{\r
-  KeyState->KeyShiftState  = EFI_SHIFT_STATE_VALID\r
-                           | (ConsoleIn->LeftCtrl   ? EFI_LEFT_CONTROL_PRESSED  : 0)\r
-                           | (ConsoleIn->RightCtrl  ? EFI_RIGHT_CONTROL_PRESSED : 0)\r
-                           | (ConsoleIn->LeftAlt    ? EFI_LEFT_ALT_PRESSED      : 0)\r
-                           | (ConsoleIn->RightAlt   ? EFI_RIGHT_ALT_PRESSED     : 0)\r
-                           | (ConsoleIn->LeftShift  ? EFI_LEFT_SHIFT_PRESSED    : 0)\r
-                           | (ConsoleIn->RightShift ? EFI_RIGHT_SHIFT_PRESSED   : 0)\r
-                           | (ConsoleIn->LeftLogo   ? EFI_LEFT_LOGO_PRESSED     : 0)\r
-                           | (ConsoleIn->RightLogo  ? EFI_RIGHT_LOGO_PRESSED    : 0)\r
-                           | (ConsoleIn->Menu       ? EFI_MENU_KEY_PRESSED      : 0)\r
-                           | (ConsoleIn->SysReq     ? EFI_SYS_REQ_PRESSED       : 0)\r
-                           ;\r
-  KeyState->KeyToggleState = EFI_TOGGLE_STATE_VALID\r
-                           | (ConsoleIn->CapsLock   ? EFI_CAPS_LOCK_ACTIVE :   0)\r
-                           | (ConsoleIn->NumLock    ? EFI_NUM_LOCK_ACTIVE :    0)\r
-                           | (ConsoleIn->ScrollLock ? EFI_SCROLL_LOCK_ACTIVE : 0)\r
-                           | (ConsoleIn->IsSupportPartialKey ? EFI_KEY_STATE_EXPOSED : 0)\r
-                           ;\r
-}\r
-\r
-/**\r
-  Get scancode from scancode buffer and translate into EFI-scancode and unicode defined by EFI spec.\r
-\r
-  The function is always called in TPL_NOTIFY.\r
-\r
-  @param ConsoleIn KEYBOARD_CONSOLE_IN_DEV instance pointer\r
-\r
-**/\r
-VOID\r
-KeyGetchar (\r
-  IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  )\r
-{\r
-  EFI_STATUS                     Status;\r
-  UINT16                         ScanCode;\r
-  BOOLEAN                        Extend0;\r
-  BOOLEAN                        Extend1;\r
-  UINTN                          Index;\r
-  EFI_KEY_DATA                   KeyData;\r
-  LIST_ENTRY                     *Link;\r
-  KEYBOARD_CONSOLE_IN_EX_NOTIFY  *CurrentNotify;\r
-  //\r
-  // 3 bytes most\r
-  //\r
-  UINT8                          ScancodeArr[3];\r
-  UINT32                         ScancodeArrPos;\r
-\r
-  //\r
-  // Check if there are enough bytes of scancode representing a single key\r
-  // available in the buffer\r
-  //\r
-  while (TRUE) {\r
-    Extend0        = FALSE;\r
-    Extend1        = FALSE;\r
-    ScancodeArrPos = 0;\r
-    Status  = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);\r
-    if (EFI_ERROR (Status)) {\r
-      return ;\r
-    }\r
-\r
-    if (ScancodeArr[ScancodeArrPos] == SCANCODE_EXTENDED0) {\r
-      //\r
-      // E0 to look ahead 2 bytes\r
-      //\r
-      Extend0 = TRUE;\r
-      ScancodeArrPos = 1;\r
-      Status         = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);\r
-      if (EFI_ERROR (Status)) {\r
-        return ;\r
-      }\r
-    } else if (ScancodeArr[ScancodeArrPos] == SCANCODE_EXTENDED1) {\r
-      //\r
-      // E1 to look ahead 3 bytes\r
-      //\r
-      Extend1 = TRUE;\r
-      ScancodeArrPos = 2;\r
-      Status         = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);\r
-      if (EFI_ERROR (Status)) {\r
-        return ;\r
-      }\r
-    }\r
-    //\r
-    // if we reach this position, scancodes for a key is in buffer now,pop them\r
-    //\r
-    Status = PopScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // store the last available byte, this byte of scancode will be checked\r
-    //\r
-    ScanCode = ScancodeArr[ScancodeArrPos];\r
-\r
-    if (!Extend1) {\r
-      //\r
-      // Check for special keys and update the driver state.\r
-      //\r
-      switch (ScanCode) {\r
-\r
-      case SCANCODE_CTRL_MAKE:\r
-        if (Extend0) {\r
-          ConsoleIn->RightCtrl = TRUE;\r
-        } else {\r
-          ConsoleIn->LeftCtrl  = TRUE;\r
-        }\r
-        break;\r
-      case SCANCODE_CTRL_BREAK:\r
-        if (Extend0) {\r
-          ConsoleIn->RightCtrl = FALSE;\r
-        } else {\r
-          ConsoleIn->LeftCtrl  = FALSE;\r
-        }\r
-        break;\r
-\r
-      case SCANCODE_ALT_MAKE:\r
-          if (Extend0) {\r
-            ConsoleIn->RightAlt = TRUE;\r
-          } else {\r
-            ConsoleIn->LeftAlt  = TRUE;\r
-          }\r
-        break;\r
-      case SCANCODE_ALT_BREAK:\r
-          if (Extend0) {\r
-            ConsoleIn->RightAlt = FALSE;\r
-          } else {\r
-            ConsoleIn->LeftAlt  = FALSE;\r
-          }\r
-        break;\r
-\r
-      case SCANCODE_LEFT_SHIFT_MAKE:\r
-        //\r
-        // To avoid recognize PRNT_SCRN key as a L_SHIFT key\r
-        // because PRNT_SCRN key generates E0 followed by L_SHIFT scan code.\r
-        // If it the second byte of the PRNT_ScRN skip it.\r
-        //\r
-        if (!Extend0) {\r
-          ConsoleIn->LeftShift  = TRUE;\r
-          break;\r
-        }\r
-        continue;\r
-\r
-      case SCANCODE_LEFT_SHIFT_BREAK:\r
-        if (!Extend0) {\r
-          ConsoleIn->LeftShift = FALSE;\r
-        }\r
-        break;\r
-\r
-      case SCANCODE_RIGHT_SHIFT_MAKE:\r
-        ConsoleIn->RightShift = TRUE;\r
-        break;\r
-      case SCANCODE_RIGHT_SHIFT_BREAK:\r
-        ConsoleIn->RightShift = FALSE;\r
-        break;\r
-\r
-      case SCANCODE_LEFT_LOGO_MAKE:\r
-        ConsoleIn->LeftLogo = TRUE;\r
-        break;\r
-      case SCANCODE_LEFT_LOGO_BREAK:\r
-        ConsoleIn->LeftLogo = FALSE;\r
-        break;\r
-\r
-      case SCANCODE_RIGHT_LOGO_MAKE:\r
-        ConsoleIn->RightLogo = TRUE;\r
-        break;\r
-      case SCANCODE_RIGHT_LOGO_BREAK:\r
-        ConsoleIn->RightLogo = FALSE;\r
-        break;\r
-\r
-      case SCANCODE_MENU_MAKE:\r
-        ConsoleIn->Menu = TRUE;\r
-        break;\r
-      case SCANCODE_MENU_BREAK:\r
-        ConsoleIn->Menu = FALSE;\r
-        break;\r
-\r
-      case SCANCODE_SYS_REQ_MAKE:\r
-        if (Extend0) {\r
-          ConsoleIn->SysReq = TRUE;\r
-        }\r
-        break;\r
-      case SCANCODE_SYS_REQ_BREAK:\r
-        if (Extend0) {\r
-          ConsoleIn->SysReq = FALSE;\r
-        }\r
-        break;\r
-\r
-      case SCANCODE_SYS_REQ_MAKE_WITH_ALT:\r
-        ConsoleIn->SysReq = TRUE;\r
-        break;\r
-      case SCANCODE_SYS_REQ_BREAK_WITH_ALT:\r
-        ConsoleIn->SysReq = FALSE;\r
-        break;\r
-\r
-      case SCANCODE_CAPS_LOCK_MAKE:\r
-        ConsoleIn->CapsLock = (BOOLEAN)!ConsoleIn->CapsLock;\r
-        UpdateStatusLights (ConsoleIn);\r
-        break;\r
-      case SCANCODE_NUM_LOCK_MAKE:\r
-        ConsoleIn->NumLock = (BOOLEAN)!ConsoleIn->NumLock;\r
-        UpdateStatusLights (ConsoleIn);\r
-        break;\r
-      case SCANCODE_SCROLL_LOCK_MAKE:\r
-        if (!Extend0) {\r
-          ConsoleIn->ScrollLock = (BOOLEAN)!ConsoleIn->ScrollLock;\r
-          UpdateStatusLights (ConsoleIn);\r
-        }\r
-        break;\r
-      }\r
-    }\r
-\r
-    //\r
-    // If this is above the valid range, ignore it\r
-    //\r
-    if (ScanCode >= SCANCODE_MAX_MAKE) {\r
-      continue;\r
-    } else {\r
-      break;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Handle Ctrl+Alt+Del hotkey\r
-  //\r
-  if ((ConsoleIn->LeftCtrl || ConsoleIn->RightCtrl) &&\r
-      (ConsoleIn->LeftAlt  || ConsoleIn->RightAlt ) &&\r
-      ScanCode == SCANCODE_DELETE_MAKE\r
-     ) {\r
-    gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
-  }\r
-\r
-  //\r
-  // Save the Shift/Toggle state\r
-  //\r
-  InitializeKeyState (ConsoleIn, &KeyData.KeyState);\r
-  KeyData.Key.ScanCode    = SCAN_NULL;\r
-  KeyData.Key.UnicodeChar = CHAR_NULL;\r
-\r
-  //\r
-  // Key Pad "/" shares the same scancode as that of "/" except Key Pad "/" has E0 prefix\r
-  //\r
-  if (Extend0 && ScanCode == 0x35) {\r
-    KeyData.Key.UnicodeChar = L'/';\r
-    KeyData.Key.ScanCode    = SCAN_NULL;\r
-\r
-  //\r
-  // PAUSE shares the same scancode as that of NUM except PAUSE has E1 prefix\r
-  //\r
-  } else if (Extend1 && ScanCode == SCANCODE_NUM_LOCK_MAKE) {\r
-    KeyData.Key.UnicodeChar = CHAR_NULL;\r
-    KeyData.Key.ScanCode    = SCAN_PAUSE;\r
-\r
-  //\r
-  // PAUSE shares the same scancode as that of SCROLL except PAUSE (CTRL pressed) has E0 prefix\r
-  //\r
-  } else if (Extend0 && ScanCode == SCANCODE_SCROLL_LOCK_MAKE) {\r
-    KeyData.Key.UnicodeChar = CHAR_NULL;\r
-    KeyData.Key.ScanCode    = SCAN_PAUSE;\r
-\r
-  //\r
-  // PRNT_SCRN shares the same scancode as that of Key Pad "*" except PRNT_SCRN has E0 prefix\r
-  //\r
-  } else if (Extend0 && ScanCode == SCANCODE_SYS_REQ_MAKE) {\r
-    KeyData.Key.UnicodeChar = CHAR_NULL;\r
-    KeyData.Key.ScanCode    = SCAN_NULL;\r
-\r
-  //\r
-  // Except the above special case, all others can be handled by convert table\r
-  //\r
-  } else {\r
-    for (Index = 0; ConvertKeyboardScanCodeToEfiKey[Index].ScanCode != TABLE_END; Index++) {\r
-      if (ScanCode == ConvertKeyboardScanCodeToEfiKey[Index].ScanCode) {\r
-        KeyData.Key.ScanCode    = ConvertKeyboardScanCodeToEfiKey[Index].EfiScanCode;\r
-        KeyData.Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar;\r
-\r
-        if ((ConsoleIn->LeftShift || ConsoleIn->RightShift) &&\r
-            (ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar != ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar)) {\r
-          KeyData.Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar;\r
-          //\r
-          // Need not return associated shift state if a class of printable characters that\r
-          // are normally adjusted by shift modifiers. e.g. Shift Key + 'f' key = 'F'\r
-          //\r
-          KeyData.KeyState.KeyShiftState &= ~(EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED);\r
-        }\r
-        //\r
-        // alphabetic key is affected by CapsLock State\r
-        //\r
-        if (ConsoleIn->CapsLock) {\r
-          if (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z') {\r
-            KeyData.Key.UnicodeChar = (UINT16) (KeyData.Key.UnicodeChar - L'a' + L'A');\r
-          } else if (KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {\r
-            KeyData.Key.UnicodeChar = (UINT16) (KeyData.Key.UnicodeChar - L'A' + L'a');\r
-          }\r
-        }\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // distinguish numeric key pad keys' 'up symbol' and 'down symbol'\r
-  //\r
-  if (ScanCode >= 0x47 && ScanCode <= 0x53) {\r
-    if (ConsoleIn->NumLock && !(ConsoleIn->LeftShift || ConsoleIn->RightShift) && !Extend0) {\r
-      KeyData.Key.ScanCode = SCAN_NULL;\r
-    } else if (ScanCode != 0x4a && ScanCode != 0x4e) {\r
-      KeyData.Key.UnicodeChar = CHAR_NULL;\r
-    }\r
-  }\r
-\r
-  //\r
-  // If the key can not be converted then just return.\r
-  //\r
-  if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {\r
-    if (!ConsoleIn->IsSupportPartialKey) {\r
-      return ;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Signal KeyNotify process event if this key pressed matches any key registered.\r
-  //\r
-  for (Link = GetFirstNode (&ConsoleIn->NotifyList); !IsNull (&ConsoleIn->NotifyList, Link); Link = GetNextNode (&ConsoleIn->NotifyList, Link)) {\r
-    CurrentNotify = CR (\r
-                      Link,\r
-                      KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
-                      NotifyEntry,\r
-                      KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
-                      );\r
-    if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {\r
-      //\r
-      // The key notification function needs to run at TPL_CALLBACK\r
-      // while current TPL is TPL_NOTIFY. It will be invoked in\r
-      // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.\r
-      //\r
-      PushEfikeyBufTail (&ConsoleIn->EfiKeyQueueForNotify, &KeyData);\r
-      gBS->SignalEvent (ConsoleIn->KeyNotifyProcessEvent);\r
-      break;\r
-    }\r
-  }\r
-\r
-  PushEfikeyBufTail (&ConsoleIn->EfiKeyQueue, &KeyData);\r
-}\r
-\r
-/**\r
-  Perform 8042 controller and keyboard Initialization.\r
-  If ExtendedVerification is TRUE, do additional test for\r
-  the keyboard interface\r
-\r
-  @param ConsoleIn - KEYBOARD_CONSOLE_IN_DEV instance pointer\r
-  @param ExtendedVerification - indicates a thorough initialization\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to init keyboard\r
-  @retval EFI_SUCCESS      Success to init keyboard\r
-**/\r
-EFI_STATUS\r
-InitKeyboard (\r
-  IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  IN BOOLEAN                     ExtendedVerification\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_STATUS              Status1;\r
-  UINT8                   CommandByte;\r
-  EFI_PS2_POLICY_PROTOCOL *Ps2Policy;\r
-  UINT32                  TryTime;\r
-\r
-  Status                 = EFI_SUCCESS;\r
-  mEnableMouseInterface  = TRUE;\r
-  TryTime                = 0;\r
-\r
-  //\r
-  // Get Ps2 policy to set this\r
-  //\r
-  gBS->LocateProtocol (\r
-        &gEfiPs2PolicyProtocolGuid,\r
-        NULL,\r
-        (VOID **) &Ps2Policy\r
-        );\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_CLEAR_BUFFER,\r
-    ConsoleIn->DevicePath\r
-    );\r
-\r
-  //\r
-  // Perform a read to cleanup the Status Register's\r
-  // output buffer full bits within MAX TRY times\r
-  //\r
-  if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA) != 0) {\r
-    while (!EFI_ERROR (Status) && TryTime < KEYBOARD_MAX_TRY) {\r
-      Status = KeyboardRead (ConsoleIn, &CommandByte);\r
-      TryTime ++;\r
-    }\r
-    //\r
-    // Exceed the max try times. The device may be error.\r
-    //\r
-    if (TryTime == KEYBOARD_MAX_TRY) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Done;\r
-    }\r
-  }\r
-  //\r
-  // We should disable mouse interface during the initialization process\r
-  // since mouse device output could block keyboard device output in the\r
-  // 60H port of 8042 controller.\r
-  //\r
-  // So if we are not initializing 8042 controller for the\r
-  // first time, we have to remember the previous mouse interface\r
-  // enabling state\r
-  //\r
-  // Test the system flag in to determine whether this is the first\r
-  // time initialization\r
-  //\r
-  if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG) != 0) {\r
-    if (!PcdGetBool (PcdFastPS2Detection)) {\r
-      //\r
-      // 8042 controller is already setup (by myself or by mouse driver):\r
-      //   See whether mouse interface is already enabled\r
-      //   which determines whether we should enable it later\r
-      //\r
-      //\r
-      // Read the command byte of 8042 controller\r
-      //\r
-      Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_READ);\r
-      if (EFI_ERROR (Status)) {\r
-        KeyboardError (ConsoleIn, L"\n\r");\r
-        goto Done;\r
-      }\r
-\r
-      Status = KeyboardRead (ConsoleIn, &CommandByte);\r
-      if (EFI_ERROR (Status)) {\r
-        KeyboardError (ConsoleIn, L"\n\r");\r
-        goto Done;\r
-      }\r
-      //\r
-      // Test the mouse enabling bit\r
-      //\r
-      if ((CommandByte & 0x20) != 0) {\r
-        mEnableMouseInterface = FALSE;\r
-      } else {\r
-        mEnableMouseInterface = TRUE;\r
-      }\r
-    } else {\r
-      mEnableMouseInterface = FALSE;\r
-    }\r
-  } else {\r
-    //\r
-    // 8042 controller is not setup yet:\r
-    //   8042 controller selftest;\r
-    //   Don't enable mouse interface later.\r
-    //\r
-    //\r
-    // Disable keyboard and mouse interfaces\r
-    //\r
-    if (!PcdGetBool (PcdFastPS2Detection)) {\r
-      Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);\r
-      if (EFI_ERROR (Status)) {\r
-        KeyboardError (ConsoleIn, L"\n\r");\r
-        goto Done;\r
-      }\r
-\r
-      Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE);\r
-      if (EFI_ERROR (Status)) {\r
-        KeyboardError (ConsoleIn, L"\n\r");\r
-        goto Done;\r
-      }\r
-\r
-      REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-        EFI_PROGRESS_CODE,\r
-        EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST,\r
-        ConsoleIn->DevicePath\r
-        );\r
-      //\r
-      // 8042 Controller Self Test\r
-      //\r
-      Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST);\r
-      if (EFI_ERROR (Status)) {\r
-        KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");\r
-        goto Done;\r
-      }\r
-\r
-      Status = KeyboardWaitForValue (ConsoleIn, 0x55);\r
-      if (EFI_ERROR (Status)) {\r
-        KeyboardError (ConsoleIn, L"8042 controller self test failed!\n\r");\r
-        goto Done;\r
-      }\r
-    }\r
-    //\r
-    // Don't enable mouse interface later\r
-    //\r
-    mEnableMouseInterface = FALSE;\r
-\r
-  }\r
-\r
-  if (Ps2Policy != NULL) {\r
-    Ps2Policy->Ps2InitHardware (ConsoleIn->Handle);\r
-  }\r
-  //\r
-  // Write 8042 Command Byte, set System Flag\r
-  // While at the same time:\r
-  //  1. disable mouse interface,\r
-  //  2. enable kbd interface,\r
-  //  3. enable PC/XT kbd translation mode\r
-  //  4. enable mouse and kbd interrupts\r
-  //\r
-  //  ( Command Byte bits:\r
-  //  7: Reserved\r
-  //  6: PC/XT translation mode\r
-  //  5: Disable Auxiliary device interface\r
-  //  4: Disable keyboard interface\r
-  //  3: Reserved\r
-  //  2: System Flag\r
-  //  1: Enable Auxiliary device interrupt\r
-  //  0: Enable Keyboard interrupt )\r
-  //\r
-  Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_WRITE);\r
-  if (EFI_ERROR (Status)) {\r
-    KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");\r
-    goto Done;\r
-  }\r
-\r
-  Status = KeyboardWrite (ConsoleIn, 0x67);\r
-  if (EFI_ERROR (Status)) {\r
-    KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Clear Memory Scancode Buffer\r
-  //\r
-  ConsoleIn->ScancodeQueue.Head = 0;\r
-  ConsoleIn->ScancodeQueue.Tail = 0;\r
-  ConsoleIn->EfiKeyQueue.Head   = 0;\r
-  ConsoleIn->EfiKeyQueue.Tail   = 0;\r
-  ConsoleIn->EfiKeyQueueForNotify.Head = 0;\r
-  ConsoleIn->EfiKeyQueueForNotify.Tail = 0;\r
-\r
-  //\r
-  // Reset the status indicators\r
-  //\r
-  ConsoleIn->CapsLock   = FALSE;\r
-  ConsoleIn->NumLock    = FALSE;\r
-  ConsoleIn->ScrollLock = FALSE;\r
-  ConsoleIn->LeftCtrl   = FALSE;\r
-  ConsoleIn->RightCtrl  = FALSE;\r
-  ConsoleIn->LeftAlt    = FALSE;\r
-  ConsoleIn->RightAlt   = FALSE;\r
-  ConsoleIn->LeftShift  = FALSE;\r
-  ConsoleIn->RightShift = FALSE;\r
-  ConsoleIn->LeftLogo   = FALSE;\r
-  ConsoleIn->RightLogo  = FALSE;\r
-  ConsoleIn->Menu       = FALSE;\r
-  ConsoleIn->SysReq     = FALSE;\r
-\r
-  ConsoleIn->IsSupportPartialKey = FALSE;\r
-  //\r
-  // For resetting keyboard is not mandatory before booting OS and sometimes keyboard responses very slow,\r
-  // and to support KB hot plug, we need to let the InitKB succeed no matter whether there is a KB device connected\r
-  // to system. So we only do the real resetting for keyboard when user asks and there is a real KB connected t system,\r
-  // and normally during booting an OS, it's skipped.\r
-  //\r
-  if (ExtendedVerification && CheckKeyboardConnect (ConsoleIn)) {\r
-    //\r
-    // Additional verifications for keyboard interface\r
-    //\r
-    //\r
-    // Keyboard Interface Test\r
-    //\r
-    Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_KEYBOARD_INTERFACE_SELF_TEST);\r
-    if (EFI_ERROR (Status)) {\r
-      KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");\r
-      goto Done;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (ConsoleIn, 0x00);\r
-    if (EFI_ERROR (Status)) {\r
-      KeyboardError (\r
-        ConsoleIn,\r
-        L"Some specific value not aquired from 8042 controller!\n\r"\r
-        );\r
-      goto Done;\r
-    }\r
-    //\r
-    // Keyboard reset with a BAT(Basic Assurance Test)\r
-    //\r
-    Status = KeyboardWrite (ConsoleIn, KEYBOARD_8048_COMMAND_RESET);\r
-    if (EFI_ERROR (Status)) {\r
-      KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");\r
-      goto Done;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);\r
-    if (EFI_ERROR (Status)) {\r
-      KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");\r
-      goto Done;\r
-    }\r
-    //\r
-    // wait for BAT completion code\r
-    //\r
-    mWaitForValueTimeOut  = KEYBOARD_BAT_TIMEOUT;\r
-\r
-    Status                = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_BAT_SUCCESS);\r
-    if (EFI_ERROR (Status)) {\r
-      KeyboardError (ConsoleIn, L"Keyboard self test failed!\n\r");\r
-      goto Done;\r
-    }\r
-\r
-    mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;\r
-\r
-    //\r
-    // Set Keyboard to use Scan Code Set 2\r
-    //\r
-    Status = KeyboardWrite (ConsoleIn, KEYBOARD_8048_COMMAND_SELECT_SCAN_CODE_SET);\r
-    if (EFI_ERROR (Status)) {\r
-      KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");\r
-      goto Done;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);\r
-    if (EFI_ERROR (Status)) {\r
-      KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");\r
-      goto Done;\r
-    }\r
-\r
-    Status = KeyboardWrite (ConsoleIn, 0x02);\r
-    if (EFI_ERROR (Status)) {\r
-      KeyboardError (ConsoleIn, L"8042 controller data write error!!\n\r");\r
-      goto Done;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);\r
-    if (EFI_ERROR (Status)) {\r
-      KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");\r
-      goto Done;\r
-    }\r
-\r
-  //\r
-  // Clear Keyboard Scancode Buffer\r
-  //\r
-  Status = KeyboardWrite (ConsoleIn, KEYBOARD_8048_COMMAND_CLEAR_OUTPUT_DATA);\r
-  if (EFI_ERROR (Status)) {\r
-    KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");\r
-    goto Done;\r
-  }\r
-\r
-  Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);\r
-  if (EFI_ERROR (Status)) {\r
-    KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");\r
-    goto Done;\r
-  }\r
-  //\r
-  if (Ps2Policy != NULL) {\r
-    if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_CAPSLOCK) == EFI_KEYBOARD_CAPSLOCK) {\r
-      ConsoleIn->CapsLock = TRUE;\r
-    }\r
-\r
-    if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_NUMLOCK) == EFI_KEYBOARD_NUMLOCK) {\r
-      ConsoleIn->NumLock = TRUE;\r
-    }\r
-\r
-    if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_SCROLLLOCK) == EFI_KEYBOARD_SCROLLLOCK) {\r
-      ConsoleIn->ScrollLock = TRUE;\r
-    }\r
-  }\r
-  //\r
-  // Update Keyboard Lights\r
-  //\r
-  Status = UpdateStatusLights (ConsoleIn);\r
-  if (EFI_ERROR (Status)) {\r
-    KeyboardError (ConsoleIn, L"Update keyboard status lights error!\n\r");\r
-    goto Done;\r
-    }\r
-  }\r
-  //\r
-  // At last, we can now enable the mouse interface if appropriate\r
-  //\r
-Done:\r
-\r
-  if (mEnableMouseInterface) {\r
-    //\r
-    // Enable mouse interface\r
-    //\r
-    Status1 = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_ENABLE_MOUSE_INTERFACE);\r
-    if (EFI_ERROR (Status1)) {\r
-      KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-/**\r
-  Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command\r
-  If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device\r
-  should not be in system.\r
-\r
-  @param[in]  ConsoleIn             Keyboard Private Data Structure\r
-\r
-  @retval     TRUE                  Keyboard in System.\r
-  @retval     FALSE                 Keyboard not in System.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-CheckKeyboardConnect (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  )\r
-{\r
-  EFI_STATUS     Status;\r
-  UINTN          WaitForValueTimeOutBcakup;\r
-\r
-  //\r
-  // enable keyboard itself and wait for its ack\r
-  // If can't receive ack, Keyboard should not be connected.\r
-  //\r
-  if (!PcdGetBool (PcdFastPS2Detection)) {\r
-    Status = KeyboardWrite (\r
-               ConsoleIn,\r
-               KEYBOARD_KBEN\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return FALSE;\r
-    }\r
-    //\r
-    // wait for 1s\r
-    //\r
-    WaitForValueTimeOutBcakup = mWaitForValueTimeOut;\r
-    mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;\r
-    Status = KeyboardWaitForValue (\r
-               ConsoleIn,\r
-               KEYBOARD_CMDECHO_ACK\r
-               );\r
-    mWaitForValueTimeOut = WaitForValueTimeOutBcakup;\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return FALSE;\r
-    }\r
-\r
-    return TRUE;\r
-  } else {\r
-    return TRUE;\r
-  }\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
deleted file mode 100644 (file)
index 1d167d1..0000000
+++ /dev/null
@@ -1,734 +0,0 @@
-/** @file\r
-  Routines implements SIMPLE_TEXT_IN protocol's interfaces based on 8042 interfaces\r
-  provided by Ps2KbdCtrller.c.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#include "Ps2Keyboard.h"\r
-\r
-/**\r
-  Check whether the EFI key buffer is empty.\r
-\r
-  @param Queue     Pointer to instance of EFI_KEY_QUEUE.\r
-\r
-  @retval TRUE    The EFI key buffer is empty.\r
-  @retval FALSE   The EFI key buffer isn't empty.\r
-**/\r
-BOOLEAN\r
-IsEfikeyBufEmpty (\r
-  IN  EFI_KEY_QUEUE         *Queue\r
-  )\r
-{\r
-  return (BOOLEAN) (Queue->Head == Queue->Tail);\r
-}\r
-\r
-/**\r
-  Read & remove one key data from the EFI key buffer.\r
-\r
-  @param Queue     Pointer to instance of EFI_KEY_QUEUE.\r
-  @param KeyData   Receive the key data.\r
-\r
-  @retval EFI_SUCCESS   The key data is popped successfully.\r
-  @retval EFI_NOT_READY There is no key data available.\r
-**/\r
-EFI_STATUS\r
-PopEfikeyBufHead (\r
-  IN  EFI_KEY_QUEUE         *Queue,\r
-  OUT EFI_KEY_DATA          *KeyData OPTIONAL\r
-  )\r
-{\r
-  if (IsEfikeyBufEmpty (Queue)) {\r
-    return EFI_NOT_READY;\r
-  }\r
-  //\r
-  // Retrieve and remove the values\r
-  //\r
-  if (KeyData != NULL) {\r
-    CopyMem (KeyData, &Queue->Buffer[Queue->Head], sizeof (EFI_KEY_DATA));\r
-  }\r
-  Queue->Head = (Queue->Head + 1) % KEYBOARD_EFI_KEY_MAX_COUNT;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Push one key data to the EFI key buffer.\r
-\r
-  @param Queue     Pointer to instance of EFI_KEY_QUEUE.\r
-  @param KeyData   The key data to push.\r
-**/\r
-VOID\r
-PushEfikeyBufTail (\r
-  IN  EFI_KEY_QUEUE         *Queue,\r
-  IN  EFI_KEY_DATA          *KeyData\r
-  )\r
-{\r
-  if ((Queue->Tail + 1) % KEYBOARD_EFI_KEY_MAX_COUNT == Queue->Head) {\r
-    //\r
-    // If Queue is full, pop the one from head.\r
-    //\r
-    PopEfikeyBufHead (Queue, NULL);\r
-  }\r
-  CopyMem (&Queue->Buffer[Queue->Tail], KeyData, sizeof (EFI_KEY_DATA));\r
-  Queue->Tail = (Queue->Tail + 1) % KEYBOARD_EFI_KEY_MAX_COUNT;\r
-}\r
-\r
-/**\r
-  Judge whether is a registed key\r
-\r
-  @param RegsiteredData       A pointer to a buffer that is filled in with the keystroke\r
-                              state data for the key that was registered.\r
-  @param InputData            A pointer to a buffer that is filled in with the keystroke\r
-                              state data for the key that was pressed.\r
-\r
-  @retval TRUE                Key be pressed matches a registered key.\r
-  @retval FLASE               Match failed.\r
-\r
-**/\r
-BOOLEAN\r
-IsKeyRegistered (\r
-  IN EFI_KEY_DATA  *RegsiteredData,\r
-  IN EFI_KEY_DATA  *InputData\r
-  )\r
-\r
-{\r
-  ASSERT (RegsiteredData != NULL && InputData != NULL);\r
-\r
-  if ((RegsiteredData->Key.ScanCode    != InputData->Key.ScanCode) ||\r
-      (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.\r
-  //\r
-  if (RegsiteredData->KeyState.KeyShiftState != 0 &&\r
-      RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {\r
-    return FALSE;\r
-  }\r
-  if (RegsiteredData->KeyState.KeyToggleState != 0 &&\r
-      RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-\r
-}\r
-\r
-/**\r
-    Reads the next keystroke from the input device. The WaitForKey Event can\r
-    be used to test for existance of a keystroke via WaitForEvent () call.\r
-\r
-    @param ConsoleInDev          Ps2 Keyboard private structure\r
-    @param KeyData               A pointer to a buffer that is filled in with the keystroke\r
-                                 state data for the key that was pressed.\r
-\r
-\r
-    @retval EFI_SUCCESS             The keystroke information was returned.\r
-    @retval EFI_NOT_READY           There was no keystroke data availiable.\r
-    @retval EFI_DEVICE_ERROR        The keystroke information was not returned due to\r
-                                    hardware errors.\r
-    @retval EFI_INVALID_PARAMETER   KeyData is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardReadKeyStrokeWorker (\r
-  IN  KEYBOARD_CONSOLE_IN_DEV           *ConsoleInDev,\r
-  OUT EFI_KEY_DATA                      *KeyData\r
-  )\r
-\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_TPL                               OldTpl;\r
-\r
-  if (KeyData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  KeyboardTimerHandler (NULL, ConsoleInDev);\r
-\r
-  if (ConsoleInDev->KeyboardErr) {\r
-    Status = EFI_DEVICE_ERROR;\r
-  } else {\r
-    Status = PopEfikeyBufHead (&ConsoleInDev->EfiKeyQueue, KeyData);\r
-    if (Status == EFI_NOT_READY) {\r
-      ZeroMem (&KeyData->Key, sizeof (KeyData->Key));\r
-      InitializeKeyState (ConsoleInDev, &KeyData->KeyState);\r
-    }\r
-  }\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Perform 8042 controller and keyboard initialization which implement SIMPLE_TEXT_IN.Reset()\r
-\r
-  @param This                 Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
-  @param ExtendedVerification Indicate that the driver may perform a more\r
-                              exhaustive verification operation of the device during\r
-                              reset, now this par is ignored in this driver\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardEfiReset (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  IN  BOOLEAN                         ExtendedVerification\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
-  if (ConsoleIn->KeyboardErr) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_RESET,\r
-    ConsoleIn->DevicePath\r
-    );\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // Call InitKeyboard to initialize the keyboard\r
-  //\r
-  Status = InitKeyboard (ConsoleIn, ExtendedVerification);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Leave critical section and return\r
-    //\r
-    gBS->RestoreTPL (OldTpl);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  //\r
-  // Report the status If a stuck key was detected\r
-  //\r
-  if (KeyReadStatusRegister (ConsoleIn) & 0x01) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_STUCK_KEY,\r
-      ConsoleIn->DevicePath\r
-      );\r
-  }\r
-  //\r
-  // Report the status If keyboard is locked\r
-  //\r
-  if ((KeyReadStatusRegister (ConsoleIn) & 0x10) == 0) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_LOCKED,\r
-      ConsoleIn->DevicePath\r
-      );\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Retrieve key values for driver user which implement SIMPLE_TEXT_IN.ReadKeyStroke().\r
-\r
-  @param This    Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
-  @param Key     The output buffer for key value\r
-\r
-  @retval EFI_SUCCESS success to read key stroke\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardReadKeyStroke (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  OUT EFI_INPUT_KEY                   *Key\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r
-  EFI_KEY_DATA            KeyData;\r
-\r
-  ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Considering if the partial keystroke is enabled, there maybe a partial\r
-  // keystroke in the queue, so here skip the partial keystroke and get the\r
-  // next key from the queue\r
-  //\r
-  while (1) {\r
-    //\r
-    // If there is no pending key, then return.\r
-    //\r
-    Status = KeyboardReadKeyStrokeWorker (ConsoleIn, &KeyData);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    //\r
-    // If it is partial keystroke, skip it.\r
-    //\r
-    if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {\r
-      continue;\r
-    }\r
-    //\r
-    // Translate the CTRL-Alpha characters to their corresponding control value\r
-    // (ctrl-a = 0x0001 through ctrl-Z = 0x001A)\r
-    //\r
-    if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {\r
-      if (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z') {\r
-        KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'a' + 1);\r
-      } else if (KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {\r
-        KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'A' + 1);\r
-      }\r
-    }\r
-\r
-    CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));\r
-    return EFI_SUCCESS;\r
-  }\r
-}\r
-\r
-/**\r
-  Event notification function for SIMPLE_TEXT_IN.WaitForKey event\r
-  Signal the event if there is key available\r
-\r
-  @param Event    the event object\r
-  @param Context  waitting context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyboardWaitForKey (\r
-  IN  EFI_EVENT               Event,\r
-  IN  VOID                    *Context\r
-  )\r
-{\r
-  EFI_TPL                     OldTpl;\r
-  KEYBOARD_CONSOLE_IN_DEV     *ConsoleIn;\r
-  EFI_KEY_DATA                KeyData;\r
-\r
-  ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  KeyboardTimerHandler (NULL, ConsoleIn);\r
-\r
-  if (!ConsoleIn->KeyboardErr) {\r
-    //\r
-    // WaitforKey doesn't suppor the partial key.\r
-    // Considering if the partial keystroke is enabled, there maybe a partial\r
-    // keystroke in the queue, so here skip the partial keystroke and get the\r
-    // next key from the queue\r
-    //\r
-    while (!IsEfikeyBufEmpty (&ConsoleIn->EfiKeyQueue)) {\r
-      CopyMem (\r
-        &KeyData,\r
-        &(ConsoleIn->EfiKeyQueue.Buffer[ConsoleIn->EfiKeyQueue.Head]),\r
-        sizeof (EFI_KEY_DATA)\r
-        );\r
-      if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {\r
-        PopEfikeyBufHead (&ConsoleIn->EfiKeyQueue, &KeyData);\r
-        continue;\r
-      }\r
-      //\r
-      // if there is pending value key, signal the event.\r
-      //\r
-      gBS->SignalEvent (Event);\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-}\r
-\r
-/**\r
-  Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event\r
-  Signal the event if there is key available\r
-\r
-  @param Event    event object\r
-  @param Context  waiting context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyboardWaitForKeyEx (\r
-  IN  EFI_EVENT               Event,\r
-  IN  VOID                    *Context\r
-  )\r
-\r
-{\r
-  KeyboardWaitForKey (Event, Context);\r
-}\r
-\r
-/**\r
-  Reset the input device and optionaly run diagnostics\r
-\r
-  @param This                     Protocol instance pointer.\r
-  @param ExtendedVerification     Driver may perform diagnostics on reset.\r
-\r
-  @retval EFI_SUCCESS             The device was reset.\r
-  @retval EFI_DEVICE_ERROR        The device is not functioning properly and could\r
-                                  not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardEfiResetEx (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN BOOLEAN                            ExtendedVerification\r
-  )\r
-\r
-{\r
-  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
-\r
-  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
-\r
-  return ConsoleInDev->ConIn.Reset (\r
-                               &ConsoleInDev->ConIn,\r
-                               ExtendedVerification\r
-                               );\r
-}\r
-\r
-/**\r
-    Reads the next keystroke from the input device. The WaitForKey Event can\r
-    be used to test for existance of a keystroke via WaitForEvent () call.\r
-\r
-\r
-    @param This         Protocol instance pointer.\r
-    @param KeyData      A pointer to a buffer that is filled in with the keystroke\r
-                        state data for the key that was pressed.\r
-\r
-    @retval EFI_SUCCESS           The keystroke information was returned.\r
-    @retval EFI_NOT_READY         There was no keystroke data availiable.\r
-    @retval EFI_DEVICE_ERROR      The keystroke information was not returned due to\r
-                                  hardware errors.\r
-    @retval EFI_INVALID_PARAMETER KeyData is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardReadKeyStrokeEx (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
-  OUT EFI_KEY_DATA                      *KeyData\r
-  )\r
-\r
-{\r
-  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
-\r
-  if (KeyData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
-  return KeyboardReadKeyStrokeWorker (ConsoleInDev, KeyData);\r
-}\r
-\r
-/**\r
-  Set certain state for the input device.\r
-\r
-  @param This               Protocol instance pointer.\r
-  @param KeyToggleState     A pointer to the EFI_KEY_TOGGLE_STATE to set the\r
-                            state for the input device.\r
-\r
-  @retval EFI_SUCCESS           The device state was set successfully.\r
-  @retval EFI_DEVICE_ERROR      The device is not functioning correctly and could\r
-                                not have the setting adjusted.\r
-  @retval EFI_UNSUPPORTED       The device does not have the ability to set its state.\r
-  @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardSetState (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_KEY_TOGGLE_STATE               *KeyToggleState\r
-  )\r
-\r
-{\r
-  EFI_STATUS                            Status;\r
-  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
-  EFI_TPL                               OldTpl;\r
-\r
-  if (KeyToggleState == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  if (ConsoleInDev->KeyboardErr) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Exit;\r
-  }\r
-\r
-  if ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Exit;\r
-  }\r
-\r
-  //\r
-  // Update the status light\r
-  //\r
-  ConsoleInDev->ScrollLock          = FALSE;\r
-  ConsoleInDev->NumLock             = FALSE;\r
-  ConsoleInDev->CapsLock            = FALSE;\r
-  ConsoleInDev->IsSupportPartialKey = FALSE;\r
-\r
-  if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {\r
-    ConsoleInDev->ScrollLock = TRUE;\r
-  }\r
-  if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {\r
-    ConsoleInDev->NumLock = TRUE;\r
-  }\r
-  if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {\r
-    ConsoleInDev->CapsLock = TRUE;\r
-  }\r
-  if ((*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED) {\r
-    ConsoleInDev->IsSupportPartialKey = TRUE;\r
-  }\r
-\r
-  Status = UpdateStatusLights (ConsoleInDev);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_DEVICE_ERROR;\r
-  }\r
-\r
-Exit:\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-\r
-}\r
-\r
-/**\r
-    Register a notification function for a particular keystroke for the input device.\r
-\r
-    @param This                       Protocol instance pointer.\r
-    @param KeyData                    A pointer to a buffer that is filled in with the keystroke\r
-                                      information data for the key that was pressed. If KeyData.Key,\r
-                                      KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState\r
-                                      are 0, then any incomplete keystroke will trigger a notification of\r
-                                      the KeyNotificationFunction.\r
-    @param KeyNotificationFunction    Points to the function to be called when the key\r
-                                      sequence is typed specified by KeyData. This notification function\r
-                                      should be called at <=TPL_CALLBACK.\r
-    @param NotifyHandle               Points to the unique handle assigned to the registered notification.\r
-\r
-    @retval EFI_SUCCESS               The notification function was registered successfully.\r
-    @retval EFI_OUT_OF_RESOURCES      Unable to allocate resources for necesssary data structures.\r
-    @retval EFI_INVALID_PARAMETER     KeyData or NotifyHandle or KeyNotificationFunction is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardRegisterKeyNotify (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_KEY_DATA                       *KeyData,\r
-  IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,\r
-  OUT VOID                              **NotifyHandle\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
-  EFI_TPL                               OldTpl;\r
-  LIST_ENTRY                            *Link;\r
-  KEYBOARD_CONSOLE_IN_EX_NOTIFY         *CurrentNotify;\r
-  KEYBOARD_CONSOLE_IN_EX_NOTIFY         *NewNotify;\r
-\r
-  if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.\r
-  //\r
-  for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {\r
-    CurrentNotify = CR (\r
-                      Link,\r
-                      KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
-                      NotifyEntry,\r
-                      KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
-                      );\r
-    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {\r
-      if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {\r
-        *NotifyHandle = CurrentNotify;\r
-        Status = EFI_SUCCESS;\r
-        goto Exit;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Allocate resource to save the notification function\r
-  //\r
-  NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));\r
-  if (NewNotify == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Exit;\r
-  }\r
-\r
-  NewNotify->Signature         = KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE;\r
-  NewNotify->KeyNotificationFn = KeyNotificationFunction;\r
-  CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));\r
-  InsertTailList (&ConsoleInDev->NotifyList, &NewNotify->NotifyEntry);\r
-\r
-  *NotifyHandle                = NewNotify;\r
-  Status                       = EFI_SUCCESS;\r
-\r
-Exit:\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-\r
-}\r
-\r
-/**\r
-    Remove a registered notification function from a particular keystroke.\r
-\r
-    @param This                       Protocol instance pointer.\r
-    @param NotificationHandle         The handle of the notification function being unregistered.\r
-\r
-\r
-    @retval EFI_SUCCESS               The notification function was unregistered successfully.\r
-    @retval EFI_INVALID_PARAMETER     The NotificationHandle is invalid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardUnregisterKeyNotify (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN VOID                               *NotificationHandle\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
-  EFI_TPL                               OldTpl;\r
-  LIST_ENTRY                            *Link;\r
-  KEYBOARD_CONSOLE_IN_EX_NOTIFY         *CurrentNotify;\r
-\r
-  if (NotificationHandle == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {\r
-    CurrentNotify = CR (\r
-                      Link,\r
-                      KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
-                      NotifyEntry,\r
-                      KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
-                      );\r
-    if (CurrentNotify == NotificationHandle) {\r
-      //\r
-      // Remove the notification function from NotifyList and free resources\r
-      //\r
-      RemoveEntryList (&CurrentNotify->NotifyEntry);\r
-\r
-      gBS->FreePool (CurrentNotify);\r
-      Status = EFI_SUCCESS;\r
-      goto Exit;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Can not find the specified Notification Handle\r
-  //\r
-  Status = EFI_INVALID_PARAMETER;\r
-Exit:\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Process key notify.\r
-\r
-  @param  Event                 Indicates the event that invoke this function.\r
-  @param  Context               Indicates the calling context.\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyNotifyProcessHandler (\r
-  IN  EFI_EVENT                 Event,\r
-  IN  VOID                      *Context\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  KEYBOARD_CONSOLE_IN_DEV       *ConsoleIn;\r
-  EFI_KEY_DATA                  KeyData;\r
-  LIST_ENTRY                    *Link;\r
-  LIST_ENTRY                    *NotifyList;\r
-  KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;\r
-  EFI_TPL                       OldTpl;\r
-\r
-  ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;\r
-\r
-  //\r
-  // Invoke notification functions.\r
-  //\r
-  NotifyList = &ConsoleIn->NotifyList;\r
-  while (TRUE) {\r
-    //\r
-    // Enter critical section\r
-    //\r
-    OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-    Status = PopEfikeyBufHead (&ConsoleIn->EfiKeyQueueForNotify, &KeyData);\r
-    //\r
-    // Leave critical section\r
-    //\r
-    gBS->RestoreTPL (OldTpl);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {\r
-      CurrentNotify = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);\r
-      if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {\r
-        CurrentNotify->KeyNotificationFn (&KeyData);\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
deleted file mode 100644 (file)
index 2dcb17f..0000000
+++ /dev/null
@@ -1,657 +0,0 @@
-/** @file\r
-\r
-  PS/2 Keyboard driver. Routines that interacts with callers,\r
-  conforming to EFI driver model\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ps2Keyboard.h"\r
-\r
-//\r
-// Function prototypes\r
-//\r
-/**\r
-  Test controller is a keyboard Controller.\r
-\r
-  @param This                 Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param Controller           driver's controller\r
-  @param RemainingDevicePath  children device path\r
-\r
-  @retval EFI_UNSUPPORTED controller is not floppy disk\r
-  @retval EFI_SUCCESS     controller is floppy disk\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KbdControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Create KEYBOARD_CONSOLE_IN_DEV instance on controller.\r
-\r
-  @param This         Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param Controller   driver controller handle\r
-  @param RemainingDevicePath Children's device path\r
-\r
-  @retval whether success to create floppy control instance.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KbdControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Stop this driver on ControllerHandle. Support stopping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KbdControllerDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN  EFI_HANDLE                     Controller,\r
-  IN  UINTN                          NumberOfChildren,\r
-  IN  EFI_HANDLE                     *ChildHandleBuffer\r
-  );\r
-\r
-/**\r
-  Free the waiting key notify list.\r
-\r
-  @param ListHead  Pointer to list head\r
-\r
-  @retval EFI_INVALID_PARAMETER  ListHead is NULL\r
-  @retval EFI_SUCCESS            Sucess to free NotifyList\r
-**/\r
-EFI_STATUS\r
-KbdFreeNotifyList (\r
-  IN OUT LIST_ENTRY           *ListHead\r
-  );\r
-\r
-//\r
-// DriverBinding Protocol Instance\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver = {\r
-  KbdControllerDriverSupported,\r
-  KbdControllerDriverStart,\r
-  KbdControllerDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-/**\r
-  Test controller is a keyboard Controller.\r
-\r
-  @param This                 Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param Controller           driver's controller\r
-  @param RemainingDevicePath  children device path\r
-\r
-  @retval EFI_UNSUPPORTED controller is not floppy disk\r
-  @retval EFI_SUCCESS     controller is floppy disk\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KbdControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Use the ISA I/O Protocol to see if Controller is the Keyboard controller\r
-  //\r
-  if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303) || IsaIo->ResourceList->Device.UID != 0) {\r
-    Status = EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Create KEYBOARD_CONSOLE_IN_DEV instance on controller.\r
-\r
-  @param This         Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param Controller   driver controller handle\r
-  @param RemainingDevicePath Children's device path\r
-\r
-  @retval whether success to create floppy control instance.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KbdControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                                Status;\r
-  EFI_STATUS                                Status1;\r
-  EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
-  KEYBOARD_CONSOLE_IN_DEV                   *ConsoleIn;\r
-  UINT8                                     Data;\r
-  EFI_STATUS_CODE_VALUE                     StatusCode;\r
-  EFI_DEVICE_PATH_PROTOCOL                  *ParentDevicePath;\r
-\r
-  StatusCode = 0;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Report that the keyboard is being enabled\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_ENABLE,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Get the ISA I/O Protocol on Controller's handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Allocate private data\r
-  //\r
-  ConsoleIn = AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_DEV));\r
-  if (ConsoleIn == NULL) {\r
-    Status      = EFI_OUT_OF_RESOURCES;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto ErrorExit;\r
-  }\r
-  //\r
-  // Setup the device instance\r
-  //\r
-  ConsoleIn->Signature              = KEYBOARD_CONSOLE_IN_DEV_SIGNATURE;\r
-  ConsoleIn->Handle                 = Controller;\r
-  (ConsoleIn->ConIn).Reset          = KeyboardEfiReset;\r
-  (ConsoleIn->ConIn).ReadKeyStroke  = KeyboardReadKeyStroke;\r
-  ConsoleIn->DataRegisterAddress    = KEYBOARD_8042_DATA_REGISTER;\r
-  ConsoleIn->StatusRegisterAddress  = KEYBOARD_8042_STATUS_REGISTER;\r
-  ConsoleIn->CommandRegisterAddress = KEYBOARD_8042_COMMAND_REGISTER;\r
-  ConsoleIn->IsaIo                  = IsaIo;\r
-  ConsoleIn->DevicePath             = ParentDevicePath;\r
-\r
-  ConsoleIn->ConInEx.Reset               = KeyboardEfiResetEx;\r
-  ConsoleIn->ConInEx.ReadKeyStrokeEx     = KeyboardReadKeyStrokeEx;\r
-  ConsoleIn->ConInEx.SetState            = KeyboardSetState;\r
-  ConsoleIn->ConInEx.RegisterKeyNotify   = KeyboardRegisterKeyNotify;\r
-  ConsoleIn->ConInEx.UnregisterKeyNotify = KeyboardUnregisterKeyNotify;\r
-\r
-  InitializeListHead (&ConsoleIn->NotifyList);\r
-\r
-  //\r
-  // Fix for random hangs in System waiting for the Key if no KBC is present in BIOS.\r
-  // When KBC decode (IO port 0x60/0x64 decode) is not enabled,\r
-  // KeyboardRead will read back as 0xFF and return status is EFI_SUCCESS.\r
-  // So instead we read status register to detect after read if KBC decode is enabled.\r
-  //\r
-\r
-  //\r
-  // Return code is ignored on purpose.\r
-  //\r
-  if (!PcdGetBool (PcdFastPS2Detection)) {\r
-    KeyboardRead (ConsoleIn, &Data);\r
-    if ((KeyReadStatusRegister (ConsoleIn) & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {\r
-      //\r
-      // If nobody decodes KBC I/O port, it will read back as 0xFF.\r
-      // Check the Time-Out and Parity bit to see if it has an active KBC in system\r
-      //\r
-      Status      = EFI_DEVICE_ERROR;\r
-      StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;\r
-      goto ErrorExit;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Setup the WaitForKey event\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_WAIT,\r
-                  TPL_NOTIFY,\r
-                  KeyboardWaitForKey,\r
-                  ConsoleIn,\r
-                  &((ConsoleIn->ConIn).WaitForKey)\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status      = EFI_OUT_OF_RESOURCES;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto ErrorExit;\r
-  }\r
-  //\r
-  // Setup the WaitForKeyEx event\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_WAIT,\r
-                  TPL_NOTIFY,\r
-                  KeyboardWaitForKeyEx,\r
-                  ConsoleIn,\r
-                  &(ConsoleIn->ConInEx.WaitForKeyEx)\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status      = EFI_OUT_OF_RESOURCES;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  // Setup a periodic timer, used for reading keystrokes at a fixed interval\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  KeyboardTimerHandler,\r
-                  ConsoleIn,\r
-                  &ConsoleIn->TimerEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status      = EFI_OUT_OF_RESOURCES;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  Status = gBS->SetTimer (\r
-                  ConsoleIn->TimerEvent,\r
-                  TimerPeriodic,\r
-                  KEYBOARD_TIMER_INTERVAL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status      = EFI_OUT_OF_RESOURCES;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  KeyNotifyProcessHandler,\r
-                  ConsoleIn,\r
-                  &ConsoleIn->KeyNotifyProcessEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status      = EFI_OUT_OF_RESOURCES;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_PRESENCE_DETECT,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Reset the keyboard device\r
-  //\r
-  Status = ConsoleIn->ConInEx.Reset (&ConsoleIn->ConInEx, FeaturePcdGet (PcdPs2KbdExtendedVerification));\r
-  if (EFI_ERROR (Status)) {\r
-    Status      = EFI_DEVICE_ERROR;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_DETECTED,\r
-    ParentDevicePath\r
-    );\r
-\r
-  ConsoleIn->ControllerNameTable = NULL;\r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gPs2KeyboardComponentName.SupportedLanguages,\r
-    &ConsoleIn->ControllerNameTable,\r
-    L"PS/2 Keyboard Device",\r
-    TRUE\r
-    );\r
-  AddUnicodeString2 (\r
-    "en",\r
-    gPs2KeyboardComponentName2.SupportedLanguages,\r
-    &ConsoleIn->ControllerNameTable,\r
-    L"PS/2 Keyboard Device",\r
-    FALSE\r
-    );\r
-\r
-\r
-  //\r
-  // Install protocol interfaces for the keyboard device.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiSimpleTextInProtocolGuid,\r
-                  &ConsoleIn->ConIn,\r
-                  &gEfiSimpleTextInputExProtocolGuid,\r
-                  &ConsoleIn->ConInEx,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  return Status;\r
-\r
-ErrorExit:\r
-  //\r
-  // Report error code\r
-  //\r
-  if (StatusCode != 0) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      StatusCode,\r
-      ParentDevicePath\r
-      );\r
-  }\r
-\r
-  if ((ConsoleIn != NULL) && (ConsoleIn->ConIn.WaitForKey != NULL)) {\r
-    gBS->CloseEvent (ConsoleIn->ConIn.WaitForKey);\r
-  }\r
-\r
-  if ((ConsoleIn != NULL) && (ConsoleIn->TimerEvent != NULL)) {\r
-    gBS->CloseEvent (ConsoleIn->TimerEvent);\r
-  }\r
-  if ((ConsoleIn != NULL) && (ConsoleIn->ConInEx.WaitForKeyEx != NULL)) {\r
-    gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
-  }\r
-  if ((ConsoleIn != NULL) && (ConsoleIn->KeyNotifyProcessEvent != NULL)) {\r
-    gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);\r
-  }\r
-  KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
-  if ((ConsoleIn != NULL) && (ConsoleIn->ControllerNameTable != NULL)) {\r
-    FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
-  }\r
-  //\r
-  // Since there will be no timer handler for keyboard input any more,\r
-  // exhaust input data just in case there is still keyboard data left\r
-  //\r
-  if (ConsoleIn != NULL) {\r
-    Status1 = EFI_SUCCESS;\r
-    while (!EFI_ERROR (Status1) && (Status != EFI_DEVICE_ERROR)) {\r
-      Status1 = KeyboardRead (ConsoleIn, &Data);;\r
-    }\r
-  }\r
-\r
-  if (ConsoleIn != NULL) {\r
-    gBS->FreePool (ConsoleIn);\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stop this driver on ControllerHandle. Support stopping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KbdControllerDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN  EFI_HANDLE                     Controller,\r
-  IN  UINTN                          NumberOfChildren,\r
-  IN  EFI_HANDLE                     *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                     Status;\r
-  EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;\r
-  KEYBOARD_CONSOLE_IN_DEV        *ConsoleIn;\r
-  UINT8                          Data;\r
-\r
-  //\r
-  // Disable Keyboard\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiSimpleTextInProtocolGuid,\r
-                  (VOID **) &ConIn,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiSimpleTextInputExProtocolGuid,\r
-                  NULL,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);\r
-\r
-  //\r
-  // Report that the keyboard is being disabled\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_DISABLE,\r
-    ConsoleIn->DevicePath\r
-    );\r
-\r
-  if (ConsoleIn->TimerEvent != NULL) {\r
-    gBS->CloseEvent (ConsoleIn->TimerEvent);\r
-    ConsoleIn->TimerEvent = NULL;\r
-  }\r
-\r
-  //\r
-  // Since there will be no timer handler for keyboard input any more,\r
-  // exhaust input data just in case there is still keyboard data left\r
-  //\r
-  Status = EFI_SUCCESS;\r
-  while (!EFI_ERROR (Status)) {\r
-    Status = KeyboardRead (ConsoleIn, &Data);;\r
-  }\r
-  //\r
-  // Uninstall the SimpleTextIn and SimpleTextInEx protocols\r
-  //\r
-  Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                  Controller,\r
-                  &gEfiSimpleTextInProtocolGuid,\r
-                  &ConsoleIn->ConIn,\r
-                  &gEfiSimpleTextInputExProtocolGuid,\r
-                  &ConsoleIn->ConInEx,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  //\r
-  // Free other resources\r
-  //\r
-  if ((ConsoleIn->ConIn).WaitForKey != NULL) {\r
-    gBS->CloseEvent ((ConsoleIn->ConIn).WaitForKey);\r
-    (ConsoleIn->ConIn).WaitForKey = NULL;\r
-  }\r
-  if (ConsoleIn->ConInEx.WaitForKeyEx != NULL) {\r
-    gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
-    ConsoleIn->ConInEx.WaitForKeyEx = NULL;\r
-  }\r
-  if (ConsoleIn->KeyNotifyProcessEvent != NULL) {\r
-    gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);\r
-    ConsoleIn->KeyNotifyProcessEvent = NULL;\r
-  }\r
-  KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
-  FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
-  gBS->FreePool (ConsoleIn);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Free the waiting key notify list.\r
-\r
-  @param ListHead  Pointer to list head\r
-\r
-  @retval EFI_INVALID_PARAMETER  ListHead is NULL\r
-  @retval EFI_SUCCESS            Sucess to free NotifyList\r
-**/\r
-EFI_STATUS\r
-KbdFreeNotifyList (\r
-  IN OUT LIST_ENTRY           *ListHead\r
-  )\r
-{\r
-  KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;\r
-\r
-  if (ListHead == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  while (!IsListEmpty (ListHead)) {\r
-    NotifyNode = CR (\r
-                   ListHead->ForwardLink,\r
-                   KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
-                   NotifyEntry,\r
-                   KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
-                   );\r
-    RemoveEntryList (ListHead->ForwardLink);\r
-    gBS->FreePool (NotifyNode);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  The module Entry Point for module Ps2Keyboard.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializePs2Keyboard(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gKeyboardControllerDriver,\r
-             ImageHandle,\r
-             &gPs2KeyboardComponentName,\r
-             &gPs2KeyboardComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
deleted file mode 100644 (file)
index 7a9b330..0000000
+++ /dev/null
@@ -1,564 +0,0 @@
-/** @file\r
-  PS/2 keyboard driver header file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _PS2KEYBOARD_H_\r
-#define _PS2KEYBOARD_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/SimpleTextIn.h>\r
-#include <Protocol/SimpleTextInEx.h>\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/Ps2Policy.h>\r
-\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gKeyboardControllerDriver;\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gPs2KeyboardComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gPs2KeyboardComponentName2;\r
-\r
-//\r
-// Driver Private Data\r
-//\r
-#define KEYBOARD_CONSOLE_IN_DEV_SIGNATURE       SIGNATURE_32 ('k', 'k', 'e', 'y')\r
-#define KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('k', 'c', 'e', 'n')\r
-\r
-typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY {\r
-  UINTN                               Signature;\r
-  EFI_KEY_DATA                        KeyData;\r
-  EFI_KEY_NOTIFY_FUNCTION             KeyNotificationFn;\r
-  LIST_ENTRY                          NotifyEntry;\r
-} KEYBOARD_CONSOLE_IN_EX_NOTIFY;\r
-\r
-#define KEYBOARD_SCAN_CODE_MAX_COUNT  32\r
-typedef struct {\r
-  UINT8                               Buffer[KEYBOARD_SCAN_CODE_MAX_COUNT];\r
-  UINTN                               Head;\r
-  UINTN                               Tail;\r
-} SCAN_CODE_QUEUE;\r
-\r
-#define KEYBOARD_EFI_KEY_MAX_COUNT    256\r
-typedef struct {\r
-  EFI_KEY_DATA                        Buffer[KEYBOARD_EFI_KEY_MAX_COUNT];\r
-  UINTN                               Head;\r
-  UINTN                               Tail;\r
-} EFI_KEY_QUEUE;\r
-\r
-typedef struct {\r
-  UINTN                               Signature;\r
-\r
-  EFI_HANDLE                          Handle;\r
-  EFI_SIMPLE_TEXT_INPUT_PROTOCOL      ConIn;\r
-  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL   ConInEx;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-\r
-  EFI_EVENT                           TimerEvent;\r
-\r
-  UINT32                              DataRegisterAddress;\r
-  UINT32                              StatusRegisterAddress;\r
-  UINT32                              CommandRegisterAddress;\r
-\r
-  BOOLEAN                             LeftCtrl;\r
-  BOOLEAN                             RightCtrl;\r
-  BOOLEAN                             LeftAlt;\r
-  BOOLEAN                             RightAlt;\r
-  BOOLEAN                             LeftShift;\r
-  BOOLEAN                             RightShift;\r
-  BOOLEAN                             LeftLogo;\r
-  BOOLEAN                             RightLogo;\r
-  BOOLEAN                             Menu;\r
-  BOOLEAN                             SysReq;\r
-\r
-  BOOLEAN                             CapsLock;\r
-  BOOLEAN                             NumLock;\r
-  BOOLEAN                             ScrollLock;\r
-\r
-  BOOLEAN                             IsSupportPartialKey;\r
-  //\r
-  // Queue storing key scancodes\r
-  //\r
-  SCAN_CODE_QUEUE                     ScancodeQueue;\r
-  EFI_KEY_QUEUE                       EfiKeyQueue;\r
-  EFI_KEY_QUEUE                       EfiKeyQueueForNotify;\r
-\r
-  //\r
-  // Error state\r
-  //\r
-  BOOLEAN                             KeyboardErr;\r
-\r
-  EFI_UNICODE_STRING_TABLE            *ControllerNameTable;\r
-\r
-  EFI_DEVICE_PATH_PROTOCOL            *DevicePath;\r
-  //\r
-  // Notification Function List\r
-  //\r
-  LIST_ENTRY                          NotifyList;\r
-  EFI_EVENT                           KeyNotifyProcessEvent;\r
-} KEYBOARD_CONSOLE_IN_DEV;\r
-\r
-#define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a)  CR (a, KEYBOARD_CONSOLE_IN_DEV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE)\r
-#define TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) \\r
-  CR (a, \\r
-      KEYBOARD_CONSOLE_IN_DEV, \\r
-      ConInEx, \\r
-      KEYBOARD_CONSOLE_IN_DEV_SIGNATURE \\r
-      )\r
-\r
-#define TABLE_END 0x0\r
-\r
-//\r
-// Driver entry point\r
-//\r
-/**\r
-  The user Entry Point for module Ps2Keyboard. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InstallPs2KeyboardDriver (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  );\r
-\r
-#define KEYBOARD_8042_DATA_REGISTER     0x60\r
-#define KEYBOARD_8042_STATUS_REGISTER   0x64\r
-#define KEYBOARD_8042_COMMAND_REGISTER  0x64\r
-\r
-#define KEYBOARD_KBEN                   0xF4\r
-#define KEYBOARD_CMDECHO_ACK            0xFA\r
-\r
-#define KEYBOARD_MAX_TRY                256     // 256\r
-#define KEYBOARD_TIMEOUT                65536   // 0.07s\r
-#define KEYBOARD_WAITFORVALUE_TIMEOUT   1000000 // 1s\r
-#define KEYBOARD_BAT_TIMEOUT            4000000 // 4s\r
-#define KEYBOARD_TIMER_INTERVAL         200000  // 0.02s\r
-#define SCANCODE_EXTENDED0              0xE0\r
-#define SCANCODE_EXTENDED1              0xE1\r
-#define SCANCODE_CTRL_MAKE              0x1D\r
-#define SCANCODE_CTRL_BREAK             0x9D\r
-#define SCANCODE_ALT_MAKE               0x38\r
-#define SCANCODE_ALT_BREAK              0xB8\r
-#define SCANCODE_LEFT_SHIFT_MAKE        0x2A\r
-#define SCANCODE_LEFT_SHIFT_BREAK       0xAA\r
-#define SCANCODE_RIGHT_SHIFT_MAKE       0x36\r
-#define SCANCODE_RIGHT_SHIFT_BREAK      0xB6\r
-#define SCANCODE_CAPS_LOCK_MAKE         0x3A\r
-#define SCANCODE_NUM_LOCK_MAKE          0x45\r
-#define SCANCODE_SCROLL_LOCK_MAKE       0x46\r
-#define SCANCODE_DELETE_MAKE            0x53\r
-#define SCANCODE_LEFT_LOGO_MAKE         0x5B //GUI key defined in Keyboard scan code\r
-#define SCANCODE_LEFT_LOGO_BREAK        0xDB\r
-#define SCANCODE_RIGHT_LOGO_MAKE        0x5C\r
-#define SCANCODE_RIGHT_LOGO_BREAK       0xDC\r
-#define SCANCODE_MENU_MAKE              0x5D //APPS key defined in Keyboard scan code\r
-#define SCANCODE_MENU_BREAK             0xDD\r
-#define SCANCODE_SYS_REQ_MAKE           0x37\r
-#define SCANCODE_SYS_REQ_BREAK          0xB7\r
-#define SCANCODE_SYS_REQ_MAKE_WITH_ALT  0x54\r
-#define SCANCODE_SYS_REQ_BREAK_WITH_ALT 0xD4\r
-\r
-#define SCANCODE_MAX_MAKE               0x60\r
-\r
-\r
-#define KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA     BIT0        ///< 0 - Output register has no data; 1 - Output register has data\r
-#define KEYBOARD_STATUS_REGISTER_HAS_INPUT_DATA      BIT1        ///< 0 - Input register has no data;  1 - Input register has data\r
-#define KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG         BIT2        ///< Set to 0 after power on reset\r
-#define KEYBOARD_STATUS_REGISTER_INPUT_DATA_TYPE     BIT3        ///< 0 - Data in input register is data; 1 - Data in input register is command\r
-#define KEYBOARD_STATUS_REGISTER_ENABLE_FLAG         BIT4        ///< 0 - Keyboard is disable; 1 - Keyboard is enable\r
-#define KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT    BIT5        ///< 0 - Transmit is complete without timeout; 1 - Transmit is timeout without complete\r
-#define KEYBOARD_STATUS_REGISTER_RECEIVE_TIMEOUT     BIT6        ///< 0 - Receive is complete without timeout; 1 - Receive is timeout without complete\r
-#define KEYBOARD_STATUS_REGISTER_PARITY              BIT7        ///< 0 - Odd parity; 1 - Even parity\r
-\r
-#define KEYBOARD_8042_COMMAND_READ                          0x20\r
-#define KEYBOARD_8042_COMMAND_WRITE                         0x60\r
-#define KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE       0xA7\r
-#define KEYBOARD_8042_COMMAND_ENABLE_MOUSE_INTERFACE        0xA8\r
-#define KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST          0xAA\r
-#define KEYBOARD_8042_COMMAND_KEYBOARD_INTERFACE_SELF_TEST  0xAB\r
-#define KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE    0xAD\r
-\r
-#define KEYBOARD_8048_COMMAND_CLEAR_OUTPUT_DATA             0xF4\r
-#define KEYBOARD_8048_COMMAND_RESET                         0xFF\r
-#define KEYBOARD_8048_COMMAND_SELECT_SCAN_CODE_SET          0xF0\r
-\r
-#define KEYBOARD_8048_RETURN_8042_BAT_SUCCESS               0xAA\r
-#define KEYBOARD_8048_RETURN_8042_BAT_ERROR                 0xFC\r
-#define KEYBOARD_8048_RETURN_8042_ACK                       0xFA\r
-\r
-\r
-//\r
-// Keyboard Controller Status\r
-//\r
-#define KBC_PARE  0x80  // Parity Error\r
-#define KBC_TIM   0x40  // General Time Out\r
-\r
-//\r
-// Other functions that are used among .c files\r
-//\r
-/**\r
-  Show keyboard status lights according to\r
-  indicators in ConsoleIn.\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-\r
-  @return status\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateStatusLights (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  );\r
-\r
-/**\r
-  write key to keyboard.\r
-\r
-  @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-  @param Data      value wanted to be written\r
-\r
-  @retval EFI_TIMEOUT - GC_TODO: Add description for return value\r
-  @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardRead (\r
-  IN KEYBOARD_CONSOLE_IN_DEV  *ConsoleIn,\r
-  OUT UINT8                   *Data\r
-  );\r
-\r
-/**\r
-  Get scancode from scancode buffer and translate into EFI-scancode and unicode defined by EFI spec.\r
-\r
-  The function is always called in TPL_NOTIFY.\r
-\r
-  @param ConsoleIn KEYBOARD_CONSOLE_IN_DEV instance pointer\r
-\r
-**/\r
-VOID\r
-KeyGetchar (\r
-  IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  );\r
-\r
-/**\r
-  Process key notify.\r
-\r
-  @param  Event                 Indicates the event that invoke this function.\r
-  @param  Context               Indicates the calling context.\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyNotifyProcessHandler (\r
-  IN  EFI_EVENT                 Event,\r
-  IN  VOID                      *Context\r
-  );\r
-\r
-/**\r
-  Perform 8042 controller and keyboard Initialization.\r
-  If ExtendedVerification is TRUE, do additional test for\r
-  the keyboard interface\r
-\r
-  @param ConsoleIn - KEYBOARD_CONSOLE_IN_DEV instance pointer\r
-  @param ExtendedVerification - indicates a thorough initialization\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to init keyboard\r
-  @retval EFI_SUCCESS      Success to init keyboard\r
-**/\r
-EFI_STATUS\r
-InitKeyboard (\r
-  IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  IN BOOLEAN                     ExtendedVerification\r
-  );\r
-\r
-\r
-\r
-/**\r
-  Timer event handler: read a series of scancodes from 8042\r
-  and put them into memory scancode buffer.\r
-  it read as much scancodes to either fill\r
-  the memory buffer or empty the keyboard buffer.\r
-  It is registered as running under TPL_NOTIFY\r
-\r
-  @param Event - The timer event\r
-  @param Context - A KEYBOARD_CONSOLE_IN_DEV pointer\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyboardTimerHandler (\r
-  IN EFI_EVENT    Event,\r
-  IN VOID         *Context\r
-  );\r
-\r
-/**\r
-  logic reset keyboard\r
-  Implement SIMPLE_TEXT_IN.Reset()\r
-  Perform 8042 controller and keyboard initialization\r
-\r
-  @param This    Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
-  @param ExtendedVerification Indicate that the driver may perform a more\r
-                              exhaustive verification operation of the device during\r
-                              reset, now this par is ignored in this driver\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardEfiReset (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  IN  BOOLEAN                         ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Implement SIMPLE_TEXT_IN.ReadKeyStroke().\r
-  Retrieve key values for driver user.\r
-\r
-  @param This    Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
-  @param Key     The output buffer for key value\r
-\r
-  @retval EFI_SUCCESS success to read key stroke\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardReadKeyStroke (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  OUT EFI_INPUT_KEY                   *Key\r
-  );\r
-\r
-/**\r
-  Event notification function for SIMPLE_TEXT_IN.WaitForKey event\r
-  Signal the event if there is key available\r
-\r
-  @param Event    the event object\r
-  @param Context  waitting context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyboardWaitForKey (\r
-  IN  EFI_EVENT               Event,\r
-  IN  VOID                    *Context\r
-  );\r
-\r
-/**\r
-  Read status register.\r
-\r
-  @param ConsoleIn  Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-\r
-  @return value in status register\r
-\r
-**/\r
-UINT8\r
-KeyReadStatusRegister (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  );\r
-\r
-/**\r
-  Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command\r
-  If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device\r
-  should not be in system.\r
-\r
-  @param[in]  ConsoleIn   Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
-\r
-  @retval     TRUE                  Keyboard in System.\r
-  @retval     FALSE                 Keyboard not in System.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-CheckKeyboardConnect (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  );\r
-\r
-/**\r
-  Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event\r
-  Signal the event if there is key available\r
-\r
-  @param Event    event object\r
-  @param Context  waiting context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyboardWaitForKeyEx (\r
-  IN  EFI_EVENT               Event,\r
-  IN  VOID                    *Context\r
-  );\r
-\r
-//\r
-// Simple Text Input Ex protocol function prototypes\r
-//\r
-\r
-/**\r
-  Reset the input device and optionaly run diagnostics\r
-\r
-  @param This                 - Protocol instance pointer.\r
-  @param ExtendedVerification - Driver may perform diagnostics on reset.\r
-\r
-  @retval EFI_SUCCESS           - The device was reset.\r
-  @retval EFI_DEVICE_ERROR      - The device is not functioning properly and could\r
-                                  not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardEfiResetEx (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN BOOLEAN                            ExtendedVerification\r
-  );\r
-\r
-/**\r
-    Reads the next keystroke from the input device. The WaitForKey Event can\r
-    be used to test for existance of a keystroke via WaitForEvent () call.\r
-\r
-\r
-    @param This       - Protocol instance pointer.\r
-    @param KeyData    - A pointer to a buffer that is filled in with the keystroke\r
-                 state data for the key that was pressed.\r
-\r
-    @retval EFI_SUCCESS           - The keystroke information was returned.\r
-    @retval EFI_NOT_READY         - There was no keystroke data availiable.\r
-    @retval EFI_DEVICE_ERROR      - The keystroke information was not returned due to\r
-                            hardware errors.\r
-    @retval EFI_INVALID_PARAMETER - KeyData is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardReadKeyStrokeEx (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
-  OUT EFI_KEY_DATA                      *KeyData\r
-  );\r
-\r
-/**\r
-  Set certain state for the input device.\r
-\r
-  @param This              - Protocol instance pointer.\r
-  @param KeyToggleState    - A pointer to the EFI_KEY_TOGGLE_STATE to set the\r
-                        state for the input device.\r
-\r
-  @retval EFI_SUCCESS           - The device state was set successfully.\r
-  @retval EFI_DEVICE_ERROR      - The device is not functioning correctly and could\r
-                            not have the setting adjusted.\r
-  @retval EFI_UNSUPPORTED       - The device does not have the ability to set its state.\r
-  @retval EFI_INVALID_PARAMETER - KeyToggleState is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardSetState (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_KEY_TOGGLE_STATE               *KeyToggleState\r
-  );\r
-\r
-/**\r
-    Register a notification function for a particular keystroke for the input device.\r
-\r
-    @param This                    - Protocol instance pointer.\r
-    @param KeyData                 - A pointer to a buffer that is filled in with the keystroke\r
-                                     information data for the key that was pressed. If KeyData.Key,\r
-                                     KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState\r
-                                     are 0, then any incomplete keystroke will trigger a notification of\r
-                                     the KeyNotificationFunction.\r
-    @param KeyNotificationFunction - Points to the function to be called when the key\r
-                                     sequence is typed specified by KeyData. This notification function\r
-                                     should be called at <=TPL_CALLBACK.\r
-    @param NotifyHandle            - Points to the unique handle assigned to the registered notification.\r
-\r
-    @retval EFI_SUCCESS             - The notification function was registered successfully.\r
-    @retval EFI_OUT_OF_RESOURCES    - Unable to allocate resources for necesssary data structures.\r
-    @retval EFI_INVALID_PARAMETER   - KeyData or NotifyHandle is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardRegisterKeyNotify (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_KEY_DATA                       *KeyData,\r
-  IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,\r
-  OUT VOID                              **NotifyHandle\r
-  );\r
-\r
-/**\r
-    Remove a registered notification function from a particular keystroke.\r
-\r
-    @param This                    - Protocol instance pointer.\r
-    @param NotificationHandle      - The handle of the notification function being unregistered.\r
-\r
-\r
-    @retval EFI_SUCCESS             - The notification function was unregistered successfully.\r
-    @retval EFI_INVALID_PARAMETER   - The NotificationHandle is invalid.\r
-    @retval EFI_NOT_FOUND           - Can not find the matching entry in database.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardUnregisterKeyNotify (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN VOID                               *NotificationHandle\r
-  );\r
-\r
-/**\r
-  Push one key data to the EFI key buffer.\r
-\r
-  @param Queue     Pointer to instance of EFI_KEY_QUEUE.\r
-  @param KeyData   The key data to push.\r
-**/\r
-VOID\r
-PushEfikeyBufTail (\r
-  IN  EFI_KEY_QUEUE         *Queue,\r
-  IN  EFI_KEY_DATA          *KeyData\r
-  );\r
-\r
-/**\r
-  Judge whether is a registed key\r
-\r
-  @param RegsiteredData       A pointer to a buffer that is filled in with the keystroke\r
-                              state data for the key that was registered.\r
-  @param InputData            A pointer to a buffer that is filled in with the keystroke\r
-                              state data for the key that was pressed.\r
-\r
-  @retval TRUE                Key be pressed matches a registered key.\r
-  @retval FLASE               Match failed.\r
-\r
-**/\r
-BOOLEAN\r
-IsKeyRegistered (\r
-  IN EFI_KEY_DATA  *RegsiteredData,\r
-  IN EFI_KEY_DATA  *InputData\r
-  );\r
-\r
-/**\r
-  Initialize the key state.\r
-\r
-  @param  ConsoleIn     The KEYBOARD_CONSOLE_IN_DEV instance.\r
-  @param  KeyState      A pointer to receive the key state information.\r
-**/\r
-VOID\r
-InitializeKeyState (\r
-  IN  KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
-  OUT EFI_KEY_STATE           *KeyState\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.uni
deleted file mode 100644 (file)
index c592058..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// /** @file\r
-// Ps2 Keyboard Driver.\r
-//\r
-// Ps2 Keyboard Driver for UEFI. The keyboard type implemented follows IBM\r
-// compatible PS2 protocol using Scan Code Set 1.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Ps2 Keyboard Driver"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Ps2 Keyboard Driver for UEFI. The keyboard type implemented follows IBM compatible PS2 protocol using Scan Code Set 1."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxeExtra.uni
deleted file mode 100644 (file)
index 53e1a2f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// Ps2KeyboardDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"PS2 Keyboard DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
deleted file mode 100644 (file)
index 01a1fe1..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-## @file\r
-# Ps2 Keyboard Driver.\r
-#\r
-# Ps2 Keyboard Driver for UEFI. The keyboard type implemented follows IBM\r
-# compatible PS2 protocol using Scan Code Set 1.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = Ps2KeyboardDxe\r
-  MODULE_UNI_FILE                = Ps2KeyboardDxe.uni\r
-  FILE_GUID                      = 3DC82376-637B-40a6-A8FC-A565417F2C38\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializePs2Keyboard\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#  DRIVER_BINDING                = gKeyboardControllerDriver;\r
-#  COMPONENT_NAME                = gPs2KeyboardComponentName;\r
-#  COMPONENT_NAME2               = gPs2KeyboardComponentName2;\r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  Ps2Keyboard.h\r
-  Ps2KbdCtrller.c\r
-  Ps2KbdTextIn.c\r
-  Ps2Keyboard.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  MemoryAllocationLib\r
-  UefiRuntimeServicesTableLib\r
-  DebugLib\r
-  ReportStatusCodeLib\r
-  UefiBootServicesTableLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  BaseLib\r
-  BaseMemoryLib\r
-  TimerLib\r
-  PcdLib\r
-\r
-[Protocols]\r
-  gEfiSimpleTextInProtocolGuid                  ## BY_START\r
-  gEfiSimpleTextInputExProtocolGuid             ## BY_START\r
-  gEfiPs2PolicyProtocolGuid                     ## SOMETIMES_CONSUMES\r
-  gEfiIsaIoProtocolGuid                         ## TO_START\r
-  gEfiDevicePathProtocolGuid                    ## TO_START\r
-\r
-[FeaturePcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification   ## CONSUMES\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFastPS2Detection             ## SOMETIMES_CONSUMES\r
-\r
-#\r
-# [Event]\r
-#\r
-#   ##\r
-#   # Timer event used to read key strokes at a regular interval.\r
-#   #\r
-#   EVENT_TYPE_PERIODIC_TIMER   ## CONSUMES\r
-#\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  Ps2KeyboardDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.c
deleted file mode 100644 (file)
index 080b442..0000000
+++ /dev/null
@@ -1,917 +0,0 @@
-/** @file\r
-  PS2 Mouse Communication Interface.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ps2MouseAbsolutePointer.h"\r
-#include "CommPs2.h"\r
-\r
-UINT8 SampleRateTbl[MaxSampleRate]  = { 0xa, 0x14, 0x28, 0x3c, 0x50, 0x64, 0xc8 };\r
-\r
-UINT8 ResolutionTbl[MaxResolution]  = { 0, 1, 2, 3 };\r
-\r
-/**\r
-  Issue self test command via IsaIo interface.\r
-\r
-  @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return EFI_SUCCESS  Success to do keyboard self testing.\r
-  @return others       Fail to do keyboard self testing.\r
-**/\r
-EFI_STATUS\r
-KbcSelfTest (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Keyboard controller self test\r
-  //\r
-  Status = Out8042Command (IsaIo, SELF_TEST);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Read return code\r
-  //\r
-  Status = In8042Data (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (Data != 0x55) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Set system flag\r
-  //\r
-  Status = Out8042Command (IsaIo, READ_CMD_BYTE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = In8042Data (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = Out8042Command (IsaIo, WRITE_CMD_BYTE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Data |= CMD_SYS_FLAG;\r
-  Status = Out8042Data (IsaIo, Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Issue command to enable keyboard AUX functionality.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableAux (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send 8042 enable mouse command\r
-  //\r
-  return Out8042Command (IsaIo, ENABLE_AUX);\r
-}\r
-\r
-/**\r
-  Issue command to disable keyboard AUX functionality.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableAux (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send 8042 disable mouse command\r
-  //\r
-  return Out8042Command (IsaIo, DISABLE_AUX);\r
-}\r
-\r
-/**\r
-  Issue command to enable keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableKb (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send 8042 enable keyboard command\r
-  //\r
-  return Out8042Command (IsaIo, ENABLE_KB);\r
-}\r
-\r
-/**\r
-  Issue command to disable keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableKb (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send 8042 disable keyboard command\r
-  //\r
-  return Out8042Command (IsaIo, DISABLE_KB);\r
-}\r
-\r
-/**\r
-  Issue command to check keyboard status.\r
-\r
-  @param IsaIo          Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param KeyboardEnable return whether keyboard is enable.\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-CheckKbStatus (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  OUT BOOLEAN                             *KeyboardEnable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Send command to read KBC command byte\r
-  //\r
-  Status = Out8042Command (IsaIo, READ_CMD_BYTE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = In8042Data (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check keyboard enable or not\r
-  //\r
-  if ((Data & CMD_KB_STS) == CMD_KB_DIS) {\r
-    *KeyboardEnable = FALSE;\r
-  } else {\r
-    *KeyboardEnable = TRUE;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Issue command to reset keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseReset (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  Status = Out8042AuxCommand (IsaIo, RESET_CMD, FALSE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = In8042AuxData (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check BAT Complete Code\r
-  //\r
-  if (Data != PS2MOUSE_BAT1) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Status = In8042AuxData (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check BAT Complete Code\r
-  //\r
-  if (Data != PS2MOUSE_BAT2) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Issue command to set mouse's sample rate\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param SampleRate value of sample rate\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetSampleRate (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_SR                             SampleRate\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Send auxiliary command to set mouse sample rate\r
-  //\r
-  Status = Out8042AuxCommand (IsaIo, SETSR_CMD, FALSE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = Out8042AuxData (IsaIo, SampleRateTbl[SampleRate]);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Issue command to set mouse's resolution.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Resolution value of resolution\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetResolution (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_RE                             Resolution\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Send auxiliary command to set mouse resolution\r
-  //\r
-  Status = Out8042AuxCommand (IsaIo, SETRE_CMD, FALSE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = Out8042AuxData (IsaIo, ResolutionTbl[Resolution]);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Issue command to set mouse's scaling.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Scaling value of scaling\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetScaling (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_SF                             Scaling\r
-  )\r
-{\r
-  UINT8 Command;\r
-\r
-  Command = (UINT8) (Scaling == Scaling1 ? SETSF1_CMD : SETSF2_CMD);\r
-\r
-  //\r
-  // Send auxiliary command to set mouse scaling data\r
-  //\r
-  return Out8042AuxCommand (IsaIo, Command, FALSE);\r
-}\r
-\r
-/**\r
-  Issue command to enable Ps2 mouse.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseEnable (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send auxiliary command to enable mouse\r
-  //\r
-  return Out8042AuxCommand (IsaIo, ENABLE_CMD, FALSE);\r
-}\r
-\r
-/**\r
-  Get mouse packet . Only care first 3 bytes\r
-\r
-  @param MouseAbsolutePointerDev  Pointer to PS2 Absolute Pointer Simulation Device Private Data Structure\r
-\r
-  @retval EFI_NOT_READY  Mouse Device not ready to input data packet, or some error happened during getting the packet\r
-  @retval EFI_SUCCESS    The data packet is gotten successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-PS2MouseGetPacket (\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV     *MouseAbsolutePointerDev\r
-  )\r
-\r
-{\r
-  EFI_STATUS  Status;\r
-  BOOLEAN     KeyboardEnable;\r
-  UINT8       Packet[PS2_PACKET_LENGTH];\r
-  UINT8       Data;\r
-  UINTN       Count;\r
-  UINTN       State;\r
-  INT16       RelativeMovementX;\r
-  INT16       RelativeMovementY;\r
-  BOOLEAN     LButton;\r
-  BOOLEAN     RButton;\r
-\r
-  KeyboardEnable  = FALSE;\r
-  Count           = 1;\r
-  State           = PS2_READ_BYTE_ONE;\r
-\r
-  //\r
-  // State machine to get mouse packet\r
-  //\r
-  while (1) {\r
-\r
-    switch (State) {\r
-    case PS2_READ_BYTE_ONE:\r
-      //\r
-      // Read mouse first byte data, if failed, immediately return\r
-      //\r
-      KbcDisableAux (MouseAbsolutePointerDev->IsaIo);\r
-      Status = PS2MouseRead (MouseAbsolutePointerDev->IsaIo, &Data, &Count, State);\r
-      if (EFI_ERROR (Status)) {\r
-        KbcEnableAux (MouseAbsolutePointerDev->IsaIo);\r
-        return EFI_NOT_READY;\r
-      }\r
-\r
-      if (Count != 1) {\r
-        KbcEnableAux (MouseAbsolutePointerDev->IsaIo);\r
-        return EFI_NOT_READY;\r
-      }\r
-\r
-      if (IS_PS2_SYNC_BYTE (Data)) {\r
-        Packet[0] = Data;\r
-        State     = PS2_READ_DATA_BYTE;\r
-\r
-        CheckKbStatus (MouseAbsolutePointerDev->IsaIo, &KeyboardEnable);\r
-        KbcDisableKb (MouseAbsolutePointerDev->IsaIo);\r
-        KbcEnableAux (MouseAbsolutePointerDev->IsaIo);\r
-      }\r
-      break;\r
-\r
-    case PS2_READ_DATA_BYTE:\r
-      Count   = 2;\r
-      Status  = PS2MouseRead (MouseAbsolutePointerDev->IsaIo, (Packet + 1), &Count, State);\r
-      if (EFI_ERROR (Status)) {\r
-        if (KeyboardEnable) {\r
-          KbcEnableKb (MouseAbsolutePointerDev->IsaIo);\r
-        }\r
-\r
-        return EFI_NOT_READY;\r
-      }\r
-\r
-      if (Count != 2) {\r
-        if (KeyboardEnable) {\r
-          KbcEnableKb (MouseAbsolutePointerDev->IsaIo);\r
-        }\r
-\r
-        return EFI_NOT_READY;\r
-      }\r
-\r
-      State = PS2_PROCESS_PACKET;\r
-      break;\r
-\r
-    case PS2_PROCESS_PACKET:\r
-      if (KeyboardEnable) {\r
-        KbcEnableKb (MouseAbsolutePointerDev->IsaIo);\r
-      }\r
-      //\r
-      // Decode the packet\r
-      //\r
-      RelativeMovementX = Packet[1];\r
-      RelativeMovementY = Packet[2];\r
-      //\r
-      //               Bit 7   |    Bit 6   |    Bit 5   |   Bit 4    |   Bit 3  |   Bit 2    |   Bit 1   |   Bit 0\r
-      //  Byte 0  | Y overflow | X overflow | Y sign bit | X sign bit | Always 1 | Middle Btn | Right Btn | Left Btn\r
-      //  Byte 1  |                                           8 bit X Movement\r
-      //  Byte 2  |                                           8 bit Y Movement\r
-      //\r
-      // X sign bit + 8 bit X Movement : 9-bit signed twos complement integer that presents the relative displacement of the device in the X direction since the last data transmission.\r
-      // Y sign bit + 8 bit Y Movement : Same as X sign bit + 8 bit X Movement.\r
-      //\r
-      //\r
-      // First, Clear X and Y high 8 bits\r
-      //\r
-      RelativeMovementX = (INT16) (RelativeMovementX & 0xFF);\r
-      RelativeMovementY = (INT16) (RelativeMovementY & 0xFF);\r
-      //\r
-      // Second, if the 9-bit signed twos complement integer is negative, set the high 8 bit 0xff\r
-      //\r
-      if ((Packet[0] & 0x10) != 0) {\r
-        RelativeMovementX = (INT16) (RelativeMovementX | 0xFF00);\r
-      }\r
-      if ((Packet[0] & 0x20) != 0) {\r
-        RelativeMovementY = (INT16) (RelativeMovementY | 0xFF00);\r
-      }\r
-\r
-\r
-      RButton           = (UINT8) (Packet[0] & 0x2);\r
-      LButton           = (UINT8) (Packet[0] & 0x1);\r
-\r
-      //\r
-      // Update mouse state\r
-      //\r
-      MouseAbsolutePointerDev->State.CurrentX += RelativeMovementX;\r
-      MouseAbsolutePointerDev->State.CurrentY -= RelativeMovementY;\r
-      MouseAbsolutePointerDev->State.CurrentZ = 0;\r
-      MouseAbsolutePointerDev->State.ActiveButtons = (UINT8) (LButton || RButton) & 0x3;\r
-      MouseAbsolutePointerDev->StateChanged      = TRUE;\r
-\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Read data via IsaIo protocol with given number.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Buffer  Buffer receive data of mouse\r
-  @param BufSize The size of buffer\r
-  @param State   Check input or read data\r
-\r
-  @return status of reading mouse data.\r
-**/\r
-EFI_STATUS\r
-PS2MouseRead (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  OUT VOID                                *Buffer,\r
-  IN OUT UINTN                            *BufSize,\r
-  IN  UINTN                               State\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       BytesRead;\r
-\r
-  Status    = EFI_SUCCESS;\r
-  BytesRead = 0;\r
-\r
-  if (State == PS2_READ_BYTE_ONE) {\r
-    //\r
-    // Check input for mouse\r
-    //\r
-    Status = CheckForInput (IsaIo);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  while (BytesRead < *BufSize) {\r
-\r
-    Status = WaitOutputFull (IsaIo, TIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Buffer);\r
-\r
-    BytesRead++;\r
-    Buffer = (UINT8 *) Buffer + 1;\r
-  }\r
-  //\r
-  // Verify the correct number of bytes read\r
-  //\r
-  if (BytesRead == 0 || BytesRead != *BufSize) {\r
-    Status = EFI_NOT_FOUND;\r
-  }\r
-\r
-  *BufSize = BytesRead;\r
-  return Status;\r
-}\r
-\r
-//\r
-// 8042 I/O function\r
-//\r
-/**\r
-  I/O work flow of outing 8042 command.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Command I/O command.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Command (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Command\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Wait keyboard controller input buffer empty\r
-  //\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Send command\r
-  //\r
-  Data = Command;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of outing 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Data\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Temp;\r
-  //\r
-  // Wait keyboard controller input buffer empty\r
-  //\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Temp = Data;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of in 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  )\r
-{\r
-  UINTN Delay;\r
-  UINT8 Temp;\r
-\r
-  Delay = TIMEOUT / 50;\r
-\r
-  do {\r
-    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);\r
-\r
-    //\r
-    // Check keyboard controller status bit 0(output buffer status)\r
-    //\r
-    if ((Temp & KBC_OUTB) == KBC_OUTB) {\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (50);\r
-    Delay--;\r
-  } while (Delay != 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of outing 8042 Aux command.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Command Aux I/O command\r
-  @param Resend  Whether need resend the Aux command.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxCommand (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Command,\r
-  IN BOOLEAN                              Resend\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Wait keyboard controller input buffer empty\r
-  //\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Send write to auxiliary device command\r
-  //\r
-  Data = WRITE_AUX_DEV;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Send auxiliary device command\r
-  //\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Command);\r
-\r
-  //\r
-  // Read return code\r
-  //\r
-  Status = In8042AuxData (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (Data == PS2_ACK) {\r
-    //\r
-    // Receive mouse acknowledge, command send success\r
-    //\r
-    return EFI_SUCCESS;\r
-\r
-  } else if (Resend) {\r
-    //\r
-    // Resend fail\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
-\r
-  } else if (Data == PS2_RESEND) {\r
-    //\r
-    // Resend command\r
-    //\r
-    Status = Out8042AuxCommand (IsaIo, Command, TRUE);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-  } else {\r
-    //\r
-    // Invalid return code\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
-\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of outing 8042 Aux data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Buffer holding return value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow.\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxData (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Data\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Temp;\r
-  //\r
-  // Wait keyboard controller input buffer empty\r
-  //\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Send write to auxiliary device command\r
-  //\r
-  Temp = WRITE_AUX_DEV;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Temp = Data;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of in 8042 Aux data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Buffer holding return value.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042AuxData (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // wait for output data\r
-  //\r
-  Status = WaitOutputFull (IsaIo, BAT_TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Check keyboard controller status, if it is output buffer full and for auxiliary device.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @retval EFI_SUCCESS   Keyboard controller is ready\r
-  @retval EFI_NOT_READY Keyboard controller is not ready\r
-**/\r
-EFI_STATUS\r
-CheckForInput (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-  //\r
-  // Check keyboard controller status, if it is output buffer full and for auxiliary device\r
-  //\r
-  if ((Data & (KBC_OUTB | KBC_AUXB)) != (KBC_OUTB | KBC_AUXB)) {\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow to wait input buffer empty in given time.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Timeout Wating time.\r
-\r
-  @retval EFI_TIMEOUT if input is still not empty in given time.\r
-  @retval EFI_SUCCESS input is empty.\r
-**/\r
-EFI_STATUS\r
-WaitInputEmpty (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINTN                                Timeout\r
-  )\r
-{\r
-  UINTN Delay;\r
-  UINT8 Data;\r
-\r
-  Delay = Timeout / 50;\r
-\r
-  do {\r
-    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-    //\r
-    // Check keyboard controller status bit 1(input buffer status)\r
-    //\r
-    if ((Data & KBC_INPB) == 0) {\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (50);\r
-    Delay--;\r
-  } while (Delay != 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow to wait output buffer full in given time.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Timeout given time\r
-\r
-  @retval EFI_TIMEOUT  output is not full in given time\r
-  @retval EFI_SUCCESS  output is full in given time.\r
-**/\r
-EFI_STATUS\r
-WaitOutputFull (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINTN                                Timeout\r
-  )\r
-{\r
-  UINTN Delay;\r
-  UINT8 Data;\r
-\r
-  Delay = Timeout / 50;\r
-\r
-  do {\r
-    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-    //\r
-    // Check keyboard controller status bit 0(output buffer status)\r
-    //  & bit5(output buffer for auxiliary device)\r
-    //\r
-    if ((Data & (KBC_OUTB | KBC_AUXB)) == (KBC_OUTB | KBC_AUXB)) {\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (50);\r
-    Delay--;\r
-  } while (Delay != 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.h
deleted file mode 100644 (file)
index de9d8cc..0000000
+++ /dev/null
@@ -1,429 +0,0 @@
-/** @file\r
-  Using PS2 Mouse to simulation Absolution Pointer Device.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __COMMPS2_H__\r
-#define __COMMPS2_H__\r
-\r
-#define PS2_PACKET_LENGTH       3\r
-#define PS2_SYNC_MASK           0xc\r
-#define PS2_SYNC_BYTE           0x8\r
-\r
-#define IS_PS2_SYNC_BYTE(byte)  ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)\r
-\r
-#define PS2_READ_BYTE_ONE       0\r
-#define PS2_READ_DATA_BYTE      1\r
-#define PS2_PROCESS_PACKET      2\r
-\r
-#define TIMEOUT                 50000\r
-#define BAT_TIMEOUT             500000\r
-\r
-//\r
-// 8042 I/O Port\r
-//\r
-#define KBC_DATA_PORT     0x60\r
-#define KBC_CMD_STS_PORT  0x64\r
-\r
-//\r
-// 8042 Command\r
-//\r
-#define READ_CMD_BYTE   0x20\r
-#define WRITE_CMD_BYTE  0x60\r
-#define DISABLE_AUX     0xa7\r
-#define ENABLE_AUX      0xa8\r
-#define SELF_TEST       0xaa\r
-#define DISABLE_KB      0xad\r
-#define ENABLE_KB       0xae\r
-#define WRITE_AUX_DEV   0xd4\r
-\r
-#define CMD_SYS_FLAG    0x04\r
-#define CMD_KB_STS      0x10\r
-#define CMD_KB_DIS      0x10\r
-#define CMD_KB_EN       0x0\r
-\r
-//\r
-// 8042 Auxiliary Device Command\r
-//\r
-#define SETSF1_CMD  0xe6\r
-#define SETSF2_CMD  0xe7\r
-#define SETRE_CMD   0xe8\r
-#define READ_CMD    0xeb\r
-#define SETRM_CMD   0xf0\r
-#define SETSR_CMD   0xf3\r
-#define ENABLE_CMD  0xf4\r
-#define DISABLE_CMD 0xf5\r
-#define RESET_CMD   0xff\r
-\r
-//\r
-// return code\r
-//\r
-#define PS2_ACK       0xfa\r
-#define PS2_RESEND    0xfe\r
-#define PS2MOUSE_BAT1 0xaa\r
-#define PS2MOUSE_BAT2 0x0\r
-\r
-//\r
-// Keyboard Controller Status\r
-//\r
-///\r
-/// Parity Error\r
-///\r
-#define KBC_PARE  0x80\r
-///\r
-/// General Time Out\r
-///\r
-#define KBC_TIM   0x40\r
-///\r
-/// Output buffer for auxiliary device (PS/2):\r
-///    0 - Holds keyboard data\r
-///    1 - Holds data for auxiliary device\r
-///\r
-#define KBC_AUXB  0x20\r
-///\r
-/// Keyboard lock status:\r
-///    0 - keyboard locked\r
-///    1 - keyboard free\r
-///\r
-#define KBC_KEYL  0x10\r
-///\r
-/// Command/Data:\r
-///    0 - data byte written via port 60h\r
-///    1 - command byte written via port 64h\r
-///\r
-#define KBC_CD  0x08\r
-///\r
-/// System Flag:\r
-///    0 - power-on reset\r
-///    1 - self-test successful\r
-///\r
-#define KBC_SYSF  0x04\r
-///\r
-/// Input Buffer Status :\r
-///    0 - input buffer empty\r
-///    1 - CPU data in input buffer\r
-///\r
-#define KBC_INPB  0x02\r
-///\r
-/// Output Buffer Status :\r
-///    0 - output buffer empty\r
-///    1 - keyboard controller data in output buffer\r
-///\r
-#define KBC_OUTB  0x01\r
-\r
-/**\r
-  Issue self test command via IsaIo interface.\r
-\r
-  @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return EFI_SUCCESS  Success to do keyboard self testing.\r
-  @return others       Fail to do keyboard self testing.\r
-**/\r
-EFI_STATUS\r
-KbcSelfTest (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to enable keyboard AUX functionality.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableAux (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to disable keyboard AUX functionality.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableAux (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to enable keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableKb (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to disable keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableKb (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to check keyboard status.\r
-\r
-  @param IsaIo          Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param KeyboardEnable return whether keyboard is enable.\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-CheckKbStatus (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  OUT BOOLEAN                             *KeyboardEnable\r
-  );\r
-\r
-/**\r
-  Issue command to reset keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseReset (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to set mouse's sample rate\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param SampleRate value of sample rate\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetSampleRate (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_SR                             SampleRate\r
-  );\r
-\r
-/**\r
-  Issue command to set mouse's resolution.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Resolution value of resolution\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetResolution (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_RE                             Resolution\r
-  );\r
-\r
-/**\r
-  Issue command to set mouse's scaling.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Scaling value of scaling\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetScaling (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_SF                             Scaling\r
-  );\r
-\r
-/**\r
-  Issue command to enable Ps2 mouse.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseEnable (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Get mouse packet . Only care first 3 bytes\r
-\r
-  @param MouseAbsolutePointerDev  Pointer to PS2 Absolute Pointer Simulation Device Private Data Structure\r
-\r
-  @retval EFI_NOT_READY  Mouse Device not ready to input data packet, or some error happened during getting the packet\r
-  @retval EFI_SUCCESS    The data packet is gotten successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-PS2MouseGetPacket (\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV     *MouseAbsolutePointerDev\r
-  );\r
-\r
-/**\r
-  Read data via IsaIo protocol with given number.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Buffer  Buffer receive data of mouse\r
-  @param BufSize The size of buffer\r
-  @param State   Check input or read data\r
-\r
-  @return status of reading mouse data.\r
-**/\r
-EFI_STATUS\r
-PS2MouseRead (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  OUT VOID                                *Buffer,\r
-  IN OUT UINTN                            *BufSize,\r
-  IN  UINTN                               State\r
-  );\r
-\r
-//\r
-// 8042 I/O function\r
-//\r
-/**\r
-  I/O work flow of outing 8042 command.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Command I/O command.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Command (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Command\r
-  );\r
-\r
-/**\r
-  I/O work flow of in 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  );\r
-\r
-/**\r
-  I/O work flow of outing 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Data\r
-  );\r
-\r
-/**\r
-  I/O work flow of outing 8042 Aux command.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Command Aux I/O command\r
-  @param Resend  Whether need resend the Aux command.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxCommand (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Command,\r
-  IN BOOLEAN                              Resend\r
-  );\r
-\r
-/**\r
-  I/O work flow of in 8042 Aux data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Buffer holding return value.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042AuxData (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  );\r
-\r
-/**\r
-  I/O work flow of outing 8042 Aux data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Buffer holding return value.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxData (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Data\r
-  );\r
-\r
-/**\r
-  Check keyboard controller status, if it is output buffer full and for auxiliary device.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @retval EFI_SUCCESS   Keyboard controller is ready\r
-  @retval EFI_NOT_READY Keyboard controller is not ready\r
-**/\r
-EFI_STATUS\r
-CheckForInput (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  I/O work flow to wait input buffer empty in given time.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Timeout Wating time.\r
-\r
-  @retval EFI_TIMEOUT if input is still not empty in given time.\r
-  @retval EFI_SUCCESS input is empty.\r
-**/\r
-EFI_STATUS\r
-WaitInputEmpty (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINTN                                Timeout\r
-  );\r
-\r
-/**\r
-  I/O work flow to wait output buffer full in given time.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Timeout given time\r
-\r
-  @retval EFI_TIMEOUT  output is not full in given time\r
-  @retval EFI_SUCCESS  output is full in given time.\r
-**/\r
-EFI_STATUS\r
-WaitOutputFull (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINTN                                Timeout\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/ComponentName.c
deleted file mode 100644 (file)
index 5ae4301..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/** @file\r
-  UEFI Component Name(2) protocol implementation for Ps2 Absolute Pointer Simulation Dxe driver.\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ps2MouseAbsolutePointer.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gPs2MouseAbsolutePointerComponentName = {\r
-  Ps2MouseAbsolutePointerComponentNameGetDriverName,\r
-  Ps2MouseAbsolutePointerComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseAbsolutePointerComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2MouseAbsolutePointerComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2MouseAbsolutePointerComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2MouseAbsolutePointerDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"faked PS/2 Touchpad Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2MouseAbsolutePointerComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mPs2MouseAbsolutePointerDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gPs2MouseAbsolutePointerComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2MouseAbsolutePointerComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS                                  Status;\r
-  EFI_ABSOLUTE_POINTER_PROTOCOL               *AbsolutePointerProtocol;\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV             *MouseAbsolutePointerDev;\r
-  EFI_ISA_IO_PROTOCOL                         *IsaIoProtocol;\r
-\r
-  //\r
-  // This is a device driver, so ChildHandle must be NULL.\r
-  //\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Check Controller's handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIoProtocol,\r
-                  gPS2MouseAbsolutePointerDriver.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           ControllerHandle,\r
-           &gEfiIsaIoProtocolGuid,\r
-           gPS2MouseAbsolutePointerDriver.DriverBindingHandle,\r
-           ControllerHandle\r
-           );\r
-\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (Status != EFI_ALREADY_STARTED) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Get the device context\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiAbsolutePointerProtocolGuid,\r
-                  (VOID **) &AbsolutePointerProtocol,\r
-                  gPS2MouseAbsolutePointerDriver.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  MouseAbsolutePointerDev = PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS (AbsolutePointerProtocol);\r
-\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           MouseAbsolutePointerDev->ControllerNameTable,\r
-           ControllerName,\r
-           (BOOLEAN)(This == &gPs2MouseAbsolutePointerComponentName)\r
-           );\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.c
deleted file mode 100644 (file)
index 52cd5c2..0000000
+++ /dev/null
@@ -1,772 +0,0 @@
-/** @file\r
-  A faked PS/2 Absolute Pointer driver. Routines that interacts with callers,\r
-  conforming to EFI driver model\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ps2MouseAbsolutePointer.h"\r
-#include "CommPs2.h"\r
-\r
-//\r
-// DriverBinding Protocol Instance\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gPS2MouseAbsolutePointerDriver = {\r
-  PS2MouseAbsolutePointerDriverSupported,\r
-  PS2MouseAbsolutePointerDriverStart,\r
-  PS2MouseAbsolutePointerDriverStop,\r
-  0x1,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-/**\r
-  Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
-  than contains a IsaIo protocol can be supported.\r
-\r
-  @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
-  @retval other               This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseAbsolutePointerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Use the ISA I/O Protocol to see if Controller is the Mouse controller\r
-  //\r
-  switch (IsaIo->ResourceList->Device.HID) {\r
-  case EISA_PNP_ID (0xF03):\r
-  //\r
-  // Microsoft PS/2 style mouse\r
-  //\r
-  case EISA_PNP_ID (0xF13):\r
-    //\r
-    // PS/2 Port for PS/2-style Mice\r
-    //\r
-    break;\r
-\r
-  case EISA_PNP_ID (0x303):\r
-    //\r
-    // IBM Enhanced (101/102-key, PS/2 mouse support)\r
-    //\r
-    if (IsaIo->ResourceList->Device.UID == 1) {\r
-      break;\r
-    }\r
-\r
-  default:\r
-    Status = EFI_UNSUPPORTED;\r
-    break;\r
-  }\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Start this driver on ControllerHandle by opening a IsaIo protocol, creating\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid\r
-  finally.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
-                               device to start.\r
-\r
-  @retval EFI_SUCCESS          This driver is added to ControllerHandle\r
-  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
-  @retval other                This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseAbsolutePointerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_STATUS                          EmptyStatus;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV     *MouseAbsolutePointerDev;\r
-  UINT8                               Data;\r
-  EFI_TPL                             OldTpl;\r
-  EFI_STATUS_CODE_VALUE               StatusCode;\r
-  EFI_DEVICE_PATH_PROTOCOL            *ParentDevicePath;\r
-\r
-  StatusCode  = 0;\r
-  MouseAbsolutePointerDev    = NULL;\r
-  IsaIo       = NULL;\r
-\r
-  //\r
-  // Open the device path protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Report that the keyboard is being enabled\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_ENABLE,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Get the ISA I/O Protocol on Controller's handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Raise TPL to avoid keyboard operation impact\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // Allocate private data\r
-  //\r
-  MouseAbsolutePointerDev = AllocateZeroPool (sizeof (PS2_MOUSE_ABSOLUTE_POINTER_DEV));\r
-  if (MouseAbsolutePointerDev == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ErrorExit;\r
-  }\r
-  //\r
-  // Setup the device instance\r
-  //\r
-  MouseAbsolutePointerDev->Signature       = PS2_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE;\r
-  MouseAbsolutePointerDev->Handle          = Controller;\r
-  MouseAbsolutePointerDev->SampleRate      = SampleRate20;\r
-  MouseAbsolutePointerDev->Resolution      = MouseResolution4;\r
-  MouseAbsolutePointerDev->Scaling         = Scaling1;\r
-  MouseAbsolutePointerDev->DataPackageSize = 3;\r
-  MouseAbsolutePointerDev->IsaIo           = IsaIo;\r
-  MouseAbsolutePointerDev->DevicePath      = ParentDevicePath;\r
-\r
-  //\r
-  // Resolution = 4 counts/mm\r
-  //\r
-  MouseAbsolutePointerDev->Mode.AbsoluteMaxX               = 1024;\r
-  MouseAbsolutePointerDev->Mode.AbsoluteMinX               = 0;\r
-  MouseAbsolutePointerDev->Mode.AbsoluteMaxY               = 798;\r
-  MouseAbsolutePointerDev->Mode.AbsoluteMinY               = 0;\r
-  MouseAbsolutePointerDev->Mode.AbsoluteMaxZ               = 0;\r
-  MouseAbsolutePointerDev->Mode.AbsoluteMinZ               = 0;\r
-  MouseAbsolutePointerDev->Mode.Attributes                 = 0x03;\r
-\r
-  MouseAbsolutePointerDev->AbsolutePointerProtocol.Reset     = MouseAbsolutePointerReset;\r
-  MouseAbsolutePointerDev->AbsolutePointerProtocol.GetState  = MouseAbsolutePointerGetState;\r
-  MouseAbsolutePointerDev->AbsolutePointerProtocol.Mode      = &(MouseAbsolutePointerDev->Mode);\r
-\r
-  //\r
-  // Initialize keyboard controller if necessary\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_MOUSE_PC_SELF_TEST,\r
-    ParentDevicePath\r
-    );\r
-\r
-  IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-  if ((Data & KBC_SYSF) != KBC_SYSF) {\r
-    Status = KbcSelfTest (IsaIo);\r
-    if (EFI_ERROR (Status)) {\r
-      StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_CONTROLLER_ERROR;\r
-      goto ErrorExit;\r
-    }\r
-  }\r
-\r
-  KbcEnableAux (IsaIo);\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_PRESENCE_DETECT,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Reset the mouse\r
-  //\r
-  Status = MouseAbsolutePointerDev->AbsolutePointerProtocol.Reset (\r
-                     &MouseAbsolutePointerDev->AbsolutePointerProtocol,\r
-                     FeaturePcdGet (PcdPs2MouseExtendedVerification)\r
-                     );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // mouse not connected\r
-    //\r
-    Status      = EFI_SUCCESS;\r
-    StatusCode  = EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_DETECTED,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Setup the WaitForKey event\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_WAIT,\r
-                  TPL_NOTIFY,\r
-                  MouseAbsolutePointerWaitForInput,\r
-                  MouseAbsolutePointerDev,\r
-                  &((MouseAbsolutePointerDev->AbsolutePointerProtocol).WaitForInput)\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ErrorExit;\r
-  }\r
-  //\r
-  // Setup a periodic timer, used to poll mouse state\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  PollMouseAbsolutePointer,\r
-                  MouseAbsolutePointerDev,\r
-                  &MouseAbsolutePointerDev->TimerEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ErrorExit;\r
-  }\r
-  //\r
-  // Start timer to poll mouse (100 samples per second)\r
-  //\r
-  Status = gBS->SetTimer (MouseAbsolutePointerDev->TimerEvent, TimerPeriodic, 100000);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  MouseAbsolutePointerDev->ControllerNameTable = NULL;\r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gPs2MouseAbsolutePointerComponentName.SupportedLanguages,\r
-    &MouseAbsolutePointerDev->ControllerNameTable,\r
-    L"Faked PS/2 Touchpad Device",\r
-    TRUE\r
-    );\r
-  AddUnicodeString2 (\r
-    "en",\r
-    gPs2MouseAbsolutePointerComponentName2.SupportedLanguages,\r
-    &MouseAbsolutePointerDev->ControllerNameTable,\r
-    L"Faked PS/2 Touchpad Device",\r
-    FALSE\r
-    );\r
-\r
-\r
-  //\r
-  // Install protocol interfaces for the mouse device.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiAbsolutePointerProtocolGuid,\r
-                  &MouseAbsolutePointerDev->AbsolutePointerProtocol,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrorExit;\r
-  }\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-\r
-ErrorExit:\r
-\r
-  KbcDisableAux (IsaIo);\r
-\r
-  if (StatusCode != 0) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      StatusCode,\r
-      ParentDevicePath\r
-      );\r
-  }\r
-\r
-  if ((MouseAbsolutePointerDev != NULL) && (MouseAbsolutePointerDev->AbsolutePointerProtocol.WaitForInput != NULL)) {\r
-    gBS->CloseEvent (MouseAbsolutePointerDev->AbsolutePointerProtocol.WaitForInput);\r
-  }\r
-\r
-  if ((MouseAbsolutePointerDev != NULL) && (MouseAbsolutePointerDev->TimerEvent != NULL)) {\r
-    gBS->CloseEvent (MouseAbsolutePointerDev->TimerEvent);\r
-  }\r
-\r
-  if ((MouseAbsolutePointerDev != NULL) && (MouseAbsolutePointerDev->ControllerNameTable != NULL)) {\r
-    FreeUnicodeStringTable (MouseAbsolutePointerDev->ControllerNameTable);\r
-  }\r
-  //\r
-  // Since there will be no timer handler for mouse input any more,\r
-  // exhaust input data just in case there is still mouse data left\r
-  //\r
-  EmptyStatus = EFI_SUCCESS;\r
-  while (!EFI_ERROR (EmptyStatus)) {\r
-    EmptyStatus = In8042Data (IsaIo, &Data);\r
-  }\r
-\r
-  if (MouseAbsolutePointerDev != NULL) {\r
-    FreePool (MouseAbsolutePointerDev);\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stop this driver on ControllerHandle. Support stopping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseAbsolutePointerDriverStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN UINTN                          NumberOfChildren,\r
-  IN EFI_HANDLE                     *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_ABSOLUTE_POINTER_PROTOCOL         *AbsolutePointerProtocol;\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV       *MouseAbsolutePointerDev;\r
-  UINT8                                 Data;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiAbsolutePointerProtocolGuid,\r
-                  (VOID **) &AbsolutePointerProtocol,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  MouseAbsolutePointerDev = PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS (AbsolutePointerProtocol);\r
-\r
-  //\r
-  // Report that the keyboard is being disabled\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_DISABLE,\r
-    MouseAbsolutePointerDev->DevicePath\r
-    );\r
-\r
-  Status = gBS->UninstallProtocolInterface (\r
-                  Controller,\r
-                  &gEfiAbsolutePointerProtocolGuid,\r
-                  &MouseAbsolutePointerDev->AbsolutePointerProtocol\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Cancel mouse data polling timer, close timer event\r
-  //\r
-  gBS->SetTimer (MouseAbsolutePointerDev->TimerEvent, TimerCancel, 0);\r
-  gBS->CloseEvent (MouseAbsolutePointerDev->TimerEvent);\r
-\r
-  //\r
-  // Since there will be no timer handler for mouse input any more,\r
-  // exhaust input data just in case there is still mouse data left\r
-  //\r
-  Status = EFI_SUCCESS;\r
-  while (!EFI_ERROR (Status)) {\r
-    Status = In8042Data (MouseAbsolutePointerDev->IsaIo, &Data);\r
-  }\r
-\r
-  gBS->CloseEvent (MouseAbsolutePointerDev->AbsolutePointerProtocol.WaitForInput);\r
-  FreeUnicodeStringTable (MouseAbsolutePointerDev->ControllerNameTable);\r
-  FreePool (MouseAbsolutePointerDev);\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and there is a mouse device connected to system.\r
-\r
-  @param This                 - Pointer of simple pointer Protocol.\r
-  @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.\r
-\r
-\r
-  @retval EFI_SUCCESS         - The command byte is written successfully.\r
-  @retval EFI_DEVICE_ERROR    - Errors occurred during resetting keyboard.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MouseAbsolutePointerReset (\r
-  IN EFI_ABSOLUTE_POINTER_PROTOCOL    *This,\r
-  IN BOOLEAN                          ExtendedVerification\r
-  )\r
-{\r
-  EFI_STATUS                       Status;\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV  *MouseAbsolutePointerDev;\r
-  EFI_TPL                          OldTpl;\r
-  BOOLEAN                          KeyboardEnable;\r
-  UINT8                            Data;\r
-\r
-  MouseAbsolutePointerDev = PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Report reset progress code\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_RESET,\r
-    MouseAbsolutePointerDev->DevicePath\r
-    );\r
-\r
-  KeyboardEnable = FALSE;\r
-\r
-  //\r
-  // Raise TPL to avoid keyboard operation impact\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  ZeroMem (&MouseAbsolutePointerDev->State, sizeof (EFI_ABSOLUTE_POINTER_STATE));\r
-  MouseAbsolutePointerDev->StateChanged = FALSE;\r
-\r
-  //\r
-  // Exhaust input data\r
-  //\r
-  Status = EFI_SUCCESS;\r
-  while (!EFI_ERROR (Status)) {\r
-    Status = In8042Data (MouseAbsolutePointerDev->IsaIo, &Data);\r
-  }\r
-\r
-  CheckKbStatus (MouseAbsolutePointerDev->IsaIo, &KeyboardEnable);\r
-\r
-  KbcDisableKb (MouseAbsolutePointerDev->IsaIo);\r
-\r
-  MouseAbsolutePointerDev->IsaIo->Io.Read (MouseAbsolutePointerDev->IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-  //\r
-  // if there's data block on KBC data port, read it out\r
-  //\r
-  if ((Data & KBC_OUTB) == KBC_OUTB) {\r
-    MouseAbsolutePointerDev->IsaIo->Io.Read (MouseAbsolutePointerDev->IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Data);\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-  //\r
-  // The PS2 mouse driver reset behavior is always successfully return no matter wheater or not there is mouse connected to system.\r
-  // This behavior is needed by performance speed. The following mouse command only succeessfully finish when mouse device is\r
-  // connected to system, so if PS2 mouse device not connect to system or user not ask for, we skip the mouse configuration and enabling\r
-  //\r
-  if (ExtendedVerification && CheckMouseAbsolutePointerConnect (MouseAbsolutePointerDev)) {\r
-    //\r
-    // Send mouse reset command and set mouse default configure\r
-    //\r
-    Status = PS2MouseReset (MouseAbsolutePointerDev->IsaIo);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = PS2MouseSetSampleRate (MouseAbsolutePointerDev->IsaIo, MouseAbsolutePointerDev->SampleRate);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = PS2MouseSetResolution (MouseAbsolutePointerDev->IsaIo, MouseAbsolutePointerDev->Resolution);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = PS2MouseSetScaling (MouseAbsolutePointerDev->IsaIo, MouseAbsolutePointerDev->Scaling);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = PS2MouseEnable (MouseAbsolutePointerDev->IsaIo);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-  }\r
-Exit:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  if (KeyboardEnable) {\r
-    KbcEnableKb (MouseAbsolutePointerDev->IsaIo);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Check whether there is Ps/2 mouse device in system\r
-\r
-  @param MouseAbsolutePointerDev - Absolute Pointer Device Private Data Structure\r
-\r
-  @retval TRUE                - Keyboard in System.\r
-  @retval FALSE               - Keyboard not in System.\r
-\r
-**/\r
-BOOLEAN\r
-CheckMouseAbsolutePointerConnect (\r
-  IN  PS2_MOUSE_ABSOLUTE_POINTER_DEV     *MouseAbsolutePointerDev\r
-  )\r
-\r
-{\r
-  EFI_STATUS     Status;\r
-\r
-  Status = PS2MouseEnable (MouseAbsolutePointerDev->IsaIo);\r
-  if (!EFI_ERROR (Status)) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Get and Clear mouse status.\r
-\r
-  @param This                 - Pointer of simple pointer Protocol.\r
-  @param State                - Output buffer holding status.\r
-\r
-  @retval EFI_INVALID_PARAMETER Output buffer is invalid.\r
-  @retval EFI_NOT_READY         Mouse is not changed status yet.\r
-  @retval EFI_SUCCESS           Mouse status is changed and get successful.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MouseAbsolutePointerGetState (\r
-  IN EFI_ABSOLUTE_POINTER_PROTOCOL     *This,\r
-  IN OUT EFI_ABSOLUTE_POINTER_STATE    *State\r
-  )\r
-{\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;\r
-  EFI_TPL       OldTpl;\r
-\r
-  MouseAbsolutePointerDev = PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS (This);\r
-\r
-  if (State == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (!MouseAbsolutePointerDev->StateChanged) {\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-  CopyMem (State, &(MouseAbsolutePointerDev->State), sizeof (EFI_ABSOLUTE_POINTER_STATE));\r
-\r
-  //\r
-  // clear mouse state\r
-  //\r
-  MouseAbsolutePointerDev->State.CurrentX = 0;\r
-  MouseAbsolutePointerDev->State.CurrentY = 0;\r
-  MouseAbsolutePointerDev->State.CurrentZ = 0;\r
-  MouseAbsolutePointerDev->State.ActiveButtons = 0x0;\r
-  MouseAbsolutePointerDev->StateChanged            = FALSE;\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  Event notification function for SIMPLE_POINTER.WaitForInput event.\r
-  Signal the event if there is input from mouse.\r
-\r
-  @param Event    event object\r
-  @param Context  event context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-MouseAbsolutePointerWaitForInput (\r
-  IN  EFI_EVENT               Event,\r
-  IN  VOID                    *Context\r
-  )\r
-{\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;\r
-\r
-  MouseAbsolutePointerDev = (PS2_MOUSE_ABSOLUTE_POINTER_DEV *) Context;\r
-\r
-  //\r
-  // Someone is waiting on the mouse event, if there's\r
-  // input from mouse, signal the event\r
-  //\r
-  if (MouseAbsolutePointerDev->StateChanged) {\r
-    gBS->SignalEvent (Event);\r
-  }\r
-\r
-}\r
-\r
-/**\r
-  Event notification function for TimerEvent event.\r
-  If mouse device is connected to system, try to get the mouse packet data.\r
-\r
-  @param Event      -  TimerEvent in PS2_MOUSE_DEV\r
-  @param Context    -  Pointer to PS2_MOUSE_DEV structure\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PollMouseAbsolutePointer(\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-\r
-{\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;\r
-\r
-  MouseAbsolutePointerDev = (PS2_MOUSE_ABSOLUTE_POINTER_DEV *) Context;\r
-\r
-  //\r
-  // Polling mouse packet data\r
-  //\r
-  PS2MouseGetPacket (MouseAbsolutePointerDev);\r
-}\r
-\r
-/**\r
-  The user Entry Point for module Ps2MouseAbsolutePointer. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializePs2MouseAbsolutePointer(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gPS2MouseAbsolutePointerDriver,\r
-             ImageHandle,\r
-             &gPs2MouseAbsolutePointerComponentName,\r
-             &gPs2MouseAbsolutePointerComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.h
deleted file mode 100644 (file)
index e7aa171..0000000
+++ /dev/null
@@ -1,394 +0,0 @@
-/** @file\r
-  A Ps2MouseAbsolutePointer driver header file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __PS2MOUSEABSOLUTEPOINTER_H__\r
-#define __PS2MOUSEABSOLUTEPOINTER_H__\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/AbsolutePointer.h>\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gPS2MouseAbsolutePointerDriver;\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gPs2MouseAbsolutePointerComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gPs2MouseAbsolutePointerComponentName2;\r
-\r
-//\r
-// PS/2 mouse sample rate\r
-//\r
-typedef enum {\r
-  SampleRate10,\r
-  SampleRate20,\r
-  SampleRate40,\r
-  SampleRate60,\r
-  SampleRate80,\r
-  SampleRate100,\r
-  SampleRate200,\r
-  MaxSampleRate\r
-} MOUSE_SR;\r
-\r
-//\r
-// PS/2 mouse resolution\r
-//\r
-typedef enum {\r
-  MouseResolution1,\r
-  MouseResolution2,\r
-  MouseResolution4,\r
-  MouseResolution8,\r
-  MaxResolution\r
-} MOUSE_RE;\r
-\r
-//\r
-// PS/2 mouse scaling\r
-//\r
-typedef enum {\r
-  Scaling1,\r
-  Scaling2\r
-} MOUSE_SF;\r
-\r
-//\r
-// Driver Private Data\r
-//\r
-#define PS2_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE SIGNATURE_32 ('p', '2', 's', 't')\r
-\r
-typedef struct {\r
-  UINTN                               Signature;\r
-\r
-  EFI_HANDLE                          Handle;\r
-  EFI_ABSOLUTE_POINTER_PROTOCOL       AbsolutePointerProtocol;\r
-  EFI_ABSOLUTE_POINTER_STATE          State;\r
-  EFI_ABSOLUTE_POINTER_MODE           Mode;\r
-  BOOLEAN                             StateChanged;\r
-\r
-  //\r
-  // PS2 Mouse device specific information\r
-  //\r
-  MOUSE_SR                            SampleRate;\r
-  MOUSE_RE                            Resolution;\r
-  MOUSE_SF                            Scaling;\r
-  UINT8                               DataPackageSize;\r
-\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-\r
-  EFI_EVENT                           TimerEvent;\r
-\r
-  EFI_UNICODE_STRING_TABLE            *ControllerNameTable;\r
-  EFI_DEVICE_PATH_PROTOCOL            *DevicePath;\r
-} PS2_MOUSE_ABSOLUTE_POINTER_DEV;\r
-\r
-#define PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS(a)  CR (a, PS2_MOUSE_ABSOLUTE_POINTER_DEV, AbsolutePointerProtocol, PS2_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE)\r
-\r
-//\r
-// Function prototypes\r
-//\r
-/**\r
-  Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
-  than contains a IsaIo protocol can be supported.\r
-\r
-  @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
-  @retval other               This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseAbsolutePointerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Start this driver on ControllerHandle by opening a IsaIo\r
-  protocol, creating PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid\r
-  finnally.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
-                               device to start.\r
-\r
-  @retval EFI_SUCCESS          This driver is added to ControllerHandle\r
-  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
-  @retval other                This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseAbsolutePointerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Stop this driver on ControllerHandle. Support stopping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseAbsolutePointerDriverStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL   *This,\r
-  IN EFI_HANDLE                    Controller,\r
-  IN UINTN                         NumberOfChildren,\r
-  IN EFI_HANDLE                    *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2MouseAbsolutePointerComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2MouseAbsolutePointerComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-/**\r
-  Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and there is a mouse device connected to system.\r
-\r
-  @param This                 - Pointer of simple pointer Protocol.\r
-  @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.\r
-\r
-\r
-  @retval EFI_SUCCESS         - The command byte is written successfully.\r
-  @retval EFI_DEVICE_ERROR    - Errors occurred during resetting keyboard.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MouseAbsolutePointerReset (\r
-  IN EFI_ABSOLUTE_POINTER_PROTOCOL  *This,\r
-  IN BOOLEAN                        ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Get and Clear mouse status.\r
-\r
-  @param This                 - Pointer of simple pointer Protocol.\r
-  @param State                - Output buffer holding status.\r
-\r
-  @retval EFI_INVALID_PARAMETER Output buffer is invalid.\r
-  @retval EFI_NOT_READY         Mouse is not changed status yet.\r
-  @retval EFI_SUCCESS           Mouse status is changed and get successful.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MouseAbsolutePointerGetState (\r
-  IN EFI_ABSOLUTE_POINTER_PROTOCOL  *This,\r
-  IN OUT EFI_ABSOLUTE_POINTER_STATE   *State\r
-  );\r
-\r
-/**\r
-\r
-  Event notification function for SIMPLE_POINTER.WaitForInput event.\r
-  Signal the event if there is input from mouse.\r
-\r
-  @param Event    event object\r
-  @param Context  event context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-MouseAbsolutePointerWaitForInput (\r
-  IN  EFI_EVENT               Event,\r
-  IN  VOID                    *Context\r
-  );\r
-\r
-/**\r
-  Event notification function for TimerEvent event.\r
-  If mouse device is connected to system, try to get the mouse packet data.\r
-\r
-  @param Event      -  TimerEvent in PS2_MOUSE_DEV\r
-  @param Context    -  Pointer to PS2_MOUSE_DEV structure\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PollMouseAbsolutePointer (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  );\r
-\r
-/**\r
-  I/O work flow of in 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  );\r
-\r
-/**\r
-  Check whether there is Ps/2 mouse device in system\r
-\r
-  @param MouseAbsolutePointerDev - Absolute Pointer Device Private Data Structure\r
-\r
-  @retval TRUE                - Keyboard in System.\r
-  @retval FALSE               - Keyboard not in System.\r
-\r
-**/\r
-BOOLEAN\r
-CheckMouseAbsolutePointerConnect (\r
-  IN  PS2_MOUSE_ABSOLUTE_POINTER_DEV     *MouseAbsolutePointerDev\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.inf
deleted file mode 100644 (file)
index ffa2b2b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-## @file\r
-# PS2 Mouse driver providing absolute (touch pad) pointer support.\r
-#\r
-# This driver simulates a touch pad absolute pointing device using a standard\r
-# PS2 mouse as the input hardware.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = Ps2MouseAbsolutePointerDxe\r
-  MODULE_UNI_FILE                = Ps2MouseAbsolutePointerDxe.uni\r
-  FILE_GUID                      = 2899C94A-1FB6-4b1a-B96B-8364975303E0\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializePs2MouseAbsolutePointer\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#  DRIVER_BINDING                = gPS2MouseAbsolutePointerDriver;\r
-#  COMPONENT_NAME                = gPs2MouseAbsolutePointerComponentName;\r
-#  COMPONENT_NAME2               = gPs2MouseAbsolutePointerComponentName2;\r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  CommPs2.h\r
-  CommPs2.c\r
-  Ps2MouseAbsolutePointer.h\r
-  Ps2MouseAbsolutePointer.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  ReportStatusCodeLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  PcdLib\r
-\r
-[Protocols]\r
-  gEfiIsaIoProtocolGuid                         ## TO_START\r
-  gEfiAbsolutePointerProtocolGuid               ## BY_START\r
-  gEfiDevicePathProtocolGuid                    ## TO_START\r
-\r
-[FeaturePcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPs2MouseExtendedVerification   ## CONSUMES\r
-\r
-#\r
-# [Event]\r
-#\r
-#   ##\r
-#   # Timer event used to check the mouse state at a regular interval.\r
-#   #\r
-#   EVENT_TYPE_PERIODIC_TIMER   ## CONSUMES\r
-#\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  Ps2MouseAbsolutePointerDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.uni
deleted file mode 100644 (file)
index 18a7f48..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// /** @file\r
-// PS2 Mouse driver providing absolute (touch pad) pointer support.\r
-//\r
-// This driver simulates a touch pad absolute pointing device using a standard\r
-// PS2 mouse as the input hardware.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "PS2 Mouse driver providing absolute (touch pad) pointer support"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This driver simulates a touch pad absolute pointing device using a standard PS2 mouse as the input hardware."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxeExtra.uni
deleted file mode 100644 (file)
index 17590cd..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// Ps2MouseAbsolutePointerDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"PS2 Tablet Pointer DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c
deleted file mode 100644 (file)
index 8975583..0000000
+++ /dev/null
@@ -1,915 +0,0 @@
-/** @file\r
-  PS2 Mouse Communication Interface.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ps2Mouse.h"\r
-#include "CommPs2.h"\r
-\r
-UINT8 SampleRateTbl[MaxSampleRate]   = { 0xa, 0x14, 0x28, 0x3c, 0x50, 0x64, 0xc8 };\r
-\r
-UINT8 ResolutionTbl[MaxResolution]  = { 0, 1, 2, 3 };\r
-\r
-/**\r
-  Issue self test command via IsaIo interface.\r
-\r
-  @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return EFI_SUCCESS  Success to do keyboard self testing.\r
-  @return others       Fail to do keyboard self testing.\r
-**/\r
-EFI_STATUS\r
-KbcSelfTest (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Keyboard controller self test\r
-  //\r
-  Status = Out8042Command (IsaIo, SELF_TEST);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Read return code\r
-  //\r
-  Status = In8042Data (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (Data != 0x55) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Set system flag\r
-  //\r
-  Status = Out8042Command (IsaIo, READ_CMD_BYTE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = In8042Data (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = Out8042Command (IsaIo, WRITE_CMD_BYTE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Data |= CMD_SYS_FLAG;\r
-  Status = Out8042Data (IsaIo, Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Issue command to enable keyboard AUX functionality.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableAux (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send 8042 enable mouse command\r
-  //\r
-  return Out8042Command (IsaIo, ENABLE_AUX);\r
-}\r
-\r
-/**\r
-  Issue command to disable keyboard AUX functionality.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableAux (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send 8042 disable mouse command\r
-  //\r
-  return Out8042Command (IsaIo, DISABLE_AUX);\r
-}\r
-\r
-/**\r
-  Issue command to enable keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableKb (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send 8042 enable keyboard command\r
-  //\r
-  return Out8042Command (IsaIo, ENABLE_KB);\r
-}\r
-\r
-/**\r
-  Issue command to disable keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableKb (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send 8042 disable keyboard command\r
-  //\r
-  return Out8042Command (IsaIo, DISABLE_KB);\r
-}\r
-\r
-/**\r
-  Issue command to check keyboard status.\r
-\r
-  @param IsaIo          Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param KeyboardEnable return whether keyboard is enable.\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-CheckKbStatus (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  OUT BOOLEAN                             *KeyboardEnable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Send command to read KBC command byte\r
-  //\r
-  Status = Out8042Command (IsaIo, READ_CMD_BYTE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = In8042Data (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check keyboard enable or not\r
-  //\r
-  if ((Data & CMD_KB_STS) == CMD_KB_DIS) {\r
-    *KeyboardEnable = FALSE;\r
-  } else {\r
-    *KeyboardEnable = TRUE;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Issue command to reset keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseReset (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  Status = Out8042AuxCommand (IsaIo, RESET_CMD, FALSE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = In8042AuxData (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check BAT Complete Code\r
-  //\r
-  if (Data != PS2MOUSE_BAT1) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Status = In8042AuxData (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check BAT Complete Code\r
-  //\r
-  if (Data != PS2MOUSE_BAT2) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Issue command to set mouse's sample rate\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param SampleRate value of sample rate\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetSampleRate (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_SR                             SampleRate\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Send auxiliary command to set mouse sample rate\r
-  //\r
-  Status = Out8042AuxCommand (IsaIo, SETSR_CMD, FALSE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = Out8042AuxData (IsaIo, SampleRateTbl[SampleRate]);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Issue command to set mouse's resolution.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Resolution value of resolution\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetResolution (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_RE                             Resolution\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Send auxiliary command to set mouse resolution\r
-  //\r
-  Status = Out8042AuxCommand (IsaIo, SETRE_CMD, FALSE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = Out8042AuxData (IsaIo, ResolutionTbl[Resolution]);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Issue command to set mouse's scaling.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Scaling value of scaling\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetScaling (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_SF                             Scaling\r
-  )\r
-{\r
-  UINT8 Command;\r
-\r
-  Command = (UINT8) (Scaling == Scaling1 ? SETSF1_CMD : SETSF2_CMD);\r
-\r
-  //\r
-  // Send auxiliary command to set mouse scaling data\r
-  //\r
-  return Out8042AuxCommand (IsaIo, Command, FALSE);\r
-}\r
-\r
-/**\r
-  Issue command to enable Ps2 mouse.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseEnable (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  //\r
-  // Send auxiliary command to enable mouse\r
-  //\r
-  return Out8042AuxCommand (IsaIo, ENABLE_CMD, FALSE);\r
-}\r
-\r
-/**\r
-  Get mouse packet . Only care first 3 bytes\r
-\r
-  @param MouseDev  Pointer of PS2 Mouse Private Data Structure\r
-\r
-  @retval EFI_NOT_READY  Mouse Device not ready to input data packet, or some error happened during getting the packet\r
-  @retval EFI_SUCCESS    The data packet is gotten successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-PS2MouseGetPacket (\r
-  PS2_MOUSE_DEV     *MouseDev\r
-  )\r
-\r
-{\r
-  EFI_STATUS  Status;\r
-  BOOLEAN     KeyboardEnable;\r
-  UINT8       Packet[PS2_PACKET_LENGTH];\r
-  UINT8       Data;\r
-  UINTN       Count;\r
-  UINTN       State;\r
-  INT16       RelativeMovementX;\r
-  INT16       RelativeMovementY;\r
-  BOOLEAN     LButton;\r
-  BOOLEAN     RButton;\r
-\r
-  KeyboardEnable  = FALSE;\r
-  Count           = 1;\r
-  State           = PS2_READ_BYTE_ONE;\r
-\r
-  //\r
-  // State machine to get mouse packet\r
-  //\r
-  while (1) {\r
-\r
-    switch (State) {\r
-    case PS2_READ_BYTE_ONE:\r
-      //\r
-      // Read mouse first byte data, if failed, immediately return\r
-      //\r
-      KbcDisableAux (MouseDev->IsaIo);\r
-      Status = PS2MouseRead (MouseDev->IsaIo, &Data, &Count, State);\r
-      if (EFI_ERROR (Status)) {\r
-        KbcEnableAux (MouseDev->IsaIo);\r
-        return EFI_NOT_READY;\r
-      }\r
-\r
-      if (Count != 1) {\r
-        KbcEnableAux (MouseDev->IsaIo);\r
-        return EFI_NOT_READY;\r
-      }\r
-\r
-      if (IS_PS2_SYNC_BYTE (Data)) {\r
-        Packet[0] = Data;\r
-        State     = PS2_READ_DATA_BYTE;\r
-\r
-        CheckKbStatus (MouseDev->IsaIo, &KeyboardEnable);\r
-        KbcDisableKb (MouseDev->IsaIo);\r
-        KbcEnableAux (MouseDev->IsaIo);\r
-      }\r
-      break;\r
-\r
-    case PS2_READ_DATA_BYTE:\r
-      Count   = 2;\r
-      Status  = PS2MouseRead (MouseDev->IsaIo, (Packet + 1), &Count, State);\r
-      if (EFI_ERROR (Status)) {\r
-        if (KeyboardEnable) {\r
-          KbcEnableKb (MouseDev->IsaIo);\r
-        }\r
-\r
-        return EFI_NOT_READY;\r
-      }\r
-\r
-      if (Count != 2) {\r
-        if (KeyboardEnable) {\r
-          KbcEnableKb (MouseDev->IsaIo);\r
-        }\r
-\r
-        return EFI_NOT_READY;\r
-      }\r
-\r
-      State = PS2_PROCESS_PACKET;\r
-      break;\r
-\r
-    case PS2_PROCESS_PACKET:\r
-      if (KeyboardEnable) {\r
-        KbcEnableKb (MouseDev->IsaIo);\r
-      }\r
-      //\r
-      // Decode the packet\r
-      //\r
-      RelativeMovementX = Packet[1];\r
-      RelativeMovementY = Packet[2];\r
-      //\r
-      //               Bit 7   |    Bit 6   |    Bit 5   |   Bit 4    |   Bit 3  |   Bit 2    |   Bit 1   |   Bit 0\r
-      //  Byte 0  | Y overflow | X overflow | Y sign bit | X sign bit | Always 1 | Middle Btn | Right Btn | Left Btn\r
-      //  Byte 1  |                                           8 bit X Movement\r
-      //  Byte 2  |                                           8 bit Y Movement\r
-      //\r
-      // X sign bit + 8 bit X Movement : 9-bit signed twos complement integer that presents the relative displacement of the device in the X direction since the last data transmission.\r
-      // Y sign bit + 8 bit Y Movement : Same as X sign bit + 8 bit X Movement.\r
-      //\r
-      //\r
-      // First, Clear X and Y high 8 bits\r
-      //\r
-      RelativeMovementX = (INT16) (RelativeMovementX & 0xFF);\r
-      RelativeMovementY = (INT16) (RelativeMovementY & 0xFF);\r
-      //\r
-      // Second, if the 9-bit signed twos complement integer is negative, set the high 8 bit 0xff\r
-      //\r
-      if ((Packet[0] & 0x10) != 0) {\r
-        RelativeMovementX = (INT16) (RelativeMovementX | 0xFF00);\r
-      }\r
-      if ((Packet[0] & 0x20) != 0) {\r
-        RelativeMovementY = (INT16) (RelativeMovementY | 0xFF00);\r
-      }\r
-\r
-\r
-      RButton           = (UINT8) (Packet[0] & 0x2);\r
-      LButton           = (UINT8) (Packet[0] & 0x1);\r
-\r
-      //\r
-      // Update mouse state\r
-      //\r
-      MouseDev->State.RelativeMovementX += RelativeMovementX;\r
-      MouseDev->State.RelativeMovementY -= RelativeMovementY;\r
-      MouseDev->State.RightButton = (UINT8) (RButton ? TRUE : FALSE);\r
-      MouseDev->State.LeftButton  = (UINT8) (LButton ? TRUE : FALSE);\r
-      MouseDev->StateChanged      = TRUE;\r
-\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Read data via IsaIo protocol with given number.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Buffer  Buffer receive data of mouse\r
-  @param BufSize The size of buffer\r
-  @param State   Check input or read data\r
-\r
-  @return status of reading mouse data.\r
-**/\r
-EFI_STATUS\r
-PS2MouseRead (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  OUT VOID                                *Buffer,\r
-  IN OUT UINTN                            *BufSize,\r
-  IN  UINTN                               State\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       BytesRead;\r
-\r
-  Status    = EFI_SUCCESS;\r
-  BytesRead = 0;\r
-\r
-  if (State == PS2_READ_BYTE_ONE) {\r
-    //\r
-    // Check input for mouse\r
-    //\r
-    Status = CheckForInput (IsaIo);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  while (BytesRead < *BufSize) {\r
-\r
-    Status = WaitOutputFull (IsaIo, TIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Buffer);\r
-\r
-    BytesRead++;\r
-    Buffer = (UINT8 *) Buffer + 1;\r
-  }\r
-  //\r
-  // Verify the correct number of bytes read\r
-  //\r
-  if (BytesRead == 0 || BytesRead != *BufSize) {\r
-    Status = EFI_NOT_FOUND;\r
-  }\r
-\r
-  *BufSize = BytesRead;\r
-  return Status;\r
-}\r
-//\r
-// 8042 I/O function\r
-//\r
-/**\r
-  I/O work flow of outing 8042 command.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Command I/O command.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Command (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Command\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Wait keyboard controller input buffer empty\r
-  //\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Send command\r
-  //\r
-  Data = Command;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of outing 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Data\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Temp;\r
-  //\r
-  // Wait keyboard controller input buffer empty\r
-  //\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Temp = Data;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of in 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  )\r
-{\r
-  UINTN Delay;\r
-  UINT8 Temp;\r
-\r
-  Delay = TIMEOUT / 50;\r
-\r
-  do {\r
-    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);\r
-\r
-    //\r
-    // Check keyboard controller status bit 0(output buffer status)\r
-    //\r
-    if ((Temp & KBC_OUTB) == KBC_OUTB) {\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (50);\r
-    Delay--;\r
-  } while (Delay != 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of outing 8042 Aux command.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Command Aux I/O command\r
-  @param Resend  Whether need resend the Aux command.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxCommand (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Command,\r
-  IN BOOLEAN                              Resend\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Data;\r
-\r
-  //\r
-  // Wait keyboard controller input buffer empty\r
-  //\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Send write to auxiliary device command\r
-  //\r
-  Data = WRITE_AUX_DEV;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Send auxiliary device command\r
-  //\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Command);\r
-\r
-  //\r
-  // Read return code\r
-  //\r
-  Status = In8042AuxData (IsaIo, &Data);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (Data == PS2_ACK) {\r
-    //\r
-    // Receive mouse acknowledge, command send success\r
-    //\r
-    return EFI_SUCCESS;\r
-\r
-  } else if (Resend) {\r
-    //\r
-    // Resend fail\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
-\r
-  } else if (Data == PS2_RESEND) {\r
-    //\r
-    // Resend command\r
-    //\r
-    Status = Out8042AuxCommand (IsaIo, Command, TRUE);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-  } else {\r
-    //\r
-    // Invalid return code\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
-\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of outing 8042 Aux data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Buffer holding return value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxData (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Data\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       Temp;\r
-  //\r
-  // Wait keyboard controller input buffer empty\r
-  //\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Send write to auxiliary device command\r
-  //\r
-  Temp = WRITE_AUX_DEV;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Temp = Data;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);\r
-\r
-  Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow of in 8042 Aux data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Buffer holding return value.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042AuxData (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // wait for output data\r
-  //\r
-  Status = WaitOutputFull (IsaIo, BAT_TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Check keyboard controller status, if it is output buffer full and for auxiliary device.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @retval EFI_SUCCESS   Keyboard controller is ready\r
-  @retval EFI_NOT_READY Keyboard controller is not ready\r
-**/\r
-EFI_STATUS\r
-CheckForInput (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-  //\r
-  // Check keyboard controller status, if it is output buffer full and for auxiliary device\r
-  //\r
-  if ((Data & (KBC_OUTB | KBC_AUXB)) != (KBC_OUTB | KBC_AUXB)) {\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow to wait input buffer empty in given time.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Timeout Wating time.\r
-\r
-  @retval EFI_TIMEOUT if input is still not empty in given time.\r
-  @retval EFI_SUCCESS input is empty.\r
-**/\r
-EFI_STATUS\r
-WaitInputEmpty (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINTN                                Timeout\r
-  )\r
-{\r
-  UINTN Delay;\r
-  UINT8 Data;\r
-\r
-  Delay = Timeout / 50;\r
-\r
-  do {\r
-    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-    //\r
-    // Check keyboard controller status bit 1(input buffer status)\r
-    //\r
-    if ((Data & KBC_INPB) == 0) {\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (50);\r
-    Delay--;\r
-  } while (Delay != 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  I/O work flow to wait output buffer full in given time.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Timeout given time\r
-\r
-  @retval EFI_TIMEOUT  output is not full in given time\r
-  @retval EFI_SUCCESS  output is full in given time.\r
-**/\r
-EFI_STATUS\r
-WaitOutputFull (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINTN                                Timeout\r
-  )\r
-{\r
-  UINTN Delay;\r
-  UINT8 Data;\r
-\r
-  Delay = Timeout / 50;\r
-\r
-  do {\r
-    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-    //\r
-    // Check keyboard controller status bit 0(output buffer status)\r
-    //  & bit5(output buffer for auxiliary device)\r
-    //\r
-    if ((Data & (KBC_OUTB | KBC_AUXB)) == (KBC_OUTB | KBC_AUXB)) {\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (50);\r
-    Delay--;\r
-  } while (Delay != 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h
deleted file mode 100644 (file)
index 68f049a..0000000
+++ /dev/null
@@ -1,429 +0,0 @@
-/** @file\r
-  PS2 Mouse Communication Interface\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _COMMPS2_H_\r
-#define _COMMPS2_H_\r
-\r
-#define PS2_PACKET_LENGTH       3\r
-#define PS2_SYNC_MASK           0xc\r
-#define PS2_SYNC_BYTE           0x8\r
-\r
-#define IS_PS2_SYNC_BYTE(byte)  ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)\r
-\r
-#define PS2_READ_BYTE_ONE       0\r
-#define PS2_READ_DATA_BYTE      1\r
-#define PS2_PROCESS_PACKET      2\r
-\r
-#define TIMEOUT                 50000\r
-#define BAT_TIMEOUT             500000\r
-\r
-//\r
-// 8042 I/O Port\r
-//\r
-#define KBC_DATA_PORT     0x60\r
-#define KBC_CMD_STS_PORT  0x64\r
-\r
-//\r
-// 8042 Command\r
-//\r
-#define READ_CMD_BYTE   0x20\r
-#define WRITE_CMD_BYTE  0x60\r
-#define DISABLE_AUX     0xa7\r
-#define ENABLE_AUX      0xa8\r
-#define SELF_TEST       0xaa\r
-#define DISABLE_KB      0xad\r
-#define ENABLE_KB       0xae\r
-#define WRITE_AUX_DEV   0xd4\r
-\r
-#define CMD_SYS_FLAG    0x04\r
-#define CMD_KB_STS      0x10\r
-#define CMD_KB_DIS      0x10\r
-#define CMD_KB_EN       0x0\r
-\r
-//\r
-// 8042 Auxiliary Device Command\r
-//\r
-#define SETSF1_CMD  0xe6\r
-#define SETSF2_CMD  0xe7\r
-#define SETRE_CMD   0xe8\r
-#define READ_CMD    0xeb\r
-#define SETRM_CMD   0xf0\r
-#define SETSR_CMD   0xf3\r
-#define ENABLE_CMD  0xf4\r
-#define DISABLE_CMD 0xf5\r
-#define RESET_CMD   0xff\r
-\r
-//\r
-// return code\r
-//\r
-#define PS2_ACK       0xfa\r
-#define PS2_RESEND    0xfe\r
-#define PS2MOUSE_BAT1 0xaa\r
-#define PS2MOUSE_BAT2 0x0\r
-\r
-//\r
-// Keyboard Controller Status\r
-//\r
-///\r
-/// Parity Error\r
-///\r
-#define KBC_PARE  0x80\r
-///\r
-/// General Time Out\r
-///\r
-#define KBC_TIM   0x40\r
-///\r
-/// Output buffer for auxiliary device (PS/2):\r
-///    0 - Holds keyboard data\r
-///    1 - Holds data for auxiliary device\r
-///\r
-#define KBC_AUXB  0x20\r
-///\r
-/// Keyboard lock status:\r
-///    0 - keyboard locked\r
-///    1 - keyboard free\r
-///\r
-#define KBC_KEYL  0x10\r
-///\r
-/// Command/Data:\r
-///    0 - data byte written via port 60h\r
-///    1 - command byte written via port 64h\r
-///\r
-#define KBC_CD  0x08\r
-///\r
-/// System Flag:\r
-///    0 - power-on reset\r
-///    1 - self-test successful\r
-///\r
-#define KBC_SYSF  0x04\r
-///\r
-/// Input Buffer Status :\r
-///    0 - input buffer empty\r
-///    1 - CPU data in input buffer\r
-///\r
-#define KBC_INPB  0x02\r
-///\r
-/// Output Buffer Status :\r
-///    0 - output buffer empty\r
-///    1 - keyboard controller data in output buffer\r
-///\r
-#define KBC_OUTB  0x01\r
-\r
-/**\r
-  Issue self test command via IsaIo interface.\r
-\r
-  @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return EFI_SUCCESS  Success to do keyboard self testing.\r
-  @return others       Fail to do keyboard self testing.\r
-**/\r
-EFI_STATUS\r
-KbcSelfTest (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to enable keyboard AUX functionality.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableAux (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to disable keyboard AUX functionality.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableAux (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to enable keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableKb (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to disable keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableKb (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to check keyboard status.\r
-\r
-  @param IsaIo          Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param KeyboardEnable return whether keyboard is enable.\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-CheckKbStatus (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  OUT BOOLEAN                             *KeyboardEnable\r
-  );\r
-\r
-/**\r
-  Issue command to reset keyboard.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseReset (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Issue command to set mouse's sample rate\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param SampleRate value of sample rate\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetSampleRate (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_SR                             SampleRate\r
-  );\r
-\r
-/**\r
-  Issue command to set mouse's resolution.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Resolution value of resolution\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetResolution (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_RE                             Resolution\r
-  );\r
-\r
-/**\r
-  Issue command to set mouse's scaling.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Scaling value of scaling\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetScaling (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN MOUSE_SF                             Scaling\r
-  );\r
-\r
-/**\r
-  Issue command to enable Ps2 mouse.\r
-\r
-  @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseEnable (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  Get mouse packet . Only care first 3 bytes\r
-\r
-  @param MouseDev  Pointer of PS2 Mouse Private Data Structure\r
-\r
-  @retval EFI_NOT_READY  Mouse Device not ready to input data packet, or some error happened during getting the packet\r
-  @retval EFI_SUCCESS    The data packet is gotten successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-PS2MouseGetPacket (\r
-  PS2_MOUSE_DEV     *MouseDev\r
-  );\r
-\r
-/**\r
-  Read data via IsaIo protocol with given number.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Buffer  Buffer receive data of mouse\r
-  @param BufSize The size of buffer\r
-  @param State   Check input or read data\r
-\r
-  @return status of reading mouse data.\r
-**/\r
-EFI_STATUS\r
-PS2MouseRead (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  OUT VOID                                *Buffer,\r
-  IN OUT UINTN                            *BufSize,\r
-  IN  UINTN                               State\r
-  );\r
-\r
-//\r
-// 8042 I/O function\r
-//\r
-/**\r
-  I/O work flow of outing 8042 command.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Command I/O command.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Command (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Command\r
-  );\r
-\r
-/**\r
-  I/O work flow of in 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  );\r
-\r
-/**\r
-  I/O work flow of outing 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Data\r
-  );\r
-\r
-/**\r
-  I/O work flow of outing 8042 Aux command.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Command Aux I/O command\r
-  @param Resend  Whether need resend the Aux command.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxCommand (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Command,\r
-  IN BOOLEAN                              Resend\r
-  );\r
-\r
-/**\r
-  I/O work flow of in 8042 Aux data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Buffer holding return value.\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042AuxData (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  );\r
-\r
-/**\r
-  I/O work flow of outing 8042 Aux data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Buffer holding return value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxData (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINT8                                Data\r
-  );\r
-\r
-/**\r
-  Check keyboard controller status, if it is output buffer full and for auxiliary device.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
-  @retval EFI_SUCCESS   Keyboard controller is ready\r
-  @retval EFI_NOT_READY Keyboard controller is not ready\r
-**/\r
-EFI_STATUS\r
-CheckForInput (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo\r
-  );\r
-\r
-/**\r
-  I/O work flow to wait input buffer empty in given time.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Timeout Wating time.\r
-\r
-  @retval EFI_TIMEOUT if input is still not empty in given time.\r
-  @retval EFI_SUCCESS input is empty.\r
-**/\r
-EFI_STATUS\r
-WaitInputEmpty (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINTN                                Timeout\r
-  );\r
-\r
-/**\r
-  I/O work flow to wait output buffer full in given time.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Timeout given time\r
-\r
-  @retval EFI_TIMEOUT  output is not full in given time\r
-  @retval EFI_SUCCESS  output is full in given time.\r
-**/\r
-EFI_STATUS\r
-WaitOutputFull (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN UINTN                                Timeout\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c
deleted file mode 100644 (file)
index e181c16..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/** @file\r
-  UEFI Component Name(2) protocol implementation for Ps2MouseDxe driver.\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ps2Mouse.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gPs2MouseComponentName = {\r
-  Ps2MouseComponentNameGetDriverName,\r
-  Ps2MouseComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2MouseComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2MouseComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2MouseDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"PS/2 Mouse Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2MouseComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mPs2MouseDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gPs2MouseComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2MouseComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS                                  Status;\r
-  EFI_SIMPLE_POINTER_PROTOCOL                 *SimplePointerProtocol;\r
-  PS2_MOUSE_DEV                               *MouseDev;\r
-  EFI_ISA_IO_PROTOCOL                         *IsaIoProtocol;\r
-\r
-  //\r
-  // This is a device driver, so ChildHandle must be NULL.\r
-  //\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Check Controller's handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIoProtocol,\r
-                  gPS2MouseDriver.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           ControllerHandle,\r
-           &gEfiIsaIoProtocolGuid,\r
-           gPS2MouseDriver.DriverBindingHandle,\r
-           ControllerHandle\r
-           );\r
-\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (Status != EFI_ALREADY_STARTED) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Get the device context\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiSimplePointerProtocolGuid,\r
-                  (VOID **) &SimplePointerProtocol,\r
-                  gPS2MouseDriver.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  MouseDev = PS2_MOUSE_DEV_FROM_THIS (SimplePointerProtocol);\r
-\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           MouseDev->ControllerNameTable,\r
-           ControllerName,\r
-           (BOOLEAN)(This == &gPs2MouseComponentName)\r
-           );\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c
deleted file mode 100644 (file)
index f8cfc43..0000000
+++ /dev/null
@@ -1,786 +0,0 @@
-/** @file\r
-  PS/2 Mouse driver. Routines that interacts with callers,\r
-  conforming to EFI driver model.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ps2Mouse.h"\r
-#include "CommPs2.h"\r
-\r
-///\r
-/// DriverBinding Protocol Instance\r
-///\r
-EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver = {\r
-  PS2MouseDriverSupported,\r
-  PS2MouseDriverStart,\r
-  PS2MouseDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-/**\r
-  Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
-  than contains a IsaIo protocol can be supported.\r
-\r
-  @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
-  @retval other               This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Use the ISA I/O Protocol to see if Controller is the Keyboard controller\r
-  //\r
-  switch (IsaIo->ResourceList->Device.HID) {\r
-  case EISA_PNP_ID (0xF03):\r
-  //\r
-  // Microsoft PS/2 style mouse\r
-  //\r
-  case EISA_PNP_ID (0xF13):\r
-    //\r
-    // PS/2 Port for PS/2-style Mice\r
-    //\r
-    break;\r
-\r
-  case EISA_PNP_ID (0x303):\r
-    //\r
-    // IBM Enhanced (101/102-key, PS/2 mouse support)\r
-    //\r
-    if (IsaIo->ResourceList->Device.UID == 1) {\r
-      break;\r
-    }\r
-\r
-  default:\r
-    Status = EFI_UNSUPPORTED;\r
-    break;\r
-  }\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Start this driver on ControllerHandle by opening a IsaIo protocol, creating\r
-  PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid\r
-  finally.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
-                               device to start.\r
-\r
-  @retval EFI_SUCCESS          This driver is added to ControllerHandle\r
-  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
-  @retval other                This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_STATUS                          EmptyStatus;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-  PS2_MOUSE_DEV                       *MouseDev;\r
-  UINT8                               Data;\r
-  EFI_TPL                             OldTpl;\r
-  EFI_STATUS_CODE_VALUE               StatusCode;\r
-  EFI_DEVICE_PATH_PROTOCOL            *ParentDevicePath;\r
-\r
-  StatusCode  = 0;\r
-  MouseDev    = NULL;\r
-  IsaIo       = NULL;\r
-\r
-  //\r
-  // Open the device path protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Report that the keyboard is being enabled\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_ENABLE,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Get the ISA I/O Protocol on Controller's handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Raise TPL to avoid keyboard operation impact\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // Allocate private data\r
-  //\r
-  MouseDev = AllocateZeroPool (sizeof (PS2_MOUSE_DEV));\r
-  if (MouseDev == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ErrorExit;\r
-  }\r
-  //\r
-  // Setup the device instance\r
-  //\r
-  MouseDev->Signature       = PS2_MOUSE_DEV_SIGNATURE;\r
-  MouseDev->Handle          = Controller;\r
-  MouseDev->SampleRate      = SampleRate20;\r
-  MouseDev->Resolution      = MouseResolution4;\r
-  MouseDev->Scaling         = Scaling1;\r
-  MouseDev->DataPackageSize = 3;\r
-  MouseDev->IsaIo           = IsaIo;\r
-  MouseDev->DevicePath      = ParentDevicePath;\r
-\r
-  //\r
-  // Resolution = 4 counts/mm\r
-  //\r
-  MouseDev->Mode.ResolutionX                = 4;\r
-  MouseDev->Mode.ResolutionY                = 4;\r
-  MouseDev->Mode.LeftButton                 = TRUE;\r
-  MouseDev->Mode.RightButton                = TRUE;\r
-\r
-  MouseDev->SimplePointerProtocol.Reset     = MouseReset;\r
-  MouseDev->SimplePointerProtocol.GetState  = MouseGetState;\r
-  MouseDev->SimplePointerProtocol.Mode      = &(MouseDev->Mode);\r
-\r
-  //\r
-  // Initialize keyboard controller if necessary\r
-  //\r
-  IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-  //\r
-  // Fix for random hangs in System waiting for the Key if no KBC is present in BIOS.\r
-  //\r
-  if ((Data & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {\r
-    //\r
-    // If nobody decodes KBC I/O port, it will read back as 0xFF.\r
-    // Check the Time-Out and Parity bit to see if it has an active KBC in system\r
-    //\r
-    Status     = EFI_DEVICE_ERROR;\r
-    StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_MOUSE_PC_SELF_TEST,\r
-    ParentDevicePath\r
-    );\r
-\r
-  if ((Data & KBC_SYSF) != KBC_SYSF) {\r
-    Status = KbcSelfTest (IsaIo);\r
-    if (EFI_ERROR (Status)) {\r
-      StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_CONTROLLER_ERROR;\r
-      goto ErrorExit;\r
-    }\r
-  }\r
-\r
-  KbcEnableAux (IsaIo);\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_PRESENCE_DETECT,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Reset the mouse\r
-  //\r
-  Status = MouseDev->SimplePointerProtocol.Reset (\r
-                     &MouseDev->SimplePointerProtocol,\r
-                     FeaturePcdGet (PcdPs2MouseExtendedVerification)\r
-                     );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // mouse not connected\r
-    //\r
-    Status      = EFI_SUCCESS;\r
-    StatusCode  = EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_DETECTED,\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Setup the WaitForKey event\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_WAIT,\r
-                  TPL_NOTIFY,\r
-                  MouseWaitForInput,\r
-                  MouseDev,\r
-                  &((MouseDev->SimplePointerProtocol).WaitForInput)\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ErrorExit;\r
-  }\r
-  //\r
-  // Setup a periodic timer, used to poll mouse state\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  PollMouse,\r
-                  MouseDev,\r
-                  &MouseDev->TimerEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ErrorExit;\r
-  }\r
-  //\r
-  // Start timer to poll mouse (100 samples per second)\r
-  //\r
-  Status = gBS->SetTimer (MouseDev->TimerEvent, TimerPeriodic, 100000);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ErrorExit;\r
-  }\r
-\r
-  MouseDev->ControllerNameTable = NULL;\r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gPs2MouseComponentName.SupportedLanguages,\r
-    &MouseDev->ControllerNameTable,\r
-    L"PS/2 Mouse Device",\r
-    TRUE\r
-    );\r
-  AddUnicodeString2 (\r
-    "en",\r
-    gPs2MouseComponentName2.SupportedLanguages,\r
-    &MouseDev->ControllerNameTable,\r
-    L"PS/2 Mouse Device",\r
-    FALSE\r
-    );\r
-\r
-\r
-  //\r
-  // Install protocol interfaces for the mouse device.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiSimplePointerProtocolGuid,\r
-                  &MouseDev->SimplePointerProtocol,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrorExit;\r
-  }\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-\r
-ErrorExit:\r
-\r
-  if (Status != EFI_DEVICE_ERROR) {\r
-    KbcDisableAux (IsaIo);\r
-  }\r
-\r
-  if (StatusCode != 0) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      StatusCode,\r
-      ParentDevicePath\r
-      );\r
-  }\r
-\r
-  if ((MouseDev != NULL) && (MouseDev->SimplePointerProtocol.WaitForInput != NULL)) {\r
-    gBS->CloseEvent (MouseDev->SimplePointerProtocol.WaitForInput);\r
-  }\r
-\r
-  if ((MouseDev != NULL) && (MouseDev->TimerEvent != NULL)) {\r
-    gBS->CloseEvent (MouseDev->TimerEvent);\r
-  }\r
-\r
-  if ((MouseDev != NULL) && (MouseDev->ControllerNameTable != NULL)) {\r
-    FreeUnicodeStringTable (MouseDev->ControllerNameTable);\r
-  }\r
-\r
-  if (Status != EFI_DEVICE_ERROR) {\r
-    //\r
-    // Since there will be no timer handler for mouse input any more,\r
-    // exhaust input data just in case there is still mouse data left\r
-    //\r
-    EmptyStatus = EFI_SUCCESS;\r
-    while (!EFI_ERROR (EmptyStatus)) {\r
-      EmptyStatus = In8042Data (IsaIo, &Data);\r
-    }\r
-  }\r
-\r
-  if (MouseDev != NULL) {\r
-    FreePool (MouseDev);\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stop this driver on ControllerHandle. Support stopping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseDriverStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN UINTN                          NumberOfChildren,\r
-  IN EFI_HANDLE                     *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;\r
-  PS2_MOUSE_DEV               *MouseDev;\r
-  UINT8                       Data;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiSimplePointerProtocolGuid,\r
-                  (VOID **) &SimplePointerProtocol,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  MouseDev = PS2_MOUSE_DEV_FROM_THIS (SimplePointerProtocol);\r
-\r
-  //\r
-  // Report that the keyboard is being disabled\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_DISABLE,\r
-    MouseDev->DevicePath\r
-    );\r
-\r
-  Status = gBS->UninstallProtocolInterface (\r
-                  Controller,\r
-                  &gEfiSimplePointerProtocolGuid,\r
-                  &MouseDev->SimplePointerProtocol\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Cancel mouse data polling timer, close timer event\r
-  //\r
-  gBS->SetTimer (MouseDev->TimerEvent, TimerCancel, 0);\r
-  gBS->CloseEvent (MouseDev->TimerEvent);\r
-\r
-  //\r
-  // Since there will be no timer handler for mouse input any more,\r
-  // exhaust input data just in case there is still mouse data left\r
-  //\r
-  Status = EFI_SUCCESS;\r
-  while (!EFI_ERROR (Status)) {\r
-    Status = In8042Data (MouseDev->IsaIo, &Data);\r
-  }\r
-\r
-  gBS->CloseEvent (MouseDev->SimplePointerProtocol.WaitForInput);\r
-  FreeUnicodeStringTable (MouseDev->ControllerNameTable);\r
-  FreePool (MouseDev);\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and there is a mouse device connected to system\r
-\r
-  @param This                 - Pointer of simple pointer Protocol.\r
-  @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.\r
-\r
-\r
-  @retval EFI_SUCCESS         - The command byte is written successfully.\r
-  @retval EFI_DEVICE_ERROR    - Errors occurred during resetting keyboard.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MouseReset (\r
-  IN EFI_SIMPLE_POINTER_PROTOCOL    *This,\r
-  IN BOOLEAN                        ExtendedVerification\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  PS2_MOUSE_DEV *MouseDev;\r
-  EFI_TPL       OldTpl;\r
-  BOOLEAN       KeyboardEnable;\r
-  UINT8         Data;\r
-\r
-  MouseDev = PS2_MOUSE_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Report reset progress code\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_MOUSE | EFI_P_PC_RESET,\r
-    MouseDev->DevicePath\r
-    );\r
-\r
-  KeyboardEnable = FALSE;\r
-\r
-  //\r
-  // Raise TPL to avoid keyboard operation impact\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  ZeroMem (&MouseDev->State, sizeof (EFI_SIMPLE_POINTER_STATE));\r
-  MouseDev->StateChanged = FALSE;\r
-\r
-  //\r
-  // Exhaust input data\r
-  //\r
-  Status = EFI_SUCCESS;\r
-  while (!EFI_ERROR (Status)) {\r
-    Status = In8042Data (MouseDev->IsaIo, &Data);\r
-  }\r
-\r
-  CheckKbStatus (MouseDev->IsaIo, &KeyboardEnable);\r
-\r
-  KbcDisableKb (MouseDev->IsaIo);\r
-\r
-  MouseDev->IsaIo->Io.Read (MouseDev->IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
-\r
-  //\r
-  // if there's data block on KBC data port, read it out\r
-  //\r
-  if ((Data & KBC_OUTB) == KBC_OUTB) {\r
-    MouseDev->IsaIo->Io.Read (MouseDev->IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Data);\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-  //\r
-  // The PS2 mouse driver reset behavior is always successfully return no matter wheater or not there is mouse connected to system.\r
-  // This behavior is needed by performance speed. The following mouse command only succeessfully finish when mouse device is\r
-  // connected to system, so if PS2 mouse device not connect to system or user not ask for, we skip the mouse configuration and enabling\r
-  //\r
-  if (ExtendedVerification && CheckMouseConnect (MouseDev)) {\r
-    //\r
-    // Send mouse reset command and set mouse default configure\r
-    //\r
-    Status = PS2MouseReset (MouseDev->IsaIo);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = PS2MouseSetSampleRate (MouseDev->IsaIo, MouseDev->SampleRate);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = PS2MouseSetResolution (MouseDev->IsaIo, MouseDev->Resolution);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = PS2MouseSetScaling (MouseDev->IsaIo, MouseDev->Scaling);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = PS2MouseEnable (MouseDev->IsaIo);\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-  }\r
-Exit:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  if (KeyboardEnable) {\r
-    KbcEnableKb (MouseDev->IsaIo);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Check whether there is Ps/2 mouse device in system\r
-\r
-  @param MouseDev   - Mouse Private Data Structure\r
-\r
-  @retval TRUE      - Keyboard in System.\r
-  @retval FALSE     - Keyboard not in System.\r
-\r
-**/\r
-BOOLEAN\r
-CheckMouseConnect (\r
-  IN  PS2_MOUSE_DEV     *MouseDev\r
-  )\r
-\r
-{\r
-  EFI_STATUS     Status;\r
-\r
-  Status = PS2MouseEnable (MouseDev->IsaIo);\r
-  if (!EFI_ERROR (Status)) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Get and Clear mouse status.\r
-\r
-  @param This                 - Pointer of simple pointer Protocol.\r
-  @param State                - Output buffer holding status.\r
-\r
-  @retval EFI_INVALID_PARAMETER Output buffer is invalid.\r
-  @retval EFI_NOT_READY         Mouse is not changed status yet.\r
-  @retval EFI_SUCCESS           Mouse status is changed and get successful.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MouseGetState (\r
-  IN EFI_SIMPLE_POINTER_PROTOCOL    *This,\r
-  IN OUT EFI_SIMPLE_POINTER_STATE   *State\r
-  )\r
-{\r
-  PS2_MOUSE_DEV *MouseDev;\r
-  EFI_TPL       OldTpl;\r
-\r
-  MouseDev = PS2_MOUSE_DEV_FROM_THIS (This);\r
-\r
-  if (State == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (!MouseDev->StateChanged) {\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-  CopyMem (State, &(MouseDev->State), sizeof (EFI_SIMPLE_POINTER_STATE));\r
-\r
-  //\r
-  // clear mouse state\r
-  //\r
-  MouseDev->State.RelativeMovementX = 0;\r
-  MouseDev->State.RelativeMovementY = 0;\r
-  MouseDev->State.RelativeMovementZ = 0;\r
-  MouseDev->StateChanged            = FALSE;\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  Event notification function for SIMPLE_POINTER.WaitForInput event.\r
-  Signal the event if there is input from mouse.\r
-\r
-  @param Event    event object\r
-  @param Context  event context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-MouseWaitForInput (\r
-  IN  EFI_EVENT               Event,\r
-  IN  VOID                    *Context\r
-  )\r
-{\r
-  PS2_MOUSE_DEV *MouseDev;\r
-\r
-  MouseDev = (PS2_MOUSE_DEV *) Context;\r
-\r
-  //\r
-  // Someone is waiting on the mouse event, if there's\r
-  // input from mouse, signal the event\r
-  //\r
-  if (MouseDev->StateChanged) {\r
-    gBS->SignalEvent (Event);\r
-  }\r
-\r
-}\r
-\r
-/**\r
-  Event notification function for TimerEvent event.\r
-  If mouse device is connected to system, try to get the mouse packet data.\r
-\r
-  @param Event      -  TimerEvent in PS2_MOUSE_DEV\r
-  @param Context    -  Pointer to PS2_MOUSE_DEV structure\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PollMouse (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-\r
-{\r
-  PS2_MOUSE_DEV *MouseDev;\r
-\r
-  MouseDev = (PS2_MOUSE_DEV *) Context;\r
-\r
-  //\r
-  // Polling mouse packet data\r
-  //\r
-  PS2MouseGetPacket (MouseDev);\r
-}\r
-\r
-/**\r
-  The user Entry Point for module Ps2Mouse. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializePs2Mouse(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gPS2MouseDriver,\r
-             ImageHandle,\r
-             &gPs2MouseComponentName,\r
-             &gPs2MouseComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h
deleted file mode 100644 (file)
index a77bac6..0000000
+++ /dev/null
@@ -1,394 +0,0 @@
-/** @file\r
-  PS/2 Mouse driver header file.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _PS2MOUSE_H_\r
-#define _PS2MOUSE_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/SimplePointer.h>\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gPS2MouseDriver;\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gPs2MouseComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gPs2MouseComponentName2;\r
-\r
-//\r
-// PS/2 mouse sample rate\r
-//\r
-typedef enum {\r
-  SampleRate10,\r
-  SampleRate20,\r
-  SampleRate40,\r
-  SampleRate60,\r
-  SampleRate80,\r
-  SampleRate100,\r
-  SampleRate200,\r
-  MaxSampleRate\r
-} MOUSE_SR;\r
-\r
-//\r
-// PS/2 mouse resolution\r
-//\r
-typedef enum {\r
-  MouseResolution1,\r
-  MouseResolution2,\r
-  MouseResolution4,\r
-  MouseResolution8,\r
-  MaxResolution\r
-} MOUSE_RE;\r
-\r
-//\r
-// PS/2 mouse scaling\r
-//\r
-typedef enum {\r
-  Scaling1,\r
-  Scaling2\r
-} MOUSE_SF;\r
-\r
-//\r
-// Driver Private Data\r
-//\r
-#define PS2_MOUSE_DEV_SIGNATURE SIGNATURE_32 ('p', 's', '2', 'm')\r
-\r
-typedef struct {\r
-  UINTN                               Signature;\r
-\r
-  EFI_HANDLE                          Handle;\r
-  EFI_SIMPLE_POINTER_PROTOCOL         SimplePointerProtocol;\r
-  EFI_SIMPLE_POINTER_STATE            State;\r
-  EFI_SIMPLE_POINTER_MODE             Mode;\r
-  BOOLEAN                             StateChanged;\r
-\r
-  //\r
-  // PS2 Mouse device specific information\r
-  //\r
-  MOUSE_SR                            SampleRate;\r
-  MOUSE_RE                            Resolution;\r
-  MOUSE_SF                            Scaling;\r
-  UINT8                               DataPackageSize;\r
-\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-\r
-  EFI_EVENT                           TimerEvent;\r
-\r
-  EFI_UNICODE_STRING_TABLE            *ControllerNameTable;\r
-  EFI_DEVICE_PATH_PROTOCOL            *DevicePath;\r
-} PS2_MOUSE_DEV;\r
-\r
-#define PS2_MOUSE_DEV_FROM_THIS(a)  CR (a, PS2_MOUSE_DEV, SimplePointerProtocol, PS2_MOUSE_DEV_SIGNATURE)\r
-\r
-//\r
-// Function prototypes\r
-//\r
-/**\r
-  Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
-  than contains a IsaIo protocol can be supported.\r
-\r
-  @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
-  @retval other               This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Start this driver on ControllerHandle by opening a IsaIo\r
-  protocol, creating PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid\r
-  finnally.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
-                               device to start.\r
-\r
-  @retval EFI_SUCCESS          This driver is added to ControllerHandle\r
-  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
-  @retval other                This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Stop this driver on ControllerHandle. Support stopping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PS2MouseDriverStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL   *This,\r
-  IN EFI_HANDLE                    Controller,\r
-  IN UINTN                         NumberOfChildren,\r
-  IN EFI_HANDLE                    *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2MouseComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ps2MouseComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-/**\r
-  Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and there is a mouse device connected to system\r
-\r
-  @param This                 - Pointer of simple pointer Protocol.\r
-  @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.\r
-\r
-\r
-  @retval EFI_SUCCESS         - The command byte is written successfully.\r
-  @retval EFI_DEVICE_ERROR    - Errors occurred during resetting keyboard.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MouseReset (\r
-  IN EFI_SIMPLE_POINTER_PROTOCOL    *This,\r
-  IN BOOLEAN                        ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Get and Clear mouse status.\r
-\r
-  @param This                 - Pointer of simple pointer Protocol.\r
-  @param State                - Output buffer holding status.\r
-\r
-  @retval EFI_INVALID_PARAMETER Output buffer is invalid.\r
-  @retval EFI_NOT_READY         Mouse is not changed status yet.\r
-  @retval EFI_SUCCESS           Mouse status is changed and get successful.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MouseGetState (\r
-  IN EFI_SIMPLE_POINTER_PROTOCOL    *This,\r
-  IN OUT EFI_SIMPLE_POINTER_STATE   *State\r
-  );\r
-\r
-/**\r
-\r
-  Event notification function for SIMPLE_POINTER.WaitForInput event.\r
-  Signal the event if there is input from mouse.\r
-\r
-  @param Event    event object\r
-  @param Context  event context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-MouseWaitForInput (\r
-  IN  EFI_EVENT               Event,\r
-  IN  VOID                    *Context\r
-  );\r
-\r
-/**\r
-  Event notification function for TimerEvent event.\r
-  If mouse device is connected to system, try to get the mouse packet data.\r
-\r
-  @param Event      -  TimerEvent in PS2_MOUSE_DEV\r
-  @param Context    -  Pointer to PS2_MOUSE_DEV structure\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PollMouse (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  );\r
-\r
-/**\r
-  I/O work flow of in 8042 data.\r
-\r
-  @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Data    Data value\r
-\r
-  @retval EFI_SUCCESS Success to execute I/O work flow\r
-  @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042Data (\r
-  IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
-  IN OUT UINT8                            *Data\r
-  );\r
-\r
-/**\r
-  Check whether there is Ps/2 mouse device in system\r
-\r
-  @param MouseDev   - Mouse Private Data Structure\r
-\r
-  @retval TRUE      - Keyboard in System.\r
-  @retval FALSE     - Keyboard not in System.\r
-\r
-**/\r
-BOOLEAN\r
-CheckMouseConnect (\r
-  IN  PS2_MOUSE_DEV     *MouseDev\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf
deleted file mode 100644 (file)
index c7769b0..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-## @file\r
-# PS2 Mouse Driver.\r
-#\r
-# This dirver provides support for PS2 based mice.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = Ps2MouseDxe\r
-  MODULE_UNI_FILE                = Ps2MouseDxe.uni\r
-  FILE_GUID                      = 202A2B0E-9A31-4812-B291-8747DF152439\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializePs2Mouse\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#  DRIVER_BINDING                = gPS2MouseDriver;\r
-#  COMPONENT_NAME                = gPs2MouseComponentName;\r
-#  COMPONENT_NAME2               = gPs2MouseComponentName2;\r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  CommPs2.h\r
-  CommPs2.c\r
-  Ps2Mouse.h\r
-  Ps2Mouse.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  ReportStatusCodeLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  PcdLib\r
-\r
-[Protocols]\r
-  gEfiIsaIoProtocolGuid                         ## TO_START\r
-  gEfiSimplePointerProtocolGuid                 ## BY_START\r
-  gEfiDevicePathProtocolGuid                    ## TO_START\r
-\r
-[FeaturePcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPs2MouseExtendedVerification   ## CONSUMES\r
-\r
-#\r
-# [Event]\r
-#\r
-#   ##\r
-#   # Timer event used to check the mouse state at a regular interval.\r
-#   #\r
-#   EVENT_TYPE_PERIODIC_TIMER   ## CONSUMES\r
-#\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  Ps2MouseDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.uni
deleted file mode 100644 (file)
index df927da..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// PS2 Mouse Driver.\r
-//\r
-// This dirver provides support for PS2 based mice.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "PS2 Mouse Driver"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This driver provides support for PS2-based mice."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxeExtra.uni
deleted file mode 100644 (file)
index d7ef172..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// Ps2MouseDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"PS2 Mouse DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c
deleted file mode 100644 (file)
index 195da7e..0000000
+++ /dev/null
@@ -1,2674 +0,0 @@
-/** @file\r
-  This file contains all helper functions on the ATA command\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-  @par Revision Reference:\r
-  2002-6: Add Atapi6 enhancement, support >120GB hard disk, including\r
-  update - ATAIdentity() func\r
-  update - AtaBlockIoReadBlocks() func\r
-  update - AtaBlockIoWriteBlocks() func\r
-  add    - AtaAtapi6Identify() func\r
-  add    - AtaReadSectorsExt() func\r
-  add    - AtaWriteSectorsExt() func\r
-  add    - AtaPioDataInExt() func\r
-  add    - AtaPioDataOutExt() func\r
-\r
-**/\r
-\r
-#include "IdeBus.h"\r
-/**\r
-  This function is called by ATAIdentify() to identity whether this disk\r
-  supports ATA/ATAPI6 48bit addressing, ie support >120G capacity\r
-\r
-  @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS       The disk specified by IdeDev is a Atapi6 supported one and\r
-                            48-bit addressing must be used\r
-  @retval EFI_UNSUPPORTED   The disk dosn't not support Atapi6 or it supports but the\r
-                            capacity is below 120G, 48bit addressing is not needed\r
-  @retval  EFI_DEVICE_ERROR      The identify data in IdeDev is incorrect\r
-  @retval  EFI_INVALID_PARAMETER The identify data in IdeDev is NULL.\r
-\r
-  @note  This function must be called after DEVICE_IDENTITY command has been\r
-          successfully returned\r
-\r
-**/\r
-EFI_STATUS\r
-AtaAtapi6Identify (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  UINT8             Index;\r
-  EFI_LBA           TmpLba;\r
-  EFI_LBA           Capacity;\r
-  EFI_IDENTIFY_DATA *Atapi6IdentifyStruct;\r
-\r
-  if (IdeDev->IdData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Atapi6IdentifyStruct = IdeDev->IdData;\r
-\r
-  if ((Atapi6IdentifyStruct->AtapiData.cmd_set_support_83 & (BIT15 | BIT14)) != 0x4000) {\r
-    //\r
-    // Per ATA-6 spec, word83: bit15 is zero and bit14 is one\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if ((Atapi6IdentifyStruct->AtapiData.cmd_set_support_83 & BIT10) == 0) {\r
-    //\r
-    // The device dosn't support 48 bit addressing\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // 48 bit address feature set is supported, get maximum capacity\r
-  //\r
-  Capacity = Atapi6IdentifyStruct->AtaData.maximum_lba_for_48bit_addressing[0];\r
-  for (Index = 1; Index < 4; Index++) {\r
-    //\r
-    // Lower byte goes first: word[100] is the lowest word, word[103] is highest\r
-    //\r
-    TmpLba = Atapi6IdentifyStruct->AtaData.maximum_lba_for_48bit_addressing[Index];\r
-    Capacity |= LShiftU64 (TmpLba, 16 * Index);\r
-  }\r
-\r
-  if (Capacity > MAX_28BIT_ADDRESSING_CAPACITY) {\r
-    //\r
-    // Capacity exceeds 120GB. 48-bit addressing is really needed\r
-    //\r
-    IdeDev->Type = Ide48bitAddressingHardDisk;\r
-\r
-    //\r
-    // Fill block media information:Media->LogicalPartition ,\r
-    // Media->WriteCaching will be filledin the DiscoverIdeDevcie() function.\r
-    //\r
-    IdeDev->BlkIo.Media->IoAlign        = 4;\r
-    IdeDev->BlkIo.Media->MediaId        = 1;\r
-    IdeDev->BlkIo.Media->RemovableMedia = FALSE;\r
-    IdeDev->BlkIo.Media->MediaPresent   = TRUE;\r
-    IdeDev->BlkIo.Media->ReadOnly       = FALSE;\r
-    IdeDev->BlkIo.Media->BlockSize      = 0x200;\r
-    IdeDev->BlkIo.Media->LastBlock      = Capacity - 1;\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-/**\r
-  Enable SMART of the disk if supported\r
-\r
-  @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
-                all the information of the IDE device.\r
-**/\r
-VOID\r
-AtaSMARTSupport (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  BOOLEAN           SMARTSupported;\r
-  UINT8             Device;\r
-  EFI_IDENTIFY_DATA *TmpAtaIdentifyPointer;\r
-  UINT8             DeviceSelect;\r
-  UINT8             LBAMid;\r
-  UINT8             LBAHigh;\r
-\r
-  //\r
-  // Detect if the device supports S.M.A.R.T.\r
-  //\r
-  if ((IdeDev->IdData->AtaData.command_set_supported_83 & 0xc000) != 0x4000) {\r
-    //\r
-    // Data in word 82 is not valid (bit15 shall be zero and bit14 shall be to one)\r
-    //\r
-    return ;\r
-  } else {\r
-    if ((IdeDev->IdData->AtaData.command_set_supported_82 & 0x0001) != 0x0001) {\r
-      //\r
-      // S.M.A.R.T is not supported by the device\r
-      //\r
-      SMARTSupported = FALSE;\r
-    } else {\r
-      SMARTSupported = TRUE;\r
-    }\r
-  }\r
-\r
-  if (!SMARTSupported) {\r
-    //\r
-    // Report nonsupport status code\r
-    //\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED)\r
-      );\r
-  } else {\r
-    //\r
-    // Enable this feature\r
-    //\r
-    REPORT_STATUS_CODE (\r
-      EFI_PROGRESS_CODE,\r
-      (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_ENABLE)\r
-      );\r
-\r
-    Device = (UINT8) ((IdeDev->Device << 4) | 0xe0);\r
-    Status = AtaNonDataCommandIn (\r
-              IdeDev,\r
-              ATA_CMD_SMART,\r
-              Device,\r
-              ATA_SMART_ENABLE_OPERATION,\r
-              0,\r
-              0,\r
-              ATA_CONSTANT_4F,\r
-              ATA_CONSTANT_C2\r
-              );\r
-    //\r
-    // Detect if this feature is enabled\r
-    //\r
-    TmpAtaIdentifyPointer = (EFI_IDENTIFY_DATA *) AllocateZeroPool (sizeof (EFI_IDENTIFY_DATA));\r
-    if (TmpAtaIdentifyPointer == NULL) {\r
-      return;\r
-    }\r
-\r
-    DeviceSelect          = (UINT8) ((IdeDev->Device) << 4);\r
-    Status = AtaPioDataIn (\r
-              IdeDev,\r
-              (VOID *) TmpAtaIdentifyPointer,\r
-              sizeof (EFI_IDENTIFY_DATA),\r
-              ATA_CMD_IDENTIFY_DRIVE,\r
-              DeviceSelect,\r
-              0,\r
-              0,\r
-              0,\r
-              0\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      gBS->FreePool (TmpAtaIdentifyPointer);\r
-      return ;\r
-    }\r
-\r
-    //\r
-    // Check if the feature is enabled\r
-    //\r
-    if ((TmpAtaIdentifyPointer->AtaData.command_set_feature_enb_85 & 0x0001) == 0x0001) {\r
-      //\r
-      // Read status data\r
-      //\r
-      AtaNonDataCommandIn (\r
-        IdeDev,\r
-        ATA_CMD_SMART,\r
-        Device,\r
-        ATA_SMART_RETURN_STATUS,\r
-        0,\r
-        0,\r
-        ATA_CONSTANT_4F,\r
-        ATA_CONSTANT_C2\r
-        );\r
-      LBAMid  = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb);\r
-      LBAHigh = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb);\r
-\r
-      if ((LBAMid == 0x4f) && (LBAHigh == 0xc2)) {\r
-        //\r
-        // The threshold exceeded condition is not detected by the device\r
-        //\r
-        REPORT_STATUS_CODE (\r
-              EFI_PROGRESS_CODE,\r
-              (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD)\r
-              );\r
-\r
-      } else if ((LBAMid == 0xf4) && (LBAHigh == 0x2c)) {\r
-        //\r
-        // The threshold exceeded condition is  detected by the device\r
-        //\r
-        REPORT_STATUS_CODE (\r
-              EFI_PROGRESS_CODE,\r
-              (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD)\r
-              );\r
-      }\r
-\r
-    } else {\r
-      //\r
-      // Report disabled status code\r
-      //\r
-      REPORT_STATUS_CODE (\r
-            EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-            (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLED)\r
-            );\r
-    }\r
-\r
-    gBS->FreePool (TmpAtaIdentifyPointer);\r
-  }\r
-\r
-  return ;\r
-}\r
-/**\r
-  Sends out an ATA Identify Command to the specified device.\r
-\r
-  This function is called by DiscoverIdeDevice() during its device\r
-  identification. It sends out the ATA Identify Command to the\r
-  specified device. Only ATA device responses to this command. If\r
-  the command succeeds, it returns the Identify data structure which\r
-  contains information about the device. This function extracts the\r
-  information it needs to fill the IDE_BLK_IO_DEV data structure,\r
-  including device type, media block size, media capacity, and etc.\r
-\r
-  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
-                 all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS      Identify ATA device successfully.\r
-  @retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.\r
-  @note  parameter IdeDev will be updated in this function.\r
-\r
-**/\r
-EFI_STATUS\r
-ATAIdentify (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  EFI_IDENTIFY_DATA *AtaIdentifyPointer;\r
-  UINT32            Capacity;\r
-  UINT8             DeviceSelect;\r
-  UINTN        Retry;\r
-\r
-  //\r
-  //  AtaIdentifyPointer is used for accommodating returned IDENTIFY data of\r
-  //  the ATA Identify command\r
-  //\r
-  AtaIdentifyPointer = (EFI_IDENTIFY_DATA *) AllocateZeroPool (sizeof (EFI_IDENTIFY_DATA));\r
-  if (AtaIdentifyPointer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  //  use ATA PIO Data In protocol to send ATA Identify command\r
-  //  and receive data from device\r
-  //\r
-  DeviceSelect  = (UINT8) ((IdeDev->Device) << 4);\r
-\r
-\r
-  Retry = 3;\r
-  while (Retry > 0) {\r
-    Status = AtaPioDataIn (\r
-              IdeDev,\r
-              (VOID *) AtaIdentifyPointer,\r
-              sizeof (EFI_IDENTIFY_DATA),\r
-              ATA_CMD_IDENTIFY_DRIVE,\r
-              DeviceSelect,\r
-              0,\r
-              0,\r
-              0,\r
-              0\r
-              );\r
-    //\r
-    // If ATA Identify command succeeds, then according to the received\r
-    // IDENTIFY data,\r
-    // identify the device type ( ATA or not ).\r
-    // If ATA device, fill the information in IdeDev.\r
-    // If not ATA device, return IDE_DEVICE_ERROR\r
-    //\r
-    if (!EFI_ERROR (Status)) {\r
-\r
-      IdeDev->IdData = AtaIdentifyPointer;\r
-\r
-      //\r
-      // Print ATA Module Name\r
-      //\r
-      PrintAtaModuleName (IdeDev);\r
-\r
-      //\r
-      // bit 15 of pAtaIdentify->config is used to identify whether device is\r
-      // ATA device or ATAPI device.\r
-      // if 0, means ATA device; if 1, means ATAPI device.\r
-      //\r
-      if ((AtaIdentifyPointer->AtaData.config & 0x8000) == 0x00) {\r
-        //\r
-        // Detect if support S.M.A.R.T. If yes, enable it as default\r
-        //\r
-        AtaSMARTSupport (IdeDev);\r
-\r
-        //\r
-        // Check whether this device needs 48-bit addressing (ATAPI-6 ata device)\r
-        //\r
-        Status = AtaAtapi6Identify (IdeDev);\r
-        if (!EFI_ERROR (Status)) {\r
-          //\r
-          // It's a disk with >120GB capacity, initialized in AtaAtapi6Identify()\r
-          //\r
-          return EFI_SUCCESS;\r
-        } else if (Status == EFI_DEVICE_ERROR) {\r
-      //\r
-      // Some disk with big capacity (>200GB) is slow when being identified\r
-      // and will return all zero for word83.\r
-      // We try twice at first. If it fails, we do a SoftRest and try again.\r
-      //\r
-      Retry--;\r
-      if (Retry == 1) {\r
-        //\r
-        // Do a SoftRest before the third attempt.\r
-        //\r
-        AtaSoftReset (IdeDev);\r
-      }\r
-      continue;\r
-      }\r
-        //\r
-        // This is a hard disk <= 120GB capacity, treat it as normal hard disk\r
-        //\r
-        IdeDev->Type = IdeHardDisk;\r
-\r
-        //\r
-        // Block Media Information:\r
-        // Media->LogicalPartition , Media->WriteCaching will be filled\r
-        // in the DiscoverIdeDevcie() function.\r
-        //\r
-        IdeDev->BlkIo.Media->IoAlign        = 4;\r
-        IdeDev->BlkIo.Media->MediaId        = 1;\r
-        IdeDev->BlkIo.Media->RemovableMedia = FALSE;\r
-        IdeDev->BlkIo.Media->MediaPresent   = TRUE;\r
-        IdeDev->BlkIo.Media->ReadOnly       = FALSE;\r
-        IdeDev->BlkIo.Media->BlockSize      = 0x200;\r
-\r
-        //\r
-        // Calculate device capacity\r
-        //\r
-        Capacity = ((UINT32)AtaIdentifyPointer->AtaData.user_addressable_sectors_hi << 16) |\r
-                  AtaIdentifyPointer->AtaData.user_addressable_sectors_lo ;\r
-        IdeDev->BlkIo.Media->LastBlock = Capacity - 1;\r
-\r
-        return EFI_SUCCESS;\r
-      }\r
-\r
-    }\r
-    break;\r
-  }\r
-\r
-  gBS->FreePool (AtaIdentifyPointer);\r
-  //\r
-  // Make sure the pIdData will not be freed again.\r
-  //\r
-  IdeDev->IdData = NULL;\r
-\r
-  return EFI_DEVICE_ERROR;\r
-}\r
-\r
-/**\r
-  This function is a helper function used to change the char order in a string. It\r
-  is designed specially for the PrintAtaModuleName() function. After the IDE device\r
-  is detected, the IDE driver gets the device module name by sending ATA command\r
-  called ATA Identify Command or ATAPI Identify Command to the specified IDE device.\r
-  The module name returned is a string of ASCII characters: the first character is bit8--bit15\r
-  of the first word, the second character is BIT0--bit7 of the first word and so on. Thus\r
-  the string can not be print directly before it is preprocessed by this func to change\r
-  the order of characters in each word in the string.\r
-\r
-  @param Destination Indicates the destination string.\r
-  @param Source      Indicates the source string.\r
-  @param Size         the length of the string\r
-**/\r
-VOID\r
-SwapStringChars (\r
-  IN CHAR8  *Destination,\r
-  IN CHAR8  *Source,\r
-  IN UINT32 Size\r
-  )\r
-{\r
-  UINT32  Index;\r
-  CHAR8   Temp;\r
-\r
-  for (Index = 0; Index < Size; Index += 2) {\r
-\r
-    Temp                    = Source[Index + 1];\r
-    Destination[Index + 1]  = Source[Index];\r
-    Destination[Index]      = Temp;\r
-  }\r
-}\r
-/**\r
-  This function is called by ATAIdentify() or ATAPIIdentify() to print device's module name.\r
-\r
-  @param  IdeDev   pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                   all the information of the IDE device.\r
-**/\r
-VOID\r
-PrintAtaModuleName (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  if (IdeDev->IdData == NULL) {\r
-    return ;\r
-  }\r
-\r
-  SwapStringChars (IdeDev->ModelName, IdeDev->IdData->AtaData.ModelName, 40);\r
-  IdeDev->ModelName[40] = 0x00;\r
-}\r
-\r
-/**\r
-  This function is used to send out ATA commands conforms to the PIO Data In Protocol.\r
-\r
-  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                      all the information of the IDE device.\r
-  @param Buffer       buffer contained data transferred from device to host.\r
-  @param ByteCount    data size in byte unit of the buffer.\r
-  @param AtaCommand   value of the Command Register\r
-  @param Head         value of the Head/Device Register\r
-  @param SectorCount  value of the Sector Count Register\r
-  @param SectorNumber value of the Sector Number Register\r
-  @param CylinderLsb  value of the low byte of the Cylinder Register\r
-  @param CylinderMsb  value of the high byte of the Cylinder Register\r
-\r
-  @retval EFI_SUCCESS      send out the ATA command and device send required data successfully.\r
-  @retval EFI_DEVICE_ERROR command sent failed.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaPioDataIn (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *Buffer,\r
-  IN  UINT32          ByteCount,\r
-  IN  UINT8           AtaCommand,\r
-  IN  UINT8           Head,\r
-  IN  UINT8           SectorCount,\r
-  IN  UINT8           SectorNumber,\r
-  IN  UINT8           CylinderLsb,\r
-  IN  UINT8           CylinderMsb\r
-  )\r
-{\r
-  UINTN       WordCount;\r
-  UINTN       Increment;\r
-  UINT16      *Buffer16;\r
-  EFI_STATUS  Status;\r
-\r
-  Status = WaitForBSYClear (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  //  e0:1110,0000-- bit7 and bit5 are reserved bits.\r
-  //           bit6 set means LBA mode\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((IdeDev->Device << 4) | 0xe0 | Head)\r
-    );\r
-\r
-  //\r
-  // All ATAPI device's ATA commands can be issued regardless of the\r
-  // state of the DRDY\r
-  //\r
-  if (IdeDev->Type == IdeHardDisk) {\r
-\r
-    Status = DRDYReady (IdeDev, ATATIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // set all the command parameters\r
-  // Before write to all the following registers, BSY and DRQ must be 0.\r
-  //\r
-  Status = DRQClear2 (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (AtaCommand == ATA_CMD_SET_FEATURES) {\r
-    IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x03);\r
-  }\r
-\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, SectorNumber);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, CylinderLsb);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, CylinderMsb);\r
-\r
-  //\r
-  // send command via Command Register\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);\r
-\r
-  Buffer16 = (UINT16 *) Buffer;\r
-\r
-  //\r
-  // According to PIO data in protocol, host can perform a series of reads to\r
-  // the data register after each time device set DRQ ready;\r
-  // The data size of "a series of read" is command specific.\r
-  // For most ATA command, data size received from device will not exceed\r
-  // 1 sector, hence the data size for "a series of read" can be the whole data\r
-  // size of one command request.\r
-  // For ATA command such as Read Sector command, the data size of one ATA\r
-  // command request is often larger than 1 sector, according to the\r
-  // Read Sector command, the data size of "a series of read" is exactly 1\r
-  // sector.\r
-  // Here for simplification reason, we specify the data size for\r
-  // "a series of read" to 1 sector (256 words) if data size of one ATA command\r
-  // request is larger than 256 words.\r
-  //\r
-  Increment = 256;\r
-\r
-  //\r
-  // used to record bytes of currently transfered data\r
-  //\r
-  WordCount = 0;\r
-\r
-  while (WordCount < ByteCount / 2) {\r
-    //\r
-    // Poll DRQ bit set, data transfer can be performed only when DRQ is ready.\r
-    //\r
-    Status = DRQReady2 (IdeDev, ATATIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Status = CheckErrorStatus (IdeDev);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    //\r
-    // Get the byte count for one series of read\r
-    //\r
-    if ((WordCount + Increment) > ByteCount / 2) {\r
-      Increment = ByteCount / 2 - WordCount;\r
-    }\r
-\r
-    IDEReadPortWMultiple (\r
-      IdeDev->PciIo,\r
-      IdeDev->IoPort->Data,\r
-      Increment,\r
-      Buffer16\r
-      );\r
-\r
-    WordCount += Increment;\r
-    Buffer16 += Increment;\r
-\r
-  }\r
-\r
-  DRQClear (IdeDev, ATATIMEOUT);\r
-\r
-  return CheckErrorStatus (IdeDev);\r
-}\r
-\r
-/**\r
-  This function is used to send out ATA commands conforms to the\r
-  PIO Data Out Protocol.\r
-\r
-  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                      to record all the information of the IDE device.\r
-  @param *Buffer      buffer contained data transferred from host to device.\r
-  @param ByteCount    data size in byte unit of the buffer.\r
-  @param AtaCommand   value of the Command Register\r
-  @param Head         value of the Head/Device Register\r
-  @param SectorCount  value of the Sector Count Register\r
-  @param SectorNumber value of the Sector Number Register\r
-  @param CylinderLsb  value of the low byte of the Cylinder Register\r
-  @param CylinderMsb  value of the high byte of the Cylinder Register\r
-\r
-  @retval EFI_SUCCESS      send out the ATA command and device received required\r
-                           data successfully.\r
-  @retval EFI_DEVICE_ERROR command sent failed.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaPioDataOut (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *Buffer,\r
-  IN  UINT32          ByteCount,\r
-  IN  UINT8           AtaCommand,\r
-  IN  UINT8           Head,\r
-  IN  UINT8           SectorCount,\r
-  IN  UINT8           SectorNumber,\r
-  IN  UINT8           CylinderLsb,\r
-  IN  UINT8           CylinderMsb\r
-  )\r
-{\r
-  UINTN       WordCount;\r
-  UINTN       Increment;\r
-  UINT16      *Buffer16;\r
-  EFI_STATUS  Status;\r
-\r
-  Status = WaitForBSYClear (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // select device via Head/Device register.\r
-  // Before write Head/Device register, BSY and DRQ must be 0.\r
-  //\r
-  Status = DRQClear2 (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // e0:1110,0000-- bit7 and bit5 are reserved bits.\r
-  //          bit6 set means LBA mode\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((IdeDev->Device << 4) | 0xe0 | Head)\r
-    );\r
-\r
-  Status = DRDYReady (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // set all the command parameters\r
-  // Before write to all the following registers, BSY and DRQ must be 0.\r
-  //\r
-  Status = DRQClear2 (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, SectorNumber);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, CylinderLsb);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, CylinderMsb);\r
-\r
-  //\r
-  // send command via Command Register\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);\r
-\r
-  Buffer16 = (UINT16 *) Buffer;\r
-\r
-  //\r
-  // According to PIO data out protocol, host can perform a series of\r
-  // writes to the data register after each time device set DRQ ready;\r
-  // The data size of "a series of read" is command specific.\r
-  // For most ATA command, data size written to device will not exceed 1 sector,\r
-  // hence the data size for "a series of write" can be the data size of one\r
-  // command request.\r
-  // For ATA command such as Write Sector command, the data size of one\r
-  // ATA command request is often larger than 1 sector, according to the\r
-  // Write Sector command, the data size of "a series of read" is exactly\r
-  // 1 sector.\r
-  // Here for simplification reason, we specify the data size for\r
-  // "a series of write" to 1 sector (256 words) if data size of one ATA command\r
-  // request is larger than 256 words.\r
-  //\r
-  Increment = 256;\r
-  WordCount = 0;\r
-\r
-  while (WordCount < ByteCount / 2) {\r
-\r
-    //\r
-    // DRQReady2-- read Alternate Status Register to determine the DRQ bit\r
-    // data transfer can be performed only when DRQ is ready.\r
-    //\r
-    Status = DRQReady2 (IdeDev, ATATIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Status = CheckErrorStatus (IdeDev);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-   //\r
-   // Check the remaining byte count is less than 512 bytes\r
-   //\r
-   if ((WordCount + Increment) > ByteCount / 2) {\r
-      Increment = ByteCount / 2 - WordCount;\r
-    }\r
-    //\r
-    // perform a series of write without check DRQ ready\r
-    //\r
-\r
-    IDEWritePortWMultiple (\r
-      IdeDev->PciIo,\r
-      IdeDev->IoPort->Data,\r
-      Increment,\r
-      Buffer16\r
-      );\r
-    WordCount += Increment;\r
-    Buffer16 += Increment;\r
-\r
-  }\r
-\r
-  DRQClear (IdeDev, ATATIMEOUT);\r
-\r
-  return CheckErrorStatus (IdeDev);\r
-}\r
-\r
-/**\r
-  This function is used to analyze the Status Register and print out\r
-  some debug information and if there is ERR bit set in the Status\r
-  Register, the Error Register's value is also be parsed and print out.\r
-\r
-  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
-                 record all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS       No err information in the Status Register.\r
-  @retval EFI_DEVICE_ERROR  Any err information in the Status Register.\r
-\r
-**/\r
-EFI_STATUS\r
-CheckErrorStatus (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  UINT8 StatusRegister;\r
-  UINT8 ErrorRegister;\r
-\r
-  StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);\r
-\r
-  DEBUG_CODE_BEGIN ();\r
-\r
-  if ((StatusRegister & ATA_STSREG_DWF) != 0) {\r
-    DEBUG (\r
-      (EFI_D_BLKIO,\r
-      "CheckErrorStatus()-- %02x : Error : Write Fault\n",\r
-      StatusRegister)\r
-      );\r
-  }\r
-\r
-  if ((StatusRegister & ATA_STSREG_CORR) != 0) {\r
-    DEBUG (\r
-      (EFI_D_BLKIO,\r
-      "CheckErrorStatus()-- %02x : Error : Corrected Data\n",\r
-      StatusRegister)\r
-      );\r
-   }\r
-\r
-  if ((StatusRegister & ATA_STSREG_ERR) != 0) {\r
-    ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);\r
-\r
-    if ((ErrorRegister & ATA_ERRREG_BBK) != 0) {\r
-      DEBUG (\r
-        (EFI_D_BLKIO,\r
-        "CheckErrorStatus()-- %02x : Error : Bad Block Detected\n",\r
-        ErrorRegister)\r
-        );\r
-      }\r
-\r
-      if ((ErrorRegister & ATA_ERRREG_UNC) != 0) {\r
-        DEBUG (\r
-          (EFI_D_BLKIO,\r
-          "CheckErrorStatus()-- %02x : Error : Uncorrectable Data\n",\r
-          ErrorRegister)\r
-          );\r
-      }\r
-\r
-      if ((ErrorRegister & ATA_ERRREG_MC) != 0) {\r
-        DEBUG (\r
-          (EFI_D_BLKIO,\r
-          "CheckErrorStatus()-- %02x : Error : Media Change\n",\r
-          ErrorRegister)\r
-          );\r
-      }\r
-\r
-      if ((ErrorRegister & ATA_ERRREG_ABRT) != 0) {\r
-        DEBUG (\r
-          (EFI_D_BLKIO,\r
-          "CheckErrorStatus()-- %02x : Error : Abort\n",\r
-          ErrorRegister)\r
-          );\r
-      }\r
-\r
-      if ((ErrorRegister & ATA_ERRREG_TK0NF) != 0) {\r
-        DEBUG (\r
-          (EFI_D_BLKIO,\r
-          "CheckErrorStatus()-- %02x : Error : Track 0 Not Found\n",\r
-          ErrorRegister)\r
-          );\r
-      }\r
-\r
-      if ((ErrorRegister & ATA_ERRREG_AMNF) != 0) {\r
-        DEBUG (\r
-          (EFI_D_BLKIO,\r
-          "CheckErrorStatus()-- %02x : Error : Address Mark Not Found\n",\r
-          ErrorRegister)\r
-          );\r
-      }\r
-    }\r
-\r
-  DEBUG_CODE_END ();\r
-\r
-  if ((StatusRegister & (ATA_STSREG_ERR | ATA_STSREG_DWF | ATA_STSREG_CORR)) == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_DEVICE_ERROR;\r
-\r
-}\r
-\r
-/**\r
-  This function is called by the AtaBlkIoReadBlocks() to perform reading from\r
-  media in block unit.\r
-\r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                        all the information of the IDE device.\r
-  @param DataBuffer     A pointer to the destination buffer for the data.\r
-  @param Lba            The starting logical block address to read from on the device media.\r
-  @param NumberOfBlocks The number of transfer data blocks.\r
-\r
-  @return status is fully dependent on the return status of AtaPioDataIn() function.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaReadSectors (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *DataBuffer,\r
-  IN  EFI_LBA         Lba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       BlocksRemaining;\r
-  UINT32      Lba32;\r
-  UINT8       Lba0;\r
-  UINT8       Lba1;\r
-  UINT8       Lba2;\r
-  UINT8       Lba3;\r
-  UINT8       AtaCommand;\r
-  UINT8       SectorCount8;\r
-  UINT16      SectorCount;\r
-  UINTN       ByteCount;\r
-  VOID        *Buffer;\r
-\r
-  Buffer = DataBuffer;\r
-\r
-  //\r
-  // Using ATA Read Sector(s) command (opcode=0x20) with PIO DATA IN protocol\r
-  //\r
-  AtaCommand      = ATA_CMD_READ_SECTORS;\r
-\r
-\r
-  BlocksRemaining = NumberOfBlocks;\r
-\r
-  Lba32           = (UINT32) Lba;\r
-\r
-  Status          = EFI_SUCCESS;\r
-\r
-  while (BlocksRemaining > 0) {\r
-\r
-    //\r
-    // in ATA-3 spec, LBA is in 28 bit width\r
-    //\r
-    Lba0  = (UINT8) Lba32;\r
-    Lba1  = (UINT8) (Lba32 >> 8);\r
-    Lba2  = (UINT8) (Lba32 >> 16);\r
-    //\r
-    // low 4 bit of Lba3 stands for LBA bit24~bit27.\r
-    //\r
-    Lba3 = (UINT8) ((Lba32 >> 24) & 0x0f);\r
-\r
-    if (BlocksRemaining >= 0x100) {\r
-\r
-      //\r
-      //  SectorCount8 is sent to Sector Count register, 0x00 means 256\r
-      //  sectors to be read\r
-      //\r
-      SectorCount8 = 0x00;\r
-      //\r
-      //  SectorCount is used to record the number of sectors to be read\r
-      //\r
-      SectorCount = 256;\r
-    } else {\r
-\r
-      SectorCount8  = (UINT8) BlocksRemaining;\r
-      SectorCount   = (UINT16) BlocksRemaining;\r
-    }\r
-\r
-    //\r
-    // ByteCount is the number of bytes that will be read\r
-    //\r
-    ByteCount = SectorCount * (IdeDev->BlkIo.Media->BlockSize);\r
-\r
-    //\r
-    // call AtaPioDataIn() to send Read Sector Command and receive data read\r
-    //\r
-    Status = AtaPioDataIn (\r
-              IdeDev,\r
-              Buffer,\r
-              (UINT32) ByteCount,\r
-              AtaCommand,\r
-              Lba3,\r
-              SectorCount8,\r
-              Lba0,\r
-              Lba1,\r
-              Lba2\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    Lba32 += SectorCount;\r
-    Buffer = ((UINT8 *) Buffer + ByteCount);\r
-    BlocksRemaining -= SectorCount;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function is called by the AtaBlkIoWriteBlocks() to perform writing onto\r
-  media in block unit.\r
-\r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
-                        all the information of the IDE device.\r
-  @param BufferData     A pointer to the source buffer for the data.\r
-  @param Lba            The starting logical block address to write onto the device media.\r
-  @param NumberOfBlocks The number of transfer data blocks.\r
-\r
-  @return status is fully dependent on the return status of AtaPioDataIn() function.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaWriteSectors (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *BufferData,\r
-  IN  EFI_LBA         Lba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       BlocksRemaining;\r
-  UINT32      Lba32;\r
-  UINT8       Lba0;\r
-  UINT8       Lba1;\r
-  UINT8       Lba2;\r
-  UINT8       Lba3;\r
-  UINT8       AtaCommand;\r
-  UINT8       SectorCount8;\r
-  UINT16      SectorCount;\r
-  UINTN       ByteCount;\r
-  VOID        *Buffer;\r
-\r
-  Buffer = BufferData;\r
-\r
-  //\r
-  // Using Write Sector(s) command (opcode=0x30) with PIO DATA OUT protocol\r
-  //\r
-  AtaCommand      = ATA_CMD_WRITE_SECTORS;\r
-\r
-  BlocksRemaining = NumberOfBlocks;\r
-\r
-  Lba32           = (UINT32) Lba;\r
-\r
-  Status          = EFI_SUCCESS;\r
-\r
-  while (BlocksRemaining > 0) {\r
-\r
-    Lba0  = (UINT8) Lba32;\r
-    Lba1  = (UINT8) (Lba32 >> 8);\r
-    Lba2  = (UINT8) (Lba32 >> 16);\r
-    Lba3  = (UINT8) ((Lba32 >> 24) & 0x0f);\r
-\r
-    if (BlocksRemaining >= 0x100) {\r
-\r
-      //\r
-      //  SectorCount8 is sent to Sector Count register, 0x00 means 256 sectors\r
-      //  to be written\r
-      //\r
-      SectorCount8 = 0x00;\r
-      //\r
-      //  SectorCount is used to record the number of sectors to be written\r
-      //\r
-      SectorCount = 256;\r
-    } else {\r
-\r
-      SectorCount8  = (UINT8) BlocksRemaining;\r
-      SectorCount   = (UINT16) BlocksRemaining;\r
-    }\r
-\r
-    ByteCount = SectorCount * (IdeDev->BlkIo.Media->BlockSize);\r
-\r
-    Status = AtaPioDataOut (\r
-              IdeDev,\r
-              Buffer,\r
-              (UINT32) ByteCount,\r
-              AtaCommand,\r
-              Lba3,\r
-              SectorCount8,\r
-              Lba0,\r
-              Lba1,\r
-              Lba2\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    Lba32 += SectorCount;\r
-    Buffer = ((UINT8 *) Buffer + ByteCount);\r
-    BlocksRemaining -= SectorCount;\r
-  }\r
-\r
-  return Status;\r
-}\r
-/**\r
-  This function is used to implement the Soft Reset on the specified device. But,\r
-  the ATA Soft Reset mechanism is so strong a reset method that it will force\r
-  resetting on both devices connected to the same cable.\r
-\r
-  It is called by IdeBlkIoReset(), a interface function of Block\r
-  I/O protocol.\r
-\r
-  This function can also be used by the ATAPI device to perform reset when\r
-  ATAPI Reset command is failed.\r
-\r
-  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                 all the information of the IDE device.\r
-  @retval EFI_SUCCESS       Soft reset completes successfully.\r
-  @retval EFI_DEVICE_ERROR  Any step during the reset process is failed.\r
-\r
-  @note  The registers initial values after ATA soft reset are different\r
-         to the ATA device and ATAPI device.\r
-**/\r
-EFI_STATUS\r
-AtaSoftReset (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-\r
-  UINT8 DeviceControl;\r
-\r
-  DeviceControl = 0;\r
-  //\r
-  // set SRST bit to initiate soft reset\r
-  //\r
-  DeviceControl |= ATA_CTLREG_SRST;\r
-\r
-  //\r
-  // disable Interrupt\r
-  //\r
-  DeviceControl |= BIT1;\r
-\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);\r
-\r
-  //\r
-  // SRST should assert for at least 5 us, we use 10 us for\r
-  // better compatibility\r
-  //\r
-  gBS->Stall (10);\r
-\r
-  //\r
-  // Enable interrupt to support UDMA, and clear SRST bit\r
-  //\r
-  DeviceControl = 0;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);\r
-\r
-  //\r
-  // Wait for at least 2 ms to check BSY status, we use 10 ms\r
-  // for better compatibility\r
-  //\r
-  gBS->Stall(10000);\r
-  //\r
-  // slave device needs at most 31s to clear BSY\r
-  //\r
-  if (WaitForBSYClear (IdeDev, 31000) == EFI_TIMEOUT) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function is used to send out ATA commands conforms to the PIO Data In\r
-  Protocol, supporting ATA/ATAPI-6 standard\r
-\r
-  Comparing with ATA-3 data in protocol, we have two differents here:\r
-  1. Do NOT wait for DRQ clear before sending command into IDE device.(the\r
-  wait will frequently fail... cause writing function return error)\r
-\r
-  2. Do NOT wait for DRQ clear after all data readed.(the wait greatly\r
-  slow down writing performance by 100 times!)\r
-\r
-  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                      to record all the information of the IDE device.\r
-  @param Buffer       buffer contained data transferred from device to host.\r
-  @param ByteCount    data size in byte unit of the buffer.\r
-  @param AtaCommand   value of the Command Register\r
-  @param StartLba     the start LBA of this transaction\r
-  @param SectorCount  the count of sectors to be transfered\r
-\r
-  @retval EFI_SUCCESS      send out the ATA command and device send required data successfully.\r
-  @retval EFI_DEVICE_ERROR command sent failed.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaPioDataInExt (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  OUT VOID        *Buffer,\r
-  IN  UINT32          ByteCount,\r
-  IN  UINT8           AtaCommand,\r
-  IN  EFI_LBA         StartLba,\r
-  IN  UINT16          SectorCount\r
-  )\r
-{\r
-  UINT8       DevSel;\r
-  UINT8       SectorCount8;\r
-  UINT8       LbaLow;\r
-  UINT8       LbaMid;\r
-  UINT8       LbaHigh;\r
-  UINTN       WordCount;\r
-  UINTN       Increment;\r
-  UINT16      *Buffer16;\r
-  EFI_STATUS  Status;\r
-\r
-  Status = WaitForBSYClear (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Select device, set bit6 as 1 to indicate LBA mode is used\r
-  //\r
-  DevSel = (UINT8) (IdeDev->Device << 4);\r
-  DevSel |= 0x40;\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    DevSel\r
-    );\r
-\r
-  //\r
-  // Wait for DRDY singnal asserting. ATAPI device needn't wait\r
-  //\r
-  if ( (IdeDev->Type == IdeHardDisk)  ||\r
-        (IdeDev->Type == Ide48bitAddressingHardDisk)) {\r
-\r
-    Status = DRDYReady (IdeDev, ATATIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Fill feature register if needed\r
-  //\r
-  if (AtaCommand == ATA_CMD_SET_FEATURES) {\r
-    IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x03);\r
-  }\r
-\r
-  //\r
-  // Fill the sector count register, which is a two-byte FIFO. Need write twice.\r
-  //\r
-  SectorCount8 = (UINT8) (SectorCount >> 8);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);\r
-\r
-  SectorCount8 = (UINT8) SectorCount;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);\r
-\r
-  //\r
-  // Fill the start LBA registers, which are also two-byte FIFO\r
-  //\r
-  LbaLow  = (UINT8) RShiftU64 (StartLba, 24);\r
-  LbaMid  = (UINT8) RShiftU64 (StartLba, 32);\r
-  LbaHigh = (UINT8) RShiftU64 (StartLba, 40);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);\r
-\r
-  LbaLow  = (UINT8) StartLba;\r
-  LbaMid  = (UINT8) RShiftU64 (StartLba, 8);\r
-  LbaHigh = (UINT8) RShiftU64 (StartLba, 16);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);\r
-\r
-  //\r
-  // Send command via Command Register, invoking the processing of this command\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);\r
-\r
-  Buffer16 = (UINT16 *) Buffer;\r
-\r
-  //\r
-  // According to PIO data in protocol, host can perform a series of reads to\r
-  // the data register after each time device set DRQ ready;\r
-  //\r
-\r
-  //\r
-  // 256 words\r
-  //\r
-  Increment = 256;\r
-\r
-  //\r
-  // used to record bytes of currently transfered data\r
-  //\r
-  WordCount = 0;\r
-\r
-  while (WordCount < ByteCount / 2) {\r
-    //\r
-    // Poll DRQ bit set, data transfer can be performed only when DRQ is ready.\r
-    //\r
-    Status = DRQReady2 (IdeDev, ATATIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Status = CheckErrorStatus (IdeDev);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    //\r
-    // Get the byte count for one series of read\r
-    //\r
-    if ((WordCount + Increment) > ByteCount / 2) {\r
-      Increment = ByteCount / 2 - WordCount;\r
-    }\r
-\r
-    IDEReadPortWMultiple (\r
-      IdeDev->PciIo,\r
-      IdeDev->IoPort->Data,\r
-      Increment,\r
-      Buffer16\r
-      );\r
-\r
-    WordCount += Increment;\r
-    Buffer16 += Increment;\r
-\r
-  }\r
-\r
-  return CheckErrorStatus (IdeDev);\r
-}\r
-/**\r
-  Send ATA Ext command into device with NON_DATA protocol.\r
-\r
-  @param  IdeDev Standard IDE device private data structure\r
-  @param  AtaCommand The ATA command to be sent\r
-  @param  Device The value in Device register\r
-  @param  Feature The value in Feature register\r
-  @param  SectorCount The value in SectorCount register\r
-  @param  LbaAddress The LBA address in 48-bit mode\r
-\r
-  @retval  EFI_SUCCESS Reading succeed\r
-  @retval  EFI_DEVICE_ERROR Error executing commands on this device.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaCommandIssueExt (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINT8           AtaCommand,\r
-  IN  UINT8           Device,\r
-  IN  UINT16          Feature,\r
-  IN  UINT16          SectorCount,\r
-  IN  EFI_LBA         LbaAddress\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       SectorCount8;\r
-  UINT8       Feature8;\r
-  UINT8       LbaLow;\r
-  UINT8       LbaMid;\r
-  UINT8       LbaHigh;\r
-\r
-  Status = WaitForBSYClear (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Select device (bit4), set LBA mode(bit6) (use 0xe0 for compatibility)\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((IdeDev->Device << 4) | 0xe0)\r
-    );\r
-\r
-  //\r
-  // ATA commands for ATA device must be issued when DRDY is set\r
-  //\r
-  Status = DRDYReady (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Pass parameter into device register block\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, Device);\r
-\r
-  //\r
-  // Fill the feature register, which is a two-byte FIFO. Need write twice.\r
-  //\r
-  Feature8 = (UINT8) (Feature >> 8);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature8);\r
-\r
-  Feature8 = (UINT8) Feature;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature8);\r
-\r
-  //\r
-  // Fill the sector count register, which is a two-byte FIFO. Need write twice.\r
-  //\r
-  SectorCount8 = (UINT8) (SectorCount >> 8);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);\r
-\r
-  SectorCount8 = (UINT8) SectorCount;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);\r
-\r
-  //\r
-  // Fill the start LBA registers, which are also two-byte FIFO\r
-  //\r
-  LbaLow = (UINT8) RShiftU64 (LbaAddress, 24);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);\r
-  LbaLow = (UINT8) LbaAddress;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);\r
-\r
-  LbaMid = (UINT8) RShiftU64 (LbaAddress, 32);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);\r
-  LbaMid = (UINT8) RShiftU64 (LbaAddress, 8);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);\r
-\r
-  LbaHigh = (UINT8) RShiftU64 (LbaAddress, 40);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);\r
-  LbaHigh = (UINT8) RShiftU64 (LbaAddress, 16);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);\r
-\r
-  //\r
-  // Work around for Segate 160G disk writing\r
-  //\r
-  gBS->Stall (1800);\r
-\r
-  //\r
-  // Send command via Command Register\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);\r
-\r
-  //\r
-  // Stall at least 400ns\r
-  //\r
-  gBS->Stall (100);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Send ATA Ext command into device with NON_DATA protocol\r
-\r
-  @param  IdeDev Standard IDE device private data structure\r
-  @param  AtaCommand The ATA command to be sent\r
-  @param  Device The value in Device register\r
-  @param  Feature The value in Feature register\r
-  @param  SectorCount The value in SectorCount register\r
-  @param  LbaAddress The LBA address in 48-bit mode\r
-\r
-  @retval  EFI_SUCCESS Reading succeed\r
-  @retval  EFI_DEVICE_ERROR Error executing commands on this device.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaCommandIssue (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINT8           AtaCommand,\r
-  IN  UINT8           Device,\r
-  IN  UINT16          Feature,\r
-  IN  UINT16          SectorCount,\r
-  IN  EFI_LBA         LbaAddress\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       SectorCount8;\r
-  UINT8       Feature8;\r
-  UINT8       Lba0;\r
-  UINT8       Lba1;\r
-  UINT8       Lba2;\r
-  UINT8       Lba3;\r
-\r
-  Status = WaitForBSYClear (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Select device (bit4), set LBA mode(bit6) (use 0xe0 for compatibility)\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((IdeDev->Device << 4) | 0xe0)\r
-    );\r
-\r
-  //\r
-  // ATA commands for ATA device must be issued when DRDY is set\r
-  //\r
-  Status = DRDYReady (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Lba0  = (UINT8) LbaAddress;\r
-  Lba1  = (UINT8) RShiftU64 (LbaAddress, 8);\r
-  Lba2  = (UINT8) RShiftU64 (LbaAddress, 16);\r
-  Lba3  = (UINT8) RShiftU64 (LbaAddress, 24);\r
-  Device = (UINT8) (Device | Lba3);\r
-\r
-  //\r
-  // Pass parameter into device register block\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, Device);\r
-\r
-  //\r
-  // Fill the feature register, which is a two-byte FIFO. Need write twice.\r
-  //\r
-  Feature8 = (UINT8) Feature;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature8);\r
-\r
-  //\r
-  // Fill the sector count register, which is a two-byte FIFO. Need write twice.\r
-  //\r
-  SectorCount8 = (UINT8) SectorCount;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);\r
-\r
-  //\r
-  // Fill the start LBA registers, which are also two-byte FIFO\r
-  //\r
-\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, Lba0);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, Lba1);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, Lba2);\r
-\r
-  //\r
-  // Send command via Command Register\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);\r
-\r
-  //\r
-  // Stall at least 400ns\r
-  //\r
-  gBS->Stall (100);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Perform an ATA Udma operation (Read, ReadExt, Write, WriteExt).\r
-\r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                        to record all the information of the IDE device.\r
-  @param DataBuffer     A pointer to the source buffer for the data.\r
-  @param StartLba       The starting logical block address to write to\r
-                        on the device media.\r
-  @param NumberOfBlocks The number of transfer data blocks.\r
-  @param UdmaOp         The perform operations could be AtaUdmaReadOp, AtaUdmaReadExOp,\r
-                        AtaUdmaWriteOp, AtaUdmaWriteExOp\r
-\r
-  @retval EFI_SUCCESS          the operation is successful.\r
-  @retval EFI_OUT_OF_RESOURCES Build PRD table failed\r
-  @retval EFI_UNSUPPORTED      Unknown channel or operations command\r
-  @retval EFI_DEVICE_ERROR     Ata command execute failed\r
-\r
-**/\r
-EFI_STATUS\r
-DoAtaUdma (\r
-  IN  IDE_BLK_IO_DEV      *IdeDev,\r
-  IN  VOID                *DataBuffer,\r
-  IN  EFI_LBA             StartLba,\r
-  IN  UINTN               NumberOfBlocks,\r
-  IN  ATA_UDMA_OPERATION  UdmaOp\r
-  )\r
-{\r
-  IDE_DMA_PRD                   *PrdAddr;\r
-  IDE_DMA_PRD                   *UsedPrdAddr;\r
-  IDE_DMA_PRD                   *TempPrdAddr;\r
-  UINT8                         RegisterValue;\r
-  UINT8                         Device;\r
-  UINT64                        IoPortForBmic;\r
-  UINT64                        IoPortForBmis;\r
-  UINT64                        IoPortForBmid;\r
-  EFI_STATUS                    Status;\r
-  UINTN                         PrdTableNum;\r
-  UINTN                         ByteCount;\r
-  UINTN                         ByteAvailable;\r
-  UINT8                         *PrdBuffer;\r
-  UINTN                         RemainBlockNum;\r
-  UINT8                         DeviceControl;\r
-  UINT32                        Count;\r
-  UINTN                         PageCount;\r
-  VOID                          *Map;\r
-  VOID                          *MemPage;\r
-  EFI_PHYSICAL_ADDRESS          DeviceAddress;\r
-  UINTN                         MaxDmaCommandSectors;\r
-  EFI_PCI_IO_PROTOCOL_OPERATION PciIoProtocolOp;\r
-  UINT8                         AtaCommand;\r
-\r
-  switch (UdmaOp) {\r
-  case AtaUdmaReadOp:\r
-    MaxDmaCommandSectors = ATAPI_MAX_DMA_CMD_SECTORS;\r
-    PciIoProtocolOp      = EfiPciIoOperationBusMasterWrite;\r
-    AtaCommand           = ATA_CMD_READ_DMA;\r
-    break;\r
-  case AtaUdmaReadExtOp:\r
-    MaxDmaCommandSectors = ATAPI_MAX_DMA_EXT_CMD_SECTORS;\r
-    PciIoProtocolOp      = EfiPciIoOperationBusMasterWrite;\r
-    AtaCommand           = ATA_CMD_READ_DMA_EXT;\r
-    break;\r
-  case AtaUdmaWriteOp:\r
-    MaxDmaCommandSectors = ATAPI_MAX_DMA_CMD_SECTORS;\r
-    PciIoProtocolOp      = EfiPciIoOperationBusMasterRead;\r
-    AtaCommand           = ATA_CMD_WRITE_DMA;\r
-    break;\r
-  case AtaUdmaWriteExtOp:\r
-    MaxDmaCommandSectors = ATAPI_MAX_DMA_EXT_CMD_SECTORS;\r
-    PciIoProtocolOp      = EfiPciIoOperationBusMasterRead;\r
-    AtaCommand           = ATA_CMD_WRITE_DMA_EXT;\r
-    break;\r
-  default:\r
-    return EFI_UNSUPPORTED;\r
-    break;\r
-  }\r
-\r
-  //\r
-  // Select device\r
-  //\r
-  Device = (UINT8) ((IdeDev->Device << 4) | 0xe0);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, Device);\r
-\r
-  //\r
-  // Enable interrupt to support UDMA\r
-  //\r
-  DeviceControl = 0;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);\r
-\r
-  if (IdePrimary == IdeDev->Channel) {\r
-    IoPortForBmic = IdeDev->IoPort->BusMasterBaseAddr + BMICP_OFFSET;\r
-    IoPortForBmis = IdeDev->IoPort->BusMasterBaseAddr + BMISP_OFFSET;\r
-    IoPortForBmid = IdeDev->IoPort->BusMasterBaseAddr + BMIDP_OFFSET;\r
-  } else {\r
-    if (IdeSecondary == IdeDev->Channel) {\r
-      IoPortForBmic = IdeDev->IoPort->BusMasterBaseAddr + BMICS_OFFSET;\r
-      IoPortForBmis = IdeDev->IoPort->BusMasterBaseAddr + BMISS_OFFSET;\r
-      IoPortForBmid = IdeDev->IoPort->BusMasterBaseAddr + BMIDS_OFFSET;\r
-    } else {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Read BMIS register and clear ERROR and INTR bit\r
-  //\r
-  IdeDev->PciIo->Io.Read (\r
-            IdeDev->PciIo,\r
-            EfiPciIoWidthUint8,\r
-            EFI_PCI_IO_PASS_THROUGH_BAR,\r
-            IoPortForBmis,\r
-            1,\r
-            &RegisterValue\r
-            );\r
-\r
-  RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);\r
-\r
-  IdeDev->PciIo->Io.Write (\r
-            IdeDev->PciIo,\r
-            EfiPciIoWidthUint8,\r
-            EFI_PCI_IO_PASS_THROUGH_BAR,\r
-            IoPortForBmis,\r
-            1,\r
-            &RegisterValue\r
-            );\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  RemainBlockNum = NumberOfBlocks;\r
-  while (RemainBlockNum > 0) {\r
-\r
-    if (RemainBlockNum >= MaxDmaCommandSectors) {\r
-      //\r
-      //  SectorCount is used to record the number of sectors to be read\r
-      //  Max 65536 sectors can be transfered at a time.\r
-      //\r
-      NumberOfBlocks = MaxDmaCommandSectors;\r
-      RemainBlockNum -= MaxDmaCommandSectors;\r
-    } else {\r
-      NumberOfBlocks  = (UINT16) RemainBlockNum;\r
-      RemainBlockNum  = 0;\r
-    }\r
-\r
-    //\r
-    // Calculate the number of PRD table to make sure the memory region\r
-    // not cross 64K boundary\r
-    //\r
-    ByteCount   = NumberOfBlocks * IdeDev->BlkIo.Media->BlockSize;\r
-    PrdTableNum = ((ByteCount >> 16) + 1) + 1;\r
-\r
-    //\r
-    // Build PRD table\r
-    //\r
-    PageCount = EFI_SIZE_TO_PAGES (2 * PrdTableNum * sizeof (IDE_DMA_PRD));\r
-    Status = IdeDev->PciIo->AllocateBuffer (\r
-                    IdeDev->PciIo,\r
-                    AllocateAnyPages,\r
-                    EfiBootServicesData,\r
-                    PageCount,\r
-                    &MemPage,\r
-                    0\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    ZeroMem ((VOID *) ((UINTN) MemPage), EFI_PAGES_TO_SIZE (PageCount));\r
-\r
-    PrdAddr = (IDE_DMA_PRD *) ((UINTN) MemPage);\r
-    //\r
-    // To make sure PRD is allocated in one 64K page\r
-    //\r
-    if (((UINTN) PrdAddr & 0x0FFFF) > (((UINTN) PrdAddr + PrdTableNum * sizeof (IDE_DMA_PRD) - 1) & 0x0FFFF)) {\r
-      UsedPrdAddr = (IDE_DMA_PRD *) ((UINTN) ((UINT8 *) PrdAddr + 0x10000) & 0xFFFF0000);\r
-    } else {\r
-      if ((UINTN) PrdAddr & 0x03) {\r
-        UsedPrdAddr = (IDE_DMA_PRD *) ((UINTN) ((UINT8 *) PrdAddr + 0x04) & 0xFFFFFFFC);\r
-      } else {\r
-        UsedPrdAddr = PrdAddr;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Build the PRD table\r
-    //\r
-    Status = IdeDev->PciIo->Map (\r
-                       IdeDev->PciIo,\r
-                       PciIoProtocolOp,\r
-                       DataBuffer,\r
-                       &ByteCount,\r
-                       &DeviceAddress,\r
-                       &Map\r
-                       );\r
-    if (EFI_ERROR (Status)) {\r
-      IdeDev->PciIo->FreeBuffer (IdeDev->PciIo, PageCount, MemPage);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    PrdBuffer   = (VOID *) ((UINTN) DeviceAddress);\r
-    TempPrdAddr = UsedPrdAddr;\r
-    while (TRUE) {\r
-\r
-      ByteAvailable = 0x10000 - ((UINTN) PrdBuffer & 0xFFFF);\r
-\r
-      if (ByteCount <= ByteAvailable) {\r
-        TempPrdAddr->RegionBaseAddr = (UINT32) ((UINTN) PrdBuffer);\r
-        TempPrdAddr->ByteCount      = (UINT16) ByteCount;\r
-        TempPrdAddr->EndOfTable     = 0x8000;\r
-        break;\r
-      }\r
-\r
-      TempPrdAddr->RegionBaseAddr = (UINT32) ((UINTN) PrdBuffer);\r
-      TempPrdAddr->ByteCount      = (UINT16) ByteAvailable;\r
-\r
-      ByteCount -= ByteAvailable;\r
-      PrdBuffer += ByteAvailable;\r
-      TempPrdAddr++;\r
-    }\r
-\r
-    //\r
-    // Set the base address to BMID register\r
-    //\r
-    IdeDev->PciIo->Io.Write (\r
-                        IdeDev->PciIo,\r
-                        EfiPciIoWidthUint32,\r
-                        EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                        IoPortForBmid,\r
-                        1,\r
-                        &UsedPrdAddr\r
-                        );\r
-\r
-    //\r
-    // Set BMIC register to identify the operation direction\r
-    //\r
-    IdeDev->PciIo->Io.Read (\r
-                        IdeDev->PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                        IoPortForBmic,\r
-                        1,\r
-                        &RegisterValue\r
-                        );\r
-\r
-    if (UdmaOp == AtaUdmaReadExtOp || UdmaOp == AtaUdmaReadOp) {\r
-      RegisterValue |= BMIC_NREAD;\r
-    } else {\r
-      RegisterValue &= ~((UINT8) BMIC_NREAD);\r
-    }\r
-\r
-    IdeDev->PciIo->Io.Write (\r
-                        IdeDev->PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                        IoPortForBmic,\r
-                        1,\r
-                        &RegisterValue\r
-                        );\r
-\r
-    if (UdmaOp == AtaUdmaWriteExtOp || UdmaOp == AtaUdmaReadExtOp) {\r
-      Status = AtaCommandIssueExt (\r
-                 IdeDev,\r
-                 AtaCommand,\r
-                 Device,\r
-                 0,\r
-                 (UINT16) NumberOfBlocks,\r
-                 StartLba\r
-                 );\r
-    } else {\r
-      Status = AtaCommandIssue (\r
-                 IdeDev,\r
-                 AtaCommand,\r
-                 Device,\r
-                 0,\r
-                 (UINT16) NumberOfBlocks,\r
-                 StartLba\r
-                 );\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      IdeDev->PciIo->FreeBuffer (IdeDev->PciIo, PageCount, MemPage);\r
-      IdeDev->PciIo->Unmap (IdeDev->PciIo, Map);\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    //\r
-    // Set START bit of BMIC register\r
-    //\r
-    IdeDev->PciIo->Io.Read (\r
-                        IdeDev->PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                        IoPortForBmic,\r
-                        1,\r
-                        &RegisterValue\r
-                        );\r
-\r
-    RegisterValue |= BMIC_START;\r
-\r
-    IdeDev->PciIo->Io.Write (\r
-                        IdeDev->PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                        IoPortForBmic,\r
-                        1,\r
-                        &RegisterValue\r
-                        );\r
-\r
-    //\r
-    // Check the INTERRUPT and ERROR bit of BMIS\r
-    // Max transfer number of sectors for one command is 65536(32Mbyte),\r
-    // it will cost 1 second to transfer these data in UDMA mode 2(33.3MBps).\r
-    // So set the variable Count to 2000, for about 2 second timeout time.\r
-    //\r
-    Status = EFI_SUCCESS;\r
-    Count = 2000;\r
-    while (TRUE) {\r
-\r
-      IdeDev->PciIo->Io.Read (\r
-                          IdeDev->PciIo,\r
-                          EfiPciIoWidthUint8,\r
-                          EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                          IoPortForBmis,\r
-                          1,\r
-                          &RegisterValue\r
-                          );\r
-      if (((RegisterValue & (BMIS_INTERRUPT | BMIS_ERROR)) != 0) || (Count == 0)) {\r
-        if (((RegisterValue & BMIS_ERROR) != 0) || (Count == 0)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-      break;\r
-        }\r
-        break;\r
-      }\r
-\r
-      gBS->Stall (1000);\r
-      Count --;\r
-    }\r
-\r
-    IdeDev->PciIo->FreeBuffer (IdeDev->PciIo, PageCount, MemPage);\r
-    IdeDev->PciIo->Unmap (IdeDev->PciIo, Map);\r
-    //\r
-    // Read BMIS register and clear ERROR and INTR bit\r
-    //\r
-    IdeDev->PciIo->Io.Read (\r
-                        IdeDev->PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                        IoPortForBmis,\r
-                        1,\r
-                        &RegisterValue\r
-                        );\r
-\r
-    RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);\r
-\r
-    IdeDev->PciIo->Io.Write (\r
-                        IdeDev->PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                        IoPortForBmis,\r
-                        1,\r
-                        &RegisterValue\r
-                        );\r
-  //\r
-    // Read Status Register of IDE device to clear interrupt\r
-    //\r
-    RegisterValue = IDEReadPortB(IdeDev->PciIo,IdeDev->IoPort->Reg.Status);\r
-    //\r
-    // Clear START bit of BMIC register\r
-    //\r
-    IdeDev->PciIo->Io.Read (\r
-                        IdeDev->PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                        IoPortForBmic,\r
-                        1,\r
-                        &RegisterValue\r
-                        );\r
-\r
-    RegisterValue &= ~((UINT8) BMIC_START);\r
-\r
-    IdeDev->PciIo->Io.Write (\r
-                        IdeDev->PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                        IoPortForBmic,\r
-                        1,\r
-                        &RegisterValue\r
-                        );\r
-\r
-    if ((RegisterValue & BMIS_ERROR) != 0) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    break;\r
-  }\r
-    DataBuffer = (UINT8 *) DataBuffer + NumberOfBlocks * IdeDev->BlkIo.Media->BlockSize;\r
-    StartLba += NumberOfBlocks;\r
-  }\r
-\r
-  //\r
-  // Disable interrupt of Select device\r
-  //\r
-  IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl);\r
-  DeviceControl |= ATA_CTLREG_IEN_L;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  This function is called by the AtaBlkIoReadBlocks() to perform reading from\r
-  media in block unit. The function has been enhanced to support >120GB access\r
-  and transfer at most 65536 blocks per command\r
-\r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                        all the information of the IDE device.\r
-  @param DataBuffer     A pointer to the destination buffer for the data.\r
-  @param StartLba       The starting logical block address to read from on the device media.\r
-  @param NumberOfBlocks The number of transfer data blocks.\r
-\r
-  @return status depends on the function DoAtaUdma() returns.\r
-**/\r
-EFI_STATUS\r
-AtaUdmaReadExt (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *DataBuffer,\r
-  IN  EFI_LBA         StartLba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-  return DoAtaUdma (IdeDev, DataBuffer, StartLba, NumberOfBlocks, AtaUdmaReadExtOp);\r
-}\r
-/**\r
-  This function is called by the AtaBlkIoReadBlocks() to perform\r
-  reading from media in block unit. The function has been enhanced to\r
-  support >120GB access and transfer at most 65536 blocks per command\r
-\r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                        all the information of the IDE device.\r
-  @param DataBuffer     A pointer to the destination buffer for the data.\r
-  @param StartLba       The starting logical block address to read from\r
-                        on the device media.\r
-  @param NumberOfBlocks The number of transfer data blocks.\r
-\r
-  @return status depends on the function DoAtaUdma() returns.\r
-**/\r
-EFI_STATUS\r
-AtaUdmaRead (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *DataBuffer,\r
-  IN  EFI_LBA         StartLba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-  return DoAtaUdma (IdeDev, DataBuffer, StartLba, NumberOfBlocks, AtaUdmaReadOp);\r
-}\r
-\r
-/**\r
-  This function is called by the AtaBlkIoReadBlocks() to perform\r
-  reading from media in block unit. The function has been enhanced to\r
-  support >120GB access and transfer at most 65536 blocks per command\r
-\r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                        all the information of the IDE device.\r
-  @param DataBuffer     A pointer to the destination buffer for the data.\r
-  @param StartLba       The starting logical block address to read from on the device media.\r
-  @param NumberOfBlocks The number of transfer data blocks.\r
-\r
-  @return status is fully dependent on the return status of AtaPioDataInExt() function.\r
-**/\r
-EFI_STATUS\r
-AtaReadSectorsExt (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *DataBuffer,\r
-  IN  EFI_LBA         StartLba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       BlocksRemaining;\r
-  EFI_LBA     Lba64;\r
-  UINT8       AtaCommand;\r
-  UINT16      SectorCount;\r
-  UINT32      ByteCount;\r
-  VOID        *Buffer;\r
-\r
-  //\r
-  // Using ATA "Read Sectors Ext" command(opcode=0x24) with PIO DATA IN protocol\r
-  //\r
-  AtaCommand      = ATA_CMD_READ_SECTORS_EXT;\r
-  Buffer          = DataBuffer;\r
-  BlocksRemaining = NumberOfBlocks;\r
-  Lba64           = StartLba;\r
-  Status          = EFI_SUCCESS;\r
-\r
-  while (BlocksRemaining > 0) {\r
-\r
-    if (BlocksRemaining >= 0x10000) {\r
-      //\r
-      //  SectorCount is used to record the number of sectors to be read\r
-      //  Max 65536 sectors can be transfered at a time.\r
-      //\r
-      SectorCount = 0xffff;\r
-    } else {\r
-      SectorCount = (UINT16) BlocksRemaining;\r
-    }\r
-\r
-    //\r
-    // ByteCount is the number of bytes that will be read\r
-    //\r
-    ByteCount = SectorCount * (IdeDev->BlkIo.Media->BlockSize);\r
-\r
-    //\r
-    // call AtaPioDataInExt() to send Read Sector Command and receive data read\r
-    //\r
-    Status = AtaPioDataInExt (\r
-              IdeDev,\r
-              Buffer,\r
-              ByteCount,\r
-              AtaCommand,\r
-              Lba64,\r
-              SectorCount\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    Lba64 += SectorCount;\r
-    Buffer = ((UINT8 *) Buffer + ByteCount);\r
-    BlocksRemaining -= SectorCount;\r
-  }\r
-\r
-  return Status;\r
-}\r
-/**\r
-  This function is the ATA implementation for ReadBlocks in the\r
-  Block I/O Protocol interface.\r
-\r
-  @param IdeBlkIoDevice Indicates the calling context.\r
-  @param MediaId        The media id that the read request is for.\r
-  @param Lba            The starting logical block address to read from on the device.\r
-  @param BufferSize     The size of the Buffer in bytes. This must be a  multiple\r
-                        of the intrinsic block size of the device.\r
-\r
-  @param Buffer         A pointer to the destination buffer for the data. The caller\r
-                        is responsible for either having implicit or explicit ownership\r
-                        of the memory that data is read into.\r
-\r
-  @retval EFI_SUCCESS          Read Blocks successfully.\r
-  @retval EFI_DEVICE_ERROR     Read Blocks failed.\r
-  @retval EFI_NO_MEDIA         There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGE     The MediaId is not for the current media.\r
-  @retval EFI_BAD_BUFFER_SIZE  The BufferSize parameter is not a multiple of the\r
-                               intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER  The read request contains LBAs that are not valid,\r
-                                 or the data buffer is not valid.\r
-\r
-  @note If Read Block error because of device error, this function will call\r
-        AtaSoftReset() function to reset device.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaBlkIoReadBlocks (\r
-  IN IDE_BLK_IO_DEV   *IdeBlkIoDevice,\r
-  IN UINT32           MediaId,\r
-  IN EFI_LBA          Lba,\r
-  IN UINTN            BufferSize,\r
-  OUT VOID            *Buffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_MEDIA  *Media;\r
-  UINTN               BlockSize;\r
-  UINTN               NumberOfBlocks;\r
-  EFI_STATUS          Status;\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  //\r
-  //  Get the intrinsic block size\r
-  //\r
-  Media           = IdeBlkIoDevice->BlkIo.Media;\r
-  BlockSize       = Media->BlockSize;\r
-\r
-  NumberOfBlocks  = BufferSize / BlockSize;\r
-\r
-  if (MediaId != Media->MediaId) {\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (!(Media->MediaPresent)) {\r
-    return EFI_NO_MEDIA;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-  if (IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {\r
-    //\r
-    // For ATA/ATAPI-6 device(capcity > 120GB), use ATA-6 read block mechanism\r
-    //\r
-    if (IdeBlkIoDevice->UdmaMode.Valid) {\r
-      Status = AtaUdmaReadExt (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-    } else {\r
-      Status = AtaReadSectorsExt (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-    }\r
-  } else {\r
-    //\r
-    // For ATA-3 compatible device, use ATA-3 read block mechanism\r
-    //\r
-    if (IdeBlkIoDevice->UdmaMode.Valid) {\r
-      Status = AtaUdmaRead (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-    } else {\r
-      Status = AtaReadSectors (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-    }\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    AtaSoftReset (IdeBlkIoDevice);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-/**\r
-  This function is used to send out ATA commands conforms to the\r
-  PIO Data Out Protocol, supporting ATA/ATAPI-6 standard\r
-\r
-  Comparing with ATA-3 data out protocol, we have two differents here:<BR>\r
-  1. Do NOT wait for DRQ clear before sending command into IDE device.(the\r
-  wait will frequently fail... cause writing function return error)\r
-\r
-  2. Do NOT wait for DRQ clear after all data readed.(the wait greatly\r
-  slow down writing performance by 100 times!)\r
-\r
-  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                       to record all the information of the IDE device.\r
-  @param Buffer       buffer contained data transferred from host to device.\r
-  @param ByteCount    data size in byte unit of the buffer.\r
-  @param AtaCommand   value of the Command Register\r
-  @param StartLba     the start LBA of this transaction\r
-  @param SectorCount  the count of sectors to be transfered\r
-\r
-  @retval EFI_SUCCESS      send out the ATA command and device receive required\r
-                           data successfully.\r
-  @retval EFI_DEVICE_ERROR command sent failed.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaPioDataOutExt (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *Buffer,\r
-  IN  UINT32          ByteCount,\r
-  IN  UINT8           AtaCommand,\r
-  IN  EFI_LBA         StartLba,\r
-  IN  UINT16          SectorCount\r
-  )\r
-{\r
-  UINT8       DevSel;\r
-  UINT8       SectorCount8;\r
-  UINT8       LbaLow;\r
-  UINT8       LbaMid;\r
-  UINT8       LbaHigh;\r
-  UINTN       WordCount;\r
-  UINTN       Increment;\r
-  UINT16      *Buffer16;\r
-  EFI_STATUS  Status;\r
-\r
-  Status = WaitForBSYClear (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Select device. Set bit6 as 1 to indicate LBA mode is used\r
-  //\r
-  DevSel = (UINT8) (IdeDev->Device << 4);\r
-  DevSel |= 0x40;\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    DevSel\r
-    );\r
-\r
-  //\r
-  // Wait for DRDY singnal asserting.\r
-  //\r
-  Status = DRDYReady (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Fill feature register if needed\r
-  //\r
-  if (AtaCommand == ATA_CMD_SET_FEATURES) {\r
-    IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x03);\r
-  }\r
-\r
-  //\r
-  // Fill the sector count register, which is a two-byte FIFO. Need write twice.\r
-  //\r
-  SectorCount8 = (UINT8) (SectorCount >> 8);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);\r
-\r
-  SectorCount8 = (UINT8) SectorCount;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);\r
-\r
-  //\r
-  // Fill the start LBA registers, which are also two-byte FIFO\r
-  //\r
-  LbaLow  = (UINT8) RShiftU64 (StartLba, 24);\r
-  LbaMid  = (UINT8) RShiftU64 (StartLba, 32);\r
-  LbaHigh = (UINT8) RShiftU64 (StartLba, 40);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);\r
-\r
-  LbaLow  = (UINT8) StartLba;\r
-  LbaMid  = (UINT8) RShiftU64 (StartLba, 8);\r
-  LbaHigh = (UINT8) RShiftU64 (StartLba, 16);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);\r
-\r
-  //\r
-  // Send command via Command Register, invoking the processing of this command\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);\r
-\r
-  Buffer16 = (UINT16 *) Buffer;\r
-\r
-  //\r
-  // According to PIO Data Out protocol, host can perform a series of writes to\r
-  // the data register after each time device set DRQ ready;\r
-  //\r
-  Increment = 256;\r
-\r
-  //\r
-  // used to record bytes of currently transfered data\r
-  //\r
-  WordCount = 0;\r
-\r
-  while (WordCount < ByteCount / 2) {\r
-    //\r
-    // Poll DRQ bit set, data transfer can be performed only when DRQ is ready.\r
-    //\r
-    Status = DRQReady2 (IdeDev, ATATIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Status = CheckErrorStatus (IdeDev);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    //\r
-    // Write data into device by one series of writing to data register\r
-    //\r
-    if ((WordCount + Increment) > ByteCount / 2) {\r
-      Increment = ByteCount / 2 - WordCount;\r
-    }\r
-\r
-    IDEWritePortWMultiple (\r
-      IdeDev->PciIo,\r
-      IdeDev->IoPort->Data,\r
-      Increment,\r
-      Buffer16\r
-      );\r
-\r
-    WordCount += Increment;\r
-    Buffer16 += Increment;\r
-\r
-  }\r
-  return CheckErrorStatus (IdeDev);\r
-}\r
-/**\r
-  This function is called by the AtaBlkIoWriteBlocks() to perform\r
-  writing to media in block unit. The function has been enhanced to\r
-  support >120GB access and transfer at most 65536 blocks per command\r
-\r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                        to record all the information of the IDE device.\r
-  @param DataBuffer     A pointer to the source buffer for the data.\r
-  @param StartLba       The starting logical block address to write to\r
-                        on the device media.\r
-  @param NumberOfBlocks The number of transfer data blocks.\r
-\r
-  @return status depends on the function DoAtaUdma() returns.\r
-**/\r
-EFI_STATUS\r
-AtaUdmaWriteExt (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *DataBuffer,\r
-  IN  EFI_LBA         StartLba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-  return DoAtaUdma (IdeDev, DataBuffer, StartLba, NumberOfBlocks, AtaUdmaWriteExtOp);\r
-}\r
-\r
-/**\r
-  This function is called by the AtaBlkIoWriteBlocks() to perform\r
-  writing to media in block unit.\r
-\r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                        to record all the information of the IDE device.\r
-  @param DataBuffer     A pointer to the source buffer for the data.\r
-  @param StartLba       The starting logical block address to write to\r
-                        on the device media.\r
-  @param NumberOfBlocks The number of transfer data blocks.\r
-\r
-  @return status depends on the function DoAtaUdma() returns.\r
-**/\r
-EFI_STATUS\r
-AtaUdmaWrite (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *DataBuffer,\r
-  IN  EFI_LBA         StartLba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-  return DoAtaUdma (IdeDev, DataBuffer, StartLba, NumberOfBlocks, AtaUdmaWriteOp);\r
-}\r
-/**\r
-  This function is called by the AtaBlkIoWriteBlocks() to perform\r
-  writing onto media in block unit. The function has been enhanced to\r
-  support >120GB access and transfer at most 65536 blocks per command\r
-\r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure,used\r
-                        to record all the information of the IDE device.\r
-  @param DataBuffer     A pointer to the source buffer for the data.\r
-  @param StartLba       The starting logical block address to write onto the device\r
-                        media.\r
-  @param NumberOfBlocks The number of transfer data blocks.\r
-\r
-  @return status is fully dependent on the return status of AtaPioDataOutExt() function.\r
-**/\r
-EFI_STATUS\r
-AtaWriteSectorsExt (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *DataBuffer,\r
-  IN  EFI_LBA         StartLba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  EFI_LBA     Lba64;\r
-  UINTN       BlocksRemaining;\r
-  UINT8       AtaCommand;\r
-  UINT16      SectorCount;\r
-  UINT32      ByteCount;\r
-  VOID        *Buffer;\r
-\r
-  //\r
-  // Using ATA "Write Sectors Ext" cmd(opcode=0x24) with PIO DATA OUT protocol\r
-  //\r
-  AtaCommand      = ATA_CMD_WRITE_SECTORS_EXT;\r
-  Lba64           = StartLba;\r
-  Buffer          = DataBuffer;\r
-  BlocksRemaining = NumberOfBlocks;\r
-\r
-  Status          = EFI_SUCCESS;\r
-\r
-  while (BlocksRemaining > 0) {\r
-\r
-    if (BlocksRemaining >= 0x10000) {\r
-      //\r
-      //  SectorCount is used to record the number of sectors to be written.\r
-      //  Max 65536 sectors can be transfered at a time.\r
-      //\r
-      SectorCount = 0xffff;\r
-    } else {\r
-      SectorCount = (UINT16) BlocksRemaining;\r
-    }\r
-\r
-    //\r
-    // ByteCount is the number of bytes that will be written\r
-    //\r
-    ByteCount = SectorCount * (IdeDev->BlkIo.Media->BlockSize);\r
-\r
-    //\r
-    // Call AtaPioDataOutExt() to send "Write Sectors Ext" Command\r
-    //\r
-    Status = AtaPioDataOutExt (\r
-              IdeDev,\r
-              Buffer,\r
-              ByteCount,\r
-              AtaCommand,\r
-              Lba64,\r
-              SectorCount\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    Lba64 += SectorCount;\r
-    Buffer = ((UINT8 *) Buffer + ByteCount);\r
-    BlocksRemaining -= SectorCount;\r
-  }\r
-\r
-  return Status;\r
-}\r
-/**\r
-  This function is the ATA implementation for WriteBlocks in the\r
-  Block I/O Protocol interface.\r
-\r
-  @param IdeBlkIoDevice  Indicates the calling context.\r
-  @param MediaId         The media id that the write request is for.\r
-  @param Lba             The starting logical block address to write onto the device.\r
-  @param BufferSize      The size of the Buffer in bytes. This must be a multiple\r
-                         of the intrinsic block size of the device.\r
-  @param Buffer          A pointer to the source buffer for the data.The caller\r
-                         is responsible for either having implicit or explicit\r
-                         ownership of the memory that data is written from.\r
-\r
-  @retval EFI_SUCCESS       Write Blocks successfully.\r
-  @retval EFI_DEVICE_ERROR  Write Blocks failed.\r
-  @retval EFI_NO_MEDIA      There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGE  The MediaId is not for the current media.\r
-\r
-  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
-                                intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
-                                or the data buffer is not valid.\r
-\r
-  @note If Write Block error because of device error, this function will call\r
-        AtaSoftReset() function to reset device.\r
-**/\r
-EFI_STATUS\r
-AtaBlkIoWriteBlocks (\r
-  IN  IDE_BLK_IO_DEV   *IdeBlkIoDevice,\r
-  IN  UINT32           MediaId,\r
-  IN  EFI_LBA          Lba,\r
-  IN  UINTN            BufferSize,\r
-  OUT VOID             *Buffer\r
-  )\r
-{\r
-\r
-  EFI_BLOCK_IO_MEDIA  *Media;\r
-  UINTN               BlockSize;\r
-  UINTN               NumberOfBlocks;\r
-  EFI_STATUS          Status;\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  //\r
-  // Get the intrinsic block size\r
-  //\r
-  Media           = IdeBlkIoDevice->BlkIo.Media;\r
-  BlockSize       = Media->BlockSize;\r
-  NumberOfBlocks  = BufferSize / BlockSize;\r
-\r
-  if (MediaId != Media->MediaId) {\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-  if (IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {\r
-    //\r
-    // For ATA/ATAPI-6 device(capcity > 120GB), use ATA-6 write block mechanism\r
-    //\r
-    if (IdeBlkIoDevice->UdmaMode.Valid) {\r
-      Status = AtaUdmaWriteExt (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-    } else {\r
-      Status = AtaWriteSectorsExt (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-    }\r
-  } else {\r
-    //\r
-    // For ATA-3 compatible device, use ATA-3 write block mechanism\r
-    //\r
-    if (IdeBlkIoDevice->UdmaMode.Valid) {\r
-      Status = AtaUdmaWrite (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-    } else {\r
-      Status = AtaWriteSectors (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-    }\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    AtaSoftReset (IdeBlkIoDevice);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Enable Long Physical Sector Feature for ATA device.\r
-\r
-  @param   IdeDev  The IDE device data\r
-\r
-  @retval  EFI_SUCCESS      The ATA device supports Long Physical Sector feature\r
-                            and corresponding fields in BlockIo structure is updated.\r
-  @retval  EFI_UNSUPPORTED  The device is not ATA device or Long Physical Sector\r
-                            feature is not supported.\r
-**/\r
-EFI_STATUS\r
-AtaEnableLongPhysicalSector (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  EFI_ATA_IDENTIFY_DATA  *AtaIdentifyData;\r
-  UINT16                 PhyLogicSectorSupport;\r
-\r
-  ASSERT (IdeDev->IdData != NULL);\r
-  //\r
-  // Only valid for ATA device\r
-  //\r
-  AtaIdentifyData       = (EFI_ATA_IDENTIFY_DATA *) &IdeDev->IdData->AtaData;\r
-  if ((AtaIdentifyData->config & 0x8000) != 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  PhyLogicSectorSupport = AtaIdentifyData->phy_logic_sector_support;\r
-  //\r
-  // Check whether Long Physical Sector Feature is supported\r
-  //\r
-  if ((PhyLogicSectorSupport & 0xc000) == 0x4000) {\r
-    IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock = 1;\r
-    IdeDev->BlkIo.Media->LowestAlignedLba              = 0;\r
-    //\r
-    // Check whether one physical block contains multiple physical blocks\r
-    //\r
-    if ((PhyLogicSectorSupport & 0x2000) != 0) {\r
-      IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock =\r
-        (UINT32) (1 << (PhyLogicSectorSupport & 0x000f));\r
-      //\r
-      // Check lowest alignment of logical blocks within physical block\r
-      //\r
-      if ((AtaIdentifyData->alignment_logic_in_phy_blocks & 0xc000) == 0x4000) {\r
-        IdeDev->BlkIo.Media->LowestAlignedLba =\r
-          (EFI_LBA) ((IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock - ((UINT32)AtaIdentifyData->alignment_logic_in_phy_blocks & 0x3fff)) %\r
-          IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock);\r
-      }\r
-    }\r
-    //\r
-    // Check logical block size\r
-    //\r
-    IdeDev->BlkIo.Media->BlockSize = 0x200;\r
-    if ((PhyLogicSectorSupport & 0x1000) != 0) {\r
-      IdeDev->BlkIo.Media->BlockSize = (UINT32) (\r
-        ((AtaIdentifyData->logic_sector_size_hi << 16) |\r
-         AtaIdentifyData->logic_sector_size_lo) * sizeof (UINT16)\r
-        );\r
-    }\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-}\r
-/**\r
-  Send ATA command into device with NON_DATA protocol\r
-\r
-  @param  IdeDev Standard IDE device private data structure\r
-  @param  AtaCommand The ATA command to be sent\r
-  @param  Device The value in Device register\r
-  @param  Feature The value in Feature register\r
-  @param  SectorCount The value in SectorCount register\r
-  @param  LbaLow The value in LBA_LOW register\r
-  @param  LbaMiddle The value in LBA_MIDDLE register\r
-  @param  LbaHigh The value in LBA_HIGH register\r
-\r
-  @retval  EFI_SUCCESS Reading succeed\r
-  @retval  EFI_ABORTED Command failed\r
-  @retval  EFI_DEVICE_ERROR Device status error.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaNonDataCommandIn (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINT8           AtaCommand,\r
-  IN  UINT8           Device,\r
-  IN  UINT8           Feature,\r
-  IN  UINT8           SectorCount,\r
-  IN  UINT8           LbaLow,\r
-  IN  UINT8           LbaMiddle,\r
-  IN  UINT8           LbaHigh\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       StatusRegister;\r
-\r
-  Status = WaitForBSYClear (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Select device (bit4), set Lba mode(bit6) (use 0xe0 for compatibility)\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((IdeDev->Device << 4) | 0xe0)\r
-    );\r
-\r
-  //\r
-  // ATA commands for ATA device must be issued when DRDY is set\r
-  //\r
-  Status = DRDYReady (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Pass parameter into device register block\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, Device);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMiddle);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);\r
-\r
-  //\r
-  // Send command via Command Register\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);\r
-\r
-  //\r
-  // Wait for command completion\r
-  // For ATAPI_SMART_CMD, we may need more timeout to let device\r
-  // adjust internal states.\r
-  //\r
-  if (AtaCommand == ATA_CMD_SMART) {\r
-    Status = WaitForBSYClear (IdeDev, ATASMARTTIMEOUT);\r
-  } else {\r
-    Status = WaitForBSYClear (IdeDev, ATATIMEOUT);\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);\r
-  if ((StatusRegister & ATA_STSREG_ERR) == ATA_STSREG_ERR) {\r
-    //\r
-    // Failed to execute command, abort operation\r
-    //\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c
deleted file mode 100644 (file)
index 892bdb9..0000000
+++ /dev/null
@@ -1,1946 +0,0 @@
-/** @file\r
-   This file contains all helper functions on the ATAPI command\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IdeBus.h"\r
-\r
-/**\r
-  This function is used to get the current status of the media residing\r
-  in the LS-120 drive or ZIP drive. The media status is returned in the\r
-  Error Status.\r
-\r
-  @param IdeDev   pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                  to record all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS         The media status is achieved successfully and the media\r
-                              can be read/written.\r
-  @retval EFI_DEVICE_ERROR    Get Media Status Command is failed.\r
-  @retval EFI_NO_MEDIA        There is no media in the drive.\r
-  @retval EFI_WRITE_PROTECTED The media is writing protected.\r
-\r
-  @note  This function must be called after the LS120EnableMediaStatus()\r
-         with second parameter set to TRUE\r
-         (means enable media status notification) is called.\r
-**/\r
-EFI_STATUS\r
-LS120GetMediaStatus (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  UINT8       DeviceSelect;\r
-  UINT8       StatusValue;\r
-  EFI_STATUS  EfiStatus;\r
-  //\r
-  // Poll Alternate Register for BSY clear within timeout.\r
-  //\r
-  EfiStatus = WaitForBSYClear2 (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (EfiStatus)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Select device via Device/Head Register.\r
-  //\r
-  DeviceSelect = (UINT8) ((IdeDev->Device) << 4 | 0xe0);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, DeviceSelect);\r
-\r
-  //\r
-  // Poll Alternate Register for DRDY set within timeout.\r
-  // After device is selected, DRDY set indicates the device is ready to\r
-  // accept command.\r
-  //\r
-  EfiStatus = DRDYReady2 (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (EfiStatus)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Get Media Status Command is sent\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, 0xDA);\r
-\r
-  //\r
-  // BSY bit will clear after command is complete.\r
-  //\r
-  EfiStatus = WaitForBSYClear2 (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (EfiStatus)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // the media status is returned by the command in the ERROR register\r
-  //\r
-  StatusValue = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);\r
-\r
-  if ((StatusValue & BIT1) != 0) {\r
-    return EFI_NO_MEDIA;\r
-  }\r
-\r
-  if ((StatusValue & BIT6) != 0) {\r
-    return EFI_WRITE_PROTECTED;\r
-  } else {\r
-    return EFI_SUCCESS;\r
-  }\r
-}\r
-/**\r
-  This function is used to send Enable Media Status Notification Command\r
-  or Disable Media Status Notification Command.\r
-\r
-  @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                to record all the information of the IDE device.\r
-\r
-  @param Enable a flag that indicates whether enable or disable media\r
-                status notification.\r
-  @retval EFI_SUCCESS      If command completes successfully.\r
-  @retval EFI_DEVICE_ERROR If command failed.\r
-**/\r
-EFI_STATUS\r
-LS120EnableMediaStatus (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  BOOLEAN         Enable\r
-  )\r
-{\r
-  UINT8       DeviceSelect;\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Poll Alternate Register for BSY clear within timeout.\r
-  //\r
-  Status = WaitForBSYClear2 (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Select device via Device/Head Register.\r
-  //\r
-  DeviceSelect = (UINT8) ((IdeDev->Device) << 4 | 0xe0);\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, DeviceSelect);\r
-\r
-  //\r
-  // Poll Alternate Register for DRDY set within timeout.\r
-  // After device is selected, DRDY set indicates the device is ready to\r
-  // accept command.\r
-  //\r
-  Status = DRDYReady2 (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (Enable) {\r
-    //\r
-    // 0x95: Enable media status notification\r
-    //\r
-    IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x95);\r
-  } else {\r
-    //\r
-    // 0x31: Disable media status notification\r
-    //\r
-    IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x31);\r
-  }\r
-  //\r
-  // Set Feature Command is sent\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, 0xEF);\r
-\r
-  //\r
-  // BSY bit will clear after command is complete.\r
-  //\r
-  Status = WaitForBSYClear (IdeDev, ATATIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function reads the pending data in the device.\r
-\r
-  @param IdeDev   Indicates the calling context.\r
-\r
-  @retval EFI_SUCCESS   Successfully read.\r
-  @retval EFI_NOT_READY The BSY is set avoiding reading.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiReadPendingData (\r
-  IN IDE_BLK_IO_DEV     *IdeDev\r
-  )\r
-{\r
-  UINT8     AltRegister;\r
-  UINT16    TempWordBuffer;\r
-\r
-  AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);\r
-  if ((AltRegister & ATA_STSREG_BSY) == ATA_STSREG_BSY) {\r
-    return EFI_NOT_READY;\r
-  }\r
-  if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_DRQ)) == ATA_STSREG_DRQ) {\r
-    TempWordBuffer = IDEReadPortB (IdeDev->PciIo,IdeDev->IoPort->Alt.AltStatus);\r
-    while ((TempWordBuffer & (ATA_STSREG_BSY | ATA_STSREG_DRQ)) == ATA_STSREG_DRQ) {\r
-      IDEReadPortWMultiple (\r
-        IdeDev->PciIo,\r
-        IdeDev->IoPort->Data,\r
-        1,\r
-        &TempWordBuffer\r
-        );\r
-      TempWordBuffer = IDEReadPortB (IdeDev->PciIo,IdeDev->IoPort->Alt.AltStatus);\r
-    }\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is called by either AtapiPacketCommandIn() or AtapiPacketCommandOut().\r
-  It is used to transfer data between host and device. The data direction is specified\r
-  by the fourth parameter.\r
-\r
-  @param IdeDev     pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                    all the information of the IDE device.\r
-  @param Buffer     buffer contained data transferred between host and device.\r
-  @param ByteCount  data size in byte unit of the buffer.\r
-  @param Read       flag used to determine the data transfer direction.\r
-                    Read equals 1, means data transferred from device to host;\r
-                    Read equals 0, means data transferred from host to device.\r
-  @param TimeOut    timeout value for wait DRQ ready before each data stream's transfer.\r
-\r
-  @retval EFI_SUCCESS      data is transferred successfully.\r
-  @retval EFI_DEVICE_ERROR the device failed to transfer data.\r
-**/\r
-EFI_STATUS\r
-PioReadWriteData (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINT16          *Buffer,\r
-  IN  UINT32          ByteCount,\r
-  IN  BOOLEAN         Read,\r
-  IN  UINTN           TimeOut\r
-  )\r
-{\r
-  //\r
-  // required transfer data in word unit.\r
-  //\r
-  UINT32      RequiredWordCount;\r
-\r
-  //\r
-  // actual transfer data in word unit.\r
-  //\r
-  UINT32      ActualWordCount;\r
-  UINT32      WordCount;\r
-  EFI_STATUS  Status;\r
-  UINT16      *PtrBuffer;\r
-\r
-  //\r
-  // No data transfer is premitted.\r
-  //\r
-  if (ByteCount == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // for performance, we assert the ByteCount is an even number\r
-  // which is actually a resonable assumption\r
-  ASSERT((ByteCount%2) == 0);\r
-\r
-  PtrBuffer         = Buffer;\r
-  RequiredWordCount = ByteCount / 2;\r
-  //\r
-  // ActuralWordCount means the word count of data really transferred.\r
-  //\r
-  ActualWordCount = 0;\r
-\r
-  while (ActualWordCount < RequiredWordCount) {\r
-\r
-    //\r
-    // before each data transfer stream, the host should poll DRQ bit ready,\r
-    // to see whether indicates device is ready to transfer data.\r
-    //\r
-    Status = DRQReady2 (IdeDev, TimeOut);\r
-    if (EFI_ERROR (Status)) {\r
-      return CheckErrorStatus (IdeDev);\r
-    }\r
-\r
-    //\r
-    // read Status Register will clear interrupt\r
-    //\r
-    IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);\r
-\r
-    //\r
-    // get current data transfer size from Cylinder Registers.\r
-    //\r
-    WordCount = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb) << 8;\r
-    WordCount = WordCount | IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb);\r
-    WordCount = WordCount & 0xffff;\r
-    WordCount /= 2;\r
-\r
-    WordCount = MIN (WordCount, (RequiredWordCount - ActualWordCount));\r
-\r
-    if (Read) {\r
-      IDEReadPortWMultiple (\r
-        IdeDev->PciIo,\r
-        IdeDev->IoPort->Data,\r
-        WordCount,\r
-        PtrBuffer\r
-        );\r
-    } else {\r
-      IDEWritePortWMultiple (\r
-        IdeDev->PciIo,\r
-        IdeDev->IoPort->Data,\r
-        WordCount,\r
-        PtrBuffer\r
-        );\r
-    }\r
-\r
-    PtrBuffer += WordCount;\r
-    ActualWordCount += WordCount;\r
-  }\r
-\r
-  if (Read) {\r
-    //\r
-    // In the case where the drive wants to send more data than we need to read,\r
-    // the DRQ bit will be set and cause delays from DRQClear2().\r
-    // We need to read data from the drive until it clears DRQ so we can move on.\r
-    //\r
-    AtapiReadPendingData (IdeDev);\r
-  }\r
-\r
-  //\r
-  // After data transfer is completed, normally, DRQ bit should clear.\r
-  //\r
-  Status = DRQClear2 (IdeDev, ATAPITIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // read status register to check whether error happens.\r
-  //\r
-  return CheckErrorStatus (IdeDev);\r
-}\r
-\r
-/**\r
-  This function is used to send out ATAPI commands conforms to the Packet Command\r
-  with PIO Data In Protocol.\r
-\r
-  @param IdeDev    pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                   to record all the information of the IDE device.\r
-  @param Packet    pointer pointing to ATAPI_PACKET_COMMAND data structure\r
-                   which contains the contents of the command.\r
-  @param Buffer    buffer contained data transferred from device to host.\r
-  @param ByteCount data size in byte unit of the buffer.\r
-  @param TimeOut   this parameter is used to specify the timeout value for the\r
-                   PioReadWriteData() function.\r
-\r
-  @retval EFI_SUCCESS       send out the ATAPI packet command successfully\r
-                            and device sends data successfully.\r
-  @retval EFI_DEVICE_ERROR  the device failed to send data.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiPacketCommandIn (\r
-  IN  IDE_BLK_IO_DEV        *IdeDev,\r
-  IN  ATAPI_PACKET_COMMAND  *Packet,\r
-  IN  UINT16                *Buffer,\r
-  IN  UINT32                ByteCount,\r
-  IN  UINTN                 TimeOut\r
-  )\r
-{\r
-  UINT16      *CommandIndex;\r
-  EFI_STATUS  Status;\r
-  UINT32      Count;\r
-\r
-  //\r
-  // Set all the command parameters by fill related registers.\r
-  // Before write to all the following registers, BSY and DRQ must be 0.\r
-  //\r
-  Status = DRQClear2 (IdeDev, ATAPITIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Select device via Device/Head Register.\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((IdeDev->Device << 4) | ATA_DEFAULT_CMD)  // DEFAULT_CMD: 0xa0 (1010,0000)\r
-    );\r
-\r
-  //\r
-  // No OVL; No DMA\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x00);\r
-\r
-  //\r
-  // set the transfersize to ATAPI_MAX_BYTE_COUNT to let the device\r
-  // determine how many data should be transferred.\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->CylinderLsb,\r
-    (UINT8) (ATAPI_MAX_BYTE_COUNT & 0x00ff)\r
-    );\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->CylinderMsb,\r
-    (UINT8) (ATAPI_MAX_BYTE_COUNT >> 8)\r
-    );\r
-\r
-  //\r
-  //  ATA_DEFAULT_CTL:0x0a (0000,1010)\r
-  //  Disable interrupt\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, ATA_DEFAULT_CTL);\r
-\r
-  //\r
-  // Send Packet command to inform device\r
-  // that the following data bytes are command packet.\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, ATA_CMD_PACKET);\r
-\r
-  Status = DRQReady (IdeDev, ATAPITIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Send out command packet\r
-  //\r
-  CommandIndex = Packet->Data16;\r
-  for (Count = 0; Count < 6; Count++, CommandIndex++) {\r
-\r
-    IDEWritePortW (IdeDev->PciIo, IdeDev->IoPort->Data, *CommandIndex);\r
-    gBS->Stall (10);\r
-  }\r
-\r
-  //\r
-  // call PioReadWriteData() function to get\r
-  // requested transfer data form device.\r
-  //\r
-  return PioReadWriteData (IdeDev, Buffer, ByteCount, 1, TimeOut);\r
-}\r
-/**\r
-  This function is used to send out ATAPI commands conforms to the Packet Command\r
-  with PIO Data Out Protocol.\r
-\r
-  @param IdeDev      pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                     to record all the information of the IDE device.\r
-  @param Packet      pointer pointing to ATAPI_PACKET_COMMAND data structure\r
-                     which contains the contents of the command.\r
-  @param Buffer      buffer contained data transferred from host to device.\r
-  @param ByteCount   data size in byte unit of the buffer.\r
-  @param TimeOut     this parameter is used to specify the timeout value\r
-                     for the PioReadWriteData() function.\r
-  @retval EFI_SUCCESS      send out the ATAPI packet command successfully\r
-                           and device received data successfully.\r
-  @retval EFI_DEVICE_ERROR the device failed to send data.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiPacketCommandOut (\r
-  IN  IDE_BLK_IO_DEV        *IdeDev,\r
-  IN  ATAPI_PACKET_COMMAND  *Packet,\r
-  IN  UINT16                *Buffer,\r
-  IN  UINT32                ByteCount,\r
-  IN  UINTN                 TimeOut\r
-  )\r
-{\r
-  UINT16      *CommandIndex;\r
-  EFI_STATUS  Status;\r
-  UINT32      Count;\r
-\r
-  //\r
-  // set all the command parameters\r
-  // Before write to all the following registers, BSY and DRQ must be 0.\r
-  //\r
-  Status = DRQClear2 (IdeDev, ATAPITIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Select device via Device/Head Register.\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((IdeDev->Device << 4) | ATA_DEFAULT_CMD)   // ATA_DEFAULT_CMD: 0xa0 (1010,0000)\r
-    );\r
-\r
-  //\r
-  // No OVL; No DMA\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x00);\r
-\r
-  //\r
-  // set the transfersize to ATAPI_MAX_BYTE_COUNT to\r
-  // let the device determine how many data should be transferred.\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->CylinderLsb,\r
-    (UINT8) (ATAPI_MAX_BYTE_COUNT & 0x00ff)\r
-    );\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->CylinderMsb,\r
-    (UINT8) (ATAPI_MAX_BYTE_COUNT >> 8)\r
-    );\r
-\r
-  //\r
-  //  DEFAULT_CTL:0x0a (0000,1010)\r
-  //  Disable interrupt\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, ATA_DEFAULT_CTL);\r
-\r
-  //\r
-  // Send Packet command to inform device\r
-  // that the following data bytes are command packet.\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, ATA_CMD_PACKET);\r
-\r
-  Status = DRQReady2 (IdeDev, ATAPITIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Send out command packet\r
-  //\r
-  CommandIndex = Packet->Data16;\r
-  for (Count = 0; Count < 6; Count++, CommandIndex++) {\r
-    IDEWritePortW (IdeDev->PciIo, IdeDev->IoPort->Data, *CommandIndex);\r
-    gBS->Stall (10);\r
-  }\r
-\r
-  //\r
-  // call PioReadWriteData() function to send requested transfer data to device.\r
-  //\r
-  return PioReadWriteData (IdeDev, Buffer, ByteCount, 0, TimeOut);\r
-}\r
-/**\r
-  Sends out ATAPI Inquiry Packet Command to the specified device. This command will\r
-  return INQUIRY data of the device.\r
-\r
-  @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                to record all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS       Inquiry command completes successfully.\r
-  @retval EFI_DEVICE_ERROR  Inquiry command failed.\r
-\r
-  @note  Parameter "IdeDev" will be updated in this function.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiInquiry (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  ATAPI_PACKET_COMMAND  Packet;\r
-  EFI_STATUS            Status;\r
-  ATAPI_INQUIRY_DATA          *InquiryData;\r
-\r
-  //\r
-  // prepare command packet for the ATAPI Inquiry Packet Command.\r
-  //\r
-  ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
-  Packet.Inquiry.opcode             = ATA_CMD_INQUIRY;\r
-  Packet.Inquiry.page_code          = 0;\r
-  Packet.Inquiry.allocation_length  = (UINT8) sizeof (ATAPI_INQUIRY_DATA);\r
-\r
-  InquiryData                       = AllocatePool (sizeof (ATAPI_INQUIRY_DATA));\r
-  if (InquiryData == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Send command packet and get requested Inquiry data.\r
-  //\r
-  Status = AtapiPacketCommandIn (\r
-            IdeDev,\r
-            &Packet,\r
-            (UINT16 *) InquiryData,\r
-            sizeof (ATAPI_INQUIRY_DATA),\r
-            ATAPITIMEOUT\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (InquiryData);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  IdeDev->InquiryData = InquiryData;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function is called by DiscoverIdeDevice() during its device\r
-  identification.\r
-  Its main purpose is to get enough information for the device media\r
-  to fill in the Media data structure of the Block I/O Protocol interface.\r
-\r
-  There are 5 steps to reach such objective:\r
-  1. Sends out the ATAPI Identify Command to the specified device.\r
-  Only ATAPI device responses to this command. If the command succeeds,\r
-  it returns the Identify data structure which filled with information\r
-  about the device. Since the ATAPI device contains removable media,\r
-  the only meaningful information is the device module name.\r
-  2. Sends out ATAPI Inquiry Packet Command to the specified device.\r
-  This command will return inquiry data of the device, which contains\r
-  the device type information.\r
-  3. Allocate sense data space for future use. We don't detect the media\r
-  presence here to improvement boot performance, especially when CD\r
-  media is present. The media detection will be performed just before\r
-  each BLK_IO read/write\r
-\r
-  @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                 to record all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS       Identify ATAPI device successfully.\r
-  @retval EFI_DEVICE_ERROR  ATAPI Identify Device Command failed or device type\r
-                            is not supported by this IDE driver.\r
-  @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed\r
-\r
-  @note   Parameter "IdeDev" will be updated in this function.\r
-**/\r
-EFI_STATUS\r
-ATAPIIdentify (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  EFI_IDENTIFY_DATA *AtapiIdentifyPointer;\r
-  UINT8             DeviceSelect;\r
-  EFI_STATUS        Status;\r
-\r
-  //\r
-  // device select bit\r
-  //\r
-  DeviceSelect          = (UINT8) ((IdeDev->Device) << 4);\r
-\r
-  AtapiIdentifyPointer  = AllocatePool (sizeof (EFI_IDENTIFY_DATA));\r
-  if (AtapiIdentifyPointer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Send ATAPI Identify Command to get IDENTIFY data.\r
-  //\r
-  Status = AtaPioDataIn (\r
-            IdeDev,\r
-            (VOID *) AtapiIdentifyPointer,\r
-            sizeof (EFI_IDENTIFY_DATA),\r
-            ATA_CMD_IDENTIFY_DEVICE,\r
-            DeviceSelect,\r
-            0,\r
-            0,\r
-            0,\r
-            0\r
-            );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (AtapiIdentifyPointer);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  IdeDev->IdData = AtapiIdentifyPointer;\r
-  PrintAtaModuleName (IdeDev);\r
-\r
-  //\r
-  // Send ATAPI Inquiry Packet Command to get INQUIRY data.\r
-  //\r
-  Status = AtapiInquiry (IdeDev);\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (IdeDev->IdData);\r
-    //\r
-    // Make sure the pIdData will not be freed again.\r
-    //\r
-    IdeDev->IdData = NULL;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Get media removable info from INQUIRY data.\r
-  //\r
-  IdeDev->BlkIo.Media->RemovableMedia = (UINT8) ((IdeDev->InquiryData->RMB & 0x80) == 0x80);\r
-\r
-  //\r
-  // Identify device type via INQUIRY data.\r
-  //\r
-  switch (IdeDev->InquiryData->peripheral_type & 0x1f) {\r
-\r
-  //\r
-  // Magnetic Disk\r
-  //\r
-  case 0x00:\r
-\r
-    //\r
-    // device is LS120 or ZIP drive.\r
-    //\r
-    IdeDev->Type = IdeMagnetic;\r
-\r
-    IdeDev->BlkIo.Media->MediaId      = 0;\r
-    //\r
-    // Give initial value\r
-    //\r
-    IdeDev->BlkIo.Media->MediaPresent = FALSE;\r
-\r
-    IdeDev->BlkIo.Media->LastBlock  = 0;\r
-    IdeDev->BlkIo.Media->BlockSize  = 0x200;\r
-    break;\r
-\r
-  //\r
-  // CD-ROM\r
-  //\r
-  case 0x05:\r
-\r
-    IdeDev->Type                      = IdeCdRom;\r
-    IdeDev->BlkIo.Media->MediaId      = 0;\r
-    //\r
-    // Give initial value\r
-    //\r
-    IdeDev->BlkIo.Media->MediaPresent = FALSE;\r
-\r
-    IdeDev->BlkIo.Media->LastBlock  = 0;\r
-    IdeDev->BlkIo.Media->BlockSize  = 0x800;\r
-    IdeDev->BlkIo.Media->ReadOnly   = TRUE;\r
-    break;\r
-\r
-  //\r
-  // Tape\r
-  //\r
-  case 0x01:\r
-\r
-  //\r
-  // WORM\r
-  //\r
-  case 0x04:\r
-\r
-  //\r
-  // Optical\r
-  //\r
-  case 0x07:\r
-\r
-  default:\r
-    IdeDev->Type = IdeUnknown;\r
-    gBS->FreePool (IdeDev->IdData);\r
-    gBS->FreePool (IdeDev->InquiryData);\r
-    //\r
-    // Make sure the pIdData and pInquiryData will not be freed again.\r
-    //\r
-    IdeDev->IdData       = NULL;\r
-    IdeDev->InquiryData  = NULL;\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // original sense data numbers\r
-  //\r
-  IdeDev->SenseDataNumber = 20;\r
-\r
-  IdeDev->SenseData = AllocatePool (IdeDev->SenseDataNumber * sizeof (ATAPI_REQUEST_SENSE_DATA));\r
-  if (IdeDev->SenseData == NULL) {\r
-    gBS->FreePool (IdeDev->IdData);\r
-    gBS->FreePool (IdeDev->InquiryData);\r
-    //\r
-    // Make sure the pIdData and pInquiryData will not be freed again.\r
-    //\r
-    IdeDev->IdData       = NULL;\r
-    IdeDev->InquiryData  = NULL;\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Sends out ATAPI Request Sense Packet Command to the specified device. This command\r
-  will return all the current Sense data in the device.  This function will pack\r
-  all the Sense data in one single buffer.\r
-\r
-  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                      to record all the information of the IDE device.\r
-  @param SenseCounts  allocated in this function, and freed by the calling function.\r
-                      This buffer is used to accommodate all the sense data returned\r
-                      by the device.\r
-\r
-  @retval EFI_SUCCESS      Request Sense command completes successfully.\r
-  @retval EFI_DEVICE_ERROR Request Sense command failed.\r
-**/\r
-EFI_STATUS\r
-AtapiRequestSense (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  OUT UINTN           *SenseCounts\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  ATAPI_REQUEST_SENSE_DATA    *Sense;\r
-  UINT16                *Ptr;\r
-  BOOLEAN               FetchSenseData;\r
-  ATAPI_PACKET_COMMAND  Packet;\r
-\r
-  *SenseCounts = 0;\r
-\r
-  ZeroMem (IdeDev->SenseData, sizeof (ATAPI_REQUEST_SENSE_DATA) * (IdeDev->SenseDataNumber));\r
-  //\r
-  // fill command packet for Request Sense Packet Command\r
-  //\r
-  ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
-  Packet.RequestSence.opcode            = ATA_CMD_REQUEST_SENSE;\r
-  Packet.RequestSence.allocation_length = (UINT8) sizeof (ATAPI_REQUEST_SENSE_DATA);\r
-\r
-  //\r
-  // initialize pointer\r
-  //\r
-  Ptr = (UINT16 *) IdeDev->SenseData;\r
-  //\r
-  //  request sense data from device continuously until no sense data\r
-  //  exists in the device.\r
-  //\r
-  for (FetchSenseData = TRUE; FetchSenseData;) {\r
-\r
-    Sense = (ATAPI_REQUEST_SENSE_DATA *) Ptr;\r
-\r
-    //\r
-    // send out Request Sense Packet Command and get one Sense data form device\r
-    //\r
-    Status = AtapiPacketCommandIn (\r
-              IdeDev,\r
-              &Packet,\r
-              Ptr,\r
-              sizeof (ATAPI_REQUEST_SENSE_DATA),\r
-              ATAPITIMEOUT\r
-              );\r
-    //\r
-    // failed to get Sense data\r
-    //\r
-    if (EFI_ERROR (Status)) {\r
-      if (*SenseCounts == 0) {\r
-        return EFI_DEVICE_ERROR;\r
-      } else {\r
-        return EFI_SUCCESS;\r
-      }\r
-    }\r
-\r
-    (*SenseCounts)++;\r
-    //\r
-    // We limit MAX sense data count to 20 in order to avoid dead loop. Some\r
-    // incompatible ATAPI devices don't retrive NO_SENSE when there is no media.\r
-    // In this case, dead loop occurs if we don't have a gatekeeper. 20 is\r
-    // supposed to be large enough for any ATAPI device.\r
-    //\r
-    if ((Sense->sense_key != ATA_SK_NO_SENSE) && ((*SenseCounts) < 20)) {\r
-      //\r
-      // Ptr is word-based pointer\r
-      //\r
-      Ptr += (sizeof (ATAPI_REQUEST_SENSE_DATA) + 1) >> 1;\r
-\r
-    } else {\r
-      //\r
-      // when no sense key, skip out the loop\r
-      //\r
-      FetchSenseData = FALSE;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function is used to parse sense data. Only the first sense data is honoured\r
-\r
-  @param IdeDev     Indicates the calling context.\r
-  @param SenseCount Count of sense data.\r
-  @param Result    The parsed result.\r
-\r
-  @retval EFI_SUCCESS           Successfully parsed.\r
-  @retval EFI_INVALID_PARAMETER Count of sense data is zero.\r
-\r
-**/\r
-EFI_STATUS\r
-ParseSenseData (\r
-  IN IDE_BLK_IO_DEV     *IdeDev,\r
-  IN UINTN              SenseCount,\r
-  OUT SENSE_RESULT      *Result\r
-  )\r
-{\r
-  ATAPI_REQUEST_SENSE_DATA      *SenseData;\r
-\r
-  if (SenseCount == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Only use the first sense data\r
-  //\r
-  SenseData = IdeDev->SenseData;\r
-  *Result   = SenseOtherSense;\r
-\r
-  switch (SenseData->sense_key) {\r
-  case ATA_SK_NO_SENSE:\r
-    *Result = SenseNoSenseKey;\r
-    break;\r
-  case ATA_SK_NOT_READY:\r
-    switch (SenseData->addnl_sense_code) {\r
-    case ATA_ASC_NO_MEDIA:\r
-      *Result = SenseNoMedia;\r
-      break;\r
-    case ATA_ASC_MEDIA_UPSIDE_DOWN:\r
-      *Result = SenseMediaError;\r
-      break;\r
-    case ATA_ASC_NOT_READY:\r
-      if (SenseData->addnl_sense_code_qualifier == ATA_ASCQ_IN_PROGRESS) {\r
-        *Result = SenseDeviceNotReadyNeedRetry;\r
-      } else {\r
-        *Result = SenseDeviceNotReadyNoRetry;\r
-      }\r
-      break;\r
-    }\r
-    break;\r
-  case ATA_SK_UNIT_ATTENTION:\r
-    if (SenseData->addnl_sense_code == ATA_ASC_MEDIA_CHANGE) {\r
-      *Result = SenseMediaChange;\r
-    }\r
-    break;\r
-  case ATA_SK_MEDIUM_ERROR:\r
-    switch (SenseData->addnl_sense_code) {\r
-    case ATA_ASC_MEDIA_ERR1:\r
-    case ATA_ASC_MEDIA_ERR2:\r
-    case ATA_ASC_MEDIA_ERR3:\r
-    case ATA_ASC_MEDIA_ERR4:\r
-      *Result = SenseMediaError;\r
-      break;\r
-    }\r
-    break;\r
-  default:\r
-    break;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Sends out ATAPI Test Unit Ready Packet Command to the specified device\r
-  to find out whether device is accessible.\r
-\r
-  @param IdeDev    Pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                   to record all the information of the IDE device.\r
-  @param SResult   Sense result for this packet command.\r
-\r
-  @retval EFI_SUCCESS      Device is accessible.\r
-  @retval EFI_DEVICE_ERROR Device is not accessible.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiTestUnitReady (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  OUT SENSE_RESULT    *SResult\r
-  )\r
-{\r
-  ATAPI_PACKET_COMMAND  Packet;\r
-  EFI_STATUS            Status;\r
-  UINTN         SenseCount;\r
-\r
-  //\r
-  // fill command packet\r
-  //\r
-  ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
-  Packet.TestUnitReady.opcode = ATA_CMD_TEST_UNIT_READY;\r
-\r
-  //\r
-  // send command packet\r
-  //\r
-  Status = AtapiPacketCommandIn (IdeDev, &Packet, NULL, 0, ATAPITIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = AtapiRequestSense (IdeDev, &SenseCount);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  ParseSenseData (IdeDev, SenseCount, SResult);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Sends out ATAPI Read Capacity Packet Command to the specified device.\r
-  This command will return the information regarding the capacity of the\r
-  media in the device.\r
-\r
-  Current device status will impact device's response to the Read Capacity\r
-  Command. For example, if the device once reset, the Read Capacity\r
-  Command will fail. The Sense data record the current device status, so\r
-  if the Read Capacity Command failed, the Sense data must be requested\r
-  and be analyzed to determine if the Read Capacity Command should retry.\r
-\r
-  @param IdeDev    Pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                   to record all the information of the IDE device.\r
-  @param SResult   Sense result for this packet command\r
-\r
-  @retval EFI_SUCCESS      Read Capacity Command finally completes successfully.\r
-  @retval EFI_DEVICE_ERROR Read Capacity Command failed because of device error.\r
-  @retval EFI_NOT_READY    Operation succeeds but returned capacity is 0\r
-\r
-  @note Parameter "IdeDev" will be updated in this function.\r
-\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiReadCapacity (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  OUT SENSE_RESULT    *SResult\r
-  )\r
-{\r
-  //\r
-  // status returned by Read Capacity Packet Command\r
-  //\r
-  EFI_STATUS                Status;\r
-  EFI_STATUS                SenseStatus;\r
-  ATAPI_PACKET_COMMAND      Packet;\r
-  UINTN           SenseCount;\r
-\r
-  //\r
-  // used for capacity data returned from ATAPI device\r
-  //\r
-  ATAPI_READ_CAPACITY_DATA        Data;\r
-  ATAPI_READ_FORMAT_CAPACITY_DATA FormatData;\r
-\r
-  ZeroMem (&Data, sizeof (Data));\r
-  ZeroMem (&FormatData, sizeof (FormatData));\r
-\r
-  if (IdeDev->Type == IdeCdRom) {\r
-\r
-    ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
-    Packet.Inquiry.opcode = ATA_CMD_READ_CAPACITY;\r
-    Status = AtapiPacketCommandIn (\r
-               IdeDev,\r
-               &Packet,\r
-               (UINT16 *) &Data,\r
-               sizeof (ATAPI_READ_CAPACITY_DATA),\r
-               ATAPITIMEOUT\r
-               );\r
-\r
-  } else {\r
-    //\r
-    // Type == IdeMagnetic\r
-    //\r
-    ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
-    Packet.ReadFormatCapacity.opcode                = ATA_CMD_READ_FORMAT_CAPACITY;\r
-    Packet.ReadFormatCapacity.allocation_length_lo  = 12;\r
-    Status = AtapiPacketCommandIn (\r
-               IdeDev,\r
-               &Packet,\r
-               (UINT16 *) &FormatData,\r
-               sizeof (ATAPI_READ_FORMAT_CAPACITY_DATA),\r
-               ATAPITIMEOUT\r
-               );\r
-  }\r
-\r
-  if (Status == EFI_TIMEOUT) {\r
-    return Status;\r
-  }\r
-\r
-  SenseStatus = AtapiRequestSense (IdeDev, &SenseCount);\r
-\r
-  if (!EFI_ERROR (SenseStatus)) {\r
-  ParseSenseData (IdeDev, SenseCount, SResult);\r
-\r
-  if (!EFI_ERROR (Status) && *SResult == SenseNoSenseKey) {\r
-      if (IdeDev->Type == IdeCdRom) {\r
-\r
-        IdeDev->BlkIo.Media->LastBlock = ((UINT32) Data.LastLba3 << 24) |\r
-          (Data.LastLba2 << 16) |\r
-          (Data.LastLba1 << 8) |\r
-          Data.LastLba0;\r
-\r
-        IdeDev->BlkIo.Media->MediaPresent = TRUE;\r
-\r
-        IdeDev->BlkIo.Media->ReadOnly = TRUE;\r
-\r
-        //\r
-        // Because the user data portion in the sector of the Data CD supported\r
-        // is always 0x800\r
-        //\r
-        IdeDev->BlkIo.Media->BlockSize = 0x800;\r
-      }\r
-\r
-      if (IdeDev->Type == IdeMagnetic) {\r
-\r
-        if (FormatData.DesCode == 3) {\r
-          IdeDev->BlkIo.Media->MediaPresent = FALSE;\r
-          IdeDev->BlkIo.Media->LastBlock    = 0;\r
-        } else {\r
-\r
-          IdeDev->BlkIo.Media->LastBlock = ((UINT32) FormatData.LastLba3 << 24) |\r
-            (FormatData.LastLba2 << 16) |\r
-            (FormatData.LastLba1 << 8)  |\r
-            FormatData.LastLba0;\r
-          if (IdeDev->BlkIo.Media->LastBlock != 0) {\r
-            IdeDev->BlkIo.Media->LastBlock--;\r
-\r
-            IdeDev->BlkIo.Media->BlockSize = (FormatData.BlockSize2 << 16) |\r
-              (FormatData.BlockSize1 << 8) |\r
-              FormatData.BlockSize0;\r
-\r
-            IdeDev->BlkIo.Media->MediaPresent = TRUE;\r
-          } else {\r
-            IdeDev->BlkIo.Media->MediaPresent = FALSE;\r
-            //\r
-            // Return EFI_NOT_READY operation succeeds but returned capacity is 0\r
-            //\r
-            return EFI_NOT_READY;\r
-          }\r
-\r
-          IdeDev->BlkIo.Media->BlockSize = 0x200;\r
-\r
-        }\r
-      }\r
-    }\r
-\r
-    return EFI_SUCCESS;\r
-\r
-  } else {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-}\r
-/**\r
-  This function is used to test the current media write-protected or not residing\r
-  in the LS-120 drive or ZIP drive.\r
-  @param IdeDev          pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                         to record all the information of the IDE device.\r
-  @param WriteProtected  if True, current media is write protected.\r
-                         if FALSE, current media is writable\r
-\r
-  @retval EFI_SUCCESS         The media write-protected status is achieved successfully\r
-  @retval EFI_DEVICE_ERROR    Get Media Status Command is failed.\r
-**/\r
-EFI_STATUS\r
-IsLS120orZipWriteProtected (\r
-  IN  IDE_BLK_IO_DEV    *IdeDev,\r
-  OUT BOOLEAN           *WriteProtected\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  *WriteProtected = FALSE;\r
-\r
-  Status          = LS120EnableMediaStatus (IdeDev, TRUE);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // the Get Media Status Command is only valid\r
-  // if a Set Features/Enable Media Status Command has been priviously issued.\r
-  //\r
-  if (LS120GetMediaStatus (IdeDev) == EFI_WRITE_PROTECTED) {\r
-\r
-    *WriteProtected = TRUE;\r
-  } else {\r
-\r
-    *WriteProtected = FALSE;\r
-  }\r
-\r
-  //\r
-  // After Get Media Status Command completes,\r
-  // Set Features/Disable Media Command should be sent.\r
-  //\r
-  Status = LS120EnableMediaStatus (IdeDev, FALSE);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Used before read/write blocks from/to ATAPI device media. Since ATAPI device\r
-  media is removable, it is necessary to detect whether media is present and\r
-  get current present media's information, and if media has been changed, Block\r
-  I/O Protocol need to be reinstalled.\r
-\r
-  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                      to record all the information of the IDE device.\r
-  @param MediaChange  return value that indicates if the media of the device has been\r
-                      changed.\r
-\r
-  @retval EFI_SUCCESS       media found successfully.\r
-  @retval EFI_DEVICE_ERROR  any error encounters during media detection.\r
-  @retval EFI_NO_MEDIA      media not found.\r
-\r
-  @note\r
-  parameter IdeDev may be updated in this function.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiDetectMedia (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  OUT BOOLEAN         *MediaChange\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_STATUS                    CleanStateStatus;\r
-  EFI_BLOCK_IO_MEDIA            OldMediaInfo;\r
-  UINTN                         RetryTimes;\r
-  UINTN                         RetryNotReady;\r
-  SENSE_RESULT                  SResult;\r
-  BOOLEAN                       WriteProtected;\r
-\r
-  CopyMem (&OldMediaInfo, IdeDev->BlkIo.Media, sizeof (EFI_BLOCK_IO_MEDIA));\r
-  *MediaChange  = FALSE;\r
-  //\r
-  // Retry for SenseDeviceNotReadyNeedRetry.\r
-  // Each retry takes 1s and we limit the upper boundary to\r
-  // 120 times about 2 min.\r
-  //\r
-  RetryNotReady = 120;\r
-\r
-  //\r
-  // Do Test Unit Ready\r
-  //\r
- DoTUR:\r
-  //\r
-  // Retry 5 times\r
-  //\r
-  RetryTimes = 5;\r
-  while (RetryTimes != 0) {\r
-\r
-    Status = AtapiTestUnitReady (IdeDev, &SResult);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Test Unit Ready error without sense data.\r
-      // For some devices, this means there's extra data\r
-      // that has not been read, so we read these extra\r
-      // data out before going on.\r
-      //\r
-      CleanStateStatus = AtapiReadPendingData (IdeDev);\r
-      if (EFI_ERROR (CleanStateStatus)) {\r
-        //\r
-        // Busy wait failed, try again\r
-        //\r
-        RetryTimes--;\r
-      }\r
-      //\r
-      // Try again without counting down RetryTimes\r
-      //\r
-      continue;\r
-    } else {\r
-      switch (SResult) {\r
-      case SenseNoSenseKey:\r
-        if (IdeDev->BlkIo.Media->MediaPresent) {\r
-          goto Done;\r
-        } else {\r
-          //\r
-          // Media present but the internal structure need refreshed.\r
-          // Try Read Capacity\r
-          //\r
-          goto DoRC;\r
-        }\r
-        break;\r
-\r
-      case SenseDeviceNotReadyNeedRetry:\r
-        if (--RetryNotReady == 0) {\r
-          return EFI_DEVICE_ERROR;\r
-        }\r
-        gBS->Stall (1000 * STALL_1_MILLI_SECOND);\r
-        continue;\r
-        break;\r
-\r
-      case SenseNoMedia:\r
-        IdeDev->BlkIo.Media->MediaPresent = FALSE;\r
-        IdeDev->BlkIo.Media->LastBlock    = 0;\r
-        goto Done;\r
-        break;\r
-\r
-      case SenseDeviceNotReadyNoRetry:\r
-      case SenseMediaError:\r
-        return EFI_DEVICE_ERROR;\r
-\r
-      case SenseMediaChange:\r
-        IdeDev->BlkIo.Media->MediaId++;\r
-        goto DoRC;\r
-        break;\r
-\r
-      default:\r
-        RetryTimes--;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_DEVICE_ERROR;\r
-\r
-  //\r
-  // Do Read Capacity\r
-  //\r
- DoRC:\r
-    RetryTimes = 5;\r
-\r
-    while (RetryTimes != 0) {\r
-\r
-      Status = AtapiReadCapacity (IdeDev, &SResult);\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        RetryTimes--;\r
-        continue;\r
-      } else {\r
-        switch (SResult) {\r
-        case SenseNoSenseKey:\r
-          goto Done;\r
-          break;\r
-\r
-        case SenseDeviceNotReadyNeedRetry:\r
-          //\r
-          // We use Test Unit Ready to retry which\r
-          // is faster.\r
-          //\r
-          goto DoTUR;\r
-          break;\r
-\r
-        case SenseNoMedia:\r
-          IdeDev->BlkIo.Media->MediaPresent = FALSE;\r
-          IdeDev->BlkIo.Media->LastBlock    = 0;\r
-          goto Done;\r
-          break;\r
-\r
-        case SenseDeviceNotReadyNoRetry:\r
-        case SenseMediaError:\r
-          return EFI_DEVICE_ERROR;\r
-\r
-        case SenseMediaChange:\r
-          IdeDev->BlkIo.Media->MediaId++;\r
-          continue;\r
-          break;\r
-\r
-        default:\r
-          RetryTimes--;\r
-          break;\r
-        }\r
-      }\r
-    }\r
-\r
-  return EFI_DEVICE_ERROR;\r
-\r
- Done:\r
-  //\r
-  // the following code is to check the write-protected for LS120 media\r
-  //\r
-  if ((IdeDev->BlkIo.Media->MediaPresent) && (IdeDev->Type == IdeMagnetic)) {\r
-\r
-    Status = IsLS120orZipWriteProtected (IdeDev, &WriteProtected);\r
-    if (!EFI_ERROR (Status)) {\r
-\r
-      if (WriteProtected) {\r
-\r
-        IdeDev->BlkIo.Media->ReadOnly = TRUE;\r
-      } else {\r
-\r
-        IdeDev->BlkIo.Media->ReadOnly = FALSE;\r
-      }\r
-\r
-    }\r
-  }\r
-\r
-  if (IdeDev->BlkIo.Media->MediaId != OldMediaInfo.MediaId) {\r
-    //\r
-    // Media change information got from the device\r
-    //\r
-    *MediaChange = TRUE;\r
-  }\r
-\r
-  if (IdeDev->BlkIo.Media->ReadOnly != OldMediaInfo.ReadOnly) {\r
-    *MediaChange = TRUE;\r
-    IdeDev->BlkIo.Media->MediaId += 1;\r
-  }\r
-\r
-  if (IdeDev->BlkIo.Media->BlockSize != OldMediaInfo.BlockSize) {\r
-    *MediaChange = TRUE;\r
-    IdeDev->BlkIo.Media->MediaId += 1;\r
-  }\r
-\r
-  if (IdeDev->BlkIo.Media->LastBlock != OldMediaInfo.LastBlock) {\r
-    *MediaChange = TRUE;\r
-    IdeDev->BlkIo.Media->MediaId += 1;\r
-  }\r
-\r
-  if (IdeDev->BlkIo.Media->MediaPresent != OldMediaInfo.MediaPresent) {\r
-    if (IdeDev->BlkIo.Media->MediaPresent) {\r
-      //\r
-      // when change from no media to media present, reset the MediaId to 1.\r
-      //\r
-      IdeDev->BlkIo.Media->MediaId = 1;\r
-    } else {\r
-      //\r
-      // when no media, reset the MediaId to zero.\r
-      //\r
-      IdeDev->BlkIo.Media->MediaId = 0;\r
-    }\r
-\r
-    *MediaChange = TRUE;\r
-  }\r
-\r
-  //\r
-  // if any change on current existing media,\r
-  // the Block I/O protocol need to be reinstalled.\r
-  //\r
-  if (*MediaChange) {\r
-    gBS->ReinstallProtocolInterface (\r
-          IdeDev->Handle,\r
-          &gEfiBlockIoProtocolGuid,\r
-          &IdeDev->BlkIo,\r
-          &IdeDev->BlkIo\r
-          );\r
-  }\r
-\r
-  if (IdeDev->BlkIo.Media->MediaPresent) {\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    return EFI_NO_MEDIA;\r
-  }\r
-}\r
-\r
-/**\r
-  This function is called by the AtapiBlkIoReadBlocks() to perform\r
-  read from media in block unit.\r
-\r
-  The main command used to access media here is READ(10) Command.\r
-  READ(10) Command requests that the ATAPI device media transfer\r
-  specified data to the host. Data is transferred in block(sector)\r
-  unit. The maximum number of blocks that can be transferred once is\r
-  65536. This is the main difference between READ(10) and READ(12)\r
-  Command. The maximum number of blocks in READ(12) is 2 power 32.\r
-\r
-  @param IdeDev           pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                          to record all the information of the IDE device.\r
-  @param Buffer           A pointer to the destination buffer for the data.\r
-  @param Lba              The starting logical block address to read from on the\r
-                          device media.\r
-  @param NumberOfBlocks   The number of transfer data blocks.\r
-\r
-  @return status is fully dependent on the return status of AtapiPacketCommandIn() function.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiReadSectors (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *Buffer,\r
-  IN  EFI_LBA         Lba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-\r
-  ATAPI_PACKET_COMMAND  Packet;\r
-  ATAPI_READ10_CMD            *Read10Packet;\r
-  EFI_STATUS            Status;\r
-  UINTN                 BlocksRemaining;\r
-  UINT32                Lba32;\r
-  UINT32                BlockSize;\r
-  UINT32                ByteCount;\r
-  UINT16                SectorCount;\r
-  VOID                  *PtrBuffer;\r
-  UINT16                MaxBlock;\r
-  UINTN                 TimeOut;\r
-\r
-  //\r
-  // fill command packet for Read(10) command\r
-  //\r
-  ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
-  Read10Packet  = &Packet.Read10;\r
-  Lba32         = (UINT32) Lba;\r
-  PtrBuffer     = Buffer;\r
-\r
-  BlockSize     = IdeDev->BlkIo.Media->BlockSize;\r
-\r
-  //\r
-  // limit the data bytes that can be transferred by one Read(10) Command\r
-  //\r
-  MaxBlock        = 65535;\r
-\r
-  BlocksRemaining = NumberOfBlocks;\r
-\r
-  Status          = EFI_SUCCESS;\r
-  while (BlocksRemaining > 0) {\r
-\r
-    if (BlocksRemaining <= MaxBlock) {\r
-\r
-      SectorCount = (UINT16) BlocksRemaining;\r
-    } else {\r
-\r
-      SectorCount = MaxBlock;\r
-    }\r
-\r
-    //\r
-    // fill the Packet data structure\r
-    //\r
-\r
-    Read10Packet->opcode = ATA_CMD_READ_10;\r
-\r
-    //\r
-    // Lba0 ~ Lba3 specify the start logical block address of the data transfer.\r
-    // Lba0 is MSB, Lba3 is LSB\r
-    //\r
-    Read10Packet->Lba3  = (UINT8) (Lba32 & 0xff);\r
-    Read10Packet->Lba2  = (UINT8) (Lba32 >> 8);\r
-    Read10Packet->Lba1  = (UINT8) (Lba32 >> 16);\r
-    Read10Packet->Lba0  = (UINT8) (Lba32 >> 24);\r
-\r
-    //\r
-    // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
-    // TranLen0 is MSB, TranLen is LSB\r
-    //\r
-    Read10Packet->TranLen1  = (UINT8) (SectorCount & 0xff);\r
-    Read10Packet->TranLen0  = (UINT8) (SectorCount >> 8);\r
-\r
-    ByteCount               = SectorCount * BlockSize;\r
-\r
-    if (IdeDev->Type == IdeCdRom) {\r
-      TimeOut = CDROMLONGTIMEOUT;\r
-    } else {\r
-      TimeOut = ATAPILONGTIMEOUT;\r
-    }\r
-\r
-    Status = AtapiPacketCommandIn (\r
-              IdeDev,\r
-              &Packet,\r
-              (UINT16 *) PtrBuffer,\r
-              ByteCount,\r
-              TimeOut\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    Lba32 += SectorCount;\r
-    PtrBuffer = (UINT8 *) PtrBuffer + SectorCount * BlockSize;\r
-    BlocksRemaining -= SectorCount;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function is called by the AtapiBlkIoWriteBlocks() to perform\r
-  write onto media in block unit.\r
-  The main command used to access media here is Write(10) Command.\r
-  Write(10) Command requests that the ATAPI device media transfer\r
-  specified data to the host. Data is transferred in block (sector)\r
-  unit. The maximum number of blocks that can be transferred once is\r
-  65536.\r
-\r
-  @param IdeDev          pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                         to record all the information of the IDE device.\r
-  @param Buffer          A pointer to the source buffer for the data.\r
-  @param Lba             The starting logical block address to write onto\r
-                         the device media.\r
-  @param NumberOfBlocks  The number of transfer data blocks.\r
-\r
-  @return status is fully dependent on the return status of AtapiPacketCommandOut() function.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiWriteSectors (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *Buffer,\r
-  IN  EFI_LBA         Lba,\r
-  IN  UINTN           NumberOfBlocks\r
-  )\r
-{\r
-\r
-  ATAPI_PACKET_COMMAND  Packet;\r
-  ATAPI_READ10_CMD            *Read10Packet;\r
-\r
-  EFI_STATUS            Status;\r
-  UINTN                 BlocksRemaining;\r
-  UINT32                Lba32;\r
-  UINT32                BlockSize;\r
-  UINT32                ByteCount;\r
-  UINT16                SectorCount;\r
-  VOID                  *PtrBuffer;\r
-  UINT16                MaxBlock;\r
-\r
-  //\r
-  // fill command packet for Write(10) command\r
-  // Write(10) command packet has the same data structure as\r
-  // Read(10) command packet,\r
-  // so here use the Read10Packet data structure\r
-  // for the Write(10) command packet.\r
-  //\r
-  ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
-  Read10Packet  = &Packet.Read10;\r
-\r
-  Lba32         = (UINT32) Lba;\r
-  PtrBuffer     = Buffer;\r
-\r
-  BlockSize     = IdeDev->BlkIo.Media->BlockSize;\r
-\r
-  //\r
-  // limit the data bytes that can be transferred by one Read(10) Command\r
-  //\r
-  MaxBlock        = (UINT16) (65536 / BlockSize);\r
-\r
-  BlocksRemaining = NumberOfBlocks;\r
-\r
-  Status          = EFI_SUCCESS;\r
-  while (BlocksRemaining > 0) {\r
-\r
-    if (BlocksRemaining >= MaxBlock) {\r
-      SectorCount = MaxBlock;\r
-    } else {\r
-      SectorCount = (UINT16) BlocksRemaining;\r
-    }\r
-\r
-    //\r
-    // Command code is WRITE_10.\r
-    //\r
-    Read10Packet->opcode = ATA_CMD_WRITE_10;\r
-\r
-    //\r
-    // Lba0 ~ Lba3 specify the start logical block address of the data transfer.\r
-    // Lba0 is MSB, Lba3 is LSB\r
-    //\r
-    Read10Packet->Lba3  = (UINT8) (Lba32 & 0xff);\r
-    Read10Packet->Lba2  = (UINT8) (Lba32 >> 8);\r
-    Read10Packet->Lba1  = (UINT8) (Lba32 >> 16);\r
-    Read10Packet->Lba0  = (UINT8) (Lba32 >> 24);\r
-\r
-    //\r
-    // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
-    // TranLen0 is MSB, TranLen is LSB\r
-    //\r
-    Read10Packet->TranLen1  = (UINT8) (SectorCount & 0xff);\r
-    Read10Packet->TranLen0  = (UINT8) (SectorCount >> 8);\r
-\r
-    ByteCount               = SectorCount * BlockSize;\r
-\r
-    Status = AtapiPacketCommandOut (\r
-              IdeDev,\r
-              &Packet,\r
-              (UINT16 *) PtrBuffer,\r
-              ByteCount,\r
-              ATAPILONGTIMEOUT\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    Lba32 += SectorCount;\r
-    PtrBuffer = ((UINT8 *) PtrBuffer + SectorCount * BlockSize);\r
-    BlocksRemaining -= SectorCount;\r
-  }\r
-\r
-  return Status;\r
-}\r
-/**\r
-  This function is used to implement the Soft Reset on the specified\r
-  ATAPI device. Different from the AtaSoftReset(), here reset is a ATA\r
-  Soft Reset Command special for ATAPI device, and it only take effects\r
-  on the specified ATAPI device, not on the whole IDE bus.\r
-  Since the ATAPI soft reset is needed when device is in exceptional\r
-  condition (such as BSY bit is always set ), I think the Soft Reset\r
-  command should be sent without waiting for the BSY clear and DRDY\r
-  set.\r
-  This function is called by IdeBlkIoReset(),\r
-  a interface function of Block I/O protocol.\r
-\r
-  @param IdeDev    pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                   to record all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS      Soft reset completes successfully.\r
-  @retval EFI_DEVICE_ERROR Any step during the reset process is failed.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiSoftReset (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  UINT8       Command;\r
-  UINT8       DeviceSelect;\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // for ATAPI device, no need to wait DRDY ready after device selecting.\r
-  // (bit7 and bit5 are both set to 1 for backward compatibility)\r
-  //\r
-  DeviceSelect = (UINT8) (((BIT7 | BIT5) | (IdeDev->Device << 4)));\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, DeviceSelect);\r
-\r
-  Command = ATA_CMD_SOFT_RESET;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, Command);\r
-\r
-  //\r
-  // BSY cleared is the only status return to the host by the device\r
-  // when reset is completed.\r
-  // slave device needs at most 31s to clear BSY\r
-  //\r
-  Status = WaitForBSYClear (IdeDev, 31000);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // stall 5 seconds to make the device status stable\r
-  //\r
-  gBS->Stall (5000000);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is the ATAPI implementation for ReadBlocks in the\r
-  Block I/O Protocol interface.\r
-\r
-  @param IdeBlkIoDevice Indicates the calling context.\r
-  @param MediaId        The media id that the read request is for.\r
-  @param Lba            The starting logical block address to read from on the device.\r
-  @param BufferSize     The size of the Buffer in bytes. This must be a multiple\r
-                        of the intrinsic block size of the device.\r
-  @param Buffer         A pointer to the destination buffer for the data. The caller\r
-                        is responsible for either having implicit or explicit\r
-                        ownership of the memory that data is read into.\r
-\r
-  @retval EFI_SUCCESS           Read Blocks successfully.\r
-  @retval EFI_DEVICE_ERROR      Read Blocks failed.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.\r
-  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
-                                intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the data buffer is not valid.\r
-**/\r
-EFI_STATUS\r
-AtapiBlkIoReadBlocks (\r
-  IN IDE_BLK_IO_DEV   *IdeBlkIoDevice,\r
-  IN UINT32           MediaId,\r
-  IN EFI_LBA          Lba,\r
-  IN UINTN            BufferSize,\r
-  OUT VOID            *Buffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_MEDIA  *Media;\r
-  UINTN               BlockSize;\r
-  UINTN               NumberOfBlocks;\r
-  EFI_STATUS          Status;\r
-\r
-  BOOLEAN             MediaChange;\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // ATAPI device media is removable, so it is a must\r
-  // to detect media first before read operation\r
-  //\r
-  MediaChange = FALSE;\r
-  Status      = AtapiDetectMedia (IdeBlkIoDevice, &MediaChange);\r
-  if (EFI_ERROR (Status)) {\r
-\r
-    if (IdeBlkIoDevice->Cache != NULL) {\r
-      gBS->FreePool (IdeBlkIoDevice->Cache);\r
-      IdeBlkIoDevice->Cache = NULL;\r
-    }\r
-\r
-    return Status;\r
-  }\r
-  //\r
-  // Get the intrinsic block size\r
-  //\r
-  Media           = IdeBlkIoDevice->BlkIo.Media;\r
-  BlockSize       = Media->BlockSize;\r
-\r
-  NumberOfBlocks  = BufferSize / BlockSize;\r
-\r
-  if (!(Media->MediaPresent)) {\r
-\r
-    if (IdeBlkIoDevice->Cache != NULL) {\r
-      gBS->FreePool (IdeBlkIoDevice->Cache);\r
-      IdeBlkIoDevice->Cache = NULL;\r
-    }\r
-    return EFI_NO_MEDIA;\r
-\r
-  }\r
-\r
-  if ((MediaId != Media->MediaId) || MediaChange) {\r
-\r
-    if (IdeBlkIoDevice->Cache != NULL) {\r
-      gBS->FreePool (IdeBlkIoDevice->Cache);\r
-      IdeBlkIoDevice->Cache = NULL;\r
-    }\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // if all the parameters are valid, then perform read sectors command\r
-  // to transfer data from device to host.\r
-  //\r
-  Status = AtapiReadSectors (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // Read blocks succeeded\r
-  //\r
-\r
-  //\r
-  // save the first block to the cache for performance\r
-  //\r
-  if (Lba == 0 && (IdeBlkIoDevice->Cache == NULL)) {\r
-    IdeBlkIoDevice->Cache = AllocatePool (BlockSize);\r
-    if (IdeBlkIoDevice->Cache!= NULL) {\r
-      CopyMem ((UINT8 *) IdeBlkIoDevice->Cache, (UINT8 *) Buffer, BlockSize);\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-/**\r
-  This function is the ATAPI implementation for WriteBlocks in the\r
-  Block I/O Protocol interface.\r
-\r
-  @param IdeBlkIoDevice  Indicates the calling context.\r
-  @param MediaId         The media id that the write request is for.\r
-  @param Lba             The starting logical block address to write onto the device.\r
-  @param BufferSize      The size of the Buffer in bytes. This must be a multiple\r
-                         of the intrinsic block size of the device.\r
-  @param Buffer          A pointer to the source buffer for the data. The caller\r
-                         is responsible for either having implicit or explicit ownership\r
-                         of the memory that data is written from.\r
-\r
-  @retval EFI_SUCCESS            Write Blocks successfully.\r
-  @retval EFI_DEVICE_ERROR       Write Blocks failed.\r
-  @retval EFI_NO_MEDIA           There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGE       The MediaId is not for the current media.\r
-  @retval EFI_BAD_BUFFER_SIZE    The BufferSize parameter is not a multiple of the\r
-                                 intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER  The write request contains LBAs that are not valid,\r
-                                 or the data buffer is not valid.\r
-\r
-  @retval EFI_WRITE_PROTECTED    The write protected is enabled or the media does not support write\r
-**/\r
-EFI_STATUS\r
-AtapiBlkIoWriteBlocks (\r
-  IN IDE_BLK_IO_DEV   *IdeBlkIoDevice,\r
-  IN UINT32           MediaId,\r
-  IN EFI_LBA          Lba,\r
-  IN UINTN            BufferSize,\r
-  OUT VOID            *Buffer\r
-  )\r
-{\r
-\r
-  EFI_BLOCK_IO_MEDIA  *Media;\r
-  UINTN               BlockSize;\r
-  UINTN               NumberOfBlocks;\r
-  EFI_STATUS          Status;\r
-  BOOLEAN             MediaChange;\r
-\r
-  if (Lba == 0 && IdeBlkIoDevice->Cache != NULL) {\r
-    gBS->FreePool (IdeBlkIoDevice->Cache);\r
-    IdeBlkIoDevice->Cache = NULL;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // ATAPI device media is removable,\r
-  // so it is a must to detect media first before write operation\r
-  //\r
-  MediaChange = FALSE;\r
-  Status      = AtapiDetectMedia (IdeBlkIoDevice, &MediaChange);\r
-  if (EFI_ERROR (Status)) {\r
-\r
-    if (Lba == 0 && IdeBlkIoDevice->Cache != NULL) {\r
-      gBS->FreePool (IdeBlkIoDevice->Cache);\r
-      IdeBlkIoDevice->Cache = NULL;\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get the intrinsic block size\r
-  //\r
-  Media           = IdeBlkIoDevice->BlkIo.Media;\r
-  BlockSize       = Media->BlockSize;\r
-  NumberOfBlocks  = BufferSize / BlockSize;\r
-\r
-  if (!(Media->MediaPresent)) {\r
-\r
-    if (Lba == 0 && IdeBlkIoDevice->Cache != NULL) {\r
-      gBS->FreePool (IdeBlkIoDevice->Cache);\r
-      IdeBlkIoDevice->Cache = NULL;\r
-    }\r
-    return EFI_NO_MEDIA;\r
-  }\r
-\r
-  if ((MediaId != Media->MediaId) || MediaChange) {\r
-\r
-    if (Lba == 0 && IdeBlkIoDevice->Cache != NULL) {\r
-      gBS->FreePool (IdeBlkIoDevice->Cache);\r
-      IdeBlkIoDevice->Cache = NULL;\r
-    }\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (Media->ReadOnly) {\r
-    return EFI_WRITE_PROTECTED;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // if all the parameters are valid,\r
-  // then perform write sectors command to transfer data from host to device.\r
-  //\r
-  Status = AtapiWriteSectors (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.c
deleted file mode 100644 (file)
index c36fc33..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/** @file\r
-  UEFI Component Name(2) protocol implementation for ConPlatform driver.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IdeBus.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gIDEBusComponentName = {\r
-  IDEBusComponentNameGetDriverName,\r
-  IDEBusComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIDEBusComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IDEBusComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IDEBusComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusDriverNameTable[] = {\r
-  { "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Bus Driver" },\r
-  { NULL , NULL }\r
-};\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusControllerNameTable[] = {\r
-  { "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Controller" },\r
-  { NULL , NULL }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mIDEBusDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gIDEBusComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-  IDE_BLK_IO_DEV        *IdeBlkIoDevice;\r
-\r
-  //\r
-  // Make sure this driver is currently managing ControllHandle\r
-  //\r
-  Status = EfiTestManagedDevice (\r
-             ControllerHandle,\r
-             gIDEBusDriverBinding.DriverBindingHandle,\r
-             &gEfiIdeControllerInitProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (ChildHandle == NULL) {\r
-    return LookupUnicodeString2 (\r
-             Language,\r
-             This->SupportedLanguages,\r
-             mIDEBusControllerNameTable,\r
-             ControllerName,\r
-             (BOOLEAN)(This == &gIDEBusComponentName)\r
-             );\r
-  }\r
-\r
-  Status = EfiTestChildHandle (\r
-             ControllerHandle,\r
-             ChildHandle,\r
-             &gEfiPciIoProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get the child context\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ChildHandle,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  (VOID **) &BlockIo,\r
-                  gIDEBusDriverBinding.DriverBindingHandle,\r
-                  ChildHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo);\r
-\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           IdeBlkIoDevice->ControllerNameTable,\r
-           ControllerName,\r
-           (BOOLEAN)(This == &gIDEBusComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Add the component name for the IDE/ATAPI device\r
-\r
-  @param  IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.\r
-\r
-**/\r
-VOID\r
-AddName (\r
-  IN  IDE_BLK_IO_DEV               *IdeBlkIoDevicePtr\r
-  )\r
-{\r
-  UINTN   StringIndex;\r
-  CHAR16  ModelName[41];\r
-\r
-  //\r
-  // Add Component Name for the IDE/ATAPI device that was discovered.\r
-  //\r
-  IdeBlkIoDevicePtr->ControllerNameTable = NULL;\r
-  for (StringIndex = 0; StringIndex < 41; StringIndex++) {\r
-    ModelName[StringIndex] = IdeBlkIoDevicePtr->ModelName[StringIndex];\r
-  }\r
-\r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gIDEBusComponentName.SupportedLanguages,\r
-    &IdeBlkIoDevicePtr->ControllerNameTable,\r
-    ModelName,\r
-    TRUE\r
-    );\r
-  AddUnicodeString2 (\r
-    "en",\r
-    gIDEBusComponentName2.SupportedLanguages,\r
-    &IdeBlkIoDevicePtr->ControllerNameTable,\r
-    ModelName,\r
-    FALSE\r
-    );\r
-\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.h
deleted file mode 100644 (file)
index bd2d0c2..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/** @file\r
-\r
-  UEFI Component Name(2) protocol implementation header file for IDE Bus driver.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _IDE_BUS_COMPONENT_NAME_H_\r
-#define _IDE_BUS_COMPONENT_NAME_H_\r
-\r
-#define ADD_IDE_ATAPI_NAME(x) AddName ((x));\r
-\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gIDEBusComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gIDEBusComponentName2;\r
-\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-\r
-/**\r
-  Add the component name for the IDE/ATAPI device\r
-\r
-  @param  IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.\r
-\r
-**/\r
-VOID\r
-AddName (\r
-  IN  IDE_BLK_IO_DEV               *IdeBlkIoDevicePtr\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverConfiguration.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverConfiguration.c
deleted file mode 100644 (file)
index 42afde2..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/** @file\r
-  Implementation of UEFI Driver Configuration Protocol for IDE bus driver which\r
-  provides ability to set IDE bus controller specific options.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#include "IdeBus.h"\r
-\r
-CHAR16 *OptionString[4] = {\r
-  L"Enable Primary Master    (Y/N)? -->",\r
-  L"Enable Primary Slave     (Y/N)? -->",\r
-  L"Enable Secondary Master  (Y/N)? -->",\r
-  L"Enable Secondary Slave   (Y/N)? -->"\r
-};\r
-\r
-//\r
-// EFI Driver Configuration Protocol\r
-//\r
-\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverDiagnostics.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverDiagnostics.c
deleted file mode 100644 (file)
index 201178f..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/** @file\r
-  Implementation of UEFI driver Dialnostics protocol which to perform diagnostic on the IDE\r
-  Bus controller.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#include "IdeBus.h"\r
-\r
-#define IDE_BUS_DIAGNOSTIC_ERROR  L"PCI IDE/ATAPI Driver Diagnostics Failed"\r
-\r
-//\r
-// EFI Driver Diagnostics Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS_PROTOCOL gIDEBusDriverDiagnostics = {\r
-  IDEBusDriverDiagnosticsRunDiagnostics,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Driver Diagnostics 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2 = {\r
-  (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) IDEBusDriverDiagnosticsRunDiagnostics,\r
-  "en"\r
-};\r
-\r
-/**\r
-  Runs diagnostics on a controller.\r
-\r
-  @param  This             A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOLinstance.\r
-  @param  ControllerHandle The handle of the controller to run diagnostics on.\r
-  @param  ChildHandle      The handle of the child controller to run diagnostics on\r
-                           This is an optional parameter that may be NULL.  It will\r
-                           be NULL for device drivers.  It will also be NULL for a\r
-                           bus drivers that wish to run diagnostics on the bus controller.\r
-                           It will not be NULL for a bus driver that wishes to run\r
-                           diagnostics on one of its child controllers.\r
-  @param  DiagnosticType   Indicates type of diagnostics to perform on the controller\r
-                           specified by ControllerHandle and ChildHandle.\r
-  @param  Language         A pointer to a three character ISO 639-2 language identifier.\r
-                           This is the language in which the optional error message should\r
-                           be returned in Buffer, and it must match one of the languages\r
-                           specified in SupportedLanguages. The number of languages supported by\r
-                           a driver is up to the driver writer.\r
-  @param  ErrorType        A GUID that defines the format of the data returned in Buffer.\r
-  @param  BufferSize       The size, in bytes, of the data returned in Buffer.\r
-  @param  Buffer           A buffer that contains a Null-terminated Unicode string\r
-                           plus some additional data whose format is defined by ErrorType.\r
-                           Buffer is allocated by this function with AllocatePool(), and\r
-                           it is the caller's responsibility to free it with a call to FreePool().\r
-\r
-  @retval  EFI_SUCCESS           The controller specified by ControllerHandle and ChildHandle passed\r
-                                 the diagnostic.\r
-  @retval  EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-  @retval  EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
-  @retval  EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval  EFI_INVALID_PARAMETER ErrorType is NULL.\r
-  @retval  EFI_INVALID_PARAMETER BufferType is NULL.\r
-  @retval  EFI_INVALID_PARAMETER Buffer is NULL.\r
-  @retval  EFI_UNSUPPORTED       The driver specified by This does not support running\r
-                                 diagnostics for the controller specified by ControllerHandle\r
-                                 and ChildHandle.\r
-  @retval  EFI_UNSUPPORTED       The driver specified by This does not support the\r
-                                 type of diagnostic specified by DiagnosticType.\r
-  @retval  EFI_UNSUPPORTED       The driver specified by This does not support the language\r
-                                 specified by Language.\r
-  @retval  EFI_OUT_OF_RESOURCES  There are not enough resources available to complete the\r
-                                 diagnostics.\r
-  @retval  EFI_OUT_OF_RESOURCES  There are not enough resources available to return the\r
-                                 status information in ErrorType, BufferSize,and Buffer.\r
-  @retval  EFI_DEVICE_ERROR      The controller specified by ControllerHandle and ChildHandle\r
-                                 did not pass the diagnostic.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusDriverDiagnosticsRunDiagnostics (\r
-  IN  EFI_DRIVER_DIAGNOSTICS_PROTOCOL               *This,\r
-  IN  EFI_HANDLE                                    ControllerHandle,\r
-  IN  EFI_HANDLE                                    ChildHandle  OPTIONAL,\r
-  IN  EFI_DRIVER_DIAGNOSTIC_TYPE                    DiagnosticType,\r
-  IN  CHAR8                                         *Language,\r
-  OUT EFI_GUID                                      **ErrorType,\r
-  OUT UINTN                                         *BufferSize,\r
-  OUT CHAR16                                        **Buffer\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-  EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
-  IDE_BLK_IO_DEV        *IdeBlkIoDevice;\r
-  UINT32                VendorDeviceId;\r
-  VOID                  *BlockBuffer;\r
-  CHAR8                 *SupportedLanguages;\r
-  BOOLEAN               Iso639Language;\r
-  BOOLEAN               Found;\r
-  UINTN                 Index;\r
-\r
-  if (Language         == NULL ||\r
-      ErrorType        == NULL ||\r
-      Buffer           == NULL ||\r
-      ControllerHandle == NULL ||\r
-      BufferSize       == NULL) {\r
-\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  SupportedLanguages = This->SupportedLanguages;\r
-  Iso639Language = (BOOLEAN)(This == &gIDEBusDriverDiagnostics);\r
-  //\r
-  // Make sure Language is in the set of Supported Languages\r
-  //\r
-  Found = FALSE;\r
-  while (*SupportedLanguages != 0) {\r
-    if (Iso639Language) {\r
-      if (CompareMem (Language, SupportedLanguages, 3) == 0) {\r
-        Found = TRUE;\r
-        break;\r
-      }\r
-      SupportedLanguages += 3;\r
-    } else {\r
-      for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
-      if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {\r
-        Found = TRUE;\r
-        break;\r
-      }\r
-      SupportedLanguages += Index;\r
-      for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
-    }\r
-  }\r
-  //\r
-  // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED\r
-  //\r
-  if (!Found) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  *ErrorType  = NULL;\r
-  *BufferSize = 0;\r
-\r
-  if (ChildHandle == NULL) {\r
-    Status = gBS->OpenProtocol (\r
-                    ControllerHandle,\r
-                    &gEfiCallerIdGuid,\r
-                    NULL,\r
-                    gIDEBusDriverBinding.DriverBindingHandle,\r
-                    ControllerHandle,\r
-                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    Status = gBS->OpenProtocol (\r
-                    ControllerHandle,\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo,\r
-                    gIDEBusDriverBinding.DriverBindingHandle,\r
-                    ControllerHandle,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    //\r
-    // Use services of PCI I/O Protocol to test the PCI IDE/ATAPI Controller\r
-    // The following test simply reads the Device ID and Vendor ID.\r
-    // It should never fail.  A real test would perform more advanced\r
-    // diagnostics.\r
-    //\r
-\r
-    Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, 1, &VendorDeviceId);\r
-    if (EFI_ERROR (Status) || VendorDeviceId == 0xffffffff) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  ChildHandle,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  (VOID **) &BlkIo,\r
-                  gIDEBusDriverBinding.DriverBindingHandle,\r
-                  ChildHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlkIo);\r
-\r
-  //\r
-  // Use services available from IdeBlkIoDevice to test the IDE/ATAPI device\r
-  //\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  IdeBlkIoDevice->BlkMedia.BlockSize,\r
-                  (VOID **) &BlockBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = IdeBlkIoDevice->BlkIo.ReadBlocks (\r
-                                  &IdeBlkIoDevice->BlkIo,\r
-                                  IdeBlkIoDevice->BlkMedia.MediaId,\r
-                                  0,\r
-                                  IdeBlkIoDevice->BlkMedia.BlockSize,\r
-                                  BlockBuffer\r
-                                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    *ErrorType  = &gEfiCallerIdGuid;\r
-    *BufferSize = sizeof (IDE_BUS_DIAGNOSTIC_ERROR);\r
-\r
-    Status = gBS->AllocatePool (\r
-                    EfiBootServicesData,\r
-                    (UINTN) (*BufferSize),\r
-                    (VOID **) Buffer\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    CopyMem (*Buffer, IDE_BUS_DIAGNOSTIC_ERROR, *BufferSize);\r
-\r
-    Status = EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  gBS->FreePool (BlockBuffer);\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c
deleted file mode 100644 (file)
index 8ab81b1..0000000
+++ /dev/null
@@ -1,1324 +0,0 @@
-/** @file\r
-  The file ontaining the helper functions implement of the Ide Bus driver\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "IdeBus.h"\r
-\r
-BOOLEAN ChannelDeviceDetected = FALSE;\r
-BOOLEAN SlaveDeviceExist      = FALSE;\r
-UINT8   SlaveDeviceType       = INVALID_DEVICE_TYPE;\r
-BOOLEAN MasterDeviceExist     = FALSE;\r
-UINT8   MasterDeviceType      = INVALID_DEVICE_TYPE;\r
-\r
-/**\r
-  read a one-byte data from a IDE port.\r
-\r
-  @param  PciIo  The PCI IO protocol instance\r
-  @param  Port   the IDE Port number\r
-\r
-  @return  the one-byte data read from IDE port\r
-**/\r
-UINT8\r
-IDEReadPortB (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  Data = 0;\r
-  //\r
-  // perform 1-byte data read from register\r
-  //\r
-  PciIo->Io.Read (\r
-              PciIo,\r
-              EfiPciIoWidthUint8,\r
-              EFI_PCI_IO_PASS_THROUGH_BAR,\r
-              (UINT64) Port,\r
-              1,\r
-              &Data\r
-              );\r
-  return Data;\r
-}\r
-/**\r
-  Reads multiple words of data from the IDE data port.\r
-  Call the IO abstraction once to do the complete read,\r
-  not one word at a time\r
-\r
-  @param  PciIo Pointer to the EFI_PCI_IO instance\r
-  @param  Port IO port to read\r
-  @param  Count No. of UINT16's to read\r
-  @param  Buffer Pointer to the data buffer for read\r
-\r
-**/\r
-VOID\r
-IDEReadPortWMultiple (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port,\r
-  IN  UINTN                 Count,\r
-  OUT VOID                  *Buffer\r
-  )\r
-{\r
-  UINT16  *AlignedBuffer;\r
-  UINT16  *WorkingBuffer;\r
-  UINTN   Size;\r
-\r
-  //\r
-  // Prepare an 16-bit alligned working buffer. CpuIo will return failure and\r
-  // not perform actual I/O operations if buffer pointer passed in is not at\r
-  // natural boundary. The "Buffer" argument is passed in by user and may not\r
-  // at 16-bit natural boundary.\r
-  //\r
-  Size = sizeof (UINT16) * Count;\r
-\r
-  gBS->AllocatePool (\r
-        EfiBootServicesData,\r
-        Size + 1,\r
-        (VOID**)&WorkingBuffer\r
-        );\r
-\r
-  AlignedBuffer = (UINT16 *) ((UINTN)(((UINTN) WorkingBuffer + 0x1) & (~0x1)));\r
-\r
-  //\r
-  // Perform UINT16 data read from FIFO\r
-  //\r
-  PciIo->Io.Read (\r
-              PciIo,\r
-              EfiPciIoWidthFifoUint16,\r
-              EFI_PCI_IO_PASS_THROUGH_BAR,\r
-              (UINT64) Port,\r
-              Count,\r
-              (UINT16*)AlignedBuffer\r
-              );\r
-\r
-  //\r
-  // Copy data to user buffer\r
-  //\r
-  CopyMem (Buffer, (UINT16*)AlignedBuffer, Size);\r
-  gBS->FreePool (WorkingBuffer);\r
-}\r
-\r
-/**\r
-  write a 1-byte data to a specific IDE port.\r
-\r
-  @param  PciIo  PCI IO protocol instance\r
-  @param  Port   The IDE port to be writen\r
-  @param  Data   The data to write to the port\r
-**/\r
-VOID\r
-IDEWritePortB (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port,\r
-  IN  UINT8                 Data\r
-  )\r
-{\r
-  //\r
-  // perform 1-byte data write to register\r
-  //\r
-  PciIo->Io.Write (\r
-              PciIo,\r
-              EfiPciIoWidthUint8,\r
-              EFI_PCI_IO_PASS_THROUGH_BAR,\r
-              (UINT64) Port,\r
-              1,\r
-              &Data\r
-              );\r
-\r
-}\r
-\r
-/**\r
-  write a 1-word data to a specific IDE port.\r
-\r
-  @param  PciIo  PCI IO protocol instance\r
-  @param  Port   The IDE port to be writen\r
-  @param  Data   The data to write to the port\r
-**/\r
-VOID\r
-IDEWritePortW (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port,\r
-  IN  UINT16                Data\r
-  )\r
-{\r
-  //\r
-  // perform 1-word data write to register\r
-  //\r
-  PciIo->Io.Write (\r
-              PciIo,\r
-              EfiPciIoWidthUint16,\r
-              EFI_PCI_IO_PASS_THROUGH_BAR,\r
-              (UINT64) Port,\r
-              1,\r
-              &Data\r
-              );\r
-}\r
-\r
-/**\r
-  Write multiple words of data to the IDE data port.\r
-  Call the IO abstraction once to do the complete read,\r
-  not one word at a time\r
-\r
-  @param  PciIo Pointer to the EFI_PCI_IO instance\r
-  @param  Port IO port to read\r
-  @param  Count No. of UINT16's to read\r
-  @param  Buffer Pointer to the data buffer for read\r
-\r
-**/\r
-VOID\r
-IDEWritePortWMultiple (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port,\r
-  IN  UINTN                 Count,\r
-  IN  VOID                  *Buffer\r
-  )\r
-{\r
-  UINT16  *AlignedBuffer;\r
-  UINT32  *WorkingBuffer;\r
-  UINTN   Size;\r
-\r
-  //\r
-  // Prepare an 16-bit alligned working buffer. CpuIo will return failure and\r
-  // not perform actual I/O operations if buffer pointer passed in is not at\r
-  // natural boundary. The "Buffer" argument is passed in by user and may not\r
-  // at 16-bit natural boundary.\r
-  //\r
-  Size = sizeof (UINT16) * Count;\r
-\r
-  gBS->AllocatePool (\r
-        EfiBootServicesData,\r
-        Size + 1,\r
-        (VOID **) &WorkingBuffer\r
-        );\r
-\r
-  AlignedBuffer = (UINT16 *) ((UINTN)(((UINTN) WorkingBuffer + 0x1) & (~0x1)));\r
-\r
-  //\r
-  // Copy data from user buffer to working buffer\r
-  //\r
-  CopyMem ((UINT16 *) AlignedBuffer, Buffer, Size);\r
-\r
-  //\r
-  // perform UINT16 data write to the FIFO\r
-  //\r
-  PciIo->Io.Write (\r
-              PciIo,\r
-              EfiPciIoWidthFifoUint16,\r
-              EFI_PCI_IO_PASS_THROUGH_BAR,\r
-              (UINT64) Port,\r
-              Count,\r
-              (UINT16 *) AlignedBuffer\r
-              );\r
-\r
-  gBS->FreePool (WorkingBuffer);\r
-}\r
-/**\r
-  Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,\r
-  use fixed addresses. In Native-PCI mode, get base addresses from BARs in\r
-  the PCI IDE controller's Configuration Space.\r
-\r
-  The steps to get IDE IO port registers' base addresses for each channel\r
-  as follows:\r
-\r
-  1. Examine the Programming Interface byte of the Class Code fields in PCI IDE\r
-  controller's Configuration Space to determine the operating mode.\r
-\r
-  2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.\r
-  <pre>\r
-  ___________________________________________\r
-  |           | Command Block | Control Block |\r
-  |  Channel  |   Registers   |   Registers   |\r
-  |___________|_______________|_______________|\r
-  |  Primary  |  1F0h - 1F7h  |  3F6h - 3F7h  |\r
-  |___________|_______________|_______________|\r
-  | Secondary |  170h - 177h  |  376h - 377h  |\r
-  |___________|_______________|_______________|\r
-\r
-  Table 1. Compatibility resource mappings\r
-  </pre>\r
-\r
-  b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs\r
-  in IDE controller's PCI Configuration Space, shown in the Table 2 below.\r
-  <pre>\r
-  ___________________________________________________\r
-  |           |   Command Block   |   Control Block   |\r
-  |  Channel  |     Registers     |     Registers     |\r
-  |___________|___________________|___________________|\r
-  |  Primary  | BAR at offset 0x10| BAR at offset 0x14|\r
-  |___________|___________________|___________________|\r
-  | Secondary | BAR at offset 0x18| BAR at offset 0x1C|\r
-  |___________|___________________|___________________|\r
-\r
-  Table 2. BARs for Register Mapping\r
-  </pre>\r
-  @note Refer to Intel ICH4 datasheet, Control Block Offset: 03F4h for\r
-  primary, 0374h for secondary. So 2 bytes extra offset should be\r
-  added to the base addresses read from BARs.\r
-\r
-  For more details, please refer to PCI IDE Controller Specification and Intel\r
-  ICH4 Datasheet.\r
-\r
-  @param  PciIo Pointer to the EFI_PCI_IO_PROTOCOL instance\r
-  @param  IdeRegsBaseAddr Pointer to IDE_REGISTERS_BASE_ADDR to\r
-           receive IDE IO port registers' base addresses\r
-\r
-  @retval EFI_UNSUPPORTED return this value when the BARs is not IO type\r
-  @retval EFI_SUCCESS     Get the Base address successfully\r
-  @retval other           read the pci configureation data error\r
-\r
-**/\r
-EFI_STATUS\r
-GetIdeRegistersBaseAddr (\r
-  IN  EFI_PCI_IO_PROTOCOL         *PciIo,\r
-  OUT IDE_REGISTERS_BASE_ADDR     *IdeRegsBaseAddr\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  PCI_TYPE00  PciData;\r
-\r
-  Status = PciIo->Pci.Read (\r
-                        PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        0,\r
-                        sizeof (PciData),\r
-                        &PciData\r
-                        );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if ((PciData.Hdr.ClassCode[0] & IDE_PRIMARY_OPERATING_MODE) == 0) {\r
-    IdeRegsBaseAddr[IdePrimary].CommandBlockBaseAddr  = 0x1f0;\r
-    IdeRegsBaseAddr[IdePrimary].ControlBlockBaseAddr  = 0x3f6;\r
-    IdeRegsBaseAddr[IdePrimary].BusMasterBaseAddr     =\r
-    (UINT16)((PciData.Device.Bar[4] & 0x0000fff0));\r
-  } else {\r
-    //\r
-    // The BARs should be of IO type\r
-    //\r
-    if ((PciData.Device.Bar[0] & BIT0) == 0 ||\r
-        (PciData.Device.Bar[1] & BIT0) == 0) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    IdeRegsBaseAddr[IdePrimary].CommandBlockBaseAddr  =\r
-    (UINT16) (PciData.Device.Bar[0] & 0x0000fff8);\r
-    IdeRegsBaseAddr[IdePrimary].ControlBlockBaseAddr  =\r
-    (UINT16) ((PciData.Device.Bar[1] & 0x0000fffc) + 2);\r
-    IdeRegsBaseAddr[IdePrimary].BusMasterBaseAddr     =\r
-    (UINT16) ((PciData.Device.Bar[4] & 0x0000fff0));\r
-  }\r
-\r
-  if ((PciData.Hdr.ClassCode[0] & IDE_SECONDARY_OPERATING_MODE) == 0) {\r
-    IdeRegsBaseAddr[IdeSecondary].CommandBlockBaseAddr  = 0x170;\r
-    IdeRegsBaseAddr[IdeSecondary].ControlBlockBaseAddr  = 0x376;\r
-    IdeRegsBaseAddr[IdeSecondary].BusMasterBaseAddr     =\r
-    (UINT16) ((PciData.Device.Bar[4] & 0x0000fff0));\r
-  } else {\r
-    //\r
-    // The BARs should be of IO type\r
-    //\r
-    if ((PciData.Device.Bar[2] & BIT0) == 0 ||\r
-        (PciData.Device.Bar[3] & BIT0) == 0) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    IdeRegsBaseAddr[IdeSecondary].CommandBlockBaseAddr  =\r
-    (UINT16) (PciData.Device.Bar[2] & 0x0000fff8);\r
-    IdeRegsBaseAddr[IdeSecondary].ControlBlockBaseAddr  =\r
-    (UINT16) ((PciData.Device.Bar[3] & 0x0000fffc) + 2);\r
-    IdeRegsBaseAddr[IdeSecondary].BusMasterBaseAddr     =\r
-    (UINT16) ((PciData.Device.Bar[4] & 0x0000fff0));\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is used to requery IDE resources. The IDE controller will\r
-  probably switch between native and legacy modes during the EFI->CSM->OS\r
-  transfer. We do this everytime before an BlkIo operation to ensure its\r
-  succeess.\r
-\r
-  @param  IdeDev The BLK_IO private data which specifies the IDE device\r
-\r
-  @retval EFI_INVALID_PARAMETER return this value when the channel is invalid\r
-  @retval EFI_SUCCESS           reassign the IDE IO resource successfully\r
-  @retval other                 get the IDE current base address effor\r
-\r
-**/\r
-EFI_STATUS\r
-ReassignIdeResources (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  IDE_REGISTERS_BASE_ADDR IdeRegsBaseAddr[IdeMaxChannel];\r
-  UINT16                  CommandBlockBaseAddr;\r
-  UINT16                  ControlBlockBaseAddr;\r
-\r
-  if (IdeDev->Channel >= IdeMaxChannel) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Requery IDE IO port registers' base addresses in case of the switch of\r
-  // native and legacy modes\r
-  //\r
-  Status = GetIdeRegistersBaseAddr (IdeDev->PciIo, IdeRegsBaseAddr);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  ZeroMem (IdeDev->IoPort, sizeof (IDE_BASE_REGISTERS));\r
-  CommandBlockBaseAddr                = IdeRegsBaseAddr[IdeDev->Channel].CommandBlockBaseAddr;\r
-  ControlBlockBaseAddr                = IdeRegsBaseAddr[IdeDev->Channel].ControlBlockBaseAddr;\r
-\r
-  IdeDev->IoPort->Data                = CommandBlockBaseAddr;\r
-  (*(UINT16 *) &IdeDev->IoPort->Reg1) = (UINT16) (CommandBlockBaseAddr + 0x01);\r
-  IdeDev->IoPort->SectorCount         = (UINT16) (CommandBlockBaseAddr + 0x02);\r
-  IdeDev->IoPort->SectorNumber        = (UINT16) (CommandBlockBaseAddr + 0x03);\r
-  IdeDev->IoPort->CylinderLsb         = (UINT16) (CommandBlockBaseAddr + 0x04);\r
-  IdeDev->IoPort->CylinderMsb         = (UINT16) (CommandBlockBaseAddr + 0x05);\r
-  IdeDev->IoPort->Head                = (UINT16) (CommandBlockBaseAddr + 0x06);\r
-\r
-  (*(UINT16 *) &IdeDev->IoPort->Reg)  = (UINT16) (CommandBlockBaseAddr + 0x07);\r
-  (*(UINT16 *) &IdeDev->IoPort->Alt)  = ControlBlockBaseAddr;\r
-  IdeDev->IoPort->DriveAddress        = (UINT16) (ControlBlockBaseAddr + 0x01);\r
-  IdeDev->IoPort->MasterSlave         = (UINT16) ((IdeDev->Device == IdeMaster) ? 1 : 0);\r
-\r
-  IdeDev->IoPort->BusMasterBaseAddr   = IdeRegsBaseAddr[IdeDev->Channel].BusMasterBaseAddr;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is called by DiscoverIdeDevice(). It is used for detect\r
-  whether the IDE device exists in the specified Channel as the specified\r
-  Device Number.\r
-\r
-  There is two IDE channels: one is Primary Channel, the other is\r
-  Secondary Channel.(Channel is the logical name for the physical "Cable".)\r
-  Different channel has different register group.\r
-\r
-  On each IDE channel, at most two IDE devices attach,\r
-  one is called Device 0 (Master device), the other is called Device 1\r
-  (Slave device). The devices on the same channel co-use the same register\r
-  group, so before sending out a command for a specified device via command\r
-  register, it is a must to select the current device to accept the command\r
-  by set the device number in the Head/Device Register.\r
-\r
-  @param IdeDev  pointer to IDE_BLK_IO_DEV data structure, used to record all the\r
-                 information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS successfully detects device.\r
-\r
-  @retval other       any failure during detection process will return this value.\r
-\r
-**/\r
-EFI_STATUS\r
-DetectIDEController (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       SectorCountReg;\r
-  UINT8       LBALowReg;\r
-  UINT8       LBAMidReg;\r
-  UINT8       LBAHighReg;\r
-  UINT8       InitStatusReg;\r
-  UINT8       StatusReg;\r
-\r
-  //\r
-  // Select slave device\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((1 << 4) | 0xe0)\r
-    );\r
-  gBS->Stall (100);\r
-\r
-  //\r
-  // Save the init slave status register\r
-  //\r
-  InitStatusReg = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);\r
-\r
-  //\r
-  // Select Master back\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((0 << 4) | 0xe0)\r
-    );\r
-  gBS->Stall (100);\r
-\r
-  //\r
-  // Send ATA Device Execut Diagnostic command.\r
-  // This command should work no matter DRDY is ready or not\r
-  //\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, 0x90);\r
-\r
-  Status    = WaitForBSYClear (IdeDev, 3500);\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG((EFI_D_ERROR, "New detecting method: Send Execute Diagnostic Command: WaitForBSYClear: Status: %d\n", Status));\r
-    return Status;\r
-  }\r
-  //\r
-  // Read device signature\r
-  //\r
-  //\r
-  // Select Master\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((0 << 4) | 0xe0)\r
-    );\r
-  gBS->Stall (100);\r
-  SectorCountReg = IDEReadPortB (\r
-                     IdeDev->PciIo,\r
-                     IdeDev->IoPort->SectorCount\r
-                     );\r
-  LBALowReg      = IDEReadPortB (\r
-                     IdeDev->PciIo,\r
-                     IdeDev->IoPort->SectorNumber\r
-                     );\r
-  LBAMidReg      = IDEReadPortB (\r
-                     IdeDev->PciIo,\r
-                     IdeDev->IoPort->CylinderLsb\r
-                     );\r
-  LBAHighReg     = IDEReadPortB (\r
-                     IdeDev->PciIo,\r
-                     IdeDev->IoPort->CylinderMsb\r
-                     );\r
-  if ((SectorCountReg == 0x1) &&\r
-      (LBALowReg      == 0x1) &&\r
-      (LBAMidReg      == 0x0) &&\r
-      (LBAHighReg     == 0x0)) {\r
-    MasterDeviceExist = TRUE;\r
-    MasterDeviceType  = ATA_DEVICE_TYPE;\r
-  } else {\r
-    if ((LBAMidReg      == 0x14) &&\r
-        (LBAHighReg     == 0xeb)) {\r
-      MasterDeviceExist = TRUE;\r
-      MasterDeviceType  = ATAPI_DEVICE_TYPE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // For some Hard Drive, it takes some time to get\r
-  // the right signature when operating in single slave mode.\r
-  // We stall 20ms to work around this.\r
-  //\r
-  if (!MasterDeviceExist) {\r
-    gBS->Stall (20000);\r
-  }\r
-\r
-  //\r
-  // Select Slave\r
-  //\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    (UINT8) ((1 << 4) | 0xe0)\r
-    );\r
-  gBS->Stall (100);\r
-  SectorCountReg = IDEReadPortB (\r
-                     IdeDev->PciIo,\r
-                     IdeDev->IoPort->SectorCount\r
-                     );\r
-  LBALowReg  = IDEReadPortB (\r
-                 IdeDev->PciIo,\r
-                 IdeDev->IoPort->SectorNumber\r
-                 );\r
-  LBAMidReg  = IDEReadPortB (\r
-                 IdeDev->PciIo,\r
-                 IdeDev->IoPort->CylinderLsb\r
-                 );\r
-  LBAHighReg = IDEReadPortB (\r
-                 IdeDev->PciIo,\r
-                 IdeDev->IoPort->CylinderMsb\r
-                 );\r
-  StatusReg  = IDEReadPortB (\r
-                 IdeDev->PciIo,\r
-                 IdeDev->IoPort->Reg.Status\r
-                 );\r
-  if ((SectorCountReg == 0x1) &&\r
-      (LBALowReg      == 0x1) &&\r
-      (LBAMidReg      == 0x0) &&\r
-      (LBAHighReg     == 0x0)) {\r
-    SlaveDeviceExist = TRUE;\r
-    SlaveDeviceType  = ATA_DEVICE_TYPE;\r
-  } else {\r
-    if ((LBAMidReg     == 0x14) &&\r
-        (LBAHighReg    == 0xeb)) {\r
-      SlaveDeviceExist = TRUE;\r
-      SlaveDeviceType  = ATAPI_DEVICE_TYPE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // When single master is plugged, slave device\r
-  // will be wrongly detected. Here's the workaround\r
-  // for ATA devices by detecting DRY bit in status\r
-  // register.\r
-  // NOTE: This workaround doesn't apply to ATAPI.\r
-  //\r
-  if (MasterDeviceExist && SlaveDeviceExist &&\r
-      (StatusReg & ATA_STSREG_DRDY) == 0               &&\r
-      (InitStatusReg & ATA_STSREG_DRDY) == 0           &&\r
-      MasterDeviceType == SlaveDeviceType   &&\r
-      SlaveDeviceType != ATAPI_DEVICE_TYPE) {\r
-    SlaveDeviceExist = FALSE;\r
-  }\r
-\r
-  //\r
-  // Indicate this channel has been detected\r
-  //\r
-  ChannelDeviceDetected = TRUE;\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Detect if there is disk attached to this port\r
-\r
-  @param  IdeDev The BLK_IO private data which specifies the IDE device.\r
-\r
-  @retval EFI_NOT_FOUND   The device or channel is not found\r
-  @retval EFI_SUCCESS     The device is found\r
-\r
-**/\r
-EFI_STATUS\r
-DiscoverIdeDevice (\r
-  IN IDE_BLK_IO_DEV *IdeDev\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  EFI_STATUS  LongPhyStatus;\r
-\r
-  //\r
-  // If a channel has not been checked, check it now. Then set it to "checked" state\r
-  // After this step, all devices in this channel have been checked.\r
-  //\r
-  if (!ChannelDeviceDetected) {\r
-    Status = DetectIDEController (IdeDev);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-  }\r
-\r
-  Status = EFI_NOT_FOUND;\r
-\r
-  //\r
-  // Device exists. test if it is an ATA device.\r
-  // Prefer the result from DetectIDEController,\r
-  // if failed, try another device type to handle\r
-  // devices that not follow the spec.\r
-  //\r
-  if ((IdeDev->Device == IdeMaster) && (MasterDeviceExist)) {\r
-    if (MasterDeviceType == ATA_DEVICE_TYPE) {\r
-      Status = ATAIdentify (IdeDev);\r
-      if (EFI_ERROR (Status)) {\r
-        Status = ATAPIIdentify (IdeDev);\r
-        if (!EFI_ERROR (Status)) {\r
-          MasterDeviceType = ATAPI_DEVICE_TYPE;\r
-        }\r
-      }\r
-    } else {\r
-      Status = ATAPIIdentify (IdeDev);\r
-      if (EFI_ERROR (Status)) {\r
-        Status = ATAIdentify (IdeDev);\r
-        if (!EFI_ERROR (Status)) {\r
-          MasterDeviceType = ATA_DEVICE_TYPE;\r
-        }\r
-      }\r
-    }\r
-  }\r
-  if ((IdeDev->Device == IdeSlave) && (SlaveDeviceExist)) {\r
-    if (SlaveDeviceType == ATA_DEVICE_TYPE) {\r
-      Status = ATAIdentify (IdeDev);\r
-      if (EFI_ERROR (Status)) {\r
-        Status = ATAPIIdentify (IdeDev);\r
-        if (!EFI_ERROR (Status)) {\r
-          SlaveDeviceType = ATAPI_DEVICE_TYPE;\r
-        }\r
-      }\r
-    } else {\r
-      Status = ATAPIIdentify (IdeDev);\r
-      if (EFI_ERROR (Status)) {\r
-        Status = ATAIdentify (IdeDev);\r
-        if (!EFI_ERROR (Status)) {\r
-          SlaveDeviceType = ATA_DEVICE_TYPE;\r
-        }\r
-      }\r
-    }\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Init Block I/O interface\r
-  //\r
-  LongPhyStatus = AtaEnableLongPhysicalSector (IdeDev);\r
-  if (!EFI_ERROR (LongPhyStatus)) {\r
-    IdeDev->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION2;\r
-  } else {\r
-    IdeDev->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION;\r
-  }\r
-  IdeDev->BlkIo.Reset               = IDEBlkIoReset;\r
-  IdeDev->BlkIo.ReadBlocks          = IDEBlkIoReadBlocks;\r
-  IdeDev->BlkIo.WriteBlocks         = IDEBlkIoWriteBlocks;\r
-  IdeDev->BlkIo.FlushBlocks         = IDEBlkIoFlushBlocks;\r
-\r
-  IdeDev->BlkMedia.LogicalPartition = FALSE;\r
-  IdeDev->BlkMedia.WriteCaching     = FALSE;\r
-\r
-  //\r
-  // Init Disk Info interface\r
-  //\r
-  gBS->CopyMem (&IdeDev->DiskInfo.Interface, &gEfiDiskInfoIdeInterfaceGuid, sizeof (EFI_GUID));\r
-  IdeDev->DiskInfo.Inquiry    = IDEDiskInfoInquiry;\r
-  IdeDev->DiskInfo.Identify   = IDEDiskInfoIdentify;\r
-  IdeDev->DiskInfo.SenseData  = IDEDiskInfoSenseData;\r
-  IdeDev->DiskInfo.WhichIde   = IDEDiskInfoWhichIde;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This interface is used to initialize all state data related to the detection of one\r
-  channel.\r
-**/\r
-VOID\r
-InitializeIDEChannelData (\r
-  VOID\r
-  )\r
-{\r
-  ChannelDeviceDetected = FALSE;\r
-  MasterDeviceExist = FALSE;\r
-  MasterDeviceType  = 0xff;\r
-  SlaveDeviceExist  = FALSE;\r
-  SlaveDeviceType   = 0xff;\r
-}\r
-/**\r
-  This function is used to poll for the DRQ bit clear in the Status\r
-  Register. DRQ is cleared when the device is finished transferring data.\r
-  So this function is called after data transfer is finished.\r
-\r
-  @param IdeDev                 pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                                to record all the information of the IDE device.\r
-  @param TimeoutInMilliSeconds  used to designate the timeout for the DRQ clear.\r
-\r
-  @retval EFI_SUCCESS           DRQ bit clear within the time out.\r
-\r
-  @retval EFI_TIMEOUT           DRQ bit not clear within the time out.\r
-\r
-  @note\r
-  Read Status Register will clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRQClear (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  )\r
-{\r
-  UINT32  Delay;\r
-  UINT8   StatusRegister;\r
-  UINT8   ErrorRegister;\r
-\r
-  Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);\r
-  do {\r
-\r
-    StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);\r
-\r
-    //\r
-    // wait for BSY == 0 and DRQ == 0\r
-    //\r
-    if ((StatusRegister & (ATA_STSREG_DRQ | ATA_STSREG_BSY)) == 0) {\r
-      break;\r
-    }\r
-\r
-    if ((StatusRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {\r
-\r
-      ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);\r
-      if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-\r
-    //\r
-    //  Stall for 30 us\r
-    //\r
-    gBS->Stall (30);\r
-\r
-    Delay--;\r
-\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function is used to poll for the DRQ bit clear in the Alternate\r
-  Status Register. DRQ is cleared when the device is finished\r
-  transferring data. So this function is called after data transfer\r
-  is finished.\r
-\r
-  @param IdeDev                pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                               to record all the information of the IDE device.\r
-\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.\r
-\r
-  @retval EFI_SUCCESS          DRQ bit clear within the time out.\r
-\r
-  @retval EFI_TIMEOUT          DRQ bit not clear within the time out.\r
-  @note   Read Alternate Status Register will not clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRQClear2 (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  )\r
-{\r
-  UINT32  Delay;\r
-  UINT8   AltRegister;\r
-  UINT8   ErrorRegister;\r
-\r
-  Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);\r
-  do {\r
-\r
-    AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);\r
-\r
-    //\r
-    //  wait for BSY == 0 and DRQ == 0\r
-    //\r
-    if ((AltRegister & (ATA_STSREG_DRQ | ATA_STSREG_BSY)) == 0) {\r
-      break;\r
-    }\r
-\r
-    if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {\r
-\r
-      ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);\r
-      if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Stall for 30 us\r
-    //\r
-    gBS->Stall (30);\r
-\r
-    Delay--;\r
-\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is used to poll for the DRQ bit set in the\r
-  Status Register.\r
-  DRQ is set when the device is ready to transfer data. So this function\r
-  is called after the command is sent to the device and before required\r
-  data is transferred.\r
-\r
-  @param IdeDev                pointer pointing to IDE_BLK_IO_DEV data structure,used to\r
-                               record all the information of the IDE device.\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS          DRQ bit set within the time out.\r
-  @retval EFI_TIMEOUT          DRQ bit not set within the time out.\r
-  @retval EFI_ABORTED          DRQ bit not set caused by the command abort.\r
-\r
-  @note  Read Status Register will clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRQReady (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  )\r
-{\r
-  UINT32  Delay;\r
-  UINT8   StatusRegister;\r
-  UINT8   ErrorRegister;\r
-\r
-  Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);\r
-  do {\r
-    //\r
-    //  read Status Register will clear interrupt\r
-    //\r
-    StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);\r
-\r
-    //\r
-    //  BSY==0,DRQ==1\r
-    //\r
-    if ((StatusRegister & (ATA_STSREG_BSY | ATA_STSREG_DRQ)) == ATA_STSREG_DRQ) {\r
-      break;\r
-    }\r
-\r
-    if ((StatusRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {\r
-\r
-      ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);\r
-      if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Stall for 30 us\r
-    //\r
-    gBS->Stall (30);\r
-\r
-    Delay--;\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function is used to poll for the DRQ bit set in the Alternate Status Register.\r
-  DRQ is set when the device is ready to transfer data. So this function is called after\r
-  the command is sent to the device and before required data is transferred.\r
-\r
-  @param IdeDev                pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
-                               record all the information of the IDE device.\r
-\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS           DRQ bit set within the time out.\r
-  @retval EFI_TIMEOUT           DRQ bit not set within the time out.\r
-  @retval EFI_ABORTED           DRQ bit not set caused by the command abort.\r
-  @note  Read Alternate Status Register will not clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRQReady2 (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  )\r
-{\r
-  UINT32  Delay;\r
-  UINT8   AltRegister;\r
-  UINT8   ErrorRegister;\r
-\r
-  Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);\r
-\r
-  do {\r
-    //\r
-    //  Read Alternate Status Register will not clear interrupt status\r
-    //\r
-    AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);\r
-    //\r
-    // BSY == 0 , DRQ == 1\r
-    //\r
-    if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_DRQ)) == ATA_STSREG_DRQ) {\r
-      break;\r
-    }\r
-\r
-    if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {\r
-\r
-      ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);\r
-      if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Stall for 30 us\r
-    //\r
-    gBS->Stall (30);\r
-\r
-    Delay--;\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is used to poll for the BSY bit clear in the Status Register. BSY\r
-  is clear when the device is not busy. Every command must be sent after device is not busy.\r
-\r
-  @param IdeDev                pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                               to record all the information of the IDE device.\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS          BSY bit clear within the time out.\r
-  @retval EFI_TIMEOUT          BSY bit not clear within the time out.\r
-\r
-  @note Read Status Register will clear interrupt status.\r
-**/\r
-EFI_STATUS\r
-WaitForBSYClear (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  )\r
-{\r
-  UINT32  Delay;\r
-  UINT8   StatusRegister;\r
-\r
-  Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);\r
-  do {\r
-\r
-    StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);\r
-    if ((StatusRegister & ATA_STSREG_BSY) == 0x00) {\r
-      break;\r
-    }\r
-\r
-    //\r
-    // Stall for 30 us\r
-    //\r
-    gBS->Stall (30);\r
-\r
-    Delay--;\r
-\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function is used to poll for the BSY bit clear in the Alternate Status Register.\r
-  BSY is clear when the device is not busy. Every command must be sent after device is\r
-  not busy.\r
-\r
-  @param IdeDev               pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                              all the information of the IDE device.\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS         BSY bit clear within the time out.\r
-  @retval EFI_TIMEOUT         BSY bit not clear within the time out.\r
-  @note   Read Alternate Status Register will not clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-WaitForBSYClear2 (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  )\r
-{\r
-  UINT32  Delay;\r
-  UINT8   AltRegister;\r
-\r
-  Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);\r
-  do {\r
-    AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);\r
-    if ((AltRegister & ATA_STSREG_BSY) == 0x00) {\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (30);\r
-\r
-    Delay--;\r
-\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function is used to poll for the DRDY bit set in the Status Register. DRDY\r
-  bit is set when the device is ready to accept command. Most ATA commands must be\r
-  sent after DRDY set except the ATAPI Packet Command.\r
-\r
-  @param IdeDev               pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                              to record all the information of the IDE device.\r
-  @param DelayInMilliSeconds  used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS         DRDY bit set within the time out.\r
-  @retval EFI_TIMEOUT         DRDY bit not set within the time out.\r
-\r
-  @note  Read Status Register will clear interrupt status.\r
-**/\r
-EFI_STATUS\r
-DRDYReady (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           DelayInMilliSeconds\r
-  )\r
-{\r
-  UINT32  Delay;\r
-  UINT8   StatusRegister;\r
-  UINT8   ErrorRegister;\r
-\r
-  Delay = (UINT32) (((DelayInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);\r
-  do {\r
-    StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);\r
-    //\r
-    //  BSY == 0 , DRDY == 1\r
-    //\r
-    if ((StatusRegister & (ATA_STSREG_DRDY | ATA_STSREG_BSY)) == ATA_STSREG_DRDY) {\r
-      break;\r
-    }\r
-\r
-    if ((StatusRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {\r
-\r
-      ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);\r
-      if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-\r
-    gBS->Stall (30);\r
-\r
-    Delay--;\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function is used to poll for the DRDY bit set in the Alternate Status Register.\r
-  DRDY bit is set when the device is ready to accept command. Most ATA commands must\r
-  be sent after DRDY set except the ATAPI Packet Command.\r
-\r
-  @param IdeDev              pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                             to record all the information of the IDE device.\r
-  @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS      DRDY bit set within the time out.\r
-  @retval EFI_TIMEOUT      DRDY bit not set within the time out.\r
-\r
-  @note  Read Alternate Status Register will clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRDYReady2 (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           DelayInMilliSeconds\r
-  )\r
-{\r
-  UINT32  Delay;\r
-  UINT8   AltRegister;\r
-  UINT8   ErrorRegister;\r
-\r
-  Delay = (UINT32) (((DelayInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);\r
-  do {\r
-    AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);\r
-    //\r
-    //  BSY == 0 , DRDY == 1\r
-    //\r
-    if ((AltRegister & (ATA_STSREG_DRDY | ATA_STSREG_BSY)) == ATA_STSREG_DRDY) {\r
-      break;\r
-    }\r
-\r
-    if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {\r
-\r
-      ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);\r
-      if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-\r
-    gBS->Stall (30);\r
-\r
-    Delay--;\r
-  } while (Delay > 0);\r
-\r
-  if (Delay == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Release resources of an IDE device before stopping it.\r
-\r
-  @param IdeBlkIoDevice  Standard IDE device private data structure\r
-\r
-**/\r
-VOID\r
-ReleaseIdeResources (\r
-  IN  IDE_BLK_IO_DEV  *IdeBlkIoDevice\r
-  )\r
-{\r
-  if (IdeBlkIoDevice == NULL) {\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Release all the resourses occupied by the IDE_BLK_IO_DEV\r
-  //\r
-\r
-  if (IdeBlkIoDevice->SenseData != NULL) {\r
-    gBS->FreePool (IdeBlkIoDevice->SenseData);\r
-    IdeBlkIoDevice->SenseData = NULL;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->Cache != NULL) {\r
-    gBS->FreePool (IdeBlkIoDevice->Cache);\r
-    IdeBlkIoDevice->Cache = NULL;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->IdData != NULL) {\r
-    gBS->FreePool (IdeBlkIoDevice->IdData);\r
-    IdeBlkIoDevice->IdData = NULL;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->InquiryData != NULL) {\r
-    gBS->FreePool (IdeBlkIoDevice->InquiryData);\r
-    IdeBlkIoDevice->InquiryData = NULL;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->ControllerNameTable != NULL) {\r
-    FreeUnicodeStringTable (IdeBlkIoDevice->ControllerNameTable);\r
-    IdeBlkIoDevice->ControllerNameTable = NULL;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->IoPort != NULL) {\r
-    gBS->FreePool (IdeBlkIoDevice->IoPort);\r
-  }\r
-\r
-  if (IdeBlkIoDevice->DevicePath != NULL) {\r
-    gBS->FreePool (IdeBlkIoDevice->DevicePath);\r
-  }\r
-\r
-  if (IdeBlkIoDevice->ExitBootServiceEvent != NULL) {\r
-    gBS->CloseEvent (IdeBlkIoDevice->ExitBootServiceEvent);\r
-    IdeBlkIoDevice->ExitBootServiceEvent = NULL;\r
-  }\r
-\r
-  gBS->FreePool (IdeBlkIoDevice);\r
-  IdeBlkIoDevice = NULL;\r
-\r
-  return ;\r
-}\r
-/**\r
-  Set the calculated Best transfer mode to a detected device.\r
-\r
-  @param IdeDev       Standard IDE device private data structure\r
-  @param TransferMode The device transfer mode to be set\r
-  @return Set transfer mode Command execute status.\r
-\r
-**/\r
-EFI_STATUS\r
-SetDeviceTransferMode (\r
-  IN IDE_BLK_IO_DEV       *IdeDev,\r
-  IN ATA_TRANSFER_MODE    *TransferMode\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       DeviceSelect;\r
-  UINT8       SectorCount;\r
-\r
-  DeviceSelect  = 0;\r
-  DeviceSelect  = (UINT8) ((IdeDev->Device) << 4);\r
-  SectorCount   = *((UINT8 *) TransferMode);\r
-\r
-  //\r
-  // Send SET FEATURE command (sub command 0x03) to set pio mode.\r
-  //\r
-  Status = AtaNonDataCommandIn (\r
-            IdeDev,\r
-            ATA_CMD_SET_FEATURES,\r
-            DeviceSelect,\r
-            0x03,\r
-            SectorCount,\r
-            0,\r
-            0,\r
-            0\r
-            );\r
-\r
-  return Status;\r
-}\r
-/**\r
-  Set drive parameters for devices not support PACKETS command.\r
-\r
-  @param IdeDev          Standard IDE device private data structure\r
-  @param DriveParameters The device parameters to be set into the disk\r
-  @return SetParameters Command execute status.\r
-\r
-**/\r
-EFI_STATUS\r
-SetDriveParameters (\r
-  IN IDE_BLK_IO_DEV       *IdeDev,\r
-  IN ATA_DRIVE_PARMS      *DriveParameters\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       DeviceSelect;\r
-\r
-  DeviceSelect  = 0;\r
-  DeviceSelect  = (UINT8) ((IdeDev->Device) << 4);\r
-\r
-  //\r
-  // Send Init drive parameters\r
-  //\r
-  Status = AtaNonDataCommandIn (\r
-            IdeDev,\r
-            ATA_CMD_INIT_DRIVE_PARAM,\r
-            (UINT8) (DeviceSelect + DriveParameters->Heads),\r
-            0,\r
-            DriveParameters->Sector,\r
-            0,\r
-            0,\r
-            0\r
-            );\r
-\r
-  //\r
-  // Send Set Multiple parameters\r
-  //\r
-  Status = AtaNonDataCommandIn (\r
-            IdeDev,\r
-            ATA_CMD_SET_MULTIPLE_MODE,\r
-            DeviceSelect,\r
-            0,\r
-            DriveParameters->MultipleSector,\r
-            0,\r
-            0,\r
-            0\r
-            );\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Enable Interrupt on IDE controller.\r
-\r
-  @param  IdeDev   Standard IDE device private data structure\r
-\r
-  @retval  EFI_SUCCESS Enable Interrupt successfully\r
-**/\r
-EFI_STATUS\r
-EnableInterrupt (\r
-  IN IDE_BLK_IO_DEV       *IdeDev\r
-  )\r
-{\r
-  UINT8 DeviceControl;\r
-\r
-  //\r
-  // Enable interrupt for DMA operation\r
-  //\r
-  DeviceControl = 0;\r
-  IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
deleted file mode 100644 (file)
index b4e9342..0000000
+++ /dev/null
@@ -1,805 +0,0 @@
-/** @file\r
-  Header file for IDE Bus Driver, containing the helper functions'\r
-  prototype.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-  @par Revision Reference:\r
-  2002-6: Add Atapi6 enhancement, support >120GB hard disk, including\r
-  Add - IDEBlkIoReadBlocksExt() func definition\r
-  Add - IDEBlkIoWriteBlocksExt() func definition\r
-\r
-**/\r
-\r
-#ifndef _IDE_H_\r
-#define _IDE_H_\r
-\r
-//\r
-// Helper functions Prototype\r
-//\r
-/**\r
-  read a one-byte data from a IDE port.\r
-\r
-  @param  PciIo  The PCI IO protocol instance\r
-  @param  Port   the IDE Port number\r
-\r
-  return  the one-byte data read from IDE port\r
-**/\r
-UINT8\r
-IDEReadPortB (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port\r
-  );\r
-\r
-/**\r
-  Reads multiple words of data from the IDE data port.\r
-  Call the IO abstraction once to do the complete read,\r
-  not one word at a time.\r
-\r
-  @param  PciIo Pointer to the EFI_PCI_IO instance\r
-  @param  Port IO port to read\r
-  @param  Count No. of UINT16's to read\r
-  @param  Buffer Pointer to the data buffer for read\r
-\r
-**/\r
-VOID\r
-IDEReadPortWMultiple (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port,\r
-  IN  UINTN                 Count,\r
-  OUT  VOID                 *Buffer\r
-  );\r
-\r
-/**\r
-  write a 1-byte data to a specific IDE port.\r
-\r
-  @param  PciIo  PCI IO protocol instance\r
-  @param  Port   The IDE port to be writen\r
-  @param  Data   The data to write to the port\r
-**/\r
-VOID\r
-IDEWritePortB (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port,\r
-  IN  UINT8                 Data\r
-  );\r
-\r
-/**\r
-  write a 1-word data to a specific IDE port.\r
-\r
-  @param  PciIo  PCI IO protocol instance\r
-  @param  Port   The IDE port to be writen\r
-  @param  Data   The data to write to the port\r
-**/\r
-VOID\r
-IDEWritePortW (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port,\r
-  IN  UINT16                Data\r
-  );\r
-\r
-/**\r
-  Write multiple words of data to the IDE data port.\r
-  Call the IO abstraction once to do the complete read,\r
-  not one word at a time.\r
-\r
-  @param  PciIo Pointer to the EFI_PCI_IO instance\r
-  @param  Port IO port to read\r
-  @param  Count No. of UINT16's to read\r
-  @param  Buffer Pointer to the data buffer for read\r
-\r
-**/\r
-VOID\r
-IDEWritePortWMultiple (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT16                Port,\r
-  IN  UINTN                 Count,\r
-  IN  VOID                  *Buffer\r
-  );\r
-\r
-/**\r
-  Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,\r
-  use fixed addresses. In Native-PCI mode, get base addresses from BARs in\r
-  the PCI IDE controller's Configuration Space.\r
-\r
-  The steps to get IDE IO port registers' base addresses for each channel\r
-  as follows:\r
-\r
-  1. Examine the Programming Interface byte of the Class Code fields in PCI IDE\r
-  controller's Configuration Space to determine the operating mode.\r
-\r
-  2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.\r
-  <pre>\r
-  ___________________________________________\r
-  |           | Command Block | Control Block |\r
-  |  Channel  |   Registers   |   Registers   |\r
-  |___________|_______________|_______________|\r
-  |  Primary  |  1F0h - 1F7h  |  3F6h - 3F7h  |\r
-  |___________|_______________|_______________|\r
-  | Secondary |  170h - 177h  |  376h - 377h  |\r
-  |___________|_______________|_______________|\r
-\r
-  Table 1. Compatibility resource mappings\r
-  </pre>\r
-\r
-  b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs\r
-  in IDE controller's PCI Configuration Space, shown in the Table 2 below.\r
-  <pre>\r
-  ___________________________________________________\r
-  |           |   Command Block   |   Control Block   |\r
-  |  Channel  |     Registers     |     Registers     |\r
-  |___________|___________________|___________________|\r
-  |  Primary  | BAR at offset 0x10| BAR at offset 0x14|\r
-  |___________|___________________|___________________|\r
-  | Secondary | BAR at offset 0x18| BAR at offset 0x1C|\r
-  |___________|___________________|___________________|\r
-\r
-  Table 2. BARs for Register Mapping\r
-  </pre>\r
-  @note Refer to Intel ICH4 datasheet, Control Block Offset: 03F4h for\r
-  primary, 0374h for secondary. So 2 bytes extra offset should be\r
-  added to the base addresses read from BARs.\r
-\r
-  For more details, please refer to PCI IDE Controller Specification and Intel\r
-  ICH4 Datasheet.\r
-\r
-  @param  PciIo Pointer to the EFI_PCI_IO_PROTOCOL instance\r
-  @param  IdeRegsBaseAddr Pointer to IDE_REGISTERS_BASE_ADDR to\r
-          receive IDE IO port registers' base addresses\r
-\r
-  @retval EFI_UNSUPPORTED return this value when the BARs is not IO type\r
-  @retval EFI_SUCCESS     Get the Base address successfully\r
-  @retval other           read the pci configureation data error\r
-\r
-**/\r
-EFI_STATUS\r
-GetIdeRegistersBaseAddr (\r
-  IN  EFI_PCI_IO_PROTOCOL         *PciIo,\r
-  OUT IDE_REGISTERS_BASE_ADDR     *IdeRegsBaseAddr\r
-  );\r
-\r
-/**\r
-  This function is used to requery IDE resources. The IDE controller will\r
-  probably switch between native and legacy modes during the EFI->CSM->OS\r
-  transfer. We do this everytime before an BlkIo operation to ensure its\r
-  succeess.\r
-\r
-  @param  IdeDev The BLK_IO private data which specifies the IDE device\r
-\r
-  @retval EFI_INVALID_PARAMETER return this value when the channel is invalid\r
-  @retval EFI_SUCCESS           reassign the IDE IO resource successfully\r
-  @retval other                 get the IDE current base address effor\r
-\r
-**/\r
-EFI_STATUS\r
-ReassignIdeResources (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  );\r
-\r
-/**\r
-  Detect if there is disk attached to this port.\r
-\r
-  @param  IdeDev The BLK_IO private data which specifies the IDE device.\r
-\r
-  @retval EFI_NOT_FOUND   The device or channel is not found\r
-  @retval EFI_SUCCESS     The device is found\r
-\r
-**/\r
-EFI_STATUS\r
-DiscoverIdeDevice (\r
-  IN IDE_BLK_IO_DEV *IdeDev\r
-  );\r
-\r
-/**\r
-  This interface is used to initialize all state data related to the\r
-  detection of one channel.\r
-\r
-**/\r
-VOID\r
-InitializeIDEChannelData (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function is used to poll for the DRQ bit clear in the Status\r
-  Register. DRQ is cleared when the device is finished transferring data.\r
-  So this function is called after data transfer is finished.\r
-\r
-  @param IdeDev                 pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                                to record all the information of the IDE device.\r
-  @param TimeoutInMilliSeconds  used to designate the timeout for the DRQ clear.\r
-\r
-  @retval EFI_SUCCESS           DRQ bit clear within the time out.\r
-\r
-  @retval EFI_TIMEOUT           DRQ bit not clear within the time out.\r
-\r
-  @note\r
-  Read Status Register will clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRQClear (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  );\r
-\r
-/**\r
-  This function is used to poll for the DRQ bit clear in the Alternate\r
-  Status Register. DRQ is cleared when the device is finished\r
-  transferring data. So this function is called after data transfer\r
-  is finished.\r
-\r
-  @param IdeDev                pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                               to record all the information of the IDE device.\r
-\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.\r
-\r
-  @retval EFI_SUCCESS          DRQ bit clear within the time out.\r
-\r
-  @retval EFI_TIMEOUT          DRQ bit not clear within the time out.\r
-  @note\r
-  Read Alternate Status Register will not clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRQClear2 (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  );\r
-\r
-/**\r
-  This function is used to poll for the DRQ bit set in the\r
-  Status Register.\r
-  DRQ is set when the device is ready to transfer data. So this function\r
-  is called after the command is sent to the device and before required\r
-  data is transferred.\r
-\r
-  @param IdeDev                pointer pointing to IDE_BLK_IO_DEV data structure,used to\r
-                               record all the information of the IDE device.\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS          DRQ bit set within the time out.\r
-  @retval EFI_TIMEOUT          DRQ bit not set within the time out.\r
-  @retval EFI_ABORTED          DRQ bit not set caused by the command abort.\r
-\r
-  @note  Read Status Register will clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRQReady (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  );\r
-\r
-/**\r
-  This function is used to poll for the DRQ bit set in the Alternate Status Register.\r
-  DRQ is set when the device is ready to transfer data. So this function is called after\r
-  the command is sent to the device and before required data is transferred.\r
-\r
-  @param IdeDev                pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
-                               record all the information of the IDE device.\r
-\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS           DRQ bit set within the time out.\r
-  @retval EFI_TIMEOUT           DRQ bit not set within the time out.\r
-  @retval EFI_ABORTED           DRQ bit not set caused by the command abort.\r
-  @note  Read Alternate Status Register will not clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRQReady2 (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  );\r
-\r
-/**\r
-  This function is used to poll for the BSY bit clear in the Status Register. BSY\r
-  is clear when the device is not busy. Every command must be sent after device is not busy.\r
-\r
-  @param IdeDev                pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                               to record all the information of the IDE device.\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS          BSY bit clear within the time out.\r
-  @retval EFI_TIMEOUT          BSY bit not clear within the time out.\r
-\r
-  @note Read Status Register will clear interrupt status.\r
-**/\r
-EFI_STATUS\r
-WaitForBSYClear (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  );\r
-\r
-/**\r
-  This function is used to poll for the BSY bit clear in the Alternate Status Register.\r
-  BSY is clear when the device is not busy. Every command must be sent after device is\r
-  not busy.\r
-\r
-  @param IdeDev               pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                              all the information of the IDE device.\r
-  @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS         BSY bit clear within the time out.\r
-  @retval EFI_TIMEOUT         BSY bit not clear within the time out.\r
-  @note   Read Alternate Status Register will not clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-WaitForBSYClear2 (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           TimeoutInMilliSeconds\r
-  );\r
-\r
-/**\r
-  This function is used to poll for the DRDY bit set in the Status Register. DRDY\r
-  bit is set when the device is ready to accept command. Most ATA commands must be\r
-  sent after DRDY set except the ATAPI Packet Command.\r
-\r
-  @param IdeDev               pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                              to record all the information of the IDE device.\r
-  @param DelayInMilliSeconds  used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS         DRDY bit set within the time out.\r
-  @retval EFI_TIMEOUT         DRDY bit not set within the time out.\r
-\r
-  @note  Read Status Register will clear interrupt status.\r
-**/\r
-EFI_STATUS\r
-DRDYReady (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           DelayInMilliSeconds\r
-  );\r
-\r
-/**\r
-  This function is used to poll for the DRDY bit set in the Alternate Status Register.\r
-  DRDY bit is set when the device is ready to accept command. Most ATA commands must\r
-  be sent after DRDY set except the ATAPI Packet Command.\r
-\r
-  @param IdeDev              pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                             to record all the information of the IDE device.\r
-  @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.\r
-\r
-  @retval EFI_SUCCESS      DRDY bit set within the time out.\r
-  @retval EFI_TIMEOUT      DRDY bit not set within the time out.\r
-\r
-  @note  Read Alternate Status Register will clear interrupt status.\r
-\r
-**/\r
-EFI_STATUS\r
-DRDYReady2 (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINTN           DelayInMilliSeconds\r
-  );\r
-\r
-//\r
-//  ATA device functions' prototype\r
-//\r
-/**\r
-  Sends out an ATA Identify Command to the specified device.\r
-\r
-  This function is called by DiscoverIdeDevice() during its device\r
-  identification. It sends out the ATA Identify Command to the\r
-  specified device. Only ATA device responses to this command. If\r
-  the command succeeds, it returns the Identify data structure which\r
-  contains information about the device. This function extracts the\r
-  information it needs to fill the IDE_BLK_IO_DEV data structure,\r
-  including device type, media block size, media capacity, and etc.\r
-\r
-  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
-                 all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS      Identify ATA device successfully.\r
-  @retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.\r
-  @note  parameter IdeDev will be updated in this function.\r
-\r
-**/\r
-EFI_STATUS\r
-ATAIdentify (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  );\r
-\r
-/**\r
-  This function is called by ATAIdentify() or ATAPIIdentify() to print device's module name.\r
-\r
-  @param  IdeDev   pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                   all the information of the IDE device.\r
-**/\r
-VOID\r
-PrintAtaModuleName (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  );\r
-/**\r
-  This function is used to send out ATA commands conforms to the PIO Data In Protocol.\r
-\r
-  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                      all the information of the IDE device.\r
-  @param Buffer       buffer contained data transferred from device to host.\r
-  @param ByteCount    data size in byte unit of the buffer.\r
-  @param AtaCommand   value of the Command Register\r
-  @param Head         value of the Head/Device Register\r
-  @param SectorCount  value of the Sector Count Register\r
-  @param SectorNumber value of the Sector Number Register\r
-  @param CylinderLsb  value of the low byte of the Cylinder Register\r
-  @param CylinderMsb  value of the high byte of the Cylinder Register\r
-\r
-  @retval EFI_SUCCESS      send out the ATA command and device send required data successfully.\r
-  @retval EFI_DEVICE_ERROR command sent failed.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaPioDataIn (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *Buffer,\r
-  IN  UINT32          ByteCount,\r
-  IN  UINT8           AtaCommand,\r
-  IN  UINT8           Head,\r
-  IN  UINT8           SectorCount,\r
-  IN  UINT8           SectorNumber,\r
-  IN  UINT8           CylinderLsb,\r
-  IN  UINT8           CylinderMsb\r
-  );\r
-\r
-/**\r
-  This function is used to send out ATA commands conforms to the\r
-  PIO Data Out Protocol.\r
-\r
-  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                      to record all the information of the IDE device.\r
-  @param *Buffer      buffer contained data transferred from host to device.\r
-  @param ByteCount    data size in byte unit of the buffer.\r
-  @param AtaCommand   value of the Command Register\r
-  @param Head         value of the Head/Device Register\r
-  @param SectorCount  value of the Sector Count Register\r
-  @param SectorNumber value of the Sector Number Register\r
-  @param CylinderLsb  value of the low byte of the Cylinder Register\r
-  @param CylinderMsb  value of the high byte of the Cylinder Register\r
-\r
-  @retval EFI_SUCCESS      send out the ATA command and device received required\r
-                           data successfully.\r
-  @retval EFI_DEVICE_ERROR command sent failed.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaPioDataOut (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  VOID            *Buffer,\r
-  IN  UINT32          ByteCount,\r
-  IN  UINT8           AtaCommand,\r
-  IN  UINT8           Head,\r
-  IN  UINT8           SectorCount,\r
-  IN  UINT8           SectorNumber,\r
-  IN  UINT8           CylinderLsb,\r
-  IN  UINT8           CylinderMsb\r
-  );\r
-\r
-/**\r
-  This function is used to analyze the Status Register and print out\r
-  some debug information and if there is ERR bit set in the Status\r
-  Register, the Error Register's value is also be parsed and print out.\r
-\r
-  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
-                 record all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS       No err information in the Status Register.\r
-  @retval EFI_DEVICE_ERROR  Any err information in the Status Register.\r
-\r
-**/\r
-EFI_STATUS\r
-CheckErrorStatus (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  );\r
-\r
-/**\r
-  This function is used to implement the Soft Reset on the specified device. But,\r
-  the ATA Soft Reset mechanism is so strong a reset method that it will force\r
-  resetting on both devices connected to the same cable.\r
-\r
-  It is called by IdeBlkIoReset(), a interface function of Block\r
-  I/O protocol.\r
-\r
-  This function can also be used by the ATAPI device to perform reset when\r
-  ATAPI Reset command is failed.\r
-\r
-  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
-                 all the information of the IDE device.\r
-  @retval EFI_SUCCESS       Soft reset completes successfully.\r
-  @retval EFI_DEVICE_ERROR  Any step during the reset process is failed.\r
-\r
-  @note  The registers initial values after ATA soft reset are different\r
-         to the ATA device and ATAPI device.\r
-**/\r
-EFI_STATUS\r
-AtaSoftReset (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  );\r
-\r
-/**\r
-  This function is the ATA implementation for ReadBlocks in the\r
-  Block I/O Protocol interface.\r
-\r
-  @param IdeBlkIoDevice Indicates the calling context.\r
-  @param MediaId        The media id that the read request is for.\r
-  @param Lba            The starting logical block address to read from on the device.\r
-  @param BufferSize     The size of the Buffer in bytes. This must be a  multiple\r
-                        of the intrinsic block size of the device.\r
-\r
-  @param Buffer         A pointer to the destination buffer for the data. The caller\r
-                        is responsible for either having implicit or explicit ownership\r
-                        of the memory that data is read into.\r
-\r
-  @retval EFI_SUCCESS          Read Blocks successfully.\r
-  @retval EFI_DEVICE_ERROR     Read Blocks failed.\r
-  @retval EFI_NO_MEDIA         There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGE     The MediaId is not for the current media.\r
-  @retval EFI_BAD_BUFFER_SIZE  The BufferSize parameter is not a multiple of the\r
-                               intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER  The read request contains LBAs that are not valid,\r
-                                 or the data buffer is not valid.\r
-\r
-  @note If Read Block error because of device error, this function will call\r
-        AtaSoftReset() function to reset device.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaBlkIoReadBlocks (\r
-  IN IDE_BLK_IO_DEV   *IdeBlkIoDevice,\r
-  IN UINT32           MediaId,\r
-  IN EFI_LBA          Lba,\r
-  IN UINTN            BufferSize,\r
-  OUT VOID            *Buffer\r
-  );\r
-\r
-/**\r
-  This function is the ATA implementation for WriteBlocks in the\r
-  Block I/O Protocol interface.\r
-\r
-  @param IdeBlkIoDevice  Indicates the calling context.\r
-  @param MediaId         The media id that the write request is for.\r
-  @param Lba             The starting logical block address to write onto the device.\r
-  @param BufferSize      The size of the Buffer in bytes. This must be a multiple\r
-                         of the intrinsic block size of the device.\r
-  @param Buffer          A pointer to the source buffer for the data.The caller\r
-                         is responsible for either having implicit or explicit\r
-                         ownership of the memory that data is written from.\r
-\r
-  @retval EFI_SUCCESS       Write Blocks successfully.\r
-  @retval EFI_DEVICE_ERROR  Write Blocks failed.\r
-  @retval EFI_NO_MEDIA      There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGE  The MediaId is not for the current media.\r
-\r
-  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
-                                intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
-                                or the data buffer is not valid.\r
-\r
-  @note If Write Block error because of device error, this function will call\r
-        AtaSoftReset() function to reset device.\r
-**/\r
-EFI_STATUS\r
-AtaBlkIoWriteBlocks (\r
-  IN IDE_BLK_IO_DEV   *IdeBlkIoDevice,\r
-  IN UINT32           MediaId,\r
-  IN EFI_LBA          Lba,\r
-  IN UINTN            BufferSize,\r
-  OUT VOID            *Buffer\r
-  );\r
-\r
-/**\r
-  This function is called by DiscoverIdeDevice() during its device\r
-  identification.\r
-  Its main purpose is to get enough information for the device media\r
-  to fill in the Media data structure of the Block I/O Protocol interface.\r
-\r
-  There are 5 steps to reach such objective:\r
-  1. Sends out the ATAPI Identify Command to the specified device.\r
-  Only ATAPI device responses to this command. If the command succeeds,\r
-  it returns the Identify data structure which filled with information\r
-  about the device. Since the ATAPI device contains removable media,\r
-  the only meaningful information is the device module name.\r
-  2. Sends out ATAPI Inquiry Packet Command to the specified device.\r
-  This command will return inquiry data of the device, which contains\r
-  the device type information.\r
-  3. Allocate sense data space for future use. We don't detect the media\r
-  presence here to improvement boot performance, especially when CD\r
-  media is present. The media detection will be performed just before\r
-  each BLK_IO read/write\r
-\r
-  @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                 to record all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS       Identify ATAPI device successfully.\r
-  @retval EFI_DEVICE_ERROR  ATAPI Identify Device Command failed or device type\r
-                            is not supported by this IDE driver.\r
-  @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed\r
-\r
-  @note   Parameter "IdeDev" will be updated in this function.\r
-**/\r
-EFI_STATUS\r
-ATAPIIdentify (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  );\r
-\r
-/**\r
-  This function is used to implement the Soft Reset on the specified\r
-  ATAPI device. Different from the AtaSoftReset(), here reset is a ATA\r
-  Soft Reset Command special for ATAPI device, and it only take effects\r
-  on the specified ATAPI device, not on the whole IDE bus.\r
-  Since the ATAPI soft reset is needed when device is in exceptional\r
-  condition (such as BSY bit is always set ), I think the Soft Reset\r
-  command should be sent without waiting for the BSY clear and DRDY\r
-  set.\r
-  This function is called by IdeBlkIoReset(),\r
-  a interface function of Block I/O protocol.\r
-\r
-  @param IdeDev    pointer pointing to IDE_BLK_IO_DEV data structure, used\r
-                   to record all the information of the IDE device.\r
-\r
-  @retval EFI_SUCCESS      Soft reset completes successfully.\r
-  @retval EFI_DEVICE_ERROR Any step during the reset process is failed.\r
-\r
-**/\r
-EFI_STATUS\r
-AtapiSoftReset (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  );\r
-\r
-/**\r
-  This function is the ATAPI implementation for ReadBlocks in the\r
-  Block I/O Protocol interface.\r
-\r
-  @param IdeBlkIoDevice Indicates the calling context.\r
-  @param MediaId        The media id that the read request is for.\r
-  @param Lba            The starting logical block address to read from on the device.\r
-  @param BufferSize     The size of the Buffer in bytes. This must be a multiple\r
-                        of the intrinsic block size of the device.\r
-  @param Buffer         A pointer to the destination buffer for the data. The caller\r
-                        is responsible for either having implicit or explicit\r
-                        ownership of the memory that data is read into.\r
-\r
-  @retval EFI_SUCCESS           Read Blocks successfully.\r
-  @retval EFI_DEVICE_ERROR      Read Blocks failed.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.\r
-  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
-                                intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the data buffer is not valid.\r
-**/\r
-EFI_STATUS\r
-AtapiBlkIoReadBlocks (\r
-  IN IDE_BLK_IO_DEV   *IdeBlkIoDevice,\r
-  IN UINT32           MediaId,\r
-  IN EFI_LBA          Lba,\r
-  IN UINTN            BufferSize,\r
-  OUT VOID            *Buffer\r
-  );\r
-\r
-/**\r
-  This function is the ATAPI implementation for WriteBlocks in the\r
-  Block I/O Protocol interface.\r
-\r
-  @param IdeBlkIoDevice  Indicates the calling context.\r
-  @param MediaId         The media id that the write request is for.\r
-  @param Lba             The starting logical block address to write onto the device.\r
-  @param BufferSize      The size of the Buffer in bytes. This must be a multiple\r
-                         of the intrinsic block size of the device.\r
-  @param Buffer          A pointer to the source buffer for the data. The caller\r
-                         is responsible for either having implicit or explicit ownership\r
-                         of the memory that data is written from.\r
-\r
-  @retval EFI_SUCCESS            Write Blocks successfully.\r
-  @retval EFI_DEVICE_ERROR       Write Blocks failed.\r
-  @retval EFI_NO_MEDIA           There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGE       The MediaId is not for the current media.\r
-  @retval EFI_BAD_BUFFER_SIZE    The BufferSize parameter is not a multiple of the\r
-                                 intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER  The write request contains LBAs that are not valid,\r
-                                 or the data buffer is not valid.\r
-\r
-  @retval EFI_WRITE_PROTECTED    The write protected is enabled or the media does not support write\r
-**/\r
-EFI_STATUS\r
-AtapiBlkIoWriteBlocks (\r
-  IN IDE_BLK_IO_DEV   *IdeBlkIoDevice,\r
-  IN UINT32           MediaId,\r
-  IN EFI_LBA          Lba,\r
-  IN UINTN            BufferSize,\r
-  OUT VOID            *Buffer\r
-  );\r
-\r
-/**\r
-  Release resources of an IDE device before stopping it.\r
-\r
-  @param IdeBlkIoDevice  Standard IDE device private data structure\r
-\r
-**/\r
-VOID\r
-ReleaseIdeResources (\r
-  IN  IDE_BLK_IO_DEV  *IdeBlkIoDevice\r
-  );\r
-\r
-/**\r
-  Set the calculated Best transfer mode to a detected device\r
-\r
-  @param IdeDev       Standard IDE device private data structure\r
-  @param TransferMode The device transfer mode to be set\r
-  @return Set transfer mode Command execute status.\r
-**/\r
-EFI_STATUS\r
-SetDeviceTransferMode (\r
-  IN IDE_BLK_IO_DEV       *IdeDev,\r
-  IN ATA_TRANSFER_MODE    *TransferMode\r
-  );\r
-/**\r
-  Send ATA command into device with NON_DATA protocol.\r
-\r
-  @param  IdeDev Standard IDE device private data structure\r
-  @param  AtaCommand The ATA command to be sent\r
-  @param  Device The value in Device register\r
-  @param  Feature The value in Feature register\r
-  @param  SectorCount The value in SectorCount register\r
-  @param  LbaLow The value in LBA_LOW register\r
-  @param  LbaMiddle The value in LBA_MIDDLE register\r
-  @param  LbaHigh The value in LBA_HIGH register\r
-\r
-  @retval  EFI_SUCCESS Reading succeed\r
-  @retval  EFI_ABORTED Command failed\r
-  @retval  EFI_DEVICE_ERROR Device status error.\r
-\r
-**/\r
-EFI_STATUS\r
-AtaNonDataCommandIn (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  IN  UINT8           AtaCommand,\r
-  IN  UINT8           Device,\r
-  IN  UINT8           Feature,\r
-  IN  UINT8           SectorCount,\r
-  IN  UINT8           LbaLow,\r
-  IN  UINT8           LbaMiddle,\r
-  IN  UINT8           LbaHigh\r
-  );\r
-\r
-/**\r
-  Enable Long Physical Sector Feature for ATA device.\r
-\r
-  @param   IdeDev  The IDE device data\r
-\r
-  @retval  EFI_SUCCESS      The ATA device supports Long Physical Sector feature\r
-                            and corresponding fields in BlockIo structure is updated.\r
-  @retval  EFI_UNSUPPORTED  The device is not ATA device or Long Physical Sector\r
-                            feature is not supported.\r
-**/\r
-EFI_STATUS\r
-AtaEnableLongPhysicalSector (\r
-  IN  IDE_BLK_IO_DEV  *IdeDev\r
-  );\r
-\r
-/**\r
-  Set drive parameters for devices not support PACKETS command.\r
-\r
-  @param IdeDev          Standard IDE device private data structure\r
-  @param DriveParameters The device parameters to be set into the disk\r
-  @return SetParameters Command execute status.\r
-\r
-**/\r
-EFI_STATUS\r
-SetDriveParameters (\r
-  IN IDE_BLK_IO_DEV       *IdeDev,\r
-  IN ATA_DRIVE_PARMS      *DriveParameters\r
-  );\r
-\r
-/**\r
-  Enable Interrupt on IDE controller.\r
-\r
-  @param  IdeDev   Standard IDE device private data structure\r
-\r
-  @retval  EFI_SUCCESS Enable Interrupt successfully\r
-**/\r
-EFI_STATUS\r
-EnableInterrupt (\r
-  IN IDE_BLK_IO_DEV       *IdeDev\r
-  );\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c
deleted file mode 100644 (file)
index deacb18..0000000
+++ /dev/null
@@ -1,1565 +0,0 @@
-/** @file\r
-  This file implement UEFI driver for IDE Bus which includes device identification,\r
-  Child device(Disk, CDROM, etc) enumeration and child handler installation, and\r
-  driver stop.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-  @par Revision Reference:\r
-  This module is modified from DXE\IDE module for Ide Contriller Init support\r
-\r
-**/\r
-\r
-#include "IdeBus.h"\r
-\r
-#define PCI_CLASS_MASS_STORAGE  0x01\r
-#define PCI_SUB_CLASS_IDE       0x01\r
-\r
-\r
-//\r
-// IDE Bus Driver Binding Protocol Instance\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding = {\r
-  IDEBusDriverBindingSupported,\r
-  IDEBusDriverBindingStart,\r
-  IDEBusDriverBindingStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-/**\r
-  Deregister an IDE device and free resources\r
-\r
-  @param  This Protocol instance pointer.\r
-  @param  Controller Ide device handle\r
-  @param  Handle Handle of device to deregister driver on\r
-\r
-  @retval EFI_SUCCESS  Deregiter a specific IDE device successfully\r
-\r
-\r
-**/\r
-EFI_STATUS\r
-DeRegisterIdeDevice (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN  EFI_HANDLE                     Controller,\r
-  IN  EFI_HANDLE                     Handle\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
-  IDE_BLK_IO_DEV        *IdeBlkIoDevice;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-  UINTN                 Index;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  (VOID **) &BlkIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlkIo);\r
-\r
-  //\r
-  // Report Status code: Device disabled\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_DISABLE),\r
-    IdeBlkIoDevice->DevicePath\r
-    );\r
-\r
-  //\r
-  // Close the child handle\r
-  //\r
-  Status = gBS->CloseProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  This->DriverBindingHandle,\r
-                  Handle\r
-                  );\r
-\r
-  Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                  Handle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  IdeBlkIoDevice->DevicePath,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  &IdeBlkIoDevice->BlkIo,\r
-                  &gEfiDiskInfoProtocolGuid,\r
-                  &IdeBlkIoDevice->DiskInfo,\r
-                  NULL\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->OpenProtocol (\r
-          Controller,\r
-          &gEfiPciIoProtocolGuid,\r
-          (VOID **) &PciIo,\r
-          This->DriverBindingHandle,\r
-          Handle,\r
-          EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-          );\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Release allocated resources\r
-  //\r
-  Index = IdeBlkIoDevice->Channel * 2 + IdeBlkIoDevice->Device;\r
-  if (Index < MAX_IDE_DEVICE) {\r
-    IdeBlkIoDevice->IdeBusDriverPrivateData->HaveScannedDevice[Index] = FALSE;\r
-  }\r
-  ReleaseIdeResources (IdeBlkIoDevice);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Supported function of Driver Binding protocol for this driver.\r
-\r
-  @param This                A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param ControllerHandle    The handle of the controller to test.\r
-  @param RemainingDevicePath A pointer to the remaining portion of a device path.\r
-\r
-  @retval  EFI_SUCCESS Driver loaded.\r
-  @retval  other       Driver not loaded.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_DEVICE_PATH_PROTOCOL          *ParentDevicePath;\r
-  EFI_DEV_PATH                      *Node;\r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL  *IdeInit;\r
-  EFI_PCI_IO_PROTOCOL               *PciIo;\r
-  PCI_TYPE00                        PciData;\r
-\r
-  if (RemainingDevicePath != NULL) {\r
-    Node = (EFI_DEV_PATH *) RemainingDevicePath;\r
-    //\r
-    // Check if RemainingDevicePath is the End of Device Path Node,\r
-    // if yes, go on checking other conditions\r
-    //\r
-    if (!IsDevicePathEnd (Node)) {\r
-      //\r
-      // If RemainingDevicePath isn't the End of Device Path Node,\r
-      // check its validation\r
-      //\r
-      if (Node->DevPath.Type != MESSAGING_DEVICE_PATH ||\r
-          Node->DevPath.SubType != MSG_ATAPI_DP ||\r
-          DevicePathNodeLength(&Node->DevPath) != sizeof(ATAPI_DEVICE_PATH)) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Verify the Ide Controller Init Protocol, which installed by the\r
-  // IdeController module.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIdeControllerInitProtocolGuid,\r
-                  (VOID **) &IdeInit,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiIdeControllerInitProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  //\r
-  // Open the EFI Device Path protocol needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Close protocol, don't use device path protocol in the Support() function\r
-  //\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiDevicePathProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  //\r
-  // Get the EfiPciIoProtocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Now further check the PCI header: Base class (offset 0x0B) and\r
-  // Sub Class (offset 0x0A). This controller should be an IDE controller\r
-  //\r
-  Status = PciIo->Pci.Read (\r
-                        PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        0,\r
-                        sizeof (PciData),\r
-                        &PciData\r
-                        );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Examine if it is IDE mode by class code\r
-    //\r
-    if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) || (PciData.Hdr.ClassCode[1] != PCI_SUB_CLASS_IDE)) {\r
-      Status = EFI_UNSUPPORTED;\r
-    } else {\r
-      Status = EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Start function of Driver binding protocol which start this driver on Controller\r
-  by detecting all disks and installing BlockIo protocol on them.\r
-\r
-  @param  This                Protocol instance pointer.\r
-  @param  Controller          Handle of device to bind driver to.\r
-  @param  RemainingDevicePath produce all possible children.\r
-\r
-  @retval  EFI_SUCCESS         This driver is added to ControllerHandle.\r
-  @retval  EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
-  @retval  other               This driver does not support this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_STATUS                        SavedStatus;\r
-  EFI_PCI_IO_PROTOCOL               *PciIo;\r
-  EFI_DEVICE_PATH_PROTOCOL          *ParentDevicePath;\r
-  EFI_DEV_PATH                      *Node;\r
-  UINT8                             IdeChannel;\r
-  UINT8                             BeginningIdeChannel;\r
-  UINT8                             EndIdeChannel;\r
-  UINT8                             IdeDevice;\r
-  UINT8                             BeginningIdeDevice;\r
-  UINT8                             EndIdeDevice;\r
-  IDE_BLK_IO_DEV                    *IdeBlkIoDevice[IdeMaxChannel][IdeMaxDevice];\r
-  IDE_BLK_IO_DEV                    *IdeBlkIoDevicePtr;\r
-  IDE_REGISTERS_BASE_ADDR           IdeRegsBaseAddr[IdeMaxChannel];\r
-  ATA_TRANSFER_MODE                 TransferMode;\r
-  ATA_DRIVE_PARMS                   DriveParameters;\r
-  EFI_DEV_PATH                      NewNode;\r
-  UINT8                             ConfigurationOptions;\r
-  UINT16                            CommandBlockBaseAddr;\r
-  UINT16                            ControlBlockBaseAddr;\r
-  UINTN                             DataSize;\r
-  IDE_BUS_DRIVER_PRIVATE_DATA       *IdeBusDriverPrivateData;\r
-  UINT64                            Supports;\r
-\r
-  //\r
-  // Local variables declaration for IdeControllerInit support\r
-  //\r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL  *IdeInit;\r
-  BOOLEAN                           EnumAll;\r
-  BOOLEAN                           ChannelEnabled;\r
-  UINT8                             MaxDevices;\r
-  EFI_IDENTIFY_DATA                 IdentifyData;\r
-  EFI_ATA_COLLECTIVE_MODE           *SupportedModes;\r
-\r
-  IdeBusDriverPrivateData = NULL;\r
-  SupportedModes          = NULL;\r
-\r
-  //\r
-  // Perform IdeBus initialization\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Now open the IDE_CONTROLLER_INIT protocol. Step7.1\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIdeControllerInitProtocolGuid,\r
-                  (VOID **) &IdeInit,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  //\r
-  // The following OpenProtocol function with _GET_PROTOCOL attribute and\r
-  // will not return EFI_ALREADY_STARTED, so save it for now\r
-  //\r
-  SavedStatus = Status;\r
-\r
-  if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {\r
-    DEBUG ((EFI_D_ERROR, "Open Init, Status=%x", Status));\r
-    //\r
-    // open protocol is not SUCCESS or not ALREADY_STARTED, error exit\r
-    //\r
-    goto ErrorExit;\r
-  }\r
-\r
-  //\r
-  // Save Enumall. Step7.2\r
-  //\r
-  EnumAll       = IdeInit->EnumAll;\r
-\r
-  //\r
-  // Consume PCI I/O protocol. Note that the OpenProtocol with _GET_PROTOCOL\r
-  // attribute will not return EFI_ALREADY_STARTED\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "Open PciIo, Status=%x", Status));\r
-    goto ErrorExit;\r
-  }\r
-\r
-  //\r
-  // We must check EFI_ALREADY_STARTED because many ATAPI devices are removable\r
-  //\r
-  if (SavedStatus != EFI_ALREADY_STARTED) {\r
-    IdeBusDriverPrivateData = AllocatePool (sizeof (IDE_BUS_DRIVER_PRIVATE_DATA));\r
-    if (IdeBusDriverPrivateData == NULL) {\r
-      Status = EFI_OUT_OF_RESOURCES;\r
-      goto ErrorExit;\r
-    }\r
-\r
-    ZeroMem (IdeBusDriverPrivateData, sizeof (IDE_BUS_DRIVER_PRIVATE_DATA));\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &Controller,\r
-                    &gEfiCallerIdGuid,\r
-                    IdeBusDriverPrivateData,\r
-                    NULL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      goto ErrorExit;\r
-    }\r
-\r
-  } else {\r
-    Status = gBS->OpenProtocol (\r
-                    Controller,\r
-                    &gEfiCallerIdGuid,\r
-                    (VOID **) &IdeBusDriverPrivateData,\r
-                    This->DriverBindingHandle,\r
-                    Controller,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      IdeBusDriverPrivateData = NULL;\r
-      goto ErrorExit;\r
-    }\r
-  }\r
-\r
-  Status = PciIo->Attributes (\r
-                    PciIo,\r
-                    EfiPciIoAttributeOperationSupported,\r
-                    0,\r
-                    &Supports\r
-                    );\r
-  if (!EFI_ERROR (Status)) {\r
-    Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
-    Status = PciIo->Attributes (\r
-                      PciIo,\r
-                      EfiPciIoAttributeOperationEnable,\r
-                      Supports,\r
-                      NULL\r
-                      );\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrorExit;\r
-  }\r
-\r
-  //\r
-  // Read the environment variable that contains the IDEBus Driver's\r
-  // Config options that were set by the Driver Configuration Protocol\r
-  //\r
-  DataSize = sizeof (ConfigurationOptions);\r
-  Status = gRT->GetVariable (\r
-                  (CHAR16 *) L"Configuration",\r
-                  &gEfiCallerIdGuid,\r
-                  NULL,\r
-                  &DataSize,\r
-                  &ConfigurationOptions\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    ConfigurationOptions = 0x0f;\r
-  }\r
-\r
-   if (EnumAll || RemainingDevicePath == NULL) {\r
-    //\r
-    // If IdeInit->EnumAll is TRUE or RemainingDevicePath is NULL,\r
-    // must enumerate all IDE devices anyway\r
-    //\r
-    BeginningIdeChannel = IdePrimary;\r
-    EndIdeChannel       = IdeSecondary;\r
-    BeginningIdeDevice  = IdeMaster;\r
-    EndIdeDevice        = IdeSlave;\r
-\r
-  } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
-    //\r
-    // If RemainingDevicePath isn't the End of Device Path Node,\r
-    // only scan the specified device by RemainingDevicePath\r
-    //\r
-    Node                = (EFI_DEV_PATH *) RemainingDevicePath;\r
-    BeginningIdeChannel = Node->Atapi.PrimarySecondary;\r
-    EndIdeChannel       = BeginningIdeChannel;\r
-    BeginningIdeDevice  = Node->Atapi.SlaveMaster;\r
-    EndIdeDevice        = BeginningIdeDevice;\r
-    if (BeginningIdeChannel >= IdeMaxChannel || EndIdeChannel >= IdeMaxChannel) {\r
-      Status = EFI_INVALID_PARAMETER;\r
-      goto ErrorExit;\r
-    }\r
-    if (BeginningIdeDevice >= IdeMaxDevice|| EndIdeDevice >= IdeMaxDevice) {\r
-      Status = EFI_INVALID_PARAMETER;\r
-      goto ErrorExit;\r
-    }\r
-\r
-  } else {\r
-    //\r
-    // If RemainingDevicePath is the End of Device Path Node,\r
-    // skip enumerate any device and return EFI_SUCESSS\r
-    //\r
-    BeginningIdeChannel = IdeMaxChannel;\r
-    EndIdeChannel       = IdeMaxChannel - 1;\r
-    BeginningIdeDevice  = IdeMaxDevice;\r
-    EndIdeDevice        = IdeMaxDevice - 1;\r
-  }\r
-\r
-  //\r
-  // Obtain IDE IO port registers' base addresses\r
-  //\r
-  Status = GetIdeRegistersBaseAddr (PciIo, IdeRegsBaseAddr);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrorExit;\r
-  }\r
-\r
-  //\r
-  // Report status code: begin IdeBus initialization\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_RESET),\r
-    ParentDevicePath\r
-    );\r
-\r
-  //\r
-  // Strictly follow the enumeration based on IDE_CONTROLLER_INIT protocol\r
-  //\r
-  for (IdeChannel = BeginningIdeChannel; IdeChannel <= EndIdeChannel; IdeChannel++) {\r
-\r
-    IdeInit->NotifyPhase (IdeInit, EfiIdeBeforeChannelEnumeration, IdeChannel);\r
-\r
-    //\r
-    // now obtain channel information fron IdeControllerInit protocol. Step9\r
-    //\r
-    Status = IdeInit->GetChannelInfo (\r
-                        IdeInit,\r
-                        IdeChannel,\r
-                        &ChannelEnabled,\r
-                        &MaxDevices\r
-                        );\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "[GetChannel, Status=%x]", Status));\r
-      continue;\r
-    }\r
-\r
-    if (!ChannelEnabled) {\r
-      continue;\r
-    }\r
-\r
-    EndIdeDevice = (UINT8) MIN ((MaxDevices - 1), EndIdeDevice);\r
-    ASSERT (EndIdeDevice < IdeMaxDevice);\r
-    //\r
-    // Now inform the IDE Controller Init Module. Sept10\r
-    //\r
-    IdeInit->NotifyPhase (IdeInit, EfiIdeBeforeChannelReset, IdeChannel);\r
-\r
-    //\r
-    // No reset channel function implemented. Sept11\r
-    //\r
-    IdeInit->NotifyPhase (IdeInit, EfiIdeAfterChannelReset, IdeChannel);\r
-\r
-    //\r
-    // Step13\r
-    //\r
-    IdeInit->NotifyPhase (\r
-              IdeInit,\r
-              EfiIdeBusBeforeDevicePresenceDetection,\r
-              IdeChannel\r
-              );\r
-\r
-    //\r
-    // Prepare to detect IDE device of this channel\r
-    //\r
-    InitializeIDEChannelData ();\r
-\r
-    //\r
-    // -- 1st inner loop --- Master/Slave ------------  Step14\r
-    //\r
-    for (IdeDevice = BeginningIdeDevice; IdeDevice <= EndIdeDevice; IdeDevice++) {\r
-      //\r
-      // Check whether the configuration options allow this device\r
-      //\r
-      if ((ConfigurationOptions & (1 << (IdeChannel * 2 + IdeDevice))) == 0) {\r
-        continue;\r
-      }\r
-\r
-      //\r
-      // The device has been scanned in another Start(), No need to scan it again\r
-      // for perf optimization.\r
-      //\r
-      if (IdeBusDriverPrivateData->HaveScannedDevice[IdeChannel * 2 + IdeDevice]) {\r
-        continue;\r
-      }\r
-\r
-      //\r
-      // create child handle for the detected device.\r
-      //\r
-      IdeBlkIoDevice[IdeChannel][IdeDevice] = AllocatePool (sizeof (IDE_BLK_IO_DEV));\r
-      if (IdeBlkIoDevice[IdeChannel][IdeDevice] == NULL) {\r
-        continue;\r
-      }\r
-\r
-      IdeBlkIoDevicePtr = IdeBlkIoDevice[IdeChannel][IdeDevice];\r
-\r
-      ZeroMem (IdeBlkIoDevicePtr, sizeof (IDE_BLK_IO_DEV));\r
-\r
-      IdeBlkIoDevicePtr->Signature  = IDE_BLK_IO_DEV_SIGNATURE;\r
-      IdeBlkIoDevicePtr->Channel    = (EFI_IDE_CHANNEL) IdeChannel;\r
-      IdeBlkIoDevicePtr->Device     = (EFI_IDE_DEVICE) IdeDevice;\r
-\r
-      //\r
-      // initialize Block IO interface's Media pointer\r
-      //\r
-      IdeBlkIoDevicePtr->BlkIo.Media = &IdeBlkIoDevicePtr->BlkMedia;\r
-\r
-      //\r
-      // Initialize IDE IO port addresses, including Command Block registers\r
-      // and Control Block registers\r
-      //\r
-      IdeBlkIoDevicePtr->IoPort = AllocatePool (sizeof (IDE_BASE_REGISTERS));\r
-      if (IdeBlkIoDevicePtr->IoPort == NULL) {\r
-        continue;\r
-      }\r
-\r
-      ZeroMem (IdeBlkIoDevicePtr->IoPort, sizeof (IDE_BASE_REGISTERS));\r
-      CommandBlockBaseAddr = IdeRegsBaseAddr[IdeChannel].CommandBlockBaseAddr;\r
-      ControlBlockBaseAddr = IdeRegsBaseAddr[IdeChannel].ControlBlockBaseAddr;\r
-\r
-      IdeBlkIoDevicePtr->IoPort->Data = CommandBlockBaseAddr;\r
-      (*(UINT16 *) &IdeBlkIoDevicePtr->IoPort->Reg1) = (UINT16) (CommandBlockBaseAddr + 0x01);\r
-      IdeBlkIoDevicePtr->IoPort->SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);\r
-      IdeBlkIoDevicePtr->IoPort->SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);\r
-      IdeBlkIoDevicePtr->IoPort->CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);\r
-      IdeBlkIoDevicePtr->IoPort->CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);\r
-      IdeBlkIoDevicePtr->IoPort->Head = (UINT16) (CommandBlockBaseAddr + 0x06);\r
-      (*(UINT16 *) &IdeBlkIoDevicePtr->IoPort->Reg) = (UINT16) (CommandBlockBaseAddr + 0x07);\r
-\r
-      (*(UINT16 *) &IdeBlkIoDevicePtr->IoPort->Alt) = ControlBlockBaseAddr;\r
-      IdeBlkIoDevicePtr->IoPort->DriveAddress = (UINT16) (ControlBlockBaseAddr + 0x01);\r
-\r
-      IdeBlkIoDevicePtr->IoPort->MasterSlave = (UINT16) ((IdeDevice == IdeMaster) ? 1 : 0);\r
-\r
-      IdeBlkIoDevicePtr->PciIo = PciIo;\r
-      IdeBlkIoDevicePtr->IdeBusDriverPrivateData = IdeBusDriverPrivateData;\r
-      IdeBlkIoDevicePtr->IoPort->BusMasterBaseAddr = IdeRegsBaseAddr[IdeChannel].BusMasterBaseAddr;\r
-\r
-      //\r
-      // Report Status code: is about to detect IDE drive\r
-      //\r
-      REPORT_STATUS_CODE_EX (\r
-        EFI_PROGRESS_CODE,\r
-        (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_PRESENCE_DETECT),\r
-        0,\r
-        &gEfiCallerIdGuid,\r
-        NULL,\r
-        NULL,\r
-        0\r
-      );\r
-\r
-      //\r
-      // Discover device, now!\r
-      //\r
-      PERF_START (NULL, "DiscoverIdeDevice", "IDE", 0);\r
-      Status = DiscoverIdeDevice (IdeBlkIoDevicePtr);\r
-      PERF_END (NULL, "DiscoverIdeDevice", "IDE", 0);\r
-\r
-      IdeBusDriverPrivateData->HaveScannedDevice[IdeChannel * 2 + IdeDevice]  = TRUE;\r
-      IdeBusDriverPrivateData->DeviceProcessed[IdeChannel * 2 + IdeDevice]    = FALSE;\r
-\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Set Device Path\r
-        //\r
-        ZeroMem (&NewNode, sizeof (NewNode));\r
-        NewNode.DevPath.Type    = MESSAGING_DEVICE_PATH;\r
-        NewNode.DevPath.SubType = MSG_ATAPI_DP;\r
-        SetDevicePathNodeLength (&NewNode.DevPath, sizeof (ATAPI_DEVICE_PATH));\r
-\r
-        NewNode.Atapi.PrimarySecondary  = (UINT8) IdeBlkIoDevicePtr->Channel;\r
-        NewNode.Atapi.SlaveMaster       = (UINT8) IdeBlkIoDevicePtr->Device;\r
-        NewNode.Atapi.Lun               = IdeBlkIoDevicePtr->Lun;\r
-        IdeBlkIoDevicePtr->DevicePath = AppendDevicePathNode (\r
-                                          ParentDevicePath,\r
-                                          &NewNode.DevPath\r
-                                          );\r
-        if (IdeBlkIoDevicePtr->DevicePath == NULL) {\r
-          ReleaseIdeResources (IdeBlkIoDevicePtr);\r
-          continue;\r
-        }\r
-\r
-        //\r
-        // Submit identify data to IDE controller init driver\r
-        //\r
-        CopyMem (&IdentifyData, IdeBlkIoDevicePtr->IdData, sizeof (IdentifyData));\r
-        IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = TRUE;\r
-        IdeInit->SubmitData (IdeInit, IdeChannel, IdeDevice, &IdentifyData);\r
-      } else {\r
-        //\r
-        // Device detection failed\r
-        //\r
-        IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;\r
-        IdeInit->SubmitData (IdeInit, IdeChannel, IdeDevice, NULL);\r
-        ReleaseIdeResources (IdeBlkIoDevicePtr);\r
-        IdeBlkIoDevicePtr = NULL;\r
-      }\r
-      //\r
-      // end of 1st inner loop ---\r
-      //\r
-    }\r
-    //\r
-    // end of 1st outer loop =========\r
-    //\r
-  }\r
-\r
-  //\r
-  // = 2nd outer loop == Primary/Secondary =================\r
-  //\r
-  for (IdeChannel = BeginningIdeChannel; IdeChannel <= EndIdeChannel; IdeChannel++) {\r
-\r
-    //\r
-    // -- 2nd inner loop --- Master/Slave --------\r
-    //\r
-    for (IdeDevice = BeginningIdeDevice; IdeDevice <= EndIdeDevice; IdeDevice++) {\r
-\r
-      ASSERT (IdeChannel * 2 + IdeDevice < MAX_IDE_DEVICE);\r
-      if (IdeBusDriverPrivateData->DeviceProcessed[IdeChannel * 2 + IdeDevice]) {\r
-        continue;\r
-      }\r
-\r
-      if (!IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice]) {\r
-        continue;\r
-      }\r
-\r
-      Status = IdeInit->CalculateMode (\r
-                          IdeInit,\r
-                          IdeChannel,\r
-                          IdeDevice,\r
-                          &SupportedModes\r
-                          );\r
-      if (EFI_ERROR (Status)) {\r
-        DEBUG ((EFI_D_ERROR, "[bStStp20S=%x]", Status));\r
-        continue;\r
-      }\r
-\r
-      ASSERT (IdeChannel < IdeMaxChannel && IdeDevice < IdeMaxDevice);\r
-      IdeBlkIoDevicePtr = IdeBlkIoDevice[IdeChannel][IdeDevice];\r
-\r
-      //\r
-      // Set best supported PIO mode on this IDE device\r
-      //\r
-      if (SupportedModes->PioMode.Mode <= AtaPioMode2) {\r
-        TransferMode.ModeCategory = ATA_MODE_CATEGORY_DEFAULT_PIO;\r
-      } else {\r
-        TransferMode.ModeCategory = ATA_MODE_CATEGORY_FLOW_PIO;\r
-      }\r
-\r
-      TransferMode.ModeNumber = (UINT8) (SupportedModes->PioMode.Mode);\r
-\r
-      if (SupportedModes->ExtModeCount == 0){\r
-        Status                  = SetDeviceTransferMode (IdeBlkIoDevicePtr, &TransferMode);\r
-\r
-        if (EFI_ERROR (Status)) {\r
-          IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;\r
-          ReleaseIdeResources (IdeBlkIoDevicePtr);\r
-          IdeBlkIoDevicePtr = NULL;\r
-          continue;\r
-        }\r
-      }\r
-\r
-      //\r
-      // Set supported DMA mode on this IDE device. Note that UDMA & MDMA cann't\r
-      // be set together. Only one DMA mode can be set to a device. If setting\r
-      // DMA mode operation fails, we can continue moving on because we only use\r
-      // PIO mode at boot time. DMA modes are used by certain kind of OS booting\r
-      //\r
-      if (SupportedModes->UdmaMode.Valid) {\r
-\r
-        TransferMode.ModeCategory = ATA_MODE_CATEGORY_UDMA;\r
-        TransferMode.ModeNumber   = (UINT8) (SupportedModes->UdmaMode.Mode);\r
-        Status                    = SetDeviceTransferMode (IdeBlkIoDevicePtr, &TransferMode);\r
-\r
-        if (EFI_ERROR (Status)) {\r
-          IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;\r
-          ReleaseIdeResources (IdeBlkIoDevicePtr);\r
-          IdeBlkIoDevicePtr = NULL;\r
-          continue;\r
-        }\r
-        //\r
-        // Record Udma Mode\r
-        //\r
-        IdeBlkIoDevicePtr->UdmaMode.Valid = TRUE;\r
-        IdeBlkIoDevicePtr->UdmaMode.Mode  = SupportedModes->UdmaMode.Mode;\r
-        EnableInterrupt (IdeBlkIoDevicePtr);\r
-      } else if (SupportedModes->MultiWordDmaMode.Valid) {\r
-\r
-        TransferMode.ModeCategory = ATA_MODE_CATEGORY_MDMA;\r
-        TransferMode.ModeNumber   = (UINT8) SupportedModes->MultiWordDmaMode.Mode;\r
-        Status                    = SetDeviceTransferMode (IdeBlkIoDevicePtr, &TransferMode);\r
-\r
-        if (EFI_ERROR (Status)) {\r
-          IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;\r
-          ReleaseIdeResources (IdeBlkIoDevicePtr);\r
-          IdeBlkIoDevicePtr = NULL;\r
-          continue;\r
-        }\r
-\r
-        EnableInterrupt (IdeBlkIoDevicePtr);\r
-      }\r
-      //\r
-      // Init driver parameters\r
-      //\r
-      DriveParameters.Sector          = (UINT8) ((ATA5_IDENTIFY_DATA *) IdeBlkIoDevicePtr->IdData)->sectors_per_track;\r
-      DriveParameters.Heads           = (UINT8) (((ATA5_IDENTIFY_DATA *) IdeBlkIoDevicePtr->IdData)->heads - 1);\r
-      DriveParameters.MultipleSector  = (UINT8) IdeBlkIoDevicePtr->IdData->AtaData.multi_sector_cmd_max_sct_cnt;\r
-      //\r
-      // Set Parameters for the device:\r
-      // 1) Init\r
-      // 2) Establish the block count for READ/WRITE MULTIPLE (EXT) command\r
-      //\r
-      if ((IdeBlkIoDevicePtr->Type == IdeHardDisk) || (IdeBlkIoDevicePtr->Type == Ide48bitAddressingHardDisk)) {\r
-        Status = SetDriveParameters (IdeBlkIoDevicePtr, &DriveParameters);\r
-      }\r
-\r
-      //\r
-      // Record PIO mode used in private data\r
-      //\r
-      IdeBlkIoDevicePtr->PioMode = (ATA_PIO_MODE) SupportedModes->PioMode.Mode;\r
-\r
-      //\r
-      // Set IDE controller Timing Blocks in the PCI Configuration Space\r
-      //\r
-      IdeInit->SetTiming (IdeInit, IdeChannel, IdeDevice, SupportedModes);\r
-\r
-      //\r
-      // Add Component Name for the IDE/ATAPI device that was discovered.\r
-      //\r
-      IdeBlkIoDevicePtr->ControllerNameTable = NULL;\r
-      ADD_IDE_ATAPI_NAME (IdeBlkIoDevicePtr);\r
-\r
-      Status = gBS->InstallMultipleProtocolInterfaces (\r
-                      &IdeBlkIoDevicePtr->Handle,\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      IdeBlkIoDevicePtr->DevicePath,\r
-                      &gEfiBlockIoProtocolGuid,\r
-                      &IdeBlkIoDevicePtr->BlkIo,\r
-                      &gEfiDiskInfoProtocolGuid,\r
-                      &IdeBlkIoDevicePtr->DiskInfo,\r
-                      NULL\r
-                      );\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        ReleaseIdeResources (IdeBlkIoDevicePtr);\r
-      }\r
-\r
-      gBS->OpenProtocol (\r
-            Controller,\r
-            &gEfiPciIoProtocolGuid,\r
-            (VOID **) &PciIo,\r
-            This->DriverBindingHandle,\r
-            IdeBlkIoDevicePtr->Handle,\r
-            EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-            );\r
-\r
-      IdeBusDriverPrivateData->DeviceProcessed[IdeChannel * 2 + IdeDevice] = TRUE;\r
-\r
-      //\r
-      // Report status code: device eanbled!\r
-      //\r
-      REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-        EFI_PROGRESS_CODE,\r
-        (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_ENABLE),\r
-        IdeBlkIoDevicePtr->DevicePath\r
-        );\r
-\r
-      //\r
-      // Create event to clear pending IDE interrupt\r
-      //\r
-      Status = gBS->CreateEventEx (\r
-                      EVT_NOTIFY_SIGNAL,\r
-                      TPL_NOTIFY,\r
-                      ClearInterrupt,\r
-                      IdeBlkIoDevicePtr,\r
-                      &gEfiEventExitBootServicesGuid,\r
-                      &IdeBlkIoDevicePtr->ExitBootServiceEvent\r
-                      );\r
-\r
-      //\r
-      // end of 2nd inner loop ----\r
-      //\r
-    }\r
-    //\r
-    // end of 2nd outer loop ==========\r
-    //\r
-  }\r
-\r
-  //\r
-  // All configurations done! Notify IdeController to do post initialization\r
-  // work such as saving IDE controller PCI settings for S3 resume\r
-  //\r
-  IdeInit->NotifyPhase (IdeInit, EfiIdeBusPhaseMaximum, 0);\r
-\r
-  if (SupportedModes != NULL) {\r
-    FreePool (SupportedModes);\r
-  }\r
-\r
-  PERF_START (NULL, "Finish IDE detection", "IDE", 1);\r
-  PERF_END (NULL, "Finish IDE detection", "IDE", 0);\r
-\r
-  return EFI_SUCCESS;\r
-\r
-ErrorExit:\r
-\r
-  //\r
-  // Report error code: controller error\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-    (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_EC_CONTROLLER_ERROR),\r
-    ParentDevicePath\r
-    );\r
-\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiIdeControllerInitProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  gBS->UninstallMultipleProtocolInterfaces (\r
-        Controller,\r
-        &gEfiCallerIdGuid,\r
-        IdeBusDriverPrivateData,\r
-        NULL\r
-        );\r
-\r
-  if (IdeBusDriverPrivateData != NULL) {\r
-    gBS->FreePool (IdeBusDriverPrivateData);\r
-  }\r
-\r
-  if (SupportedModes != NULL) {\r
-    gBS->FreePool (SupportedModes);\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiPciIoProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiDevicePathProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  return Status;\r
-\r
-}\r
-/**\r
-  Stop function of Driver Binding Protocol which is to stop the driver on Controller Handle and all\r
-  child handle attached to the controller handle if there are.\r
-\r
-  @param  This Protocol instance pointer.\r
-  @param  Controller Handle of device to stop driver on\r
-  @param  NumberOfChildren Not used\r
-  @param  ChildHandleBuffer Not used\r
-\r
-  @retval  EFI_SUCCESS This driver is removed DeviceHandle\r
-  @retval  other This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Controller,\r
-  IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_PCI_IO_PROTOCOL         *PciIo;\r
-  BOOLEAN                     AllChildrenStopped;\r
-  UINTN                       Index;\r
-  IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;\r
-  UINT64                      Supports;\r
-\r
-  IdeBusDriverPrivateData = NULL;\r
-\r
-  if (NumberOfChildren == 0) {\r
-\r
-    Status = gBS->OpenProtocol (\r
-                    Controller,\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo,\r
-                    This->DriverBindingHandle,\r
-                    Controller,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = PciIo->Attributes (\r
-                        PciIo,\r
-                        EfiPciIoAttributeOperationSupported,\r
-                        0,\r
-                        &Supports\r
-                        );\r
-      if (!EFI_ERROR (Status)) {\r
-        Supports &= (UINT64)(EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO | EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO | EFI_PCI_DEVICE_ENABLE);\r
-        PciIo->Attributes (\r
-                PciIo,\r
-                EfiPciIoAttributeOperationDisable,\r
-                Supports,\r
-                NULL\r
-                );\r
-      }\r
-    }\r
-\r
-    gBS->OpenProtocol (\r
-          Controller,\r
-          &gEfiCallerIdGuid,\r
-          (VOID **) &IdeBusDriverPrivateData,\r
-          This->DriverBindingHandle,\r
-          Controller,\r
-          EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-          );\r
-\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-          Controller,\r
-          &gEfiCallerIdGuid,\r
-          IdeBusDriverPrivateData,\r
-          NULL\r
-          );\r
-\r
-    if (IdeBusDriverPrivateData != NULL) {\r
-      gBS->FreePool (IdeBusDriverPrivateData);\r
-    }\r
-    //\r
-    // Close the bus driver\r
-    //\r
-    gBS->CloseProtocol (\r
-          Controller,\r
-          &gEfiIdeControllerInitProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Controller\r
-          );\r
-    gBS->CloseProtocol (\r
-          Controller,\r
-          &gEfiPciIoProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Controller\r
-          );\r
-    gBS->CloseProtocol (\r
-          Controller,\r
-          &gEfiDevicePathProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Controller\r
-          );\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  AllChildrenStopped = TRUE;\r
-\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-\r
-    Status = DeRegisterIdeDevice (This, Controller, ChildHandleBuffer[Index]);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      AllChildrenStopped = FALSE;\r
-    }\r
-  }\r
-\r
-  if (!AllChildrenStopped) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  issue ATA or ATAPI command to reset a block IO device.\r
-  @param  This                  Block IO protocol instance pointer.\r
-  @param  ExtendedVerification  If FALSE,for ATAPI device, driver will only invoke ATAPI reset method\r
-                                If TRUE, for ATAPI device, driver need invoke ATA reset method after\r
-                                invoke ATAPI reset method\r
-\r
-  @retval EFI_DEVICE_ERROR      When the device is neighther ATA device or ATAPI device.\r
-  @retval EFI_SUCCESS           The device reset successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBlkIoReset (\r
-  IN  EFI_BLOCK_IO_PROTOCOL   *This,\r
-  IN  BOOLEAN                 ExtendedVerification\r
-  )\r
-{\r
-  IDE_BLK_IO_DEV  *IdeBlkIoDevice;\r
-  EFI_STATUS      Status;\r
-  EFI_TPL         OldTpl;\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (This);\r
-  //\r
-  // Requery IDE IO resources in case of the switch of native and legacy modes\r
-  //\r
-  ReassignIdeResources (IdeBlkIoDevice);\r
-\r
-  //\r
-  // for ATA device, using ATA reset method\r
-  //\r
-  if (IdeBlkIoDevice->Type == IdeHardDisk ||\r
-      IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {\r
-    Status = AtaSoftReset (IdeBlkIoDevice);\r
-    goto Done;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->Type == IdeUnknown) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // for ATAPI device, using ATAPI reset method\r
-  //\r
-  Status = AtapiSoftReset (IdeBlkIoDevice);\r
-  if (ExtendedVerification) {\r
-    Status = AtaSoftReset (IdeBlkIoDevice);\r
-  }\r
-\r
-Done:\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Read data from a block IO device\r
-\r
-  @param  This       Block IO protocol instance pointer.\r
-  @param  MediaId    The media ID of the device\r
-  @param  Lba        Starting LBA address to read data\r
-  @param  BufferSize The size of data to be read\r
-  @param  Buffer     Caller supplied buffer to save data\r
-\r
-  @retval EFI_DEVICE_ERROR  unknown device type\r
-  @retval other             read data status.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBlkIoReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL   *This,\r
-  IN  UINT32                  MediaId,\r
-  IN  EFI_LBA                 Lba,\r
-  IN  UINTN                   BufferSize,\r
-  OUT VOID                    *Buffer\r
-  )\r
-{\r
-  IDE_BLK_IO_DEV  *IdeBlkIoDevice;\r
-  EFI_STATUS      Status;\r
-  EFI_TPL         OldTpl;\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Requery IDE IO resources in case of the switch of native and legacy modes\r
-  //\r
-  ReassignIdeResources (IdeBlkIoDevice);\r
-\r
-  //\r
-  // For ATA compatible device, use ATA read block's mechanism\r
-  //\r
-  if (IdeBlkIoDevice->Type == IdeHardDisk ||\r
-      IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {\r
-    Status = AtaBlkIoReadBlocks (\r
-            IdeBlkIoDevice,\r
-            MediaId,\r
-            Lba,\r
-            BufferSize,\r
-            Buffer\r
-            );\r
-    goto Done;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->Type == IdeUnknown) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // for ATAPI device, using ATAPI read block's mechanism\r
-  //\r
-  Status = AtapiBlkIoReadBlocks (\r
-          IdeBlkIoDevice,\r
-          MediaId,\r
-          Lba,\r
-          BufferSize,\r
-          Buffer\r
-          );\r
-\r
-Done:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Write data to block io device.\r
-\r
-  @param  This       Protocol instance pointer.\r
-  @param  MediaId    The media ID of the device\r
-  @param  Lba        Starting LBA address to write data\r
-  @param  BufferSize The size of data to be written\r
-  @param  Buffer     Caller supplied buffer to save data\r
-\r
-  @retval EFI_DEVICE_ERROR  unknown device type\r
-  @retval other             write data status\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBlkIoWriteBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL   *This,\r
-  IN  UINT32                  MediaId,\r
-  IN  EFI_LBA                 Lba,\r
-  IN  UINTN                   BufferSize,\r
-  IN  VOID                    *Buffer\r
-  )\r
-{\r
-  IDE_BLK_IO_DEV  *IdeBlkIoDevice;\r
-  EFI_STATUS      Status;\r
-  EFI_TPL         OldTpl;\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (This);\r
-  //\r
-  // Requery IDE IO resources in case of the switch of native and legacy modes\r
-  //\r
-  ReassignIdeResources (IdeBlkIoDevice);\r
-\r
-  //\r
-  // for ATA device, using ATA write block's mechanism\r
-  //\r
-  if (IdeBlkIoDevice->Type == IdeHardDisk ||\r
-      IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {\r
-\r
-    Status = AtaBlkIoWriteBlocks (\r
-            IdeBlkIoDevice,\r
-            MediaId,\r
-            Lba,\r
-            BufferSize,\r
-            Buffer\r
-            );\r
-    goto Done;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->Type == IdeUnknown) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // for ATAPI device, using ATAPI write block's mechanism\r
-  //\r
-  Status = AtapiBlkIoWriteBlocks (\r
-          IdeBlkIoDevice,\r
-          MediaId,\r
-          Lba,\r
-          BufferSize,\r
-          Buffer\r
-          );\r
-\r
-Done:\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-/**\r
-  Flushes all modified data to a physical block devices\r
-\r
-  @param  This  Indicates a pointer to the calling context which to sepcify a\r
-                sepcific block device\r
-\r
-  @retval EFI_SUCCESS   Always return success.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBlkIoFlushBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL   *This\r
-  )\r
-{\r
-  //\r
-  // return directly\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is used by the IDE bus driver to get inquiry data.\r
-  Data format of Identify data is defined by the Interface GUID.\r
-\r
-  @param  This                  Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
-  @param  InquiryData           Pointer to a buffer for the inquiry data.\r
-  @param  InquiryDataSize       Pointer to the value for the inquiry data size.\r
-\r
-  @retval EFI_SUCCESS           The command was accepted without any errors.\r
-  @retval EFI_NOT_FOUND         Device does not support this data class\r
-  @retval EFI_DEVICE_ERROR      Error reading InquiryData from device\r
-  @retval EFI_BUFFER_TOO_SMALL  IntquiryDataSize not big enough\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEDiskInfoInquiry (\r
-  IN     EFI_DISK_INFO_PROTOCOL   *This,\r
-  IN OUT VOID                     *InquiryData,\r
-  IN OUT UINT32                   *InquiryDataSize\r
-  )\r
-{\r
-  IDE_BLK_IO_DEV  *IdeBlkIoDevice;\r
-\r
-  IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS (This);\r
-\r
-  if (*InquiryDataSize < sizeof (ATAPI_INQUIRY_DATA)) {\r
-    *InquiryDataSize = sizeof (ATAPI_INQUIRY_DATA);\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->InquiryData == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  gBS->CopyMem (InquiryData, IdeBlkIoDevice->InquiryData, sizeof (ATAPI_INQUIRY_DATA));\r
-  *InquiryDataSize = sizeof (ATAPI_INQUIRY_DATA);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is used by the IDE bus driver to get identify data.\r
-  Data format of Identify data is defined by the Interface GUID.\r
-\r
-  @param  This                  Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
-  @param  IdentifyData          Pointer to a buffer for the identify data.\r
-  @param  IdentifyDataSize      Pointer to the value for the identify data size.\r
-\r
-  @retval EFI_SUCCESS           The command was accepted without any errors.\r
-  @retval EFI_NOT_FOUND         Device does not support this data class\r
-  @retval EFI_DEVICE_ERROR      Error reading IdentifyData from device\r
-  @retval EFI_BUFFER_TOO_SMALL  IdentifyDataSize not big enough\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEDiskInfoIdentify (\r
-  IN     EFI_DISK_INFO_PROTOCOL   *This,\r
-  IN OUT VOID                     *IdentifyData,\r
-  IN OUT UINT32                   *IdentifyDataSize\r
-  )\r
-{\r
-  IDE_BLK_IO_DEV  *IdeBlkIoDevice;\r
-\r
-  IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS (This);\r
-\r
-  if (*IdentifyDataSize < sizeof (EFI_IDENTIFY_DATA)) {\r
-    *IdentifyDataSize = sizeof (EFI_IDENTIFY_DATA);\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  }\r
-\r
-  if (IdeBlkIoDevice->IdData == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  gBS->CopyMem (IdentifyData, IdeBlkIoDevice->IdData, sizeof (EFI_IDENTIFY_DATA));\r
-  *IdentifyDataSize = sizeof (EFI_IDENTIFY_DATA);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is used by the IDE bus driver to get sense data.\r
-  Data format of Sense data is defined by the Interface GUID.\r
-\r
-  @param  This                  Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
-  @param  SenseData             Pointer to the SenseData.\r
-  @param  SenseDataSize         Size of SenseData in bytes.\r
-  @param  SenseDataNumber       Pointer to the value for the identify data size.\r
-\r
-  @retval EFI_SUCCESS           The command was accepted without any errors.\r
-  @retval EFI_NOT_FOUND         Device does not support this data class\r
-  @retval EFI_DEVICE_ERROR      Error reading InquiryData from device\r
-  @retval EFI_BUFFER_TOO_SMALL  SenseDataSize not big enough\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEDiskInfoSenseData (\r
-  IN     EFI_DISK_INFO_PROTOCOL   *This,\r
-  IN OUT VOID                     *SenseData,\r
-  IN OUT UINT32                   *SenseDataSize,\r
-  OUT    UINT8                    *SenseDataNumber\r
-  )\r
-{\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  This function is used by the IDE bus driver to get controller information.\r
-\r
-  @param  This                  Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
-  @param  IdeChannel            Pointer to the Ide Channel number. Primary or secondary.\r
-  @param  IdeDevice             Pointer to the Ide Device number. Master or slave.\r
-\r
-  @retval EFI_SUCCESS           IdeChannel and IdeDevice are valid\r
-  @retval EFI_UNSUPPORTED       This is not an IDE device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEDiskInfoWhichIde (\r
-  IN  EFI_DISK_INFO_PROTOCOL   *This,\r
-  OUT UINT32                   *IdeChannel,\r
-  OUT UINT32                   *IdeDevice\r
-  )\r
-{\r
-  IDE_BLK_IO_DEV  *IdeBlkIoDevice;\r
-\r
-  IdeBlkIoDevice  = IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS (This);\r
-  *IdeChannel     = IdeBlkIoDevice->Channel;\r
-  *IdeDevice      = IdeBlkIoDevice->Device;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  The is an event(generally the event is exitBootService event) call back function.\r
-  Clear pending IDE interrupt before OS loader/kernel take control of the IDE device.\r
-\r
-  @param  Event   Pointer to this event\r
-  @param  Context Event handler private data\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-ClearInterrupt (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-{\r
-  EFI_STATUS      Status;\r
-  UINT64          IoPortForBmis;\r
-  UINT8           RegisterValue;\r
-  IDE_BLK_IO_DEV  *IdeDev;\r
-\r
-  //\r
-  // Get our context\r
-  //\r
-  IdeDev = (IDE_BLK_IO_DEV *) Context;\r
-\r
-  //\r
-  // Obtain IDE IO port registers' base addresses\r
-  //\r
-  Status = ReassignIdeResources (IdeDev);\r
-  if (EFI_ERROR (Status)) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Check whether interrupt is pending\r
-  //\r
-\r
-  //\r
-  // Reset IDE device to force it de-assert interrupt pin\r
-  // Note: this will reset all devices on this IDE channel\r
-  //\r
-  Status = AtaSoftReset (IdeDev);\r
-  if (EFI_ERROR (Status)) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Get base address of IDE Bus Master Status Regsiter\r
-  //\r
-  if (IdePrimary == IdeDev->Channel) {\r
-    IoPortForBmis = IdeDev->IoPort->BusMasterBaseAddr + BMISP_OFFSET;\r
-  } else {\r
-    if (IdeSecondary == IdeDev->Channel) {\r
-      IoPortForBmis = IdeDev->IoPort->BusMasterBaseAddr + BMISS_OFFSET;\r
-    } else {\r
-      return;\r
-    }\r
-  }\r
-  //\r
-  // Read BMIS register and clear ERROR and INTR bit\r
-  //\r
-  IdeDev->PciIo->Io.Read (\r
-                      IdeDev->PciIo,\r
-                      EfiPciIoWidthUint8,\r
-                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                      IoPortForBmis,\r
-                      1,\r
-                      &RegisterValue\r
-                      );\r
-\r
-  RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);\r
-\r
-  IdeDev->PciIo->Io.Write (\r
-                      IdeDev->PciIo,\r
-                      EfiPciIoWidthUint8,\r
-                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                      IoPortForBmis,\r
-                      1,\r
-                      &RegisterValue\r
-                      );\r
-\r
-  //\r
-  // Select the other device on this channel to ensure this device to release the interrupt pin\r
-  //\r
-  if (IdeDev->Device == 0) {\r
-    RegisterValue = (1 << 4) | 0xe0;\r
-  } else {\r
-    RegisterValue = (0 << 4) | 0xe0;\r
-  }\r
-  IDEWritePortB (\r
-    IdeDev->PciIo,\r
-    IdeDev->IoPort->Head,\r
-    RegisterValue\r
-    );\r
-\r
-}\r
-\r
-/**\r
-  The user Entry Point for module IdeBus. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeIdeBus(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallAllDriverProtocols2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gIDEBusDriverBinding,\r
-             ImageHandle,\r
-             &gIDEBusComponentName,\r
-             &gIDEBusComponentName2,\r
-             NULL,\r
-             NULL,\r
-             &gIDEBusDriverDiagnostics,\r
-             &gIDEBusDriverDiagnostics2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.h
deleted file mode 100644 (file)
index b58c18c..0000000
+++ /dev/null
@@ -1,421 +0,0 @@
-/** @file\r
-  Header file for IDE Bus Driver.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _IDE_BUS_H_\r
-#define _IDE_BUS_H_\r
-\r
-\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Protocol/IdeControllerInit.h>\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/DiskInfo.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PerformanceLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-#include <Guid/EventGroup.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-#include "IdeData.h"\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL      gIDEBusDriverBinding;\r
-extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL  gIDEBusDriverDiagnostics;\r
-extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2;\r
-\r
-//\r
-// Extra Definition to porting\r
-//\r
-#define MAX_IDE_DEVICE    4\r
-#define MAX_IDE_CHANNELS  2\r
-#define MAX_IDE_DRIVES    2\r
-\r
-#define INVALID_DEVICE_TYPE 0xff\r
-#define ATA_DEVICE_TYPE     0x00\r
-#define ATAPI_DEVICE_TYPE   0x01\r
-\r
-typedef struct {\r
-  BOOLEAN HaveScannedDevice[MAX_IDE_DEVICE];\r
-  BOOLEAN DeviceFound[MAX_IDE_DEVICE];\r
-  BOOLEAN DeviceProcessed[MAX_IDE_DEVICE];\r
-} IDE_BUS_DRIVER_PRIVATE_DATA;\r
-\r
-#define IDE_BLK_IO_DEV_SIGNATURE  SIGNATURE_32 ('i', 'b', 'i', 'd')\r
-\r
-typedef struct {\r
-  UINT32                      Signature;\r
-\r
-  EFI_HANDLE                  Handle;\r
-  EFI_BLOCK_IO_PROTOCOL       BlkIo;\r
-  EFI_BLOCK_IO_MEDIA          BlkMedia;\r
-  EFI_DISK_INFO_PROTOCOL      DiskInfo;\r
-  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
-  EFI_PCI_IO_PROTOCOL         *PciIo;\r
-  IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;\r
-\r
-  //\r
-  // Local Data for IDE interface goes here\r
-  //\r
-  EFI_IDE_CHANNEL             Channel;\r
-  EFI_IDE_DEVICE              Device;\r
-  UINT16                      Lun;\r
-  IDE_DEVICE_TYPE             Type;\r
-\r
-  IDE_BASE_REGISTERS          *IoPort;\r
-  UINT16                      AtapiError;\r
-\r
-  ATAPI_INQUIRY_DATA                *InquiryData;\r
-  EFI_IDENTIFY_DATA           *IdData;\r
-  ATA_PIO_MODE                PioMode;\r
-  EFI_ATA_MODE                UdmaMode;\r
-  CHAR8                       ModelName[41];\r
-  ATAPI_REQUEST_SENSE_DATA          *SenseData;\r
-  UINT8                       SenseDataNumber;\r
-  UINT8                       *Cache;\r
-\r
-  //\r
-  // ExitBootService Event, it is used to clear pending IDE interrupt\r
-  //\r
-  EFI_EVENT                   ExitBootServiceEvent;\r
-\r
-  EFI_UNICODE_STRING_TABLE    *ControllerNameTable;\r
-} IDE_BLK_IO_DEV;\r
-\r
-#include "ComponentName.h"\r
-\r
-#define IDE_BLOCK_IO_DEV_FROM_THIS(a)           CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)\r
-#define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)\r
-\r
-#include "Ide.h"\r
-\r
-\r
-/**\r
-  Supported function of Driver Binding protocol for this driver.\r
-\r
-  @param This                A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param ControllerHandle    The handle of the controller to test.\r
-  @param RemainingDevicePath A pointer to the remaining portion of a device path.\r
-\r
-  @retval  EFI_SUCCESS Driver loaded.\r
-  @retval  other       Driver not loaded.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Start function of Driver binding protocol which start this driver on Controller\r
-  by detecting all disks and installing BlockIo protocol on them.\r
-\r
-  @param  This                Protocol instance pointer.\r
-  @param  Controller          Handle of device to bind driver to.\r
-  @param  RemainingDevicePath produce all possible children.\r
-\r
-  @retval  EFI_SUCCESS         This driver is added to ControllerHandle.\r
-  @retval  EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
-  @retval  other               This driver does not support this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Stop function of Driver Binding Protocol which is to stop the driver on Controller Handle and all\r
-  child handle attached to the controller handle if there are.\r
-\r
-  @param  This Protocol instance pointer.\r
-  @param  Controller Handle of device to stop driver on\r
-  @param  NumberOfChildren Not used\r
-  @param  ChildHandleBuffer Not used\r
-\r
-  @retval  EFI_SUCCESS This driver is removed DeviceHandle\r
-  @retval  other This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL *This,\r
-  IN  EFI_HANDLE                  Controller,\r
-  IN  UINTN                       NumberOfChildren,\r
-  IN  EFI_HANDLE                  *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// EFI Driver Configuration Functions\r
-//\r
-\r
-\r
-\r
-\r
-//\r
-// EFI Driver Diagnostics Functions\r
-//\r
-/**\r
-  Runs diagnostics on a controller.\r
-\r
-  @param  This             A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOLinstance.\r
-  @param  ControllerHandle The handle of the controller to run diagnostics on.\r
-  @param  ChildHandle      The handle of the child controller to run diagnostics on\r
-                           This is an optional parameter that may be NULL.  It will\r
-                           be NULL for device drivers.  It will also be NULL for a\r
-                           bus drivers that wish to run diagnostics on the bus controller.\r
-                           It will not be NULL for a bus driver that wishes to run\r
-                           diagnostics on one of its child controllers.\r
-  @param  DiagnosticType   Indicates type of diagnostics to perform on the controller\r
-                           specified by ControllerHandle and ChildHandle.\r
-  @param  Language         A pointer to a three character ISO 639-2 language identifier.\r
-                           This is the language in which the optional error message should\r
-                           be returned in Buffer, and it must match one of the languages\r
-                           specified in SupportedLanguages. The number of languages supported by\r
-                           a driver is up to the driver writer.\r
-  @param  ErrorType        A GUID that defines the format of the data returned in Buffer.\r
-  @param  BufferSize       The size, in bytes, of the data returned in Buffer.\r
-  @param  Buffer           A buffer that contains a Null-terminated Unicode string\r
-                           plus some additional data whose format is defined by ErrorType.\r
-                           Buffer is allocated by this function with AllocatePool(), and\r
-                           it is the caller's responsibility to free it with a call to FreePool().\r
-\r
-  @retval  EFI_SUCCESS           The controller specified by ControllerHandle and ChildHandle passed\r
-                                 the diagnostic.\r
-  @retval  EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-  @retval  EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
-  @retval  EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval  EFI_INVALID_PARAMETER ErrorType is NULL.\r
-  @retval  EFI_INVALID_PARAMETER BufferType is NULL.\r
-  @retval  EFI_INVALID_PARAMETER Buffer is NULL.\r
-  @retval  EFI_UNSUPPORTED       The driver specified by This does not support running\r
-                                 diagnostics for the controller specified by ControllerHandle\r
-                                 and ChildHandle.\r
-  @retval  EFI_UNSUPPORTED       The driver specified by This does not support the\r
-                                 type of diagnostic specified by DiagnosticType.\r
-  @retval  EFI_UNSUPPORTED       The driver specified by This does not support the language\r
-                                 specified by Language.\r
-  @retval  EFI_OUT_OF_RESOURCES  There are not enough resources available to complete the\r
-                                 diagnostics.\r
-  @retval  EFI_OUT_OF_RESOURCES  There are not enough resources available to return the\r
-                                 status information in ErrorType, BufferSize,and Buffer.\r
-  @retval  EFI_DEVICE_ERROR      The controller specified by ControllerHandle and ChildHandle\r
-                                 did not pass the diagnostic.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBusDriverDiagnosticsRunDiagnostics (\r
-  IN  EFI_DRIVER_DIAGNOSTICS_PROTOCOL               *This,\r
-  IN  EFI_HANDLE                                    ControllerHandle,\r
-  IN  EFI_HANDLE                                    ChildHandle  OPTIONAL,\r
-  IN  EFI_DRIVER_DIAGNOSTIC_TYPE                    DiagnosticType,\r
-  IN  CHAR8                                         *Language,\r
-  OUT EFI_GUID                                      **ErrorType,\r
-  OUT UINTN                                         *BufferSize,\r
-  OUT CHAR16                                        **Buffer\r
-  );\r
-\r
-/**\r
-  issue ATA or ATAPI command to reset a block IO device.\r
-  @param  This                  Block IO protocol instance pointer.\r
-  @param  ExtendedVerification  If FALSE,for ATAPI device, driver will only invoke ATAPI reset method\r
-                                If TRUE, for ATAPI device, driver need invoke ATA reset method after\r
-                                invoke ATAPI reset method\r
-\r
-  @retval EFI_DEVICE_ERROR      When the device is neighther ATA device or ATAPI device.\r
-  @retval EFI_SUCCESS           The device reset successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBlkIoReset (\r
-  IN  EFI_BLOCK_IO_PROTOCOL       *This,\r
-  IN  BOOLEAN                     ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Read data from a block IO device.\r
-\r
-  @param  This       Block IO protocol instance pointer.\r
-  @param  MediaId    The media ID of the device\r
-  @param  Lba        Starting LBA address to read data\r
-  @param  BufferSize The size of data to be read\r
-  @param  Buffer     Caller supplied buffer to save data\r
-\r
-  @retval EFI_DEVICE_ERROR  unknown device type\r
-  @retval EFI_SUCCESS       read the data successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBlkIoReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL       *This,\r
-  IN  UINT32                      MediaId,\r
-  IN  EFI_LBA                     Lba,\r
-  IN  UINTN                       BufferSize,\r
-  OUT VOID                        *Buffer\r
-  );\r
-\r
-/**\r
-  Write data to block io device\r
-\r
-  @param  This       Protocol instance pointer.\r
-  @param  MediaId    The media ID of the device\r
-  @param  Lba        Starting LBA address to write data\r
-  @param  BufferSize The size of data to be written\r
-  @param  Buffer     Caller supplied buffer to save data\r
-\r
-  @retval EFI_DEVICE_ERROR  unknown device type\r
-  @retval other             write data status\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBlkIoWriteBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL       *This,\r
-  IN  UINT32                      MediaId,\r
-  IN  EFI_LBA                     Lba,\r
-  IN  UINTN                       BufferSize,\r
-  IN  VOID                        *Buffer\r
-  );\r
-\r
-/**\r
-  Flushes all modified data to a physical block devices\r
-\r
-  @param  This  Indicates a pointer to the calling context which to sepcify a\r
-                sepcific block device\r
-\r
-  @retval EFI_SUCCESS   Always return success.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEBlkIoFlushBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL       *This\r
-  );\r
-/**\r
-  This function is used by the IDE bus driver to get inquiry data.\r
-  Data format of Identify data is defined by the Interface GUID.\r
-\r
-  @param  This                  Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
-  @param  InquiryData           Pointer to a buffer for the inquiry data.\r
-  @param  InquiryDataSize       Pointer to the value for the inquiry data size.\r
-\r
-  @retval EFI_SUCCESS           The command was accepted without any errors.\r
-  @retval EFI_NOT_FOUND         Device does not support this data class\r
-  @retval EFI_DEVICE_ERROR      Error reading InquiryData from device\r
-  @retval EFI_BUFFER_TOO_SMALL  IntquiryDataSize not big enough\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEDiskInfoInquiry (\r
-  IN EFI_DISK_INFO_PROTOCOL       *This,\r
-  IN OUT VOID                     *InquiryData,\r
-  IN OUT UINT32                   *InquiryDataSize\r
-  );\r
-\r
-/**\r
-  This function is used by the IDE bus driver to get identify data.\r
-  Data format of Identify data is defined by the Interface GUID.\r
-\r
-  @param  This                  Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
-  @param  IdentifyData          Pointer to a buffer for the identify data.\r
-  @param  IdentifyDataSize      Pointer to the value for the identify data size.\r
-\r
-  @retval EFI_SUCCESS           The command was accepted without any errors.\r
-  @retval EFI_NOT_FOUND         Device does not support this data class\r
-  @retval EFI_DEVICE_ERROR      Error reading IdentifyData from device\r
-  @retval EFI_BUFFER_TOO_SMALL  IdentifyDataSize not big enough\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEDiskInfoIdentify (\r
-  IN EFI_DISK_INFO_PROTOCOL       *This,\r
-  IN OUT VOID                     *IdentifyData,\r
-  IN OUT UINT32                   *IdentifyDataSize\r
-  );\r
-\r
-/**\r
-  This function is used by the IDE bus driver to get sense data.\r
-  Data format of Sense data is defined by the Interface GUID.\r
-\r
-  @param  This                  Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
-  @param  SenseData             Pointer to the SenseData.\r
-  @param  SenseDataSize         Size of SenseData in bytes.\r
-  @param  SenseDataNumber       Pointer to the value for the identify data size.\r
-\r
-  @retval EFI_SUCCESS           The command was accepted without any errors.\r
-  @retval EFI_NOT_FOUND         Device does not support this data class\r
-  @retval EFI_DEVICE_ERROR      Error reading InquiryData from device\r
-  @retval EFI_BUFFER_TOO_SMALL  SenseDataSize not big enough\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEDiskInfoSenseData (\r
-  IN EFI_DISK_INFO_PROTOCOL       *This,\r
-  IN OUT VOID                     *SenseData,\r
-  IN OUT UINT32                   *SenseDataSize,\r
-  OUT UINT8                       *SenseDataNumber\r
-  );\r
-\r
-/**\r
-  This function is used by the IDE bus driver to get controller information.\r
-\r
-  @param  This                  Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
-  @param  IdeChannel            Pointer to the Ide Channel number. Primary or secondary.\r
-  @param  IdeDevice             Pointer to the Ide Device number. Master or slave.\r
-\r
-  @retval EFI_SUCCESS           IdeChannel and IdeDevice are valid\r
-  @retval EFI_UNSUPPORTED       This is not an IDE device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IDEDiskInfoWhichIde (\r
-  IN EFI_DISK_INFO_PROTOCOL       *This,\r
-  OUT UINT32                      *IdeChannel,\r
-  OUT UINT32                      *IdeDevice\r
-  );\r
-/**\r
-  The is an event(generally the event is exitBootService event) call back function.\r
-  Clear pending IDE interrupt before OS loader/kernel take control of the IDE device.\r
-\r
-  @param  Event   Pointer to this event\r
-  @param  Context Event handler private data\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-ClearInterrupt (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  );\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
deleted file mode 100644 (file)
index d199a7e..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-## @file\r
-# IDE bus driver.\r
-#\r
-# This driver will enumerate IDE device and export the blockIo protocol for every device.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = IdeBusDxe\r
-  MODULE_UNI_FILE                = IdeBusDxe.uni\r
-  FILE_GUID                      = 69FD8E47-A161-4550-B01A-5594CEB2B2B2\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializeIdeBus\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-#  DRIVER_BINDING                =  gIDEBusDriverBinding\r
-#  COMPONENT_NAME                =  gIDEBusComponentName\r
-#  COMPONENT_NAME2               =  gIDEBusComponentName2\r
-#  Variable Guid C Name: gConfigurationGuid Variable Name: L"Configuration"\r
-#\r
-#\r
-\r
-[Sources]\r
-  DriverDiagnostics.c\r
-  DriverConfiguration.c\r
-  ComponentName.h\r
-  ComponentName.c\r
-  Atapi.c\r
-  Ata.c\r
-  Ide.c\r
-  IdeBus.c\r
-  IdeData.h\r
-  Ide.h\r
-  IdeBus.h\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  DevicePathLib\r
-  UefiRuntimeServicesTableLib\r
-  UefiBootServicesTableLib\r
-  PerformanceLib\r
-  MemoryAllocationLib\r
-  ReportStatusCodeLib\r
-  BaseMemoryLib\r
-  UefiLib\r
-  BaseLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-\r
-\r
-[Guids]\r
-  gEfiDiskInfoIdeInterfaceGuid                  ## SOMETIMES_PRODUCES ## UNDEFINED # DiskInfo Interface Guid\r
-  gEfiEventExitBootServicesGuid                 ## CONSUMES  ## Event\r
-\r
-\r
-[Protocols]\r
-  gEfiDiskInfoProtocolGuid                      ## BY_START\r
-  gEfiBlockIoProtocolGuid                       ## BY_START\r
-  gEfiIdeControllerInitProtocolGuid             ## TO_START\r
-  gEfiPciIoProtocolGuid                         ## TO_START\r
-  ## TO_START\r
-  ## BY_START\r
-  gEfiDevicePathProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  IdeBusDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.uni b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.uni
deleted file mode 100644 (file)
index da64497..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// IDE bus driver.\r
-//\r
-// This driver will enumerate IDE device and export the blockIo protocol for every device.\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "IDE bus driver"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This driver will enumerate IDE device and export the blockIo protocol for every device."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxeExtra.uni
deleted file mode 100644 (file)
index c23d45d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// IdeBusDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"IDE Bus DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeData.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeData.h
deleted file mode 100644 (file)
index fef5432..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-/** @file\r
-  Header file for IDE Bus Driver's Data Structures\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _IDE_DATA_H_\r
-#define _IDE_DATA_H_\r
-\r
-#include <IndustryStandard/Atapi.h>\r
-\r
-//\r
-// common constants\r
-//\r
-#define STALL_1_MILLI_SECOND  1000    // stall 1 ms\r
-#define STALL_1_SECOND        1000000 // stall 1 second\r
-typedef enum {\r
-  IdePrimary    = 0,\r
-  IdeSecondary  = 1,\r
-  IdeMaxChannel = 2\r
-} EFI_IDE_CHANNEL;\r
-\r
-typedef enum {\r
-  IdeMaster     = 0,\r
-  IdeSlave      = 1,\r
-  IdeMaxDevice  = 2\r
-} EFI_IDE_DEVICE;\r
-\r
-typedef enum {\r
-  IdeMagnetic,                        /* ZIP Drive or LS120 Floppy Drive */\r
-  IdeCdRom,                           /* ATAPI CDROM */\r
-  IdeHardDisk,                        /* Hard Disk */\r
-  Ide48bitAddressingHardDisk,         /* Hard Disk larger than 120GB */\r
-  IdeUnknown\r
-} IDE_DEVICE_TYPE;\r
-\r
-typedef enum {\r
-  SenseNoSenseKey,\r
-  SenseDeviceNotReadyNoRetry,\r
-  SenseDeviceNotReadyNeedRetry,\r
-  SenseNoMedia,\r
-  SenseMediaChange,\r
-  SenseMediaError,\r
-  SenseOtherSense\r
-} SENSE_RESULT;\r
-\r
-typedef enum {\r
-  AtaUdmaReadOp,\r
-  AtaUdmaReadExtOp,\r
-  AtaUdmaWriteOp,\r
-  AtaUdmaWriteExtOp\r
-} ATA_UDMA_OPERATION;\r
-\r
-//\r
-// IDE Registers\r
-//\r
-typedef union {\r
-  UINT16  Command;        /* when write */\r
-  UINT16  Status;         /* when read */\r
-} IDE_CMD_OR_STATUS;\r
-\r
-typedef union {\r
-  UINT16  Error;          /* when read */\r
-  UINT16  Feature;        /* when write */\r
-} IDE_ERROR_OR_FEATURE;\r
-\r
-typedef union {\r
-  UINT16  AltStatus;      /* when read */\r
-  UINT16  DeviceControl;  /* when write */\r
-} IDE_ALTSTATUS_OR_DEVICECONTROL;\r
-\r
-//\r
-// IDE registers set\r
-//\r
-typedef struct {\r
-  UINT16                          Data;\r
-  IDE_ERROR_OR_FEATURE            Reg1;\r
-  UINT16                          SectorCount;\r
-  UINT16                          SectorNumber;\r
-  UINT16                          CylinderLsb;\r
-  UINT16                          CylinderMsb;\r
-  UINT16                          Head;\r
-  IDE_CMD_OR_STATUS               Reg;\r
-\r
-  IDE_ALTSTATUS_OR_DEVICECONTROL  Alt;\r
-  UINT16                          DriveAddress;\r
-\r
-  UINT16                          MasterSlave;\r
-  UINT16                          BusMasterBaseAddr;\r
-} IDE_BASE_REGISTERS;\r
-\r
-//\r
-// IDE registers' base addresses\r
-//\r
-typedef struct {\r
-  UINT16  CommandBlockBaseAddr;\r
-  UINT16  ControlBlockBaseAddr;\r
-  UINT16  BusMasterBaseAddr;\r
-} IDE_REGISTERS_BASE_ADDR;\r
-\r
-//\r
-// Bit definitions in Programming Interface byte of the Class Code field\r
-// in PCI IDE controller's Configuration Space\r
-//\r
-#define IDE_PRIMARY_OPERATING_MODE            BIT0\r
-#define IDE_PRIMARY_PROGRAMMABLE_INDICATOR    BIT1\r
-#define IDE_SECONDARY_OPERATING_MODE          BIT2\r
-#define IDE_SECONDARY_PROGRAMMABLE_INDICATOR  BIT3\r
-\r
-\r
-//\r
-// Bus Master Reg\r
-//\r
-#define BMIC_NREAD      BIT3\r
-#define BMIC_START      BIT0\r
-#define BMIS_INTERRUPT  BIT2\r
-#define BMIS_ERROR      BIT1\r
-\r
-#define BMICP_OFFSET    0x00\r
-#define BMISP_OFFSET    0x02\r
-#define BMIDP_OFFSET    0x04\r
-#define BMICS_OFFSET    0x08\r
-#define BMISS_OFFSET    0x0A\r
-#define BMIDS_OFFSET    0x0C\r
-\r
-//\r
-// Time Out Value For IDE Device Polling\r
-//\r
-\r
-//\r
-// ATATIMEOUT is used for waiting time out for ATA device\r
-//\r
-\r
-//\r
-// 1 second\r
-//\r
-#define ATATIMEOUT  1000\r
-\r
-//\r
-// ATAPITIMEOUT is used for waiting operation\r
-// except read and write time out for ATAPI device\r
-//\r
-\r
-//\r
-// 1 second\r
-//\r
-#define ATAPITIMEOUT  1000\r
-\r
-//\r
-// ATAPILONGTIMEOUT is used for waiting read and\r
-// write operation timeout for ATAPI device\r
-//\r
-\r
-//\r
-// 2 seconds\r
-//\r
-#define CDROMLONGTIMEOUT  2000\r
-\r
-//\r
-// 5 seconds\r
-//\r
-#define ATAPILONGTIMEOUT  5000\r
-\r
-//\r
-// 10 seconds\r
-//\r
-#define ATASMARTTIMEOUT   10000\r
-\r
-\r
-//\r
-// ATAPI6 related data structure definition\r
-//\r
-\r
-//\r
-// The maximum sectors count in 28 bit addressing mode\r
-//\r
-#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  UINT32  RegionBaseAddr;\r
-  UINT16  ByteCount;\r
-  UINT16  EndOfTable;\r
-} IDE_DMA_PRD;\r
-\r
-#pragma pack()\r
-\r
-#define SETFEATURE        TRUE\r
-#define CLEARFEATURE      FALSE\r
-\r
-///\r
-/// PIO mode definition\r
-///\r
-typedef enum _ATA_PIO_MODE_ {\r
-  AtaPioModeBelow2,\r
-  AtaPioMode2,\r
-  AtaPioMode3,\r
-  AtaPioMode4\r
-} ATA_PIO_MODE;\r
-\r
-//\r
-// Multi word DMA definition\r
-//\r
-typedef enum _ATA_MDMA_MODE_ {\r
-  AtaMdmaMode0,\r
-  AtaMdmaMode1,\r
-  AtaMdmaMode2\r
-} ATA_MDMA_MODE;\r
-\r
-//\r
-// UDMA mode definition\r
-//\r
-typedef enum _ATA_UDMA_MODE_ {\r
-  AtaUdmaMode0,\r
-  AtaUdmaMode1,\r
-  AtaUdmaMode2,\r
-  AtaUdmaMode3,\r
-  AtaUdmaMode4,\r
-  AtaUdmaMode5\r
-} ATA_UDMA_MODE;\r
-\r
-#define ATA_MODE_CATEGORY_DEFAULT_PIO 0x00\r
-#define ATA_MODE_CATEGORY_FLOW_PIO    0x01\r
-#define ATA_MODE_CATEGORY_MDMA        0x04\r
-#define ATA_MODE_CATEGORY_UDMA        0x08\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  UINT8 ModeNumber : 3;\r
-  UINT8 ModeCategory : 5;\r
-} ATA_TRANSFER_MODE;\r
-\r
-typedef struct {\r
-  UINT8 Sector;\r
-  UINT8 Heads;\r
-  UINT8 MultipleSector;\r
-} ATA_DRIVE_PARMS;\r
-\r
-#pragma pack()\r
-//\r
-// IORDY Sample Point field value\r
-//\r
-#define ISP_5_CLK 0\r
-#define ISP_4_CLK 1\r
-#define ISP_3_CLK 2\r
-#define ISP_2_CLK 3\r
-\r
-//\r
-// Recovery Time field value\r
-//\r
-#define RECVY_4_CLK 0\r
-#define RECVY_3_CLK 1\r
-#define RECVY_2_CLK 2\r
-#define RECVY_1_CLK 3\r
-\r
-//\r
-// Slave IDE Timing Register Enable\r
-//\r
-#define SITRE BIT14\r
-\r
-//\r
-// DMA Timing Enable Only Select 1\r
-//\r
-#define DTE1  BIT7\r
-\r
-//\r
-// Pre-fetch and Posting Enable Select 1\r
-//\r
-#define PPE1  BIT6\r
-\r
-//\r
-// IORDY Sample Point Enable Select 1\r
-//\r
-#define IE1 BIT5\r
-\r
-//\r
-// Fast Timing Bank Drive Select 1\r
-//\r
-#define TIME1 BIT4\r
-\r
-//\r
-// DMA Timing Enable Only Select 0\r
-//\r
-#define DTE0  BIT3\r
-\r
-//\r
-// Pre-fetch and Posting Enable Select 0\r
-//\r
-#define PPE0  BIT2\r
-\r
-//\r
-// IOREY Sample Point Enable Select 0\r
-//\r
-#define IE0 BIT1\r
-\r
-//\r
-// Fast Timing Bank Drive Select 0\r
-//\r
-#define TIME0 BIT0\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/ComponentName.c
deleted file mode 100644 (file)
index 6e6251d..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/** @file\r
-  Implements EFI Component Name Protocol for VGA Mini Port Driver.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "VgaMiniPort.h"\r
-\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gPciVgaMiniPortComponentName = {\r
-  PciVgaMiniPortComponentNameGetDriverName,\r
-  PciVgaMiniPortComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPciVgaMiniPortComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PciVgaMiniPortComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PciVgaMiniPortComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPciVgaMiniPortDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"PCI VGA Mini Port Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param  Language              A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-  @param  DriverName            A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mPciVgaMiniPortDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gPciVgaMiniPortComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param  ControllerHandle      The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-  @param  ChildHandle           The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-  @param  Language              A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-  @param  ControllerName        A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.c b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.c
deleted file mode 100644 (file)
index e9ab494..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-/** @file\r
-  Implements EFI Driver Binding Protocol and VGA Mini Port Protocol for VGA Mini Port Driver.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "VgaMiniPort.h"\r
-\r
-//\r
-// EFI Driver Binding Protocol Instance\r
-//\r
-//   This driver has a version value of 0x00000000.  This is the\r
-//   lowest possible priority for a driver.  This is done on purpose to help\r
-//   the developers of UGA drivers.  This driver can bind if no UGA driver\r
-//   is present, so a console is available.  Then, when a UGA driver is loaded\r
-//   this driver can be disconnected, and the UGA driver can be connected.\r
-//   As long as the UGA driver has a version value greater than 0x00000000, it\r
-//   will be connected first and will block this driver from connecting.\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gPciVgaMiniPortDriverBinding = {\r
-  PciVgaMiniPortDriverBindingSupported,\r
-  PciVgaMiniPortDriverBindingStart,\r
-  PciVgaMiniPortDriverBindingStop,\r
-  0x00000000,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-/**\r
-  Entrypoint of VGA Mini Port Driver.\r
-\r
-  This function is the entrypoint of UVGA Mini Port Driver. It installs Driver Binding\r
-  Protocols together with Component Name Protocols.\r
-\r
-  @param  ImageHandle       The firmware allocated handle for the EFI image.\r
-  @param  SystemTable       A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortDriverEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gPciVgaMiniPortDriverBinding,\r
-             ImageHandle,\r
-             &gPciVgaMiniPortComponentName,\r
-             &gPciVgaMiniPortComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Check whether VGA Mini Port driver supports this device.\r
-\r
-  @param  This                   The driver binding protocol.\r
-  @param  Controller             The controller handle to check.\r
-  @param  RemainingDevicePath    The remaining device path.\r
-\r
-  @retval EFI_SUCCESS            The driver supports this controller.\r
-  @retval EFI_UNSUPPORTED        This device isn't supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-  PCI_TYPE00          Pci;\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // See if this is a PCI VGA Controller by looking at the Command register and\r
-  // Class Code Register\r
-  //\r
-  Status = PciIo->Pci.Read (\r
-                        PciIo,\r
-                        EfiPciIoWidthUint32,\r
-                        0,\r
-                        sizeof (Pci) / sizeof (UINT32),\r
-                        &Pci\r
-                        );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = EFI_UNSUPPORTED;\r
-  //\r
-  // See if the device is an enabled VGA device.\r
-  // Most systems can only have on VGA device on at a time.\r
-  //\r
-  if (((Pci.Hdr.Command & 0x03) == 0x03) && IS_PCI_VGA (&Pci)) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-\r
-Done:\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiPciIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Starts the VGA device with this driver.\r
-\r
-  This function consumes PCI I/O Protocol, and installs VGA Mini Port Protocol\r
-  onto the VGA device handle.\r
-\r
-  @param  This                   The driver binding instance.\r
-  @param  Controller             The controller to check.\r
-  @param  RemainingDevicePath    The remaining device patch.\r
-\r
-  @retval EFI_SUCCESS            The controller is controlled by the driver.\r
-  @retval EFI_ALREADY_STARTED    The controller is already controlled by the driver.\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-  PCI_VGA_MINI_PORT_DEV *PciVgaMiniPortPrivate;\r
-\r
-  PciVgaMiniPortPrivate = NULL;\r
-  PciIo                 = NULL;\r
-  //\r
-  // Open the IO Abstraction(s) needed\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Allocate the private device structure\r
-  //\r
-  PciVgaMiniPortPrivate = AllocateZeroPool (sizeof (PCI_VGA_MINI_PORT_DEV));\r
-  ASSERT (PciVgaMiniPortPrivate != NULL);\r
-\r
-  //\r
-  // Initialize the private device structure\r
-  //\r
-  PciVgaMiniPortPrivate->Signature = PCI_VGA_MINI_PORT_DEV_SIGNATURE;\r
-  PciVgaMiniPortPrivate->Handle = Controller;\r
-  PciVgaMiniPortPrivate->PciIo = PciIo;\r
-\r
-  PciVgaMiniPortPrivate->VgaMiniPort.SetMode = PciVgaMiniPortSetMode;\r
-  PciVgaMiniPortPrivate->VgaMiniPort.VgaMemoryOffset = 0xb8000;\r
-  PciVgaMiniPortPrivate->VgaMiniPort.CrtcAddressRegisterOffset = 0x3d4;\r
-  PciVgaMiniPortPrivate->VgaMiniPort.CrtcDataRegisterOffset = 0x3d5;\r
-  PciVgaMiniPortPrivate->VgaMiniPort.VgaMemoryBar = EFI_PCI_IO_PASS_THROUGH_BAR;\r
-  PciVgaMiniPortPrivate->VgaMiniPort.CrtcAddressRegisterBar = EFI_PCI_IO_PASS_THROUGH_BAR;\r
-  PciVgaMiniPortPrivate->VgaMiniPort.CrtcDataRegisterBar = EFI_PCI_IO_PASS_THROUGH_BAR;\r
-  PciVgaMiniPortPrivate->VgaMiniPort.MaxMode = 1;\r
-\r
-  //\r
-  // Install VGA Mini Port Protocol\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiVgaMiniPortProtocolGuid,\r
-                  &PciVgaMiniPortPrivate->VgaMiniPort,\r
-                  NULL\r
-                  );\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiPciIoProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-    if (PciVgaMiniPortPrivate != NULL) {\r
-      FreePool (PciVgaMiniPortPrivate);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Stop the VGA device with this driver.\r
-\r
-  This function uninstalls VGA Mini Port Protocol from the VGA device handle,\r
-  and closes PCI I/O Protocol.\r
-\r
-  @param  This                   The driver binding protocol.\r
-  @param  Controller             The controller to release.\r
-  @param  NumberOfChildren       The child number that opened controller\r
-                                 BY_CHILD.\r
-  @param  ChildHandleBuffer      The array of child handle.\r
-\r
-  @retval EFI_SUCCESS            The controller or children are stopped.\r
-  @retval EFI_DEVICE_ERROR       Failed to stop the driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Controller,\r
-  IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_VGA_MINI_PORT_PROTOCOL  *VgaMiniPort;\r
-  PCI_VGA_MINI_PORT_DEV       *PciVgaMiniPortPrivate;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiVgaMiniPortProtocolGuid,\r
-                  (VOID **) &VgaMiniPort,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  PciVgaMiniPortPrivate = PCI_VGA_MINI_PORT_DEV_FROM_THIS (VgaMiniPort);\r
-\r
-  Status = gBS->UninstallProtocolInterface (\r
-                  Controller,\r
-                  &gEfiVgaMiniPortProtocolGuid,\r
-                  &PciVgaMiniPortPrivate->VgaMiniPort\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiPciIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  FreePool (PciVgaMiniPortPrivate);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-//\r
-// VGA Mini Port Protocol Functions\r
-//\r
-\r
-/**\r
-  Sets the text display mode of a VGA controller.\r
-\r
-  This function implements EFI_VGA_MINI_PORT_PROTOCOL.SetMode().\r
-  If ModeNumber exceeds the valid range, then EFI_UNSUPPORTED is returned.\r
-  Otherwise, EFI_SUCCESS is directly returned without real operation.\r
-\r
-  @param This                 Protocol instance pointer.\r
-  @param ModeNumber           Mode number.  0 - 80x25   1-80x50\r
-\r
-  @retval EFI_SUCCESS         The mode was set\r
-  @retval EFI_UNSUPPORTED     ModeNumber is not supported.\r
-  @retval EFI_DEVICE_ERROR    The device is not functioning properly.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortSetMode (\r
-  IN  EFI_VGA_MINI_PORT_PROTOCOL  *This,\r
-  IN  UINTN                       ModeNumber\r
-  )\r
-{\r
-  if (ModeNumber > This->MaxMode) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.h b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.h
deleted file mode 100644 (file)
index ee5c5be..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-/** @file\r
-  Internal include file for VGA Mini Port Driver.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _VGA_MINIPORT_H_\r
-#define _VGA_MINIPORT_H_\r
-\r
-//\r
-// The package level header files this module uses\r
-//\r
-#include <PiDxe.h>\r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/VgaMiniPort.h>\r
-#include <Protocol/ComponentName2.h>\r
-\r
-\r
-//\r
-// The Library classes this module consumes\r
-//\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL  gPciVgaMiniPortDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gPciVgaMiniPortComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gPciVgaMiniPortComponentName2;\r
-\r
-//\r
-// PCI VGA MiniPort Device Structure\r
-//\r
-#define PCI_VGA_MINI_PORT_DEV_SIGNATURE   SIGNATURE_32('P','V','M','P')\r
-\r
-typedef struct {\r
-  UINTN                         Signature;\r
-  EFI_HANDLE                    Handle;\r
-  EFI_VGA_MINI_PORT_PROTOCOL    VgaMiniPort;\r
-  EFI_PCI_IO_PROTOCOL           *PciIo;\r
-} PCI_VGA_MINI_PORT_DEV;\r
-\r
-#define PCI_VGA_MINI_PORT_DEV_FROM_THIS(a) CR(a, PCI_VGA_MINI_PORT_DEV, VgaMiniPort, PCI_VGA_MINI_PORT_DEV_SIGNATURE)\r
-\r
-//\r
-// Driver Binding Protocol functions\r
-//\r
-/**\r
-  Check whether VGA Mini Port driver supports this device.\r
-\r
-  @param  This                   The driver binding protocol.\r
-  @param  Controller             The controller handle to check.\r
-  @param  RemainingDevicePath    The remaining device path.\r
-\r
-  @retval EFI_SUCCESS            The driver supports this controller.\r
-  @retval EFI_UNSUPPORTED        This device isn't supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Starts the VGA device with this driver.\r
-\r
-  This function consumes PCI I/O Protocol, and installs VGA Mini Port Protocol\r
-  onto the VGA device handle.\r
-\r
-  @param  This                   The driver binding instance.\r
-  @param  Controller             The controller to check.\r
-  @param  RemainingDevicePath    The remaining device patch.\r
-\r
-  @retval EFI_SUCCESS            The controller is controlled by the driver.\r
-  @retval EFI_ALREADY_STARTED    The controller is already controlled by the driver.\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Stop the VGA device with this driver.\r
-\r
-  This function uninstalls VGA Mini Port Protocol from the VGA device handle,\r
-  and closes PCI I/O Protocol.\r
-\r
-  @param  This                   The driver binding protocol.\r
-  @param  Controller             The controller to release.\r
-  @param  NumberOfChildren       The child number that opened controller\r
-                                 BY_CHILD.\r
-  @param  ChildHandleBuffer      The array of child handle.\r
-\r
-  @retval EFI_SUCCESS            The controller or children are stopped.\r
-  @retval EFI_DEVICE_ERROR       Failed to stop the driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param  Language              A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-  @param  DriverName            A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param  ControllerHandle      The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-  @param  ChildHandle           The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-  @param  Language              A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-  @param  ControllerName        A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-//\r
-// VGA Mini Port Protocol functions\r
-//\r
-/**\r
-  Sets the text display mode of a VGA controller.\r
-\r
-  This function implements EFI_VGA_MINI_PORT_PROTOCOL.SetMode().\r
-  If ModeNumber exceeds the valid range, then EFI_UNSUPPORTED is returned.\r
-  Otherwise, EFI_SUCCESS is directly returned without real operation.\r
-\r
-  @param This                 Protocol instance pointer.\r
-  @param ModeNumber           Mode number.  0 - 80x25   1-80x50\r
-\r
-  @retval EFI_SUCCESS         The mode was set\r
-  @retval EFI_UNSUPPORTED     ModeNumber is not supported.\r
-  @retval EFI_DEVICE_ERROR    The device is not functioning properly.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciVgaMiniPortSetMode (\r
-  IN  EFI_VGA_MINI_PORT_PROTOCOL  *This,\r
-  IN  UINTN                       ModeNumber\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.uni b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.uni
deleted file mode 100644 (file)
index 073d902..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// VGA Mini Port Driver that manages VGA device and produces VGA Mini Port Protocol.\r
-//\r
-// VGA Mini Port Driver that manages VGA device and produces the VGA Mini Port Protocol.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "VGA Mini Port Driver that manages VGA device and produces the VGA Mini Port Protocol"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "VGA Mini Port Driver that manages VGA device and produces the VGA Mini Port Protocol."\r
-\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf
deleted file mode 100644 (file)
index 151df78..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-## @file\r
-# VGA Mini Port Driver that manages VGA device and produces VGA Mini Port Protocol.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = VgaMiniPort\r
-  MODULE_UNI_FILE                = VgaMiniPort.uni\r
-  FILE_GUID                      = 15C5E761-58D8-461a-9173-CAB020916264\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = PciVgaMiniPortDriverEntryPoint\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#  DRIVER_BINDING                = gPciVgaMiniPortDriverBinding;\r
-#  COMPONENT_NAME                = gPciVgaMiniPortComponentName;\r
-#  COMPONENT_NAME2               = gPciVgaMiniPortComponentName2;\r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  VgaMiniPort.c\r
-  VgaMiniPort.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiLib\r
-  DebugLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  BaseMemoryLib\r
-  MemoryAllocationLib\r
-\r
-[Protocols]\r
-  gEfiPciIoProtocolGuid                         ## TO_START\r
-  gEfiVgaMiniPortProtocolGuid                   ## BY_START\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  VgaMiniPortExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortExtra.uni b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortExtra.uni
deleted file mode 100644 (file)
index a1d747c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// VgaMiniPort Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"VGA Mini Port DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosBlkIo.c b/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosBlkIo.c
deleted file mode 100644 (file)
index e580e1a..0000000
+++ /dev/null
@@ -1,773 +0,0 @@
-/** @file\r
-  EFI glue for BIOS INT 13h block devices.\r
-\r
-  This file is coded to EDD 3.0 as defined by T13 D1386 Revision 4\r
-  Availible on http://www.t13.org/#Project drafts\r
-  Currently at ftp://fission.dt.wdc.com/pub/standards/x3t13/project/d1386r4.pdf\r
-\r
-Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosBlkIo.h"\r
-\r
-//\r
-// Global data declaration\r
-//\r
-//\r
-// EFI Driver Binding Protocol Instance\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gBiosBlockIoDriverBinding = {\r
-  BiosBlockIoDriverBindingSupported,\r
-  BiosBlockIoDriverBindingStart,\r
-  BiosBlockIoDriverBindingStop,\r
-  0x3,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-//\r
-// Semaphore to control access to global variables mActiveInstances and mBufferUnder1Mb\r
-//\r
-EFI_LOCK                    mGlobalDataLock = EFI_INITIALIZE_LOCK_VARIABLE(TPL_APPLICATION);\r
-\r
-//\r
-// Number of active instances of this protocol.  This is used to allocate/free\r
-// the shared buffer.  You must acquire the semaphore to modify.\r
-//\r
-UINTN                       mActiveInstances = 0;\r
-\r
-//\r
-// Pointer to the beginning of the buffer used for real mode thunk\r
-// You must acquire the semaphore to modify.\r
-//\r
-EFI_PHYSICAL_ADDRESS        mBufferUnder1Mb = 0;\r
-\r
-//\r
-// Address packet is a buffer under 1 MB for all version EDD calls\r
-//\r
-EDD_DEVICE_ADDRESS_PACKET   *mEddBufferUnder1Mb;\r
-\r
-//\r
-// This is a buffer for INT 13h func 48 information\r
-//\r
-BIOS_LEGACY_DRIVE           *mLegacyDriverUnder1Mb;\r
-\r
-//\r
-// Buffer of 0xFE00 bytes for EDD 1.1 transfer must be under 1 MB\r
-//  0xFE00 bytes is the max transfer size supported.\r
-//\r
-VOID                        *mEdd11Buffer;\r
-\r
-/**\r
-  Driver entry point.\r
-\r
-  @param  ImageHandle  Handle of driver image.\r
-  @param  SystemTable  Pointer to system table.\r
-\r
-  @retval EFI_SUCCESS  Entrypoint successfully executed.\r
-  @retval Others       Fail to execute entrypoint.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverEntryPoint (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Install protocols\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gBiosBlockIoDriverBinding,\r
-             ImageHandle,\r
-             &gBiosBlockIoComponentName,\r
-             &gBiosBlockIoComponentName2\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Install Legacy BIOS GUID to mark this driver as a BIOS Thunk Driver\r
-  //\r
-  return gBS->InstallMultipleProtocolInterfaces (\r
-                &ImageHandle,\r
-                &gEfiLegacyBiosGuid,\r
-                NULL,\r
-                NULL\r
-                );\r
-}\r
-\r
-/**\r
-  Check whether the driver supports this device.\r
-\r
-  @param  This                   The Udriver binding protocol.\r
-  @param  Controller             The controller handle to check.\r
-  @param  RemainingDevicePath    The remaining device path.\r
-\r
-  @retval EFI_SUCCESS            The driver supports this controller.\r
-  @retval other                  This device isn't supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  PCI_TYPE00                Pci;\r
-\r
-  //\r
-  // See if the Legacy BIOS Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiDevicePathProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // See if this is a PCI VGA Controller by looking at the Command register and\r
-  // Class Code Register\r
-  //\r
-  Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, sizeof (Pci) / sizeof (UINT32), &Pci);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Done;\r
-  }\r
-\r
-  Status = EFI_UNSUPPORTED;\r
-  if (Pci.Hdr.ClassCode[2] == PCI_CLASS_MASS_STORAGE ||\r
-      (Pci.Hdr.ClassCode[2] == PCI_BASE_CLASS_INTELLIGENT && Pci.Hdr.ClassCode[1] == PCI_SUB_CLASS_INTELLIGENT)\r
-      ) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-\r
-Done:\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiPciIoProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Starts the device with this driver.\r
-\r
-  @param  This                   The driver binding instance.\r
-  @param  Controller             Handle of device to bind driver to.\r
-  @param  RemainingDevicePath    Optional parameter use to pick a specific child\r
-                                 device to start.\r
-\r
-  @retval EFI_SUCCESS            The controller is controlled by the driver.\r
-  @retval Other                  This controller cannot be started.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-  UINT8                     DiskStart;\r
-  UINT8                     DiskEnd;\r
-  BIOS_BLOCK_IO_DEV         *BiosBlockIoPrivate;\r
-  EFI_DEVICE_PATH_PROTOCOL  *PciDevPath;\r
-  UINTN                     Index;\r
-  UINTN                     Flags;\r
-  UINTN                     TmpAddress;\r
-  BOOLEAN                   DeviceEnable;\r
-\r
-  //\r
-  // Initialize variables\r
-  //\r
-  PciIo      = NULL;\r
-  PciDevPath = NULL;\r
-\r
-  DeviceEnable = FALSE;\r
-\r
-  //\r
-  // See if the Legacy BIOS Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-  //\r
-  // Open the IO Abstraction(s) needed\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &PciDevPath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-  //\r
-  // Enable the device and make sure VGA cycles are being forwarded to this VGA device\r
-  //\r
-  Status = PciIo->Attributes (\r
-                    PciIo,\r
-                    EfiPciIoAttributeOperationEnable,\r
-                    EFI_PCI_DEVICE_ENABLE,\r
-                    NULL\r
-                    );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-\r
-  DeviceEnable = TRUE;\r
-\r
-  //\r
-  // Check to see if there is a legacy option ROM image associated with this PCI device\r
-  //\r
-  Status = LegacyBios->CheckPciRom (\r
-                        LegacyBios,\r
-                        Controller,\r
-                        NULL,\r
-                        NULL,\r
-                        &Flags\r
-                        );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-  //\r
-  // Post the legacy option ROM if it is available.\r
-  //\r
-  Status = LegacyBios->InstallPciRom (\r
-                        LegacyBios,\r
-                        Controller,\r
-                        NULL,\r
-                        &Flags,\r
-                        &DiskStart,\r
-                        &DiskEnd,\r
-                        NULL,\r
-                        NULL\r
-                        );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-  //\r
-  // All instances share a buffer under 1MB to put real mode thunk code in\r
-  // If it has not been allocated, then we allocate it.\r
-  //\r
-  if (mBufferUnder1Mb == 0) {\r
-    //\r
-    // Should only be here if there are no active instances\r
-    //\r
-    ASSERT (mActiveInstances == 0);\r
-\r
-    //\r
-    // Acquire the lock\r
-    //\r
-    EfiAcquireLock (&mGlobalDataLock);\r
-\r
-    //\r
-    // Allocate below 1MB\r
-    //\r
-    mBufferUnder1Mb = 0x00000000000FFFFF;\r
-    Status          = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, BLOCK_IO_BUFFER_PAGE_SIZE, &mBufferUnder1Mb);\r
-\r
-    //\r
-    // Release the lock\r
-    //\r
-    EfiReleaseLock (&mGlobalDataLock);\r
-\r
-    //\r
-    // Check memory allocation success\r
-    //\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // In checked builds we want to assert if the allocate failed.\r
-      //\r
-      ASSERT_EFI_ERROR (Status);\r
-      Status          = EFI_OUT_OF_RESOURCES;\r
-      mBufferUnder1Mb = 0;\r
-      goto Error;\r
-    }\r
-\r
-    TmpAddress = (UINTN) mBufferUnder1Mb;\r
-    //\r
-    // Adjusting the value to be on proper boundary\r
-    //\r
-    mEdd11Buffer = (VOID *) ALIGN_VARIABLE (TmpAddress);\r
-\r
-    TmpAddress   = (UINTN) mEdd11Buffer + MAX_EDD11_XFER;\r
-    //\r
-    // Adjusting the value to be on proper boundary\r
-    //\r
-    mLegacyDriverUnder1Mb = (BIOS_LEGACY_DRIVE *) ALIGN_VARIABLE (TmpAddress);\r
-\r
-    TmpAddress = (UINTN) mLegacyDriverUnder1Mb + sizeof (BIOS_LEGACY_DRIVE);\r
-    //\r
-    // Adjusting the value to be on proper boundary\r
-    //\r
-    mEddBufferUnder1Mb = (EDD_DEVICE_ADDRESS_PACKET *) ALIGN_VARIABLE (TmpAddress);\r
-  }\r
-  //\r
-  // Allocate the private device structure for each disk\r
-  //\r
-  for (Index = DiskStart; Index < DiskEnd; Index++) {\r
-\r
-    Status = gBS->AllocatePool (\r
-                    EfiBootServicesData,\r
-                    sizeof (BIOS_BLOCK_IO_DEV),\r
-                    (VOID **) &BiosBlockIoPrivate\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      goto Error;\r
-    }\r
-    //\r
-    // Zero the private device structure\r
-    //\r
-    ZeroMem (BiosBlockIoPrivate, sizeof (BIOS_BLOCK_IO_DEV));\r
-\r
-    //\r
-    // Initialize the private device structure\r
-    //\r
-    BiosBlockIoPrivate->Signature                 = BIOS_CONSOLE_BLOCK_IO_DEV_SIGNATURE;\r
-    BiosBlockIoPrivate->ControllerHandle          = Controller;\r
-    BiosBlockIoPrivate->LegacyBios                = LegacyBios;\r
-    BiosBlockIoPrivate->PciIo                     = PciIo;\r
-\r
-    BiosBlockIoPrivate->Bios.Floppy               = FALSE;\r
-    BiosBlockIoPrivate->Bios.Number               = (UINT8) Index;\r
-    BiosBlockIoPrivate->Bios.Letter               = (UINT8) (Index - 0x80 + 'C');\r
-    BiosBlockIoPrivate->BlockMedia.RemovableMedia = FALSE;\r
-\r
-    if (BiosInitBlockIo (BiosBlockIoPrivate)) {\r
-      SetBiosInitBlockIoDevicePath (PciDevPath, &BiosBlockIoPrivate->Bios, &BiosBlockIoPrivate->DevicePath);\r
-\r
-      //\r
-      // Install the Block Io Protocol onto a new child handle\r
-      //\r
-      Status = gBS->InstallMultipleProtocolInterfaces (\r
-                      &BiosBlockIoPrivate->Handle,\r
-                      &gEfiBlockIoProtocolGuid,\r
-                      &BiosBlockIoPrivate->BlockIo,\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      BiosBlockIoPrivate->DevicePath,\r
-                      NULL\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        gBS->FreePool (BiosBlockIoPrivate);\r
-      }\r
-      //\r
-      // Open For Child Device\r
-      //\r
-      Status = gBS->OpenProtocol (\r
-                      Controller,\r
-                      &gEfiPciIoProtocolGuid,\r
-                      (VOID **) &BiosBlockIoPrivate->PciIo,\r
-                      This->DriverBindingHandle,\r
-                      BiosBlockIoPrivate->Handle,\r
-                      EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                      );\r
-\r
-    } else {\r
-      gBS->FreePool (BiosBlockIoPrivate);\r
-    }\r
-  }\r
-\r
-Error:\r
-  if (EFI_ERROR (Status)) {\r
-    if (PciIo != NULL) {\r
-      if (DeviceEnable) {\r
-        PciIo->Attributes (\r
-                PciIo,\r
-                EfiPciIoAttributeOperationDisable,\r
-                EFI_PCI_DEVICE_ENABLE,\r
-                NULL\r
-                );\r
-      }\r
-      gBS->CloseProtocol (\r
-            Controller,\r
-            &gEfiPciIoProtocolGuid,\r
-            This->DriverBindingHandle,\r
-            Controller\r
-            );\r
-      if (PciDevPath != NULL) {\r
-        gBS->CloseProtocol (\r
-              Controller,\r
-              &gEfiDevicePathProtocolGuid,\r
-              This->DriverBindingHandle,\r
-              Controller\r
-              );\r
-      }\r
-      if (mBufferUnder1Mb != 0 && mActiveInstances == 0) {\r
-        gBS->FreePages (mBufferUnder1Mb, BLOCK_IO_BUFFER_PAGE_SIZE);\r
-\r
-        //\r
-        // Clear the buffer back to 0\r
-        //\r
-        EfiAcquireLock (&mGlobalDataLock);\r
-        mBufferUnder1Mb = 0;\r
-        EfiReleaseLock (&mGlobalDataLock);\r
-      }\r
-    }\r
-  } else {\r
-    //\r
-    // Successfully installed, so increment the number of active instances\r
-    //\r
-    EfiAcquireLock (&mGlobalDataLock);\r
-    mActiveInstances++;\r
-    EfiReleaseLock (&mGlobalDataLock);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stop the device handled by this driver.\r
-\r
-  @param  This                   The driver binding protocol.\r
-  @param  Controller             The controller to release.\r
-  @param  NumberOfChildren       The number of handles in ChildHandleBuffer.\r
-  @param  ChildHandleBuffer      The array of child handle.\r
-\r
-  @retval EFI_SUCCESS            The device was stopped.\r
-  @retval EFI_DEVICE_ERROR       The device could not be stopped due to a device error.\r
-  @retval Others                 Fail to uninstall protocols attached on the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Controller,\r
-  IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  BOOLEAN               AllChildrenStopped;\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-  BIOS_BLOCK_IO_DEV     *BiosBlockIoPrivate;\r
-  UINTN                 Index;\r
-\r
-  //\r
-  // Decrement the number of active instances\r
-  //\r
-  if (mActiveInstances != 0) {\r
-    //\r
-    // Add a check since the stop function will be called 2 times for each handle\r
-    //\r
-    EfiAcquireLock (&mGlobalDataLock);\r
-    mActiveInstances--;\r
-    EfiReleaseLock (&mGlobalDataLock);\r
-  }\r
-\r
-  if ((mActiveInstances == 0) && (mBufferUnder1Mb != 0)) {\r
-    //\r
-    // Free our global buffer\r
-    //\r
-    Status = gBS->FreePages (mBufferUnder1Mb, BLOCK_IO_BUFFER_PAGE_SIZE);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    EfiAcquireLock (&mGlobalDataLock);\r
-    mBufferUnder1Mb = 0;\r
-    EfiReleaseLock (&mGlobalDataLock);\r
-  }\r
-\r
-  AllChildrenStopped = TRUE;\r
-\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-    Status = gBS->OpenProtocol (\r
-                    ChildHandleBuffer[Index],\r
-                    &gEfiBlockIoProtocolGuid,\r
-                    (VOID **) &BlockIo,\r
-                    This->DriverBindingHandle,\r
-                    Controller,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    BiosBlockIoPrivate = BIOS_BLOCK_IO_FROM_THIS (BlockIo);\r
-\r
-    //\r
-    // Release PCI I/O and Block IO Protocols on the clild handle.\r
-    //\r
-    Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                    ChildHandleBuffer[Index],\r
-                    &gEfiBlockIoProtocolGuid,\r
-                    &BiosBlockIoPrivate->BlockIo,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    BiosBlockIoPrivate->DevicePath,\r
-                    NULL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      AllChildrenStopped = FALSE;\r
-    }\r
-    //\r
-    // Shutdown the hardware\r
-    //\r
-    BiosBlockIoPrivate->PciIo->Attributes (\r
-                                BiosBlockIoPrivate->PciIo,\r
-                                EfiPciIoAttributeOperationDisable,\r
-                                EFI_PCI_DEVICE_ENABLE,\r
-                                NULL\r
-                                );\r
-\r
-    gBS->CloseProtocol (\r
-          Controller,\r
-          &gEfiPciIoProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          ChildHandleBuffer[Index]\r
-          );\r
-\r
-    gBS->FreePool (BiosBlockIoPrivate);\r
-  }\r
-\r
-  if (!AllChildrenStopped) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Status = gBS->CloseProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  This->DriverBindingHandle,\r
-                  Controller\r
-                  );\r
-\r
-  Status = gBS->CloseProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  This->DriverBindingHandle,\r
-                  Controller\r
-                  );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Build device path for device.\r
-\r
-  @param  BaseDevicePath         Base device path.\r
-  @param  Drive                  Legacy drive.\r
-  @param  DevicePath             Device path for output.\r
-\r
-**/\r
-VOID\r
-SetBiosInitBlockIoDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *BaseDevicePath,\r
-  IN  BIOS_LEGACY_DRIVE         *Drive,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePath\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  BLOCKIO_VENDOR_DEVICE_PATH  VendorNode;\r
-\r
-  Status = EFI_UNSUPPORTED;\r
-\r
-  //\r
-  // BugBug: Check for memory leaks!\r
-  //\r
-  if (Drive->EddVersion == EDD_VERSION_30) {\r
-    //\r
-    // EDD 3.0 case.\r
-    //\r
-    Status = BuildEdd30DevicePath (BaseDevicePath, Drive, DevicePath);\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // EDD 1.1 device case or it is unrecognized EDD 3.0 device\r
-    //\r
-    ZeroMem (&VendorNode, sizeof (VendorNode));\r
-    VendorNode.DevicePath.Header.Type     = HARDWARE_DEVICE_PATH;\r
-    VendorNode.DevicePath.Header.SubType  = HW_VENDOR_DP;\r
-    SetDevicePathNodeLength (&VendorNode.DevicePath.Header, sizeof (VendorNode));\r
-    CopyMem (&VendorNode.DevicePath.Guid, &gBlockIoVendorGuid, sizeof (EFI_GUID));\r
-    VendorNode.LegacyDriveLetter  = Drive->Number;\r
-    *DevicePath                   = AppendDevicePathNode (BaseDevicePath, &VendorNode.DevicePath.Header);\r
-  }\r
-}\r
-\r
-/**\r
-  Build device path for EDD 3.0.\r
-\r
-  @param  BaseDevicePath         Base device path.\r
-  @param  Drive                  Legacy drive.\r
-  @param  DevicePath             Device path for output.\r
-\r
-  @retval EFI_SUCCESS            The device path is built successfully.\r
-  @retval EFI_UNSUPPORTED        It is failed to built device path.\r
-\r
-**/\r
-EFI_STATUS\r
-BuildEdd30DevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *BaseDevicePath,\r
-  IN  BIOS_LEGACY_DRIVE         *Drive,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  **DevicePath\r
-  )\r
-{\r
-  //\r
-  // AVL    UINT64                  Address;\r
-  // AVL    EFI_HANDLE              Handle;\r
-  //\r
-  EFI_DEV_PATH  Node;\r
-  UINT32        Controller;\r
-\r
-  Controller = (UINT32) Drive->Parameters.InterfacePath.Pci.Controller;\r
-\r
-  ZeroMem (&Node, sizeof (Node));\r
-  if ((AsciiStrnCmp ("ATAPI", Drive->Parameters.InterfaceType, 5) == 0) ||\r
-      (AsciiStrnCmp ("ATA", Drive->Parameters.InterfaceType, 3) == 0)\r
-      ) {\r
-    //\r
-    // ATA or ATAPI drive found\r
-    //\r
-    Node.Atapi.Header.Type    = MESSAGING_DEVICE_PATH;\r
-    Node.Atapi.Header.SubType = MSG_ATAPI_DP;\r
-    SetDevicePathNodeLength (&Node.Atapi.Header, sizeof (ATAPI_DEVICE_PATH));\r
-    Node.Atapi.SlaveMaster      = Drive->Parameters.DevicePath.Atapi.Master;\r
-    Node.Atapi.Lun              = Drive->Parameters.DevicePath.Atapi.Lun;\r
-    Node.Atapi.PrimarySecondary = (UINT8) Controller;\r
-  } else {\r
-    //\r
-    // Not an ATA/ATAPI drive\r
-    //\r
-    if (Controller != 0) {\r
-      ZeroMem (&Node, sizeof (Node));\r
-      Node.Controller.Header.Type      = HARDWARE_DEVICE_PATH;\r
-      Node.Controller.Header.SubType   = HW_CONTROLLER_DP;\r
-      SetDevicePathNodeLength (&Node.Controller.Header, sizeof (CONTROLLER_DEVICE_PATH));\r
-      Node.Controller.ControllerNumber = Controller;\r
-      *DevicePath                      = AppendDevicePathNode (*DevicePath, &Node.DevPath);\r
-    }\r
-\r
-    ZeroMem (&Node, sizeof (Node));\r
-\r
-    if (AsciiStrnCmp ("SCSI", Drive->Parameters.InterfaceType, 4) == 0) {\r
-      //\r
-      // SCSI drive\r
-      //\r
-      Node.Scsi.Header.Type     = MESSAGING_DEVICE_PATH;\r
-      Node.Scsi.Header.SubType  = MSG_SCSI_DP;\r
-      SetDevicePathNodeLength (&Node.Scsi.Header, sizeof (SCSI_DEVICE_PATH));\r
-\r
-      //\r
-      // Lun is miss aligned in both EDD and Device Path data structures.\r
-      //  thus we do a byte copy, to prevent alignment traps on IA-64.\r
-      //\r
-      CopyMem (&Node.Scsi.Lun, &Drive->Parameters.DevicePath.Scsi.Lun, sizeof (UINT16));\r
-      Node.Scsi.Pun = Drive->Parameters.DevicePath.Scsi.Pun;\r
-\r
-    } else if (AsciiStrnCmp ("USB", Drive->Parameters.InterfaceType, 3) == 0) {\r
-      //\r
-      // USB drive\r
-      //\r
-      Node.Usb.Header.Type    = MESSAGING_DEVICE_PATH;\r
-      Node.Usb.Header.SubType = MSG_USB_DP;\r
-      SetDevicePathNodeLength (&Node.Usb.Header, sizeof (USB_DEVICE_PATH));\r
-      Node.Usb.ParentPortNumber = (UINT8) Drive->Parameters.DevicePath.Usb.Reserved;\r
-\r
-    } else if (AsciiStrnCmp ("1394", Drive->Parameters.InterfaceType, 4) == 0) {\r
-      //\r
-      // 1394 drive\r
-      //\r
-      Node.F1394.Header.Type    = MESSAGING_DEVICE_PATH;\r
-      Node.F1394.Header.SubType = MSG_1394_DP;\r
-      SetDevicePathNodeLength (&Node.F1394.Header, sizeof (F1394_DEVICE_PATH));\r
-      Node.F1394.Guid = Drive->Parameters.DevicePath.FireWire.Guid;\r
-\r
-    } else if (AsciiStrnCmp ("FIBRE", Drive->Parameters.InterfaceType, 5) == 0) {\r
-      //\r
-      // Fibre drive\r
-      //\r
-      Node.FibreChannel.Header.Type     = MESSAGING_DEVICE_PATH;\r
-      Node.FibreChannel.Header.SubType  = MSG_FIBRECHANNEL_DP;\r
-      SetDevicePathNodeLength (&Node.FibreChannel.Header, sizeof (FIBRECHANNEL_DEVICE_PATH));\r
-      Node.FibreChannel.WWN = Drive->Parameters.DevicePath.FibreChannel.Wwn;\r
-      Node.FibreChannel.Lun = Drive->Parameters.DevicePath.FibreChannel.Lun;\r
-\r
-    } else {\r
-      DEBUG (\r
-        (\r
-        DEBUG_BLKIO, "It is unrecognized EDD 3.0 device, Drive Number = %x, InterfaceType = %s\n",\r
-        Drive->Number,\r
-        Drive->Parameters.InterfaceType\r
-        )\r
-        );\r
-    }\r
-  }\r
-\r
-  if (Node.DevPath.Type == 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  *DevicePath = AppendDevicePathNode (BaseDevicePath, &Node.DevPath);\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosBlkIo.h b/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosBlkIo.h
deleted file mode 100644 (file)
index 61efafb..0000000
+++ /dev/null
@@ -1,425 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _BIOS_BLOCK_IO_H_\r
-#define _BIOS_BLOCK_IO_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/LegacyBios.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Guid/LegacyBios.h>\r
-#include <Guid/BlockIoVendor.h>\r
-\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-\r
-#include "Edd.h"\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gBiosBlockIoComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gBiosBlockIoComponentName2;\r
-\r
-\r
-//\r
-// Define the I2O class code\r
-//\r
-#define PCI_BASE_CLASS_INTELLIGENT  0x0e\r
-#define PCI_SUB_CLASS_INTELLIGENT   0x00\r
-\r
-//\r
-// Number of pages needed for our buffer under 1MB\r
-//\r
-#define BLOCK_IO_BUFFER_PAGE_SIZE (((sizeof (EDD_DEVICE_ADDRESS_PACKET) + sizeof (BIOS_LEGACY_DRIVE) + MAX_EDD11_XFER) / EFI_PAGE_SIZE) + 1 \\r
-        )\r
-\r
-//\r
-// Driver Binding Protocol functions\r
-//\r
-\r
-/**\r
-  Check whether the driver supports this device.\r
-\r
-  @param  This                   The Udriver binding protocol.\r
-  @param  Controller             The controller handle to check.\r
-  @param  RemainingDevicePath    The remaining device path.\r
-\r
-  @retval EFI_SUCCESS            The driver supports this controller.\r
-  @retval other                  This device isn't supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-\r
-/**\r
-  Starts the device with this driver.\r
-\r
-  @param  This                   The driver binding instance.\r
-  @param  Controller             Handle of device to bind driver to.\r
-  @param  RemainingDevicePath    Optional parameter use to pick a specific child\r
-                                 device to start.\r
-\r
-  @retval EFI_SUCCESS            The controller is controlled by the driver.\r
-  @retval Other                  This controller cannot be started.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Stop the device handled by this driver.\r
-\r
-  @param  This                   The driver binding protocol.\r
-  @param  Controller             The controller to release.\r
-  @param  NumberOfChildren       The number of handles in ChildHandleBuffer.\r
-  @param  ChildHandleBuffer      The array of child handle.\r
-\r
-  @retval EFI_SUCCESS            The device was stopped.\r
-  @retval EFI_DEVICE_ERROR       The device could not be stopped due to a device error.\r
-  @retval Others                 Fail to uninstall protocols attached on the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// Other internal functions\r
-//\r
-\r
-/**\r
-  Build device path for EDD 3.0.\r
-\r
-  @param  BaseDevicePath         Base device path.\r
-  @param  Drive                  Legacy drive.\r
-  @param  DevicePath             Device path for output.\r
-\r
-  @retval EFI_SUCCESS            The device path is built successfully.\r
-  @retval EFI_UNSUPPORTED        It is failed to built device path.\r
-\r
-**/\r
-EFI_STATUS\r
-BuildEdd30DevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *BaseDevicePath,\r
-  IN  BIOS_LEGACY_DRIVE         *Drive,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  **DevicePath\r
-  );\r
-\r
-/**\r
-  Initialize block I/O device instance\r
-\r
-  @param  Dev   Instance of block I/O device instance\r
-\r
-  @retval TRUE  Initialization succeeds.\r
-  @retval FALSE Initialization fails.\r
-\r
-**/\r
-BOOLEAN\r
-BiosInitBlockIo (\r
-  IN  BIOS_BLOCK_IO_DEV     *Dev\r
-  );\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    Id of the media, changes every time the media is replaced.\r
-  @param  Lba        The starting Logical Block Address to read from\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
-                     responsible for either having implicit or explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd30BiosReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  );\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    The media ID that the write request is for.\r
-  @param  Lba        The starting logical block address to be written. The caller is\r
-                     responsible for writing to only legitimate locations.\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The data was written correctly to the device.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd30BiosWriteBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  UINT32                 MediaId,\r
-  IN  EFI_LBA                Lba,\r
-  IN  UINTN                  BufferSize,\r
-  OUT VOID                   *Buffer\r
-  );\r
-\r
-/**\r
-  Flush the Block Device.\r
-\r
-  @param  This              Indicates a pointer to the calling context.\r
-\r
-  @retval EFI_SUCCESS       All outstanding data was written to the device\r
-  @retval EFI_DEVICE_ERROR  The device reported an error while writting back the data\r
-  @retval EFI_NO_MEDIA      There is no media in the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoFlushBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Reset the Block Device.\r
-\r
-  @param  This                 Indicates a pointer to the calling context.\r
-  @param  ExtendedVerification Driver may perform diagnostics on reset.\r
-\r
-  @retval EFI_SUCCESS          The device was reset.\r
-  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
-                               not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoReset (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This,\r
-  IN  BOOLEAN                ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    Id of the media, changes every time the media is replaced.\r
-  @param  Lba        The starting Logical Block Address to read from\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
-                     responsible for either having implicit or explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd11BiosReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  );\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    The media ID that the write request is for.\r
-  @param  Lba        The starting logical block address to be written. The caller is\r
-                     responsible for writing to only legitimate locations.\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The data was written correctly to the device.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd11BiosWriteBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  );\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    Id of the media, changes every time the media is replaced.\r
-  @param  Lba        The starting Logical Block Address to read from\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
-                     responsible for either having implicit or explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosReadLegacyDrive (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  );\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    The media ID that the write request is for.\r
-  @param  Lba        The starting logical block address to be written. The caller is\r
-                     responsible for writing to only legitimate locations.\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The data was written correctly to the device.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosWriteLegacyDrive (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  );\r
-\r
-/**\r
-  Gets parameters of block I/O device.\r
-\r
-  @param  BiosBlockIoDev Instance of block I/O device.\r
-  @param  Drive          Legacy drive.\r
-\r
-  @return  Result of device parameter retrieval.\r
-\r
-**/\r
-UINTN\r
-Int13GetDeviceParameters (\r
-  IN BIOS_BLOCK_IO_DEV    *BiosBlockIoDev,\r
-  IN BIOS_LEGACY_DRIVE    *Drive\r
-  );\r
-\r
-/**\r
-  Extension of INT13 call.\r
-\r
-  @param  BiosBlockIoDev Instance of block I/O device.\r
-  @param  Drive          Legacy drive.\r
-\r
-  @return  Result of this extension.\r
-\r
-**/\r
-UINTN\r
-Int13Extensions (\r
-  IN BIOS_BLOCK_IO_DEV    *BiosBlockIoDev,\r
-  IN BIOS_LEGACY_DRIVE    *Drive\r
-  );\r
-\r
-/**\r
-  Gets parameters of legacy drive.\r
-\r
-  @param  BiosBlockIoDev Instance of block I/O device.\r
-  @param  Drive          Legacy drive.\r
-\r
-  @return  Result of drive parameter retrieval.\r
-\r
-**/\r
-UINTN\r
-GetDriveParameters (\r
-  IN BIOS_BLOCK_IO_DEV    *BiosBlockIoDev,\r
-  IN  BIOS_LEGACY_DRIVE   *Drive\r
-  );\r
-\r
-/**\r
-  Build device path for device.\r
-\r
-  @param  BaseDevicePath         Base device path.\r
-  @param  Drive                  Legacy drive.\r
-  @param  DevicePath             Device path for output.\r
-\r
-**/\r
-VOID\r
-SetBiosInitBlockIoDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *BaseDevicePath,\r
-  IN  BIOS_LEGACY_DRIVE         *Drive,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePath\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosInt13.c b/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosInt13.c
deleted file mode 100644 (file)
index 082a674..0000000
+++ /dev/null
@@ -1,1488 +0,0 @@
-/** @file\r
-  Routines that use BIOS to support INT 13 devices.\r
-\r
-Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosBlkIo.h"\r
-\r
-//\r
-// Module global variables\r
-//\r
-//\r
-// Address packet is a buffer under 1 MB for all version EDD calls\r
-//\r
-extern EDD_DEVICE_ADDRESS_PACKET  *mEddBufferUnder1Mb;\r
-\r
-//\r
-// This is a buffer for INT 13h func 48 information\r
-//\r
-extern BIOS_LEGACY_DRIVE          *mLegacyDriverUnder1Mb;\r
-\r
-//\r
-// Buffer of 0xFE00 bytes for EDD 1.1 transfer must be under 1 MB\r
-//  0xFE00 bytes is the max transfer size supported.\r
-//\r
-extern VOID                       *mEdd11Buffer;\r
-\r
-\r
-/**\r
-  Initialize block I/O device instance\r
-\r
-  @param  Dev   Instance of block I/O device instance\r
-\r
-  @retval TRUE  Initialization succeeds.\r
-  @retval FALSE Initialization fails.\r
-\r
-**/\r
-BOOLEAN\r
-BiosInitBlockIo (\r
-  IN  BIOS_BLOCK_IO_DEV         *Dev\r
-  )\r
-{\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-  EFI_BLOCK_IO_MEDIA    *BlockMedia;\r
-  BIOS_LEGACY_DRIVE     *Bios;\r
-\r
-  BlockIo         = &Dev->BlockIo;\r
-  BlockIo->Media  = &Dev->BlockMedia;\r
-  BlockMedia      = BlockIo->Media;\r
-  Bios            = &Dev->Bios;\r
-\r
-  if (Int13GetDeviceParameters (Dev, Bios) != 0) {\r
-    if (Int13Extensions (Dev, Bios) != 0) {\r
-      BlockMedia->LastBlock = (EFI_LBA) Bios->Parameters.PhysicalSectors - 1;\r
-      BlockMedia->BlockSize = (UINT32) Bios->Parameters.BytesPerSector;\r
-\r
-      if ((Bios->Parameters.Flags & EDD_DEVICE_REMOVABLE) == EDD_DEVICE_REMOVABLE) {\r
-        BlockMedia->RemovableMedia = TRUE;\r
-      }\r
-\r
-    } else {\r
-      //\r
-      // Legacy Interfaces\r
-      //\r
-      BlockMedia->BlockSize = 512;\r
-      BlockMedia->LastBlock = (Bios->MaxHead + 1) * Bios->MaxSector * (Bios->MaxCylinder + 1) - 1;\r
-    }\r
-\r
-    DEBUG ((DEBUG_INIT, "BlockSize = %d  LastBlock = %d\n", BlockMedia->BlockSize, BlockMedia->LastBlock));\r
-\r
-    BlockMedia->LogicalPartition  = FALSE;\r
-    BlockMedia->WriteCaching      = FALSE;\r
-\r
-    //\r
-    // BugBug: Need to set this for removable media devices if they do not\r
-    //  have media present\r
-    //\r
-    BlockMedia->ReadOnly      = FALSE;\r
-    BlockMedia->MediaPresent  = TRUE;\r
-\r
-    BlockIo->Reset            = BiosBlockIoReset;\r
-    BlockIo->FlushBlocks      = BiosBlockIoFlushBlocks;\r
-\r
-    if (!Bios->ExtendedInt13) {\r
-      //\r
-      // Legacy interfaces\r
-      //\r
-      BlockIo->ReadBlocks   = BiosReadLegacyDrive;\r
-      BlockIo->WriteBlocks  = BiosWriteLegacyDrive;\r
-    } else if ((Bios->EddVersion == EDD_VERSION_30) && (Bios->Extensions64Bit)) {\r
-      //\r
-      // EDD 3.0 Required for Device path, but extended reads are not required.\r
-      //\r
-      BlockIo->ReadBlocks   = Edd30BiosReadBlocks;\r
-      BlockIo->WriteBlocks  = Edd30BiosWriteBlocks;\r
-    } else {\r
-      //\r
-      // Assume EDD 1.1 - Read and Write functions.\r
-      //  This could be EDD 3.0 without Extensions64Bit being set.\r
-      // If it's EDD 1.1 this will work, but the device path will not\r
-      //  be correct. This will cause confusion to EFI OS installation.\r
-      //\r
-      BlockIo->ReadBlocks   = Edd11BiosReadBlocks;\r
-      BlockIo->WriteBlocks  = Edd11BiosWriteBlocks;\r
-    }\r
-\r
-    BlockMedia->LogicalPartition  = FALSE;\r
-    BlockMedia->WriteCaching      = FALSE;\r
-\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Gets parameters of block I/O device.\r
-\r
-  @param  BiosBlockIoDev Instance of block I/O device.\r
-  @param  Drive          Legacy drive.\r
-\r
-  @return  Result of device parameter retrieval.\r
-\r
-**/\r
-UINTN\r
-Int13GetDeviceParameters (\r
-  IN  BIOS_BLOCK_IO_DEV    *BiosBlockIoDev,\r
-  IN  BIOS_LEGACY_DRIVE    *Drive\r
-  )\r
-{\r
-  UINTN                 CarryFlag;\r
-  UINT16                Cylinder;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  Regs.H.AH = 0x08;\r
-  Regs.H.DL = Drive->Number;\r
-  CarryFlag = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-  DEBUG ((DEBUG_INIT, "Int13GetDeviceParameters: INT 13 08 DL=%02x : CF=%d AH=%02x\n", Drive->Number, CarryFlag, Regs.H.AH));\r
-  if (CarryFlag != 0 || Regs.H.AH != 0x00) {\r
-    Drive->ErrorCode = Regs.H.AH;\r
-    return FALSE;\r
-  }\r
-\r
-  if (Drive->Floppy) {\r
-    if (Regs.H.BL == 0x10) {\r
-      Drive->AtapiFloppy = TRUE;\r
-    } else {\r
-      Drive->MaxHead      = Regs.H.DH;\r
-      Drive->MaxSector    = Regs.H.CL;\r
-      Drive->MaxCylinder  = Regs.H.CH;\r
-      if (Drive->MaxSector == 0) {\r
-        //\r
-        // BugBug: You can not trust the Carry flag.\r
-        //\r
-        return FALSE;\r
-      }\r
-    }\r
-  } else {\r
-    Drive->MaxHead  = (UINT8) (Regs.H.DH & 0x3f);\r
-    Cylinder        = (UINT16) (((UINT16) Regs.H.DH & 0xc0) << 4);\r
-    Cylinder        = (UINT16) (Cylinder | ((UINT16) Regs.H.CL & 0xc0) << 2);\r
-    Drive->MaxCylinder  = (UINT16) (Cylinder + Regs.H.CH);\r
-    Drive->MaxSector    = (UINT8) (Regs.H.CL & 0x3f);\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Extension of INT13 call.\r
-\r
-  @param  BiosBlockIoDev Instance of block I/O device.\r
-  @param  Drive          Legacy drive.\r
-\r
-  @return  Result of this extension.\r
-\r
-**/\r
-UINTN\r
-Int13Extensions (\r
-  IN  BIOS_BLOCK_IO_DEV    *BiosBlockIoDev,\r
-  IN  BIOS_LEGACY_DRIVE    *Drive\r
-  )\r
-{\r
-  INTN                  CarryFlag;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  Regs.H.AH = 0x41;\r
-  Regs.X.BX = 0x55aa;\r
-  Regs.H.DL = Drive->Number;\r
-  CarryFlag = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-  DEBUG ((DEBUG_INIT, "Int13Extensions: INT 13 41 DL=%02x : CF=%d BX=%04x\n", Drive->Number, CarryFlag, Regs.X.BX));\r
-  if (CarryFlag != 0 || Regs.X.BX != 0xaa55) {\r
-    Drive->ExtendedInt13            = FALSE;\r
-    Drive->DriveLockingAndEjecting  = FALSE;\r
-    Drive->Edd                      = FALSE;\r
-    return FALSE;\r
-  }\r
-\r
-  Drive->EddVersion               = Regs.H.AH;\r
-  Drive->ExtendedInt13            = (BOOLEAN) ((Regs.X.CX & 0x01) == 0x01);\r
-  Drive->DriveLockingAndEjecting  = (BOOLEAN) ((Regs.X.CX & 0x02) == 0x02);\r
-  Drive->Edd                      = (BOOLEAN) ((Regs.X.CX & 0x04) == 0x04);\r
-  Drive->Extensions64Bit          = (BOOLEAN) (Regs.X.CX & 0x08);\r
-\r
-  Drive->ParametersValid          = (UINT8) GetDriveParameters (BiosBlockIoDev, Drive);\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Gets parameters of legacy drive.\r
-\r
-  @param  BiosBlockIoDev Instance of block I/O device.\r
-  @param  Drive          Legacy drive.\r
-\r
-  @return  Result of drive parameter retrieval.\r
-\r
-**/\r
-UINTN\r
-GetDriveParameters (\r
-  IN  BIOS_BLOCK_IO_DEV   *BiosBlockIoDev,\r
-  IN  BIOS_LEGACY_DRIVE   *Drive\r
-  )\r
-{\r
-  INTN                  CarryFlag;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-  UINTN                 PointerMath;\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  Regs.H.AH = 0x48;\r
-  Regs.H.DL = Drive->Number;\r
-\r
-  //\r
-  // EDD Buffer must be passed in with max buffer size as first entry in the buffer\r
-  //\r
-  mLegacyDriverUnder1Mb->Parameters.StructureSize = (UINT16) sizeof (EDD_DRIVE_PARAMETERS);\r
-  Regs.X.DS = EFI_SEGMENT ((UINTN)(&mLegacyDriverUnder1Mb->Parameters));\r
-  Regs.X.SI = EFI_OFFSET ((UINTN)(&mLegacyDriverUnder1Mb->Parameters));\r
-  CarryFlag = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-  DEBUG ((DEBUG_INIT, "GetDriveParameters: INT 13 48 DL=%02x : CF=%d AH=%02x\n", Drive->Number, CarryFlag, Regs.H.AH));\r
-  if (CarryFlag != 0 || Regs.H.AH != 0x00) {\r
-    Drive->ErrorCode = Regs.H.AH;\r
-    SetMem (&Drive->Parameters, sizeof (Drive->Parameters), 0xaf);\r
-    return FALSE;\r
-  }\r
-  //\r
-  // We only have one buffer < 1MB, so copy into our instance data\r
-  //\r
-  CopyMem (\r
-    &Drive->Parameters,\r
-    &mLegacyDriverUnder1Mb->Parameters,\r
-    sizeof (Drive->Parameters)\r
-    );\r
-\r
-  if (Drive->AtapiFloppy) {\r
-    //\r
-    // Sense Media Type\r
-    //\r
-    Regs.H.AH = 0x20;\r
-    Regs.H.DL = Drive->Number;\r
-    CarryFlag = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-    DEBUG ((DEBUG_INIT, "GetDriveParameters: INT 13 20 DL=%02x : CF=%d AL=%02x\n", Drive->Number, CarryFlag, Regs.H.AL));\r
-    if (CarryFlag != 0) {\r
-      //\r
-      // Media not present or unknown media present\r
-      //\r
-      if ((Drive->Parameters.Flags & EDD_GEOMETRY_VALID) == EDD_GEOMETRY_VALID) {\r
-        Drive->MaxHead    = (UINT8) (Drive->Parameters.MaxHeads - 1);\r
-        Drive->MaxSector  = (UINT8) Drive->Parameters.SectorsPerTrack;\r
-        ASSERT (Drive->MaxSector != 0);\r
-        Drive->MaxCylinder = (UINT16) (Drive->Parameters.MaxCylinders - 1);\r
-      } else {\r
-        Drive->MaxHead      = 0;\r
-        Drive->MaxSector    = 1;\r
-        Drive->MaxCylinder  = 0;\r
-      }\r
-\r
-    } else {\r
-      //\r
-      // Media Present\r
-      //\r
-      switch (Regs.H.AL) {\r
-      case 0x03:\r
-        //\r
-        // 720 KB\r
-        //\r
-        Drive->MaxHead      = 1;\r
-        Drive->MaxSector    = 9;\r
-        Drive->MaxCylinder  = 79;\r
-        break;\r
-\r
-      case 0x04:\r
-        //\r
-        // 1.44MB\r
-        //\r
-        Drive->MaxHead      = 1;\r
-        Drive->MaxSector    = 18;\r
-        Drive->MaxCylinder  = 79;\r
-        break;\r
-\r
-      case 0x06:\r
-        //\r
-        // 2.88MB\r
-        //\r
-        Drive->MaxHead      = 1;\r
-        Drive->MaxSector    = 36;\r
-        Drive->MaxCylinder  = 79;\r
-        break;\r
-\r
-      case 0x0C:\r
-        //\r
-        // 360 KB\r
-        //\r
-        Drive->MaxHead      = 1;\r
-        Drive->MaxSector    = 9;\r
-        Drive->MaxCylinder  = 39;\r
-        break;\r
-\r
-      case 0x0D:\r
-        //\r
-        // 1.2 MB\r
-        //\r
-        Drive->MaxHead      = 1;\r
-        Drive->MaxSector    = 15;\r
-        Drive->MaxCylinder  = 79;\r
-        break;\r
-\r
-      case 0x0E:\r
-        //\r
-        // Toshiba 3 mode\r
-        //\r
-      case 0x0F:\r
-        //\r
-        // NEC 3 mode\r
-        //\r
-      case 0x10:\r
-        //\r
-        // Default Media\r
-        //\r
-        if ((Drive->Parameters.Flags & EDD_GEOMETRY_VALID) == EDD_GEOMETRY_VALID) {\r
-          Drive->MaxHead    = (UINT8) (Drive->Parameters.MaxHeads - 1);\r
-          Drive->MaxSector  = (UINT8) Drive->Parameters.SectorsPerTrack;\r
-          ASSERT (Drive->MaxSector != 0);\r
-          Drive->MaxCylinder = (UINT16) (Drive->Parameters.MaxCylinders - 1);\r
-        } else {\r
-          Drive->MaxHead      = 0;\r
-          Drive->MaxSector    = 1;\r
-          Drive->MaxCylinder  = 0;\r
-        }\r
-        break;\r
-\r
-      default:\r
-        //\r
-        // Unknown media type.\r
-        //\r
-        Drive->MaxHead      = 0;\r
-        Drive->MaxSector    = 1;\r
-        Drive->MaxCylinder  = 0;\r
-        break;\r
-      }\r
-    }\r
-\r
-    Drive->Parameters.PhysicalSectors = (Drive->MaxHead + 1) * Drive->MaxSector * (Drive->MaxCylinder + 1);\r
-    Drive->Parameters.BytesPerSector  = 512;\r
-  }\r
-  //\r
-  // This data comes from the BIOS so it may not allways be valid\r
-  //  since the BIOS may reuse this buffer for future accesses\r
-  //\r
-  PointerMath = EFI_SEGMENT (Drive->Parameters.Fdpt) << 4;\r
-  PointerMath += EFI_OFFSET (Drive->Parameters.Fdpt);\r
-  Drive->FdptPointer = (VOID *) PointerMath;\r
-\r
-  return TRUE;\r
-}\r
-//\r
-// Block IO Routines\r
-//\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    Id of the media, changes every time the media is replaced.\r
-  @param  Lba        The starting Logical Block Address to read from\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
-                     responsible for either having implicit or explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd30BiosReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_MEDIA        *Media;\r
-  BIOS_BLOCK_IO_DEV         *BiosBlockIoDev;\r
-  EDD_DEVICE_ADDRESS_PACKET *AddressPacket;\r
-  //\r
-  // I exist only for readability\r
-  //\r
-  EFI_IA32_REGISTER_SET     Regs;\r
-  UINT64                    TransferBuffer;\r
-  UINTN                     NumberOfBlocks;\r
-  UINTN                     TransferByteSize;\r
-  UINTN                     BlockSize;\r
-  BIOS_LEGACY_DRIVE         *Bios;\r
-  UINTN                     CarryFlag;\r
-  UINTN                     MaxTransferBlocks;\r
-  EFI_BLOCK_IO_PROTOCOL     *BlockIo;\r
-\r
-  Media     = This->Media;\r
-  BlockSize = Media->BlockSize;\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  if (MediaId != Media->MediaId) {\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Lba + (BufferSize / BlockSize) - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  BiosBlockIoDev    = BIOS_BLOCK_IO_FROM_THIS (This);\r
-  AddressPacket     = mEddBufferUnder1Mb;\r
-\r
-  MaxTransferBlocks = MAX_EDD11_XFER / BlockSize;\r
-\r
-  TransferBuffer    = (UINT64)(UINTN) Buffer;\r
-  for (; BufferSize > 0;) {\r
-    NumberOfBlocks  = BufferSize / BlockSize;\r
-    NumberOfBlocks  = NumberOfBlocks > MaxTransferBlocks ? MaxTransferBlocks : NumberOfBlocks;\r
-    //\r
-    // Max transfer MaxTransferBlocks\r
-    //\r
-    AddressPacket->PacketSizeInBytes  = (UINT8) sizeof (EDD_DEVICE_ADDRESS_PACKET);\r
-    AddressPacket->Zero               = 0;\r
-    AddressPacket->NumberOfBlocks     = (UINT8) NumberOfBlocks;\r
-    AddressPacket->Zero2              = 0;\r
-    AddressPacket->SegOffset          = 0xffffffff;\r
-    AddressPacket->Lba                = (UINT64) Lba;\r
-    AddressPacket->TransferBuffer     = TransferBuffer;\r
-\r
-    Regs.H.AH                         = 0x42;\r
-    Regs.H.DL                         = BiosBlockIoDev->Bios.Number;\r
-    Regs.X.SI                         = EFI_OFFSET (AddressPacket);\r
-    Regs.X.DS                         = EFI_SEGMENT (AddressPacket);\r
-\r
-    CarryFlag                         = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-    DEBUG (\r
-      (\r
-      DEBUG_BLKIO, "Edd30BiosReadBlocks: INT 13 42 DL=%02x : CF=%d AH=%02x\n", BiosBlockIoDev->Bios.Number,\r
-      CarryFlag, Regs.H.AH\r
-      )\r
-      );\r
-\r
-    Media->MediaPresent = TRUE;\r
-    if (CarryFlag != 0) {\r
-      //\r
-      // Return Error Status\r
-      //\r
-      BiosBlockIoDev->Bios.ErrorCode = Regs.H.AH;\r
-      if (BiosBlockIoDev->Bios.ErrorCode == BIOS_DISK_CHANGED) {\r
-        Media->MediaId++;\r
-        Bios = &BiosBlockIoDev->Bios;\r
-        if (Int13GetDeviceParameters (BiosBlockIoDev, Bios) != 0) {\r
-          if (Int13Extensions (BiosBlockIoDev, Bios) != 0) {\r
-            Media->LastBlock  = (EFI_LBA) Bios->Parameters.PhysicalSectors - 1;\r
-            Media->BlockSize  = (UINT32) Bios->Parameters.BytesPerSector;\r
-          } else {\r
-            ASSERT (FALSE);\r
-          }\r
-\r
-          Media->ReadOnly = FALSE;\r
-          gBS->HandleProtocol (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
-          gBS->ReinstallProtocolInterface (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, BlockIo, BlockIo);\r
-          return EFI_MEDIA_CHANGED;\r
-        }\r
-      }\r
-\r
-      if (Media->RemovableMedia) {\r
-        Media->MediaPresent = FALSE;\r
-      }\r
-\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    TransferByteSize  = NumberOfBlocks * BlockSize;\r
-    BufferSize        = BufferSize - TransferByteSize;\r
-    TransferBuffer += TransferByteSize;\r
-    Lba += NumberOfBlocks;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    The media ID that the write request is for.\r
-  @param  Lba        The starting logical block address to be written. The caller is\r
-                     responsible for writing to only legitimate locations.\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The data was written correctly to the device.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd30BiosWriteBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_MEDIA        *Media;\r
-  BIOS_BLOCK_IO_DEV         *BiosBlockIoDev;\r
-  EDD_DEVICE_ADDRESS_PACKET *AddressPacket;\r
-  //\r
-  // I exist only for readability\r
-  //\r
-  EFI_IA32_REGISTER_SET     Regs;\r
-  UINT64                    TransferBuffer;\r
-  UINTN                     NumberOfBlocks;\r
-  UINTN                     TransferByteSize;\r
-  UINTN                     BlockSize;\r
-  BIOS_LEGACY_DRIVE         *Bios;\r
-  UINTN                     CarryFlag;\r
-  UINTN                     MaxTransferBlocks;\r
-  EFI_BLOCK_IO_PROTOCOL     *BlockIo;\r
-\r
-  Media     = This->Media;\r
-  BlockSize = Media->BlockSize;\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  if (MediaId != Media->MediaId) {\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if ((Lba + (BufferSize / BlockSize) - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  BiosBlockIoDev    = BIOS_BLOCK_IO_FROM_THIS (This);\r
-  AddressPacket     = mEddBufferUnder1Mb;\r
-\r
-  MaxTransferBlocks = MAX_EDD11_XFER / BlockSize;\r
-\r
-  TransferBuffer    = (UINT64)(UINTN) Buffer;\r
-  for (; BufferSize > 0;) {\r
-    NumberOfBlocks  = BufferSize / BlockSize;\r
-    NumberOfBlocks  = NumberOfBlocks > MaxTransferBlocks ? MaxTransferBlocks : NumberOfBlocks;\r
-    //\r
-    // Max transfer MaxTransferBlocks\r
-    //\r
-    AddressPacket->PacketSizeInBytes  = (UINT8) sizeof (EDD_DEVICE_ADDRESS_PACKET);\r
-    AddressPacket->Zero               = 0;\r
-    AddressPacket->NumberOfBlocks     = (UINT8) NumberOfBlocks;\r
-    AddressPacket->Zero2              = 0;\r
-    AddressPacket->SegOffset          = 0xffffffff;\r
-    AddressPacket->Lba                = (UINT64) Lba;\r
-    AddressPacket->TransferBuffer     = TransferBuffer;\r
-\r
-    Regs.H.AH                         = 0x43;\r
-    Regs.H.AL                         = 0x00;\r
-    //\r
-    // Write Verify Off\r
-    //\r
-    Regs.H.DL = (UINT8) (BiosBlockIoDev->Bios.Number);\r
-    Regs.X.SI = EFI_OFFSET (AddressPacket);\r
-    Regs.X.DS = EFI_SEGMENT (AddressPacket);\r
-\r
-    CarryFlag = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-    DEBUG (\r
-      (\r
-      DEBUG_BLKIO, "Edd30BiosWriteBlocks: INT 13 43 DL=%02x : CF=%d AH=%02x\n", BiosBlockIoDev->Bios.Number,\r
-      CarryFlag, Regs.H.AH\r
-      )\r
-      );\r
-\r
-    Media->MediaPresent = TRUE;\r
-    if (CarryFlag != 0) {\r
-      //\r
-      // Return Error Status\r
-      //\r
-      BiosBlockIoDev->Bios.ErrorCode = Regs.H.AH;\r
-      if (BiosBlockIoDev->Bios.ErrorCode == BIOS_DISK_CHANGED) {\r
-        Media->MediaId++;\r
-        Bios = &BiosBlockIoDev->Bios;\r
-        if (Int13GetDeviceParameters (BiosBlockIoDev, Bios) != 0) {\r
-          if (Int13Extensions (BiosBlockIoDev, Bios) != 0) {\r
-            Media->LastBlock  = (EFI_LBA) Bios->Parameters.PhysicalSectors - 1;\r
-            Media->BlockSize  = (UINT32) Bios->Parameters.BytesPerSector;\r
-          } else {\r
-            ASSERT (FALSE);\r
-          }\r
-\r
-          Media->ReadOnly = FALSE;\r
-          gBS->HandleProtocol (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
-          gBS->ReinstallProtocolInterface (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, BlockIo, BlockIo);\r
-          return EFI_MEDIA_CHANGED;\r
-        }\r
-      } else if (BiosBlockIoDev->Bios.ErrorCode == BIOS_WRITE_PROTECTED) {\r
-        Media->ReadOnly = TRUE;\r
-        return EFI_WRITE_PROTECTED;\r
-      }\r
-\r
-      if (Media->RemovableMedia) {\r
-        Media->MediaPresent = FALSE;\r
-      }\r
-\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Media->ReadOnly   = FALSE;\r
-    TransferByteSize  = NumberOfBlocks * BlockSize;\r
-    BufferSize        = BufferSize - TransferByteSize;\r
-    TransferBuffer += TransferByteSize;\r
-    Lba += NumberOfBlocks;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Flush the Block Device.\r
-\r
-  @param  This              Indicates a pointer to the calling context.\r
-\r
-  @retval EFI_SUCCESS       All outstanding data was written to the device\r
-  @retval EFI_DEVICE_ERROR  The device reported an error while writting back the data\r
-  @retval EFI_NO_MEDIA      There is no media in the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoFlushBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL  *This\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Reset the Block Device.\r
-\r
-  @param  This                 Indicates a pointer to the calling context.\r
-  @param  ExtendedVerification Driver may perform diagnostics on reset.\r
-\r
-  @retval EFI_SUCCESS          The device was reset.\r
-  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
-                               not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoReset (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  BOOLEAN               ExtendedVerification\r
-  )\r
-{\r
-  BIOS_BLOCK_IO_DEV     *BiosBlockIoDev;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-  UINTN                 CarryFlag;\r
-\r
-  BiosBlockIoDev  = BIOS_BLOCK_IO_FROM_THIS (This);\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  Regs.H.AH       = 0x00;\r
-  Regs.H.DL       = BiosBlockIoDev->Bios.Number;\r
-  CarryFlag       = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-  DEBUG (\r
-    (\r
-    DEBUG_INIT, "BiosBlockIoReset: INT 13 00 DL=%02x : CF=%d AH=%02x\n", BiosBlockIoDev->Bios.Number, CarryFlag,\r
-    Regs.H.AH\r
-    )\r
-    );\r
-  if (CarryFlag != 0) {\r
-    if (Regs.H.AL == BIOS_RESET_FAILED) {\r
-      Regs.H.AH = 0x00;\r
-      Regs.H.DL = BiosBlockIoDev->Bios.Number;\r
-      CarryFlag = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-      DEBUG (\r
-        (\r
-        DEBUG_INIT, "BiosBlockIoReset: INT 13 00 DL=%02x : CF=%d AH=%02x\n", BiosBlockIoDev->Bios.Number, CarryFlag,\r
-        Regs.H.AH\r
-        )\r
-        );\r
-      if (CarryFlag != 0) {\r
-        BiosBlockIoDev->Bios.ErrorCode = Regs.H.AH;\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-//\r
-//\r
-// These functions need to double buffer all data under 1MB!\r
-//\r
-//\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    Id of the media, changes every time the media is replaced.\r
-  @param  Lba        The starting Logical Block Address to read from\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
-                     responsible for either having implicit or explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd11BiosReadBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_MEDIA        *Media;\r
-  BIOS_BLOCK_IO_DEV         *BiosBlockIoDev;\r
-  EDD_DEVICE_ADDRESS_PACKET *AddressPacket;\r
-  //\r
-  // I exist only for readability\r
-  //\r
-  EFI_IA32_REGISTER_SET     Regs;\r
-  UINT64                    TransferBuffer;\r
-  UINTN                     NumberOfBlocks;\r
-  UINTN                     TransferByteSize;\r
-  UINTN                     BlockSize;\r
-  BIOS_LEGACY_DRIVE         *Bios;\r
-  UINTN                     CarryFlag;\r
-  UINTN                     MaxTransferBlocks;\r
-  EFI_BLOCK_IO_PROTOCOL     *BlockIo;\r
-\r
-  Media     = This->Media;\r
-  BlockSize = Media->BlockSize;\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  if (MediaId != Media->MediaId) {\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Lba + (BufferSize / BlockSize) - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  BiosBlockIoDev    = BIOS_BLOCK_IO_FROM_THIS (This);\r
-  AddressPacket     = mEddBufferUnder1Mb;\r
-\r
-  MaxTransferBlocks = MAX_EDD11_XFER / BlockSize;\r
-\r
-  TransferBuffer    = (UINT64)(UINTN) mEdd11Buffer;\r
-  for (; BufferSize > 0;) {\r
-    NumberOfBlocks  = BufferSize / BlockSize;\r
-    NumberOfBlocks  = NumberOfBlocks > MaxTransferBlocks ? MaxTransferBlocks : NumberOfBlocks;\r
-    //\r
-    // Max transfer MaxTransferBlocks\r
-    //\r
-    AddressPacket->PacketSizeInBytes  = (UINT8) sizeof (EDD_DEVICE_ADDRESS_PACKET);\r
-    AddressPacket->Zero               = 0;\r
-    AddressPacket->NumberOfBlocks     = (UINT8) NumberOfBlocks;\r
-    AddressPacket->Zero2              = 0;\r
-    //\r
-    // TransferBuffer has been 4KB alignment. Normalize TransferBuffer to make offset as 0 in seg:offset\r
-    // format to transfer maximum 127 blocks of data.\r
-    // Otherwise when offset adding data size exceeds 0xFFFF, if OpROM does not normalize TransferBuffer,\r
-    // INT13 function 42H will return data boundary error 09H.\r
-    //\r
-    AddressPacket->SegOffset = (UINT32) LShiftU64 (RShiftU64(TransferBuffer, 4), 16);\r
-    AddressPacket->Lba  = (UINT64) Lba;\r
-\r
-    Regs.H.AH           = 0x42;\r
-    Regs.H.DL           = BiosBlockIoDev->Bios.Number;\r
-    Regs.X.SI           = EFI_OFFSET (AddressPacket);\r
-    Regs.X.DS           = EFI_SEGMENT (AddressPacket);\r
-\r
-    CarryFlag           = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-    DEBUG (\r
-      (\r
-      DEBUG_BLKIO, "Edd11BiosReadBlocks: INT 13 42 DL=%02x : CF=%d AH=%02x : LBA 0x%lx  Block(s) %0d \n",\r
-      BiosBlockIoDev->Bios.Number, CarryFlag, Regs.H.AH, Lba, NumberOfBlocks\r
-      )\r
-      );\r
-    Media->MediaPresent = TRUE;\r
-    if (CarryFlag != 0) {\r
-      //\r
-      // Return Error Status\r
-      //\r
-      BiosBlockIoDev->Bios.ErrorCode = Regs.H.AH;\r
-      if (BiosBlockIoDev->Bios.ErrorCode == BIOS_DISK_CHANGED) {\r
-        Media->MediaId++;\r
-        Bios = &BiosBlockIoDev->Bios;\r
-        if (Int13GetDeviceParameters (BiosBlockIoDev, Bios) != 0) {\r
-          if (Int13Extensions (BiosBlockIoDev, Bios) != 0) {\r
-            Media->LastBlock  = (EFI_LBA) Bios->Parameters.PhysicalSectors - 1;\r
-            Media->BlockSize  = (UINT32) Bios->Parameters.BytesPerSector;\r
-          } else {\r
-            ASSERT (FALSE);\r
-          }\r
-\r
-          Media->ReadOnly = FALSE;\r
-          gBS->HandleProtocol (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
-          gBS->ReinstallProtocolInterface (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, BlockIo, BlockIo);\r
-          return EFI_MEDIA_CHANGED;\r
-        }\r
-      }\r
-\r
-      if (Media->RemovableMedia) {\r
-        Media->MediaPresent = FALSE;\r
-      }\r
-\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    TransferByteSize = NumberOfBlocks * BlockSize;\r
-    CopyMem (Buffer, (VOID *) (UINTN) TransferBuffer, TransferByteSize);\r
-    BufferSize  = BufferSize - TransferByteSize;\r
-    Buffer      = (VOID *) ((UINT8 *) Buffer + TransferByteSize);\r
-    Lba += NumberOfBlocks;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    The media ID that the write request is for.\r
-  @param  Lba        The starting logical block address to be written. The caller is\r
-                     responsible for writing to only legitimate locations.\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The data was written correctly to the device.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Edd11BiosWriteBlocks (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_MEDIA        *Media;\r
-  BIOS_BLOCK_IO_DEV         *BiosBlockIoDev;\r
-  EDD_DEVICE_ADDRESS_PACKET *AddressPacket;\r
-  //\r
-  // I exist only for readability\r
-  //\r
-  EFI_IA32_REGISTER_SET     Regs;\r
-  UINT64                    TransferBuffer;\r
-  UINTN                     NumberOfBlocks;\r
-  UINTN                     TransferByteSize;\r
-  UINTN                     BlockSize;\r
-  BIOS_LEGACY_DRIVE         *Bios;\r
-  UINTN                     CarryFlag;\r
-  UINTN                     MaxTransferBlocks;\r
-  EFI_BLOCK_IO_PROTOCOL     *BlockIo;\r
-\r
-  Media     = This->Media;\r
-  BlockSize = Media->BlockSize;\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  if (MediaId != Media->MediaId) {\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Lba + (BufferSize / BlockSize) - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  BiosBlockIoDev    = BIOS_BLOCK_IO_FROM_THIS (This);\r
-  AddressPacket     = mEddBufferUnder1Mb;\r
-\r
-  MaxTransferBlocks = MAX_EDD11_XFER / BlockSize;\r
-\r
-  TransferBuffer    = (UINT64)(UINTN) mEdd11Buffer;\r
-  for (; BufferSize > 0;) {\r
-    NumberOfBlocks  = BufferSize / BlockSize;\r
-    NumberOfBlocks  = NumberOfBlocks > MaxTransferBlocks ? MaxTransferBlocks : NumberOfBlocks;\r
-    //\r
-    // Max transfer MaxTransferBlocks\r
-    //\r
-    AddressPacket->PacketSizeInBytes  = (UINT8) sizeof (EDD_DEVICE_ADDRESS_PACKET);\r
-    AddressPacket->Zero               = 0;\r
-    AddressPacket->NumberOfBlocks     = (UINT8) NumberOfBlocks;\r
-    AddressPacket->Zero2              = 0;\r
-    //\r
-    // TransferBuffer has been 4KB alignment. Normalize TransferBuffer to make offset as 0 in seg:offset\r
-    // format to transfer maximum 127 blocks of data.\r
-    // Otherwise when offset adding data size exceeds 0xFFFF, if OpROM does not normalize TransferBuffer,\r
-    // INT13 function 42H will return data boundary error 09H.\r
-    //\r
-    AddressPacket->SegOffset = (UINT32) LShiftU64 (RShiftU64(TransferBuffer, 4), 16);\r
-    AddressPacket->Lba  = (UINT64) Lba;\r
-\r
-    Regs.H.AH           = 0x43;\r
-    Regs.H.AL           = 0x00;\r
-    //\r
-    // Write Verify disable\r
-    //\r
-    Regs.H.DL         = BiosBlockIoDev->Bios.Number;\r
-    Regs.X.SI         = EFI_OFFSET (AddressPacket);\r
-    Regs.X.DS         = EFI_SEGMENT (AddressPacket);\r
-\r
-    TransferByteSize  = NumberOfBlocks * BlockSize;\r
-    CopyMem ((VOID *) (UINTN) TransferBuffer, Buffer, TransferByteSize);\r
-\r
-    CarryFlag = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-    DEBUG (\r
-      (\r
-      DEBUG_BLKIO, "Edd11BiosWriteBlocks: INT 13 43 DL=%02x : CF=%d AH=%02x\n: LBA 0x%lx  Block(s) %0d \n",\r
-      BiosBlockIoDev->Bios.Number, CarryFlag, Regs.H.AH, Lba, NumberOfBlocks\r
-      )\r
-      );\r
-    Media->MediaPresent = TRUE;\r
-    if (CarryFlag != 0) {\r
-      //\r
-      // Return Error Status\r
-      //\r
-      BiosBlockIoDev->Bios.ErrorCode = Regs.H.AH;\r
-      if (BiosBlockIoDev->Bios.ErrorCode == BIOS_DISK_CHANGED) {\r
-        Media->MediaId++;\r
-        Bios = &BiosBlockIoDev->Bios;\r
-        if (Int13GetDeviceParameters (BiosBlockIoDev, Bios) != 0) {\r
-          if (Int13Extensions (BiosBlockIoDev, Bios) != 0) {\r
-            Media->LastBlock  = (EFI_LBA) Bios->Parameters.PhysicalSectors - 1;\r
-            Media->BlockSize  = (UINT32) Bios->Parameters.BytesPerSector;\r
-          } else {\r
-            ASSERT (FALSE);\r
-          }\r
-\r
-          Media->ReadOnly = FALSE;\r
-          gBS->HandleProtocol (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
-          gBS->ReinstallProtocolInterface (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, BlockIo, BlockIo);\r
-          return EFI_MEDIA_CHANGED;\r
-        }\r
-      } else if (BiosBlockIoDev->Bios.ErrorCode == BIOS_WRITE_PROTECTED) {\r
-        Media->ReadOnly = TRUE;\r
-        return EFI_WRITE_PROTECTED;\r
-      }\r
-\r
-      if (Media->RemovableMedia) {\r
-        Media->MediaPresent = FALSE;\r
-      }\r
-\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Media->ReadOnly = FALSE;\r
-    BufferSize      = BufferSize - TransferByteSize;\r
-    Buffer          = (VOID *) ((UINT8 *) Buffer + TransferByteSize);\r
-    Lba += NumberOfBlocks;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    Id of the media, changes every time the media is replaced.\r
-  @param  Lba        The starting Logical Block Address to read from\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
-                     responsible for either having implicit or explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosReadLegacyDrive (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_MEDIA    *Media;\r
-  BIOS_BLOCK_IO_DEV     *BiosBlockIoDev;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-  UINTN                 UpperCylinder;\r
-  UINTN                 Temp;\r
-  UINTN                 Cylinder;\r
-  UINTN                 Head;\r
-  UINTN                 Sector;\r
-  UINTN                 NumberOfBlocks;\r
-  UINTN                 TransferByteSize;\r
-  UINTN                 ShortLba;\r
-  UINTN                 CheckLba;\r
-  UINTN                 BlockSize;\r
-  BIOS_LEGACY_DRIVE     *Bios;\r
-  UINTN                 CarryFlag;\r
-  UINTN                 Retry;\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-\r
-  Media     = This->Media;\r
-  BlockSize = Media->BlockSize;\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  if (MediaId != Media->MediaId) {\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Lba + (BufferSize / BlockSize) - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  BiosBlockIoDev  = BIOS_BLOCK_IO_FROM_THIS (This);\r
-  ShortLba        = (UINTN) Lba;\r
-\r
-  while (BufferSize != 0) {\r
-    //\r
-    // Compute I/O location in Sector, Head, Cylinder format\r
-    //\r
-    Sector    = (ShortLba % BiosBlockIoDev->Bios.MaxSector) + 1;\r
-    Temp      = ShortLba / BiosBlockIoDev->Bios.MaxSector;\r
-    Head      = Temp % (BiosBlockIoDev->Bios.MaxHead + 1);\r
-    Cylinder  = Temp / (BiosBlockIoDev->Bios.MaxHead + 1);\r
-\r
-    //\r
-    // Limit transfer to this Head & Cylinder\r
-    //\r
-    NumberOfBlocks  = BufferSize / BlockSize;\r
-    Temp            = BiosBlockIoDev->Bios.MaxSector - Sector + 1;\r
-    NumberOfBlocks  = NumberOfBlocks > Temp ? Temp : NumberOfBlocks;\r
-\r
-    Retry           = 3;\r
-    do {\r
-      //\r
-      // Perform the IO\r
-      //\r
-      Regs.H.AH     = 2;\r
-      Regs.H.AL     = (UINT8) NumberOfBlocks;\r
-      Regs.H.DL     = BiosBlockIoDev->Bios.Number;\r
-\r
-      UpperCylinder = (Cylinder & 0x0f00) >> 2;\r
-\r
-      CheckLba      = Cylinder * (BiosBlockIoDev->Bios.MaxHead + 1) + Head;\r
-      CheckLba      = CheckLba * BiosBlockIoDev->Bios.MaxSector + Sector - 1;\r
-\r
-      DEBUG (\r
-        (DEBUG_BLKIO,\r
-        "RLD: LBA %x (%x), Sector %x (%x), Head %x (%x), Cyl %x, UCyl %x\n",\r
-        ShortLba,\r
-        CheckLba,\r
-        Sector,\r
-        BiosBlockIoDev->Bios.MaxSector,\r
-        Head,\r
-        BiosBlockIoDev->Bios.MaxHead,\r
-        Cylinder,\r
-        UpperCylinder)\r
-        );\r
-      ASSERT (CheckLba == ShortLba);\r
-\r
-      Regs.H.CL = (UINT8) ((Sector & 0x3f) + (UpperCylinder & 0xff));\r
-      Regs.H.DH = (UINT8) (Head & 0x3f);\r
-      Regs.H.CH = (UINT8) (Cylinder & 0xff);\r
-\r
-      Regs.X.BX = EFI_OFFSET (mEdd11Buffer);\r
-      Regs.X.ES = EFI_SEGMENT (mEdd11Buffer);\r
-\r
-      DEBUG (\r
-        (DEBUG_BLKIO,\r
-        "INT 13h: AX:(02%02x) DX:(%02x%02x) CX:(%02x%02x) BX:(%04x) ES:(%04x)\n",\r
-        Regs.H.AL,\r
-        (UINT8) (Head & 0x3f),\r
-        Regs.H.DL,\r
-        (UINT8) (Cylinder & 0xff),\r
-        (UINT8) ((Sector & 0x3f) + (UpperCylinder & 0xff)),\r
-        EFI_OFFSET (mEdd11Buffer),\r
-        EFI_SEGMENT (mEdd11Buffer))\r
-        );\r
-\r
-      CarryFlag = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-      DEBUG (\r
-        (\r
-        DEBUG_BLKIO, "BiosReadLegacyDrive: INT 13 02 DL=%02x : CF=%d AH=%02x\n", BiosBlockIoDev->Bios.Number,\r
-        CarryFlag, Regs.H.AH\r
-        )\r
-        );\r
-      Retry--;\r
-    } while (CarryFlag != 0 && Retry != 0 && Regs.H.AH != BIOS_DISK_CHANGED);\r
-\r
-    Media->MediaPresent = TRUE;\r
-    if (CarryFlag != 0) {\r
-      //\r
-      // Return Error Status\r
-      //\r
-      BiosBlockIoDev->Bios.ErrorCode = Regs.H.AH;\r
-      if (BiosBlockIoDev->Bios.ErrorCode == BIOS_DISK_CHANGED) {\r
-        Media->MediaId++;\r
-        Bios = &BiosBlockIoDev->Bios;\r
-        if (Int13GetDeviceParameters (BiosBlockIoDev, Bios) != 0) {\r
-          //\r
-          // If the size of the media changed we need to reset the disk geometry\r
-          //\r
-          if (Int13Extensions (BiosBlockIoDev, Bios) != 0) {\r
-            Media->LastBlock  = (EFI_LBA) Bios->Parameters.PhysicalSectors - 1;\r
-            Media->BlockSize  = (UINT32) Bios->Parameters.BytesPerSector;\r
-          } else {\r
-            //\r
-            // Legacy Interfaces\r
-            //\r
-            Media->LastBlock  = (Bios->MaxHead + 1) * Bios->MaxSector * (Bios->MaxCylinder + 1) - 1;\r
-            Media->BlockSize  = 512;\r
-          }\r
-\r
-          Media->ReadOnly = FALSE;\r
-          gBS->HandleProtocol (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
-          gBS->ReinstallProtocolInterface (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, BlockIo, BlockIo);\r
-          return EFI_MEDIA_CHANGED;\r
-        }\r
-      }\r
-\r
-      if (Media->RemovableMedia) {\r
-        Media->MediaPresent = FALSE;\r
-      }\r
-\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    TransferByteSize = NumberOfBlocks * BlockSize;\r
-    CopyMem (Buffer, mEdd11Buffer, TransferByteSize);\r
-\r
-    ShortLba    = ShortLba + NumberOfBlocks;\r
-    BufferSize  = BufferSize - TransferByteSize;\r
-    Buffer      = (VOID *) ((UINT8 *) Buffer + TransferByteSize);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    The media ID that the write request is for.\r
-  @param  Lba        The starting logical block address to be written. The caller is\r
-                     responsible for writing to only legitimate locations.\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The data was written correctly to the device.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosWriteLegacyDrive (\r
-  IN  EFI_BLOCK_IO_PROTOCOL *This,\r
-  IN  UINT32                MediaId,\r
-  IN  EFI_LBA               Lba,\r
-  IN  UINTN                 BufferSize,\r
-  OUT VOID                  *Buffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_MEDIA    *Media;\r
-  BIOS_BLOCK_IO_DEV     *BiosBlockIoDev;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-  UINTN                 UpperCylinder;\r
-  UINTN                 Temp;\r
-  UINTN                 Cylinder;\r
-  UINTN                 Head;\r
-  UINTN                 Sector;\r
-  UINTN                 NumberOfBlocks;\r
-  UINTN                 TransferByteSize;\r
-  UINTN                 ShortLba;\r
-  UINTN                 CheckLba;\r
-  UINTN                 BlockSize;\r
-  BIOS_LEGACY_DRIVE     *Bios;\r
-  UINTN                 CarryFlag;\r
-  UINTN                 Retry;\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-\r
-  Media     = This->Media;\r
-  BlockSize = Media->BlockSize;\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-  if (MediaId != Media->MediaId) {\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if (Lba > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Lba + (BufferSize / BlockSize) - 1) > Media->LastBlock) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize % BlockSize != 0) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  BiosBlockIoDev  = BIOS_BLOCK_IO_FROM_THIS (This);\r
-  ShortLba        = (UINTN) Lba;\r
-\r
-  while (BufferSize != 0) {\r
-    //\r
-    // Compute I/O location in Sector, Head, Cylinder format\r
-    //\r
-    Sector    = (ShortLba % BiosBlockIoDev->Bios.MaxSector) + 1;\r
-    Temp      = ShortLba / BiosBlockIoDev->Bios.MaxSector;\r
-    Head      = Temp % (BiosBlockIoDev->Bios.MaxHead + 1);\r
-    Cylinder  = Temp / (BiosBlockIoDev->Bios.MaxHead + 1);\r
-\r
-    //\r
-    // Limit transfer to this Head & Cylinder\r
-    //\r
-    NumberOfBlocks  = BufferSize / BlockSize;\r
-    Temp            = BiosBlockIoDev->Bios.MaxSector - Sector + 1;\r
-    NumberOfBlocks  = NumberOfBlocks > Temp ? Temp : NumberOfBlocks;\r
-\r
-    Retry           = 3;\r
-    do {\r
-      //\r
-      // Perform the IO\r
-      //\r
-      Regs.H.AH     = 3;\r
-      Regs.H.AL     = (UINT8) NumberOfBlocks;\r
-      Regs.H.DL     = BiosBlockIoDev->Bios.Number;\r
-\r
-      UpperCylinder = (Cylinder & 0x0f00) >> 2;\r
-\r
-      CheckLba      = Cylinder * (BiosBlockIoDev->Bios.MaxHead + 1) + Head;\r
-      CheckLba      = CheckLba * BiosBlockIoDev->Bios.MaxSector + Sector - 1;\r
-\r
-      DEBUG (\r
-        (DEBUG_BLKIO,\r
-        "RLD: LBA %x (%x), Sector %x (%x), Head %x (%x), Cyl %x, UCyl %x\n",\r
-        ShortLba,\r
-        CheckLba,\r
-        Sector,\r
-        BiosBlockIoDev->Bios.MaxSector,\r
-        Head,\r
-        BiosBlockIoDev->Bios.MaxHead,\r
-        Cylinder,\r
-        UpperCylinder)\r
-        );\r
-      ASSERT (CheckLba == ShortLba);\r
-\r
-      Regs.H.CL         = (UINT8) ((Sector & 0x3f) + (UpperCylinder & 0xff));\r
-      Regs.H.DH         = (UINT8) (Head & 0x3f);\r
-      Regs.H.CH         = (UINT8) (Cylinder & 0xff);\r
-\r
-      Regs.X.BX         = EFI_OFFSET (mEdd11Buffer);\r
-      Regs.X.ES         = EFI_SEGMENT (mEdd11Buffer);\r
-\r
-      TransferByteSize  = NumberOfBlocks * BlockSize;\r
-      CopyMem (mEdd11Buffer, Buffer, TransferByteSize);\r
-\r
-      DEBUG (\r
-        (DEBUG_BLKIO,\r
-        "INT 13h: AX:(03%02x) DX:(%02x%02x) CX:(%02x%02x) BX:(%04x) ES:(%04x)\n",\r
-        Regs.H.AL,\r
-        (UINT8) (Head & 0x3f),\r
-        Regs.H.DL,\r
-        (UINT8) (Cylinder & 0xff),\r
-        (UINT8) ((Sector & 0x3f) + (UpperCylinder & 0xff)),\r
-        EFI_OFFSET (mEdd11Buffer),\r
-        EFI_SEGMENT (mEdd11Buffer))\r
-        );\r
-\r
-      CarryFlag = BiosBlockIoDev->LegacyBios->Int86 (BiosBlockIoDev->LegacyBios, 0x13, &Regs);\r
-      DEBUG (\r
-        (\r
-        DEBUG_BLKIO, "BiosWriteLegacyDrive: INT 13 03 DL=%02x : CF=%d AH=%02x\n", BiosBlockIoDev->Bios.Number,\r
-        CarryFlag, Regs.H.AH\r
-        )\r
-        );\r
-      Retry--;\r
-    } while (CarryFlag != 0 && Retry != 0 && Regs.H.AH != BIOS_DISK_CHANGED);\r
-\r
-    Media->MediaPresent = TRUE;\r
-    if (CarryFlag != 0) {\r
-      //\r
-      // Return Error Status\r
-      //\r
-      BiosBlockIoDev->Bios.ErrorCode = Regs.H.AH;\r
-      if (BiosBlockIoDev->Bios.ErrorCode == BIOS_DISK_CHANGED) {\r
-        Media->MediaId++;\r
-        Bios = &BiosBlockIoDev->Bios;\r
-        if (Int13GetDeviceParameters (BiosBlockIoDev, Bios) != 0) {\r
-          if (Int13Extensions (BiosBlockIoDev, Bios) != 0) {\r
-            Media->LastBlock  = (EFI_LBA) Bios->Parameters.PhysicalSectors - 1;\r
-            Media->BlockSize  = (UINT32) Bios->Parameters.BytesPerSector;\r
-          } else {\r
-            //\r
-            // Legacy Interfaces\r
-            //\r
-            Media->LastBlock  = (Bios->MaxHead + 1) * Bios->MaxSector * (Bios->MaxCylinder + 1) - 1;\r
-            Media->BlockSize  = 512;\r
-          }\r
-          //\r
-          // If the size of the media changed we need to reset the disk geometry\r
-          //\r
-          Media->ReadOnly = FALSE;\r
-          gBS->HandleProtocol (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
-          gBS->ReinstallProtocolInterface (BiosBlockIoDev->Handle, &gEfiBlockIoProtocolGuid, BlockIo, BlockIo);\r
-          return EFI_MEDIA_CHANGED;\r
-        }\r
-      } else if (BiosBlockIoDev->Bios.ErrorCode == BIOS_WRITE_PROTECTED) {\r
-        Media->ReadOnly = TRUE;\r
-        return EFI_WRITE_PROTECTED;\r
-      }\r
-\r
-      if (Media->RemovableMedia) {\r
-        Media->MediaPresent = FALSE;\r
-      }\r
-\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Media->ReadOnly = FALSE;\r
-    ShortLba        = ShortLba + NumberOfBlocks;\r
-    BufferSize      = BufferSize - TransferByteSize;\r
-    Buffer          = (VOID *) ((UINT8 *) Buffer + TransferByteSize);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxe.inf b/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxe.inf
deleted file mode 100644 (file)
index 2486c2a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-## @file\r
-# BIOS Block IO module.\r
-#\r
-# This is the UEFI driver to thunk legacy BIOS int13 interface into UEFI block IO interface.\r
-# Once connected it installs EfiBlockIoProtocol on top of legacy BIOS int13.\r
-#\r
-# Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = BlockIoDxe\r
-  MODULE_UNI_FILE                = BlockIoDxe.uni\r
-  FILE_GUID                      = 4495E47E-42A9-4007-8c17-B6664F909D04\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = BiosBlockIoDriverEntryPoint\r
-\r
-[Sources]\r
-  BiosBlkIo.h\r
-  Edd.h\r
-  BiosBlkIo.c\r
-  BiosInt13.c\r
-  ComponentName.c\r
-\r
-[LibraryClasses]\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  BaseMemoryLib\r
-  UefiBootServicesTableLib\r
-  UefiLib\r
-  DevicePathLib\r
-  MemoryAllocationLib\r
-\r
-\r
-[Protocols]\r
-  gEfiBlockIoProtocolGuid    ## BY_START\r
-  gEfiDevicePathProtocolGuid ## BY_START\r
-  gEfiDevicePathProtocolGuid ## TO_START\r
-  gEfiPciIoProtocolGuid      ## TO_START\r
-  gEfiLegacyBiosProtocolGuid ## TO_START\r
-\r
-\r
-[Guids]\r
-  gEfiLegacyBiosGuid ## PRODUCES            ## UNDEFINED\r
-  gBlockIoVendorGuid ## SOMETIMES_CONSUMES  ## UNDEFINED\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  BlockIoDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxe.uni b/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxe.uni
deleted file mode 100644 (file)
index 4095d32..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// /** @file\r
-// BIOS Block IO module.\r
-//\r
-// This is the UEFI driver to thunk legacy BIOS int13 interface into UEFI block IO interface.\r
-// Once connected it installs EfiBlockIoProtocol on top of legacy BIOS int13.\r
-//\r
-// Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "BIOS Block IO module"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This is the UEFI driver to thunk legacy BIOS int13 interface into the UEFI block IO interface. Once connected, it installs EfiBlockIoProtocol on top of legacy BIOS int13."\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxeExtra.uni b/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxeExtra.uni
deleted file mode 100644 (file)
index 14e35d9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// BlockIoDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Legacy Block I/O DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/ComponentName.c b/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/ComponentName.c
deleted file mode 100644 (file)
index bd70e6b..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 1999 - 2011, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosBlkIo.h"\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL     gBiosBlockIoComponentName = {\r
-  BiosBlockIoComponentNameGetDriverName,\r
-  BiosBlockIoComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL    gBiosBlockIoComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) BiosBlockIoComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) BiosBlockIoComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosBlockIoDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"BIOS[INT13] Block Io Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mBiosBlockIoDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gBiosBlockIoComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosBlockIoComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/Edd.h b/IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/Edd.h
deleted file mode 100644 (file)
index 2358a07..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/** @file\r
-  Include file to suport EDD 3.0.\r
-  This file is coded to T13 D1386 Revision 3\r
-  Availible on http://www.t13.org/#Project drafts\r
-  Currently at ftp://fission.dt.wdc.com/pub/standards/x3t13/project/d1386r3.pdf\r
-\r
-Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _EDD_H_\r
-#define _EDD_H_\r
-\r
-//\r
-// packing with no compiler padding, so that the fields\r
-// of the following architected structures can be\r
-// properly accessed from C code.\r
-//\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  UINT8   Bus;\r
-  UINT8   Device;\r
-  UINT8   Function;\r
-  UINT8   Controller;\r
-  UINT32  Reserved;\r
-} EDD_PCI;\r
-\r
-typedef struct {\r
-  UINT16  Base;\r
-  UINT16  Reserved;\r
-  UINT32  Reserved2;\r
-} EDD_LEGACY;\r
-\r
-typedef union {\r
-  EDD_PCI     Pci;\r
-  EDD_LEGACY  Legacy;\r
-} EDD_INTERFACE_PATH;\r
-\r
-typedef struct {\r
-  UINT8 Master;\r
-  UINT8 Reserved[15];\r
-} EDD_ATA;\r
-\r
-typedef struct {\r
-  UINT8 Master;\r
-  UINT8 Lun;\r
-  UINT8 Reserved[14];\r
-} EDD_ATAPI;\r
-\r
-typedef struct {\r
-  UINT16  Pun;\r
-  UINT64  Lun;\r
-  UINT8   Reserved[6];\r
-} EDD_SCSI;\r
-\r
-typedef struct {\r
-  UINT64  SerialNumber;\r
-  UINT64  Reserved;\r
-} EDD_USB;\r
-\r
-typedef struct {\r
-  UINT64  Guid;\r
-  UINT64  Reserved;\r
-} EDD_1394;\r
-\r
-typedef struct {\r
-  UINT64  Wwn;\r
-  UINT64  Lun;\r
-} EDD_FIBRE;\r
-\r
-typedef union {\r
-  EDD_ATA   Ata;\r
-  EDD_ATAPI Atapi;\r
-  EDD_SCSI  Scsi;\r
-  EDD_USB   Usb;\r
-  EDD_1394  FireWire;\r
-  EDD_FIBRE FibreChannel;\r
-} EDD_DEVICE_PATH;\r
-\r
-typedef struct {\r
-  UINT16              StructureSize;\r
-  UINT16              Flags;\r
-  UINT32              MaxCylinders;\r
-  UINT32              MaxHeads;\r
-  UINT32              SectorsPerTrack;\r
-  UINT64              PhysicalSectors;\r
-  UINT16              BytesPerSector;\r
-  UINT32              Fdpt;\r
-  UINT16              Key;\r
-  UINT8               DevicePathLength;\r
-  UINT8               Reserved1;\r
-  UINT16              Reserved2;\r
-  CHAR8               HostBusType[4];\r
-  CHAR8               InterfaceType[8];\r
-  EDD_INTERFACE_PATH  InterfacePath;\r
-  EDD_DEVICE_PATH     DevicePath;\r
-  UINT8               Reserved3;\r
-  UINT8               Checksum;\r
-} EDD_DRIVE_PARAMETERS;\r
-\r
-//\r
-// EDD_DRIVE_PARAMETERS.Flags defines\r
-//\r
-#define EDD_GEOMETRY_VALID          0x02\r
-#define EDD_DEVICE_REMOVABLE        0x04\r
-#define EDD_WRITE_VERIFY_SUPPORTED  0x08\r
-#define EDD_DEVICE_CHANGE           0x10\r
-#define EDD_DEVICE_LOCKABLE         0x20\r
-\r
-//\r
-// BUGBUG: This bit does not follow the spec. It tends to be always set\r
-//  to work properly with Win98.\r
-//\r
-#define EDD_DEVICE_GEOMETRY_MAX 0x40\r
-\r
-typedef struct {\r
-  UINT8   PacketSizeInBytes;  // 0x18\r
-  UINT8   Zero;\r
-  UINT8   NumberOfBlocks;     // Max 0x7f\r
-  UINT8   Zero2;\r
-  UINT32  SegOffset;\r
-  UINT64  Lba;\r
-  UINT64  TransferBuffer;\r
-  UINT32  ExtendedBlockCount; // Max 0xffffffff\r
-  UINT32  Zero3;\r
-} EDD_DEVICE_ADDRESS_PACKET;\r
-\r
-#define EDD_VERSION_30  0x30\r
-\r
-//\r
-// Int 13 BIOS Errors\r
-//\r
-#define BIOS_PASS                   0x00\r
-#define BIOS_WRITE_PROTECTED        0x03\r
-#define BIOS_SECTOR_NOT_FOUND       0x04\r
-#define BIOS_RESET_FAILED           0x05\r
-#define BIOS_DISK_CHANGED           0x06\r
-#define BIOS_DRIVE_DOES_NOT_EXIST   0x07\r
-#define BIOS_DMA_ERROR              0x08\r
-#define BIOS_DATA_BOUNDRY_ERROR     0x09\r
-#define BIOS_BAD_SECTOR             0x0a\r
-#define BIOS_BAD_TRACK              0x0b\r
-#define BIOS_MEADIA_TYPE_NOT_FOUND  0x0c\r
-#define BIOS_INVALED_FORMAT         0x0d\r
-#define BIOS_ECC_ERROR              0x10\r
-#define BIOS_ECC_CORRECTED_ERROR    0x11\r
-#define BIOS_HARD_DRIVE_FAILURE     0x20\r
-#define BIOS_SEEK_FAILED            0x40\r
-#define BIOS_DRIVE_TIMEOUT          0x80\r
-#define BIOS_DRIVE_NOT_READY        0xaa\r
-#define BIOS_UNDEFINED_ERROR        0xbb\r
-#define BIOS_WRITE_FAULT            0xcc\r
-#define BIOS_SENSE_FAILED           0xff\r
-\r
-#define MAX_EDD11_XFER              0xfe00\r
-\r
-#pragma pack()\r
-//\r
-// Internal Data Structures\r
-//\r
-typedef struct {\r
-  CHAR8                 Letter;\r
-  UINT8                 Number;\r
-  UINT8                 EddVersion;\r
-  BOOLEAN               ExtendedInt13;\r
-  BOOLEAN               DriveLockingAndEjecting;\r
-  BOOLEAN               Edd;\r
-  BOOLEAN               Extensions64Bit;\r
-  BOOLEAN               ParametersValid;\r
-  UINT8                 ErrorCode;\r
-  VOID                  *FdptPointer;\r
-  BOOLEAN               Floppy;\r
-  BOOLEAN               AtapiFloppy;\r
-  UINT8                 MaxHead;\r
-  UINT8                 MaxSector;\r
-  UINT16                MaxCylinder;\r
-  UINT16                Pad;\r
-  EDD_DRIVE_PARAMETERS  Parameters;\r
-} BIOS_LEGACY_DRIVE;\r
-\r
-#define BIOS_CONSOLE_BLOCK_IO_DEV_SIGNATURE SIGNATURE_32 ('b', 'b', 'i', 'o')\r
-typedef struct {\r
-  UINTN                     Signature;\r
-\r
-  EFI_HANDLE                Handle;\r
-  EFI_HANDLE                ControllerHandle;\r
-  EFI_BLOCK_IO_PROTOCOL     BlockIo;\r
-  EFI_BLOCK_IO_MEDIA        BlockMedia;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-\r
-  BIOS_LEGACY_DRIVE         Bios;\r
-\r
-} BIOS_BLOCK_IO_DEV;\r
-\r
-#define BIOS_BLOCK_IO_FROM_THIS(a)  CR (a, BIOS_BLOCK_IO_DEV, BlockIo, BIOS_CONSOLE_BLOCK_IO_DEV_SIGNATURE)\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c
deleted file mode 100644 (file)
index 7f3f48b..0000000
+++ /dev/null
@@ -1,2514 +0,0 @@
-/** @file\r
-  ConsoleOut Routines that speak VGA.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosKeyboard.h"\r
-\r
-//\r
-// EFI Driver Binding Protocol Instance\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gBiosKeyboardDriverBinding = {\r
-  BiosKeyboardDriverBindingSupported,\r
-  BiosKeyboardDriverBindingStart,\r
-  BiosKeyboardDriverBindingStop,\r
-  0x3,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-/**\r
-  Enqueue the key.\r
-\r
-  @param  Queue                 The queue to be enqueued.\r
-  @param  KeyData               The key data to be enqueued.\r
-\r
-  @retval EFI_NOT_READY         The queue is full.\r
-  @retval EFI_SUCCESS           Successfully enqueued the key data.\r
-\r
-**/\r
-EFI_STATUS\r
-Enqueue (\r
-  IN SIMPLE_QUEUE         *Queue,\r
-  IN EFI_KEY_DATA         *KeyData\r
-  )\r
-{\r
-  if ((Queue->Rear + 1) % QUEUE_MAX_COUNT == Queue->Front) {\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  CopyMem (&Queue->Buffer[Queue->Rear], KeyData, sizeof (EFI_KEY_DATA));\r
-  Queue->Rear = (Queue->Rear + 1) % QUEUE_MAX_COUNT;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Dequeue the key.\r
-\r
-  @param  Queue                 The queue to be dequeued.\r
-  @param  KeyData               The key data to be dequeued.\r
-\r
-  @retval EFI_NOT_READY         The queue is empty.\r
-  @retval EFI_SUCCESS           Successfully dequeued the key data.\r
-\r
-**/\r
-EFI_STATUS\r
-Dequeue (\r
-  IN SIMPLE_QUEUE         *Queue,\r
-  IN EFI_KEY_DATA         *KeyData\r
-  )\r
-{\r
-  if (Queue->Front == Queue->Rear) {\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  CopyMem (KeyData, &Queue->Buffer[Queue->Front], sizeof (EFI_KEY_DATA));\r
-  Queue->Front  = (Queue->Front + 1) % QUEUE_MAX_COUNT;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Check whether the queue is empty.\r
-\r
-  @param  Queue                 The queue to be checked.\r
-\r
-  @retval EFI_NOT_READY         The queue is empty.\r
-  @retval EFI_SUCCESS           The queue is not empty.\r
-\r
-**/\r
-EFI_STATUS\r
-CheckQueue (\r
-  IN SIMPLE_QUEUE         *Queue\r
-  )\r
-{\r
-  if (Queue->Front == Queue->Rear) {\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// EFI Driver Binding Protocol Functions\r
-//\r
-\r
-/**\r
-  Check whether the driver supports this device.\r
-\r
-  @param  This                   The Udriver binding protocol.\r
-  @param  Controller             The controller handle to check.\r
-  @param  RemainingDevicePath    The remaining device path.\r
-\r
-  @retval EFI_SUCCESS            The driver supports this controller.\r
-  @retval other                  This device isn't supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL                  *LegacyBios;\r
-  EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
-\r
-  //\r
-  // See if the Legacy BIOS Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiLegacyBiosProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &LegacyBios\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Use the ISA I/O Protocol to see if Controller is the Keyboard controller\r
-  //\r
-  if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303) || IsaIo->ResourceList->Device.UID != 0) {\r
-    Status = EFI_UNSUPPORTED;\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Starts the device with this driver.\r
-\r
-  @param  This                   The driver binding instance.\r
-  @param  Controller             Handle of device to bind driver to.\r
-  @param  RemainingDevicePath    Optional parameter use to pick a specific child\r
-                                 device to start.\r
-\r
-  @retval EFI_SUCCESS            The controller is controlled by the driver.\r
-  @retval Other                  This controller cannot be started.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL                  *LegacyBios;\r
-  EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
-  BIOS_KEYBOARD_DEV                         *BiosKeyboardPrivate;\r
-  EFI_IA32_REGISTER_SET                     Regs;\r
-  BOOLEAN                                   CarryFlag;\r
-  EFI_PS2_POLICY_PROTOCOL                   *Ps2Policy;\r
-  UINT8                                     Command;\r
-  EFI_STATUS_CODE_VALUE                     StatusCode;\r
-\r
-  BiosKeyboardPrivate = NULL;\r
-  IsaIo = NULL;\r
-  StatusCode          = 0;\r
-\r
-  //\r
-  // Get Ps2 policy to set. Will be use if present.\r
-  //\r
-  gBS->LocateProtocol (\r
-        &gEfiPs2PolicyProtocolGuid,\r
-        NULL,\r
-        (VOID **) &Ps2Policy\r
-        );\r
-\r
-  //\r
-  // See if the Legacy BIOS Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiLegacyBiosProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &LegacyBios\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Open the IO Abstraction(s) needed\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Allocate the private device structure\r
-  //\r
-    BiosKeyboardPrivate = (BIOS_KEYBOARD_DEV *) AllocateZeroPool (sizeof (BIOS_KEYBOARD_DEV));\r
-  if (NULL == BiosKeyboardPrivate) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Initialize the private device structure\r
-  //\r
-  BiosKeyboardPrivate->Signature                  = BIOS_KEYBOARD_DEV_SIGNATURE;\r
-  BiosKeyboardPrivate->Handle                     = Controller;\r
-  BiosKeyboardPrivate->LegacyBios                 = LegacyBios;\r
-  BiosKeyboardPrivate->IsaIo                      = IsaIo;\r
-\r
-  BiosKeyboardPrivate->SimpleTextIn.Reset         = BiosKeyboardReset;\r
-  BiosKeyboardPrivate->SimpleTextIn.ReadKeyStroke = BiosKeyboardReadKeyStroke;\r
-\r
-  BiosKeyboardPrivate->DataRegisterAddress        = KEYBOARD_8042_DATA_REGISTER;\r
-  BiosKeyboardPrivate->StatusRegisterAddress      = KEYBOARD_8042_STATUS_REGISTER;\r
-  BiosKeyboardPrivate->CommandRegisterAddress     = KEYBOARD_8042_COMMAND_REGISTER;\r
-  BiosKeyboardPrivate->ExtendedKeyboard           = TRUE;\r
-\r
-  BiosKeyboardPrivate->KeyState.KeyShiftState     = 0;\r
-  BiosKeyboardPrivate->KeyState.KeyToggleState    = 0;\r
-  BiosKeyboardPrivate->Queue.Front                = 0;\r
-  BiosKeyboardPrivate->Queue.Rear                 = 0;\r
-  BiosKeyboardPrivate->QueueForNotify.Front       = 0;\r
-  BiosKeyboardPrivate->QueueForNotify.Rear        = 0;\r
-  BiosKeyboardPrivate->SimpleTextInputEx.Reset               = BiosKeyboardResetEx;\r
-  BiosKeyboardPrivate->SimpleTextInputEx.ReadKeyStrokeEx     = BiosKeyboardReadKeyStrokeEx;\r
-  BiosKeyboardPrivate->SimpleTextInputEx.SetState            = BiosKeyboardSetState;\r
-  BiosKeyboardPrivate->SimpleTextInputEx.RegisterKeyNotify   = BiosKeyboardRegisterKeyNotify;\r
-  BiosKeyboardPrivate->SimpleTextInputEx.UnregisterKeyNotify = BiosKeyboardUnregisterKeyNotify;\r
-  InitializeListHead (&BiosKeyboardPrivate->NotifyList);\r
-\r
-  //\r
-  // Report that the keyboard is being enabled\r
-  //\r
-  REPORT_STATUS_CODE (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_ENABLE\r
-    );\r
-\r
-  //\r
-  // Setup the WaitForKey event\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_WAIT,\r
-                  TPL_NOTIFY,\r
-                  BiosKeyboardWaitForKey,\r
-                  &(BiosKeyboardPrivate->SimpleTextIn),\r
-                  &((BiosKeyboardPrivate->SimpleTextIn).WaitForKey)\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    (BiosKeyboardPrivate->SimpleTextIn).WaitForKey = NULL;\r
-    goto Done;\r
-  }\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_WAIT,\r
-                  TPL_NOTIFY,\r
-                  BiosKeyboardWaitForKeyEx,\r
-                  &(BiosKeyboardPrivate->SimpleTextInputEx),\r
-                  &(BiosKeyboardPrivate->SimpleTextInputEx.WaitForKeyEx)\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    BiosKeyboardPrivate->SimpleTextInputEx.WaitForKeyEx = NULL;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Setup a periodic timer, used for reading keystrokes at a fixed interval\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  BiosKeyboardTimerHandler,\r
-                  BiosKeyboardPrivate,\r
-                  &BiosKeyboardPrivate->TimerEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status      = EFI_OUT_OF_RESOURCES;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  Status = gBS->SetTimer (\r
-                  BiosKeyboardPrivate->TimerEvent,\r
-                  TimerPeriodic,\r
-                  KEYBOARD_TIMER_INTERVAL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status      = EFI_OUT_OF_RESOURCES;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  KeyNotifyProcessHandler,\r
-                  BiosKeyboardPrivate,\r
-                  &BiosKeyboardPrivate->KeyNotifyProcessEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status      = EFI_OUT_OF_RESOURCES;\r
-    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Report a Progress Code for an attempt to detect the precense of the keyboard device in the system\r
-  //\r
-  REPORT_STATUS_CODE (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_PRESENCE_DETECT\r
-    );\r
-\r
-  //\r
-  // Reset the keyboard device\r
-  //\r
-  Status = BiosKeyboardPrivate->SimpleTextInputEx.Reset (\r
-                                                    &BiosKeyboardPrivate->SimpleTextInputEx,\r
-                                                    FeaturePcdGet (PcdPs2KbdExtendedVerification)\r
-                                                    );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "[KBD]Reset Failed. Status - %r\n", Status));\r
-    StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;\r
-    goto Done;\r
-  }\r
-  //\r
-  // Do platform specific policy like port swapping and keyboard light default\r
-  //\r
-  if (Ps2Policy != NULL) {\r
-\r
-    Ps2Policy->Ps2InitHardware (Controller);\r
-\r
-    Command = 0;\r
-    if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_CAPSLOCK) == EFI_KEYBOARD_CAPSLOCK) {\r
-      Command |= 4;\r
-    }\r
-\r
-    if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_NUMLOCK) == EFI_KEYBOARD_NUMLOCK) {\r
-      Command |= 2;\r
-    }\r
-\r
-    if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_SCROLLLOCK) == EFI_KEYBOARD_SCROLLLOCK) {\r
-      Command |= 1;\r
-    }\r
-\r
-    KeyboardWrite (BiosKeyboardPrivate, 0xed);\r
-    KeyboardWaitForValue (BiosKeyboardPrivate, 0xfa, KEYBOARD_WAITFORVALUE_TIMEOUT);\r
-    KeyboardWrite (BiosKeyboardPrivate, Command);\r
-    //\r
-    // Call Legacy BIOS Protocol to set whatever is necessary\r
-    //\r
-    LegacyBios->UpdateKeyboardLedStatus (LegacyBios, Command);\r
-  }\r
-  //\r
-  // Get Configuration\r
-  //\r
-  Regs.H.AH = 0xc0;\r
-  CarryFlag = BiosKeyboardPrivate->LegacyBios->Int86 (\r
-                                                 BiosKeyboardPrivate->LegacyBios,\r
-                                                 0x15,\r
-                                                 &Regs\r
-                                                 );\r
-\r
-  if (!CarryFlag) {\r
-    //\r
-    // Check bit 6 of Feature Byte 2.\r
-    // If it is set, then Int 16 Func 09 is supported\r
-    //\r
-    if (*(UINT8 *) (((UINTN) Regs.X.ES << 4) + Regs.X.BX + 0x06) & 0x40) {\r
-      //\r
-      // Get Keyboard Functionality\r
-      //\r
-      Regs.H.AH = 0x09;\r
-      CarryFlag = BiosKeyboardPrivate->LegacyBios->Int86 (\r
-                                                     BiosKeyboardPrivate->LegacyBios,\r
-                                                     0x16,\r
-                                                     &Regs\r
-                                                     );\r
-\r
-      if (!CarryFlag) {\r
-        //\r
-        // Check bit 5 of AH.\r
-        // If it is set, then INT 16 Finc 10-12 are supported.\r
-        //\r
-        if ((Regs.H.AL & 0x40) != 0) {\r
-          //\r
-          // Set the flag to use INT 16 Func 10-12\r
-          //\r
-          BiosKeyboardPrivate->ExtendedKeyboard = TRUE;\r
-        }\r
-      }\r
-    }\r
-  }\r
-  DEBUG ((EFI_D_INFO, "[KBD]Extended keystrokes supported by CSM16 - %02x\n", (UINTN)BiosKeyboardPrivate->ExtendedKeyboard));\r
-  //\r
-  // Install protocol interfaces for the keyboard device.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiSimpleTextInProtocolGuid,\r
-                  &BiosKeyboardPrivate->SimpleTextIn,\r
-                  &gEfiSimpleTextInputExProtocolGuid,\r
-                  &BiosKeyboardPrivate->SimpleTextInputEx,\r
-                  NULL\r
-                  );\r
-\r
-Done:\r
-  if (StatusCode != 0) {\r
-    //\r
-    // Report an Error Code for failing to start the keyboard device\r
-    //\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      StatusCode\r
-      );\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-\r
-    if (BiosKeyboardPrivate != NULL) {\r
-      if ((BiosKeyboardPrivate->SimpleTextIn).WaitForKey != NULL) {\r
-        gBS->CloseEvent ((BiosKeyboardPrivate->SimpleTextIn).WaitForKey);\r
-      }\r
-\r
-      if ((BiosKeyboardPrivate->SimpleTextInputEx).WaitForKeyEx != NULL) {\r
-        gBS->CloseEvent ((BiosKeyboardPrivate->SimpleTextInputEx).WaitForKeyEx);\r
-      }\r
-\r
-      if (BiosKeyboardPrivate->KeyNotifyProcessEvent != NULL) {\r
-        gBS->CloseEvent (BiosKeyboardPrivate->KeyNotifyProcessEvent);\r
-      }\r
-\r
-      BiosKeyboardFreeNotifyList (&BiosKeyboardPrivate->NotifyList);\r
-\r
-      if (BiosKeyboardPrivate->TimerEvent != NULL) {\r
-        gBS->CloseEvent (BiosKeyboardPrivate->TimerEvent);\r
-      }\r
-\r
-      FreePool (BiosKeyboardPrivate);\r
-    }\r
-\r
-    if (IsaIo != NULL) {\r
-      gBS->CloseProtocol (\r
-             Controller,\r
-             &gEfiIsaIoProtocolGuid,\r
-             This->DriverBindingHandle,\r
-             Controller\r
-             );\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stop the device handled by this driver.\r
-\r
-  @param  This                   The driver binding protocol.\r
-  @param  Controller             The controller to release.\r
-  @param  NumberOfChildren       The number of handles in ChildHandleBuffer.\r
-  @param  ChildHandleBuffer      The array of child handle.\r
-\r
-  @retval EFI_SUCCESS            The device was stopped.\r
-  @retval EFI_DEVICE_ERROR       The device could not be stopped due to a device error.\r
-  @retval Others                 Fail to uninstall protocols attached on the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Controller,\r
-  IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                     Status;\r
-  EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn;\r
-  BIOS_KEYBOARD_DEV              *BiosKeyboardPrivate;\r
-\r
-  //\r
-  // Disable Keyboard\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiSimpleTextInProtocolGuid,\r
-                  (VOID **) &SimpleTextIn,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiSimpleTextInputExProtocolGuid,\r
-                  NULL,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  BiosKeyboardPrivate = BIOS_KEYBOARD_DEV_FROM_THIS (SimpleTextIn);\r
-\r
-  Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                  Controller,\r
-                  &gEfiSimpleTextInProtocolGuid,\r
-                  &BiosKeyboardPrivate->SimpleTextIn,\r
-                  &gEfiSimpleTextInputExProtocolGuid,\r
-                  &BiosKeyboardPrivate->SimpleTextInputEx,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Release the IsaIo protocol on the controller handle\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  //\r
-  // Free other resources\r
-  //\r
-  gBS->CloseEvent ((BiosKeyboardPrivate->SimpleTextIn).WaitForKey);\r
-  gBS->CloseEvent (BiosKeyboardPrivate->TimerEvent);\r
-  gBS->CloseEvent (BiosKeyboardPrivate->SimpleTextInputEx.WaitForKeyEx);\r
-  gBS->CloseEvent (BiosKeyboardPrivate->KeyNotifyProcessEvent);\r
-  BiosKeyboardFreeNotifyList (&BiosKeyboardPrivate->NotifyList);\r
-\r
-  FreePool (BiosKeyboardPrivate);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Read data byte from output buffer of Keyboard Controller without delay and waiting for buffer-empty state.\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-\r
-  @return  The data byte read from output buffer of Keyboard Controller from data port which often is port 60H.\r
-\r
-**/\r
-UINT8\r
-KeyReadDataRegister (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  //\r
-  // Use IsaIo protocol to perform IO operations\r
-  //\r
-  BiosKeyboardPrivate->IsaIo->Io.Read (\r
-                                   BiosKeyboardPrivate->IsaIo,\r
-                                   EfiIsaIoWidthUint8,\r
-                                   BiosKeyboardPrivate->DataRegisterAddress,\r
-                                   1,\r
-                                   &Data\r
-                                   );\r
-\r
-  return Data;\r
-}\r
-\r
-/**\r
-  Read status byte from status register of Keyboard Controller without delay and waiting for buffer-empty state.\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-\r
-  @return  The status byte read from status register of Keyboard Controller from command port which often is port 64H.\r
-\r
-**/\r
-UINT8\r
-KeyReadStatusRegister (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate\r
-  )\r
-{\r
-  UINT8 Data;\r
-\r
-  //\r
-  // Use IsaIo protocol to perform IO operations\r
-  //\r
-  BiosKeyboardPrivate->IsaIo->Io.Read (\r
-                                   BiosKeyboardPrivate->IsaIo,\r
-                                   EfiIsaIoWidthUint8,\r
-                                   BiosKeyboardPrivate->StatusRegisterAddress,\r
-                                   1,\r
-                                   &Data\r
-                                   );\r
-\r
-  return Data;\r
-}\r
-\r
-/**\r
-  Write command byte to control register of Keyboard Controller without delay and waiting for buffer-empty state.\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-  @param   Data                 Data byte to write.\r
-\r
-**/\r
-VOID\r
-KeyWriteCommandRegister (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate,\r
-  IN UINT8              Data\r
-  )\r
-{\r
-  //\r
-  // Use IsaIo protocol to perform IO operations\r
-  //\r
-  BiosKeyboardPrivate->IsaIo->Io.Write (\r
-                                   BiosKeyboardPrivate->IsaIo,\r
-                                   EfiIsaIoWidthUint8,\r
-                                   BiosKeyboardPrivate->CommandRegisterAddress,\r
-                                   1,\r
-                                   &Data\r
-                                   );\r
-}\r
-\r
-/**\r
-  Write data byte to input buffer or input/output ports of Keyboard Controller without delay and waiting for buffer-empty state.\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-  @param   Data                 Data byte to write.\r
-\r
-**/\r
-VOID\r
-KeyWriteDataRegister (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate,\r
-  IN UINT8              Data\r
-  )\r
-{\r
-  //\r
-  // Use IsaIo protocol to perform IO operations\r
-  //\r
-  BiosKeyboardPrivate->IsaIo->Io.Write (\r
-                                   BiosKeyboardPrivate->IsaIo,\r
-                                   EfiIsaIoWidthUint8,\r
-                                   BiosKeyboardPrivate->DataRegisterAddress,\r
-                                   1,\r
-                                   &Data\r
-                                   );\r
-}\r
-\r
-/**\r
-  Read data byte from output buffer of Keyboard Controller with delay and waiting for buffer-empty state.\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-  @param   Data                 The pointer for data that being read out.\r
-\r
-  @retval  EFI_SUCCESS          The data byte read out successfully.\r
-  @retval  EFI_TIMEOUT          Timeout occurred during reading out data byte.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardRead (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate,\r
-  OUT UINT8             *Data\r
-  )\r
-{\r
-  UINT32  TimeOut;\r
-  UINT32  RegFilled;\r
-\r
-  TimeOut   = 0;\r
-  RegFilled = 0;\r
-\r
-  //\r
-  // wait till output buffer full then perform the read\r
-  //\r
-  for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-    if ((KeyReadStatusRegister (BiosKeyboardPrivate) & KBC_STSREG_VIA64_OUTB) != 0) {\r
-      RegFilled = 1;\r
-      *Data     = KeyReadDataRegister (BiosKeyboardPrivate);\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (30);\r
-  }\r
-\r
-  if (RegFilled == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write data byte to input buffer or input/output ports of Keyboard Controller with delay and waiting for buffer-empty state.\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-  @param   Data                 Data byte to write.\r
-\r
-  @retval  EFI_SUCCESS          The data byte is written successfully.\r
-  @retval  EFI_TIMEOUT          Timeout occurred during writing.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardWrite (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate,\r
-  IN UINT8              Data\r
-  )\r
-{\r
-  UINT32  TimeOut;\r
-  UINT32  RegEmptied;\r
-\r
-  TimeOut     = 0;\r
-  RegEmptied  = 0;\r
-\r
-  //\r
-  // wait for input buffer empty\r
-  //\r
-  for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-    if ((KeyReadStatusRegister (BiosKeyboardPrivate) & KBC_STSREG_VIA64_INPB) == 0) {\r
-      RegEmptied = 1;\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (30);\r
-  }\r
-\r
-  if (RegEmptied == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-  //\r
-  // Write it\r
-  //\r
-  KeyWriteDataRegister (BiosKeyboardPrivate, Data);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write command byte to control register of Keyboard Controller with delay and waiting for buffer-empty state.\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-  @param   Data                 Command byte to write.\r
-\r
-  @retval  EFI_SUCCESS          The command byte is written successfully.\r
-  @retval  EFI_TIMEOUT          Timeout occurred during writing.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardCommand (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate,\r
-  IN UINT8              Data\r
-  )\r
-{\r
-  UINT32  TimeOut;\r
-  UINT32  RegEmptied;\r
-\r
-  TimeOut     = 0;\r
-  RegEmptied  = 0;\r
-\r
-  //\r
-  // Wait For Input Buffer Empty\r
-  //\r
-  for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-    if ((KeyReadStatusRegister (BiosKeyboardPrivate) & KBC_STSREG_VIA64_INPB) == 0) {\r
-      RegEmptied = 1;\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (30);\r
-  }\r
-\r
-  if (RegEmptied == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-  //\r
-  // issue the command\r
-  //\r
-  KeyWriteCommandRegister (BiosKeyboardPrivate, Data);\r
-\r
-  //\r
-  // Wait For Input Buffer Empty again\r
-  //\r
-  RegEmptied = 0;\r
-  for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-    if ((KeyReadStatusRegister (BiosKeyboardPrivate) & KBC_STSREG_VIA64_INPB) == 0) {\r
-      RegEmptied = 1;\r
-      break;\r
-    }\r
-\r
-    gBS->Stall (30);\r
-  }\r
-\r
-  if (RegEmptied == 0) {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Wait for a specific value to be presented in\r
-  Data register of Keyboard Controller by keyboard and then read it,\r
-  used in keyboard commands ack\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-  @param   Value                The value to be waited for\r
-  @param   WaitForValueTimeOut  The limit of microseconds for timeout\r
-\r
-  @retval  EFI_SUCCESS          The command byte is written successfully.\r
-  @retval  EFI_TIMEOUT          Timeout occurred during writing.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardWaitForValue (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate,\r
-  IN UINT8              Value,\r
-  IN UINTN              WaitForValueTimeOut\r
-  )\r
-{\r
-  UINT8   Data;\r
-  UINT32  TimeOut;\r
-  UINT32  SumTimeOut;\r
-  UINT32  GotIt;\r
-\r
-  GotIt       = 0;\r
-  TimeOut     = 0;\r
-  SumTimeOut  = 0;\r
-\r
-  //\r
-  // Make sure the initial value of 'Data' is different from 'Value'\r
-  //\r
-  Data = 0;\r
-  if (Data == Value) {\r
-    Data = 1;\r
-  }\r
-  //\r
-  // Read from 8042 (multiple times if needed)\r
-  // until the expected value appears\r
-  // use SumTimeOut to control the iteration\r
-  //\r
-  while (1) {\r
-    //\r
-    // Perform a read\r
-    //\r
-    for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {\r
-      if ((KeyReadStatusRegister (BiosKeyboardPrivate) & KBC_STSREG_VIA64_OUTB) != 0) {\r
-        Data = KeyReadDataRegister (BiosKeyboardPrivate);\r
-        break;\r
-      }\r
-\r
-      gBS->Stall (30);\r
-    }\r
-\r
-    SumTimeOut += TimeOut;\r
-\r
-    if (Data == Value) {\r
-      GotIt = 1;\r
-      break;\r
-    }\r
-\r
-    if (SumTimeOut >= WaitForValueTimeOut) {\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Check results\r
-  //\r
-  if (GotIt != 0) {\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    return EFI_TIMEOUT;\r
-  }\r
-\r
-}\r
-\r
-/**\r
-  Reads the next keystroke from the input device. The WaitForKey Event can\r
-  be used to test for existance of a keystroke via WaitForEvent () call.\r
-\r
-  @param  BiosKeyboardPrivate   Bioskeyboard driver private structure.\r
-  @param  KeyData               A pointer to a buffer that is filled in with the keystroke\r
-                                state data for the key that was pressed.\r
-\r
-  @retval EFI_SUCCESS           The keystroke information was returned.\r
-  @retval EFI_NOT_READY         There was no keystroke data availiable.\r
-  @retval EFI_DEVICE_ERROR      The keystroke information was not returned due to\r
-                                hardware errors.\r
-  @retval EFI_INVALID_PARAMETER KeyData is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardReadKeyStrokeWorker (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate,\r
-  OUT EFI_KEY_DATA      *KeyData\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_TPL                               OldTpl;\r
-  if (KeyData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Use TimerEvent callback function to check whether there's any key pressed\r
-  //\r
-\r
-  //\r
-  // Stall 1ms to give a chance to let other driver interrupt this routine for their timer event.\r
-  // Csm will be used to check whether there is a key pending, but the csm will disable all\r
-  // interrupt before switch to compatibility16, which mean all the efiCompatibility timer\r
-  // event will stop work during the compatibility16. And If a caller recursivly invoke this function,\r
-  // e.g. OS loader, other drivers which are driven by timer event will have a bad performance during this period,\r
-  // e.g. usb keyboard driver.\r
-  // Add a stall period can greatly increate other driver performance during the WaitForKey is recursivly invoked.\r
-  // 1ms delay will make little impact to the thunk keyboard driver, and user can not feel the delay at all when input.\r
-  //\r
-  gBS->Stall (1000);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  BiosKeyboardTimerHandler (NULL, BiosKeyboardPrivate);\r
-  //\r
-  // If there's no key, just return\r
-  //\r
-  Status = CheckQueue (&BiosKeyboardPrivate->Queue);\r
-  if (EFI_ERROR (Status)) {\r
-    ZeroMem (&KeyData->Key, sizeof (KeyData->Key));\r
-    CopyMem (&KeyData->KeyState, &BiosKeyboardPrivate->KeyState, sizeof (EFI_KEY_STATE));\r
-    gBS->RestoreTPL (OldTpl);\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  Status = Dequeue (&BiosKeyboardPrivate->Queue, KeyData);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// EFI Simple Text In Protocol Functions\r
-//\r
-/**\r
-  Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE) then do some extra keyboard validations.\r
-\r
-  @param  This                  Pointer of simple text Protocol.\r
-  @param  ExtendedVerification  Whether perform the extra validation of keyboard. True: perform; FALSE: skip.\r
-\r
-  @retval EFI_SUCCESS           The command byte is written successfully.\r
-  @retval EFI_DEVICE_ERROR      Errors occurred during resetting keyboard.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardReset (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  IN  BOOLEAN                         ExtendedVerification\r
-  )\r
-{\r
-  BIOS_KEYBOARD_DEV *BiosKeyboardPrivate;\r
-  EFI_STATUS        Status;\r
-  EFI_TPL           OldTpl;\r
-  UINT8             CommandByte;\r
-  BOOLEAN           MouseEnable;\r
-  EFI_INPUT_KEY     Key;\r
-\r
-  MouseEnable         = FALSE;\r
-  BiosKeyboardPrivate = BIOS_KEYBOARD_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // 1\r
-  // Report reset progress code\r
-  //\r
-  REPORT_STATUS_CODE (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_RESET\r
-    );\r
-\r
-  //\r
-  // Report a Progress Code for clearing the keyboard buffer\r
-  //\r
-  REPORT_STATUS_CODE (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_CLEAR_BUFFER\r
-    );\r
-\r
-  //\r
-  // 2\r
-  // Raise TPL to avoid mouse operation impact\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  //\r
-  // Exhaust output buffer data\r
-  //\r
-  do {\r
-    Status = BiosKeyboardReadKeyStroke (\r
-               This,\r
-               &Key\r
-               );\r
-  } while (!EFI_ERROR (Status));\r
-  //\r
-  // 3\r
-  // check for KBC itself firstly for setted-up already or not by reading SYSF (bit2) of status register via 64H\r
-  // if not skip step 4&5 and jump to step 6 to selftest KBC and report this\r
-  // else   go step 4\r
-  //\r
-  if (!PcdGetBool (PcdFastPS2Detection)) {\r
-    if ((KeyReadStatusRegister (BiosKeyboardPrivate) & KBC_STSREG_VIA64_SYSF) != 0) {\r
-      //\r
-      // 4\r
-      // CheckMouseStatus to decide enable it later or not\r
-      //\r
-      //\r
-      // Read the command byte of KBC\r
-      //\r
-      Status = KeyboardCommand (\r
-                 BiosKeyboardPrivate,\r
-                 KBC_CMDREG_VIA64_CMDBYTE_R\r
-                 );\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        Status    = EFI_DEVICE_ERROR;\r
-        goto Exit;\r
-      }\r
-\r
-      Status = KeyboardRead (\r
-                 BiosKeyboardPrivate,\r
-                 &CommandByte\r
-                 );\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        Status    = EFI_DEVICE_ERROR;\r
-        goto Exit;\r
-      }\r
-      //\r
-      // Check mouse enabled or not before\r
-      //\r
-      if ((CommandByte & KB_CMMBYTE_DISABLE_AUX) != 0) {\r
-        MouseEnable = FALSE;\r
-      } else {\r
-        MouseEnable = TRUE;\r
-      }\r
-      //\r
-      // 5\r
-      // disable mouse (via KBC) and Keyborad device\r
-      //\r
-      Status = KeyboardCommand (\r
-                 BiosKeyboardPrivate,\r
-                 KBC_CMDREG_VIA64_AUX_DISABLE\r
-                 );\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        Status    = EFI_DEVICE_ERROR;\r
-        goto Exit;\r
-      }\r
-\r
-      Status = KeyboardCommand (\r
-                 BiosKeyboardPrivate,\r
-                 KBC_CMDREG_VIA64_KB_DISABLE\r
-                 );\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        Status    = EFI_DEVICE_ERROR;\r
-        goto Exit;\r
-      }\r
-    } else {\r
-      //\r
-      // 6\r
-      // KBC Self Test\r
-      //\r
-      //\r
-      // Report a Progress Code for performing a self test on the keyboard controller\r
-      //\r
-      REPORT_STATUS_CODE (\r
-        EFI_PROGRESS_CODE,\r
-        EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST\r
-        );\r
-\r
-      Status = KeyboardCommand (\r
-                 BiosKeyboardPrivate,\r
-                 KBC_CMDREG_VIA64_KBC_SLFTEST\r
-                 );\r
-      if (EFI_ERROR (Status)) {\r
-        Status    = EFI_DEVICE_ERROR;\r
-        goto Exit;\r
-      }\r
-\r
-      Status = KeyboardWaitForValue (\r
-                 BiosKeyboardPrivate,\r
-                 KBC_CMDECHO_KBCSLFTEST_OK,\r
-                 KEYBOARD_WAITFORVALUE_TIMEOUT\r
-                 );\r
-      if (EFI_ERROR (Status)) {\r
-        Status    = EFI_DEVICE_ERROR;\r
-        goto Exit;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // 7\r
-  // Disable  Mouse interface, enable  Keyboard interface and declare selftest success\r
-  //\r
-  // Mouse device will block keyboard interface before it be configured, so we should disable mouse first.\r
-  //\r
-  Status = KeyboardCommand (\r
-             BiosKeyboardPrivate,\r
-             KBC_CMDREG_VIA64_CMDBYTE_W\r
-             );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    Status    = EFI_DEVICE_ERROR;\r
-    goto Exit;\r
-  }\r
-\r
-  //\r
-  // Write 8042 Command Byte, set System Flag\r
-  // While at the same time:\r
-  //  1. disable mouse interface,\r
-  //  2. enable kbd interface,\r
-  //  3. enable PC/XT kbd translation mode\r
-  //  4. enable mouse and kbd interrupts\r
-  //\r
-  //Command Byte bits:\r
-  //  7: Reserved\r
-  //  6: PC/XT translation mode\r
-  //  5: Disable Auxiliary device interface\r
-  //  4: Disable keyboard interface\r
-  //  3: Reserved\r
-  //  2: System Flag\r
-  //  1: Enable Auxiliary device interrupt\r
-  //  0: Enable Keyboard interrupt\r
-  //\r
-  CommandByte = 0;\r
-  Status = KeyboardWrite (\r
-             BiosKeyboardPrivate,\r
-             (UINT8) ((CommandByte &\r
-              (~KB_CMMBYTE_DISABLE_KB)) |\r
-              KB_CMMBYTE_KSCAN2UNI_COV |\r
-              KB_CMMBYTE_ENABLE_AUXINT |\r
-              KB_CMMBYTE_ENABLE_KBINT  |\r
-              KB_CMMBYTE_SLFTEST_SUCC  |\r
-              KB_CMMBYTE_DISABLE_AUX)\r
-             );\r
-\r
-  //\r
-  // For resetting keyboard is not mandatory before booting OS and sometimes keyboard responses very slow,\r
-  // so we only do the real resetting for keyboard when user asks, and normally during booting an OS, it's skipped.\r
-  // Call CheckKeyboardConnect() to check whether keyboard is connected, if it is not connected,\r
-  // Real reset will not do.\r
-  //\r
-  if (ExtendedVerification && CheckKeyboardConnect (BiosKeyboardPrivate)) {\r
-    //\r
-    // 8\r
-    // Send keyboard reset command then read ACK\r
-    //\r
-    Status = KeyboardWrite (\r
-               BiosKeyboardPrivate,\r
-               KBC_INPBUF_VIA60_KBRESET\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDECHO_ACK,\r
-               KEYBOARD_WAITFORVALUE_TIMEOUT\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-    //\r
-    // 9\r
-    // Wait for keyboard return test OK.\r
-    //\r
-    Status = KeyboardWaitForValue (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDECHO_BATTEST_OK,\r
-               KEYBOARD_WAITFORVALUE_TIMEOUT\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-    //\r
-    // 10\r
-    // set keyboard scan code set = 02 (standard configuration)\r
-    //\r
-    Status = KeyboardWrite (\r
-               BiosKeyboardPrivate,\r
-               KBC_INPBUF_VIA60_KBSCODE\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDECHO_ACK,\r
-               KEYBOARD_WAITFORVALUE_TIMEOUT\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = KeyboardWrite (\r
-               BiosKeyboardPrivate,\r
-               KBC_INPBUF_VIA60_SCODESET2\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDECHO_ACK,\r
-               KEYBOARD_WAITFORVALUE_TIMEOUT\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-    //\r
-    // 11\r
-    // enable keyboard itself (not via KBC) by writing CMD F4 via 60H\r
-    //\r
-    Status = KeyboardWrite (\r
-               BiosKeyboardPrivate,\r
-               KBC_INPBUF_VIA60_KBEN\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDECHO_ACK,\r
-               KEYBOARD_WAITFORVALUE_TIMEOUT\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-    //\r
-    // 12\r
-    // Additional validation, do it as follow:\r
-    // 1). check for status register of PARE && TIM via 64H\r
-    // 2). perform KB checking by writing ABh via 64H\r
-    //\r
-    if ((KeyReadStatusRegister (BiosKeyboardPrivate) & (KBC_STSREG_VIA64_PARE | KBC_STSREG_VIA64_TIM)) != 0) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = KeyboardCommand (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDREG_VIA64_KB_CKECK\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDECHO_KBCHECK_OK,\r
-               KEYBOARD_WAITFORVALUE_TIMEOUT\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-  }\r
-  //\r
-  // 13\r
-  // Done for validating keyboard. Enable keyboard (via KBC)\r
-  // and recover the command byte to proper value\r
-  //\r
-  if (!PcdGetBool (PcdFastPS2Detection)) {\r
-    Status = KeyboardCommand (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDREG_VIA64_KB_ENABLE\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-      goto Exit;\r
-    }\r
-  }\r
-\r
-  //\r
-  // 14\r
-  // conditionally enable mouse (via KBC)\r
-  //\r
-  if (MouseEnable) {\r
-    Status = KeyboardCommand (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDREG_VIA64_AUX_ENABLE\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status    = EFI_DEVICE_ERROR;\r
-\r
-    }\r
-  }\r
-\r
-Exit:\r
-  //\r
-  // 15\r
-  // resume priority of task level\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-\r
-}\r
-\r
-/**\r
-  Read out the scan code of the key that has just been stroked.\r
-\r
-  @param  This        Pointer of simple text Protocol.\r
-  @param  Key         Pointer for store the key that read out.\r
-\r
-  @retval EFI_SUCCESS The key is read out successfully.\r
-  @retval other       The key reading failed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardReadKeyStroke (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  OUT EFI_INPUT_KEY                   *Key\r
-  )\r
-{\r
-  BIOS_KEYBOARD_DEV     *BiosKeyboardPrivate;\r
-  EFI_STATUS            Status;\r
-  EFI_KEY_DATA          KeyData;\r
-\r
-  BiosKeyboardPrivate = BIOS_KEYBOARD_DEV_FROM_THIS (This);\r
-\r
-  Status = KeyboardReadKeyStrokeWorker (BiosKeyboardPrivate, &KeyData);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Convert the Ctrl+[a-z] to Ctrl+[1-26]\r
-  //\r
-  if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {\r
-    if (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z') {\r
-      KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'a' + 1);\r
-    } else if (KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {\r
-      KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'A' + 1);\r
-    }\r
-  }\r
-\r
-  CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Waiting on the keyboard event, if there's any key pressed by the user, signal the event\r
-\r
-  @param  Event       The event that be siganlled when any key has been stroked.\r
-  @param  Context     Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_PROTOCOL.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BiosKeyboardWaitForKey (\r
-  IN  EFI_EVENT  Event,\r
-  IN  VOID       *Context\r
-  )\r
-{\r
-  //\r
-  // Stall 1ms to give a chance to let other driver interrupt this routine for their timer event.\r
-  // Csm will be used to check whether there is a key pending, but the csm will disable all\r
-  // interrupt before switch to compatibility16, which mean all the efiCompatibility timer\r
-  // event will stop work during the compatibility16. And If a caller recursivly invoke this function,\r
-  // e.g. UI setup or Shell, other drivers which are driven by timer event will have a bad performance during this period,\r
-  // e.g. usb keyboard driver.\r
-  // Add a stall period can greatly increate other driver performance during the WaitForKey is recursivly invoked.\r
-  // 1ms delay will make little impact to the thunk keyboard driver, and user can not feel the delay at all when input.\r
-  //\r
-  gBS->Stall (1000);\r
-  //\r
-  // Use TimerEvent callback function to check whether there's any key pressed\r
-  //\r
-  BiosKeyboardTimerHandler (NULL, BIOS_KEYBOARD_DEV_FROM_THIS (Context));\r
-\r
-  if (!EFI_ERROR (BiosKeyboardCheckForKey (Context))) {\r
-    gBS->SignalEvent (Event);\r
-  }\r
-}\r
-\r
-/**\r
-  Check key buffer to get the key stroke status.\r
-\r
-  @param  This         Pointer of the protocol EFI_SIMPLE_TEXT_IN_PROTOCOL.\r
-\r
-  @retval EFI_SUCCESS  A key is being pressed now.\r
-  @retval Other        No key is now pressed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardCheckForKey (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This\r
-  )\r
-{\r
-  BIOS_KEYBOARD_DEV     *BiosKeyboardPrivate;\r
-\r
-  BiosKeyboardPrivate = BIOS_KEYBOARD_DEV_FROM_THIS (This);\r
-\r
-  return CheckQueue (&BiosKeyboardPrivate->Queue);\r
-}\r
-//\r
-// Private worker functions\r
-//\r
-#define TABLE_END 0x0\r
-\r
-typedef struct _CONVERT_TABLE_ENTRY {\r
-  UINT16  ScanCode;\r
-  UINT16  EfiScanCode;\r
-} CONVERT_TABLE_ENTRY;\r
-\r
-CONVERT_TABLE_ENTRY mConvertTable[] = {\r
-  {\r
-    0x47,\r
-    SCAN_HOME\r
-  },\r
-  {\r
-    0x48,\r
-    SCAN_UP\r
-  },\r
-  {\r
-    0x49,\r
-    SCAN_PAGE_UP\r
-  },\r
-  {\r
-    0x4b,\r
-    SCAN_LEFT\r
-  },\r
-  {\r
-    0x4d,\r
-    SCAN_RIGHT\r
-  },\r
-  {\r
-    0x4f,\r
-    SCAN_END\r
-  },\r
-  {\r
-    0x50,\r
-    SCAN_DOWN\r
-  },\r
-  {\r
-    0x51,\r
-    SCAN_PAGE_DOWN\r
-  },\r
-  {\r
-    0x52,\r
-    SCAN_INSERT\r
-  },\r
-  {\r
-    0x53,\r
-    SCAN_DELETE\r
-  },\r
-  //\r
-  // Function Keys are only valid if KeyChar == 0x00\r
-  //  This function does not require KeyChar to be 0x00\r
-  //\r
-  {\r
-    0x3b,\r
-    SCAN_F1\r
-  },\r
-  {\r
-    0x3c,\r
-    SCAN_F2\r
-  },\r
-  {\r
-    0x3d,\r
-    SCAN_F3\r
-  },\r
-  {\r
-    0x3e,\r
-    SCAN_F4\r
-  },\r
-  {\r
-    0x3f,\r
-    SCAN_F5\r
-  },\r
-  {\r
-    0x40,\r
-    SCAN_F6\r
-  },\r
-  {\r
-    0x41,\r
-    SCAN_F7\r
-  },\r
-  {\r
-    0x42,\r
-    SCAN_F8\r
-  },\r
-  {\r
-    0x43,\r
-    SCAN_F9\r
-  },\r
-  {\r
-    0x44,\r
-    SCAN_F10\r
-  },\r
-  {\r
-    0x85,\r
-    SCAN_F11\r
-  },\r
-  {\r
-    0x86,\r
-    SCAN_F12\r
-  },\r
-  //\r
-  // Convert ALT + Fn keys\r
-  //\r
-  {\r
-    0x68,\r
-    SCAN_F1\r
-  },\r
-  {\r
-    0x69,\r
-    SCAN_F2\r
-  },\r
-  {\r
-    0x6a,\r
-    SCAN_F3\r
-  },\r
-  {\r
-    0x6b,\r
-    SCAN_F4\r
-  },\r
-  {\r
-    0x6c,\r
-    SCAN_F5\r
-  },\r
-  {\r
-    0x6d,\r
-    SCAN_F6\r
-  },\r
-  {\r
-    0x6e,\r
-    SCAN_F7\r
-  },\r
-  {\r
-    0x6f,\r
-    SCAN_F8\r
-  },\r
-  {\r
-    0x70,\r
-    SCAN_F9\r
-  },\r
-  {\r
-    0x71,\r
-    SCAN_F10\r
-  },\r
-  {\r
-    TABLE_END,\r
-    SCAN_NULL\r
-  },\r
-};\r
-\r
-/**\r
-  Convert unicode combined with scan code of key to the counterpart of EFIScancode of it.\r
-\r
-  @param  KeyChar      Unicode of key.\r
-  @param  ScanCode     Scan code of key.\r
-\r
-  @return The value of EFI Scancode for the key.\r
-  @retval SCAN_NULL   No corresponding value in the EFI convert table is found for the key.\r
-\r
-**/\r
-UINT16\r
-ConvertToEFIScanCode (\r
-  IN  CHAR16  KeyChar,\r
-  IN  UINT16  ScanCode\r
-  )\r
-{\r
-  UINT16  EfiScanCode;\r
-  UINT16  Index;\r
-\r
-  if (KeyChar == CHAR_ESC) {\r
-    EfiScanCode = SCAN_ESC;\r
-  } else if (KeyChar == 0x00 || KeyChar == 0xe0) {\r
-    //\r
-    // Movement & Function Keys\r
-    //\r
-    for (Index = 0; (Index < sizeof (mConvertTable) / sizeof (CONVERT_TABLE_ENTRY)) && (mConvertTable[Index].ScanCode != TABLE_END); Index += 1) {\r
-      if (ScanCode == mConvertTable[Index].ScanCode) {\r
-        return mConvertTable[Index].EfiScanCode;\r
-      }\r
-    }\r
-    //\r
-    // Reach Table end, return default value\r
-    //\r
-    return SCAN_NULL;\r
-  } else {\r
-    return SCAN_NULL;\r
-  }\r
-\r
-  return EfiScanCode;\r
-}\r
-\r
-/**\r
-  Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command\r
-  If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device\r
-  should not be in system.\r
-\r
-  @param  BiosKeyboardPrivate  Keyboard Private Data Struture\r
-\r
-  @retval TRUE  Keyboard in System.\r
-  @retval FALSE Keyboard not in System.\r
-\r
-**/\r
-BOOLEAN\r
-CheckKeyboardConnect (\r
-  IN  BIOS_KEYBOARD_DEV     *BiosKeyboardPrivate\r
-  )\r
-{\r
-  EFI_STATUS     Status;\r
-\r
-  Status         = EFI_SUCCESS;\r
-  //\r
-  // enable keyboard itself and wait for its ack\r
-  // If can't receive ack, Keyboard should not be connected.\r
-  //\r
-  if (!PcdGetBool (PcdFastPS2Detection)) {\r
-    Status = KeyboardWrite (\r
-               BiosKeyboardPrivate,\r
-               KBC_INPBUF_VIA60_KBEN\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "[KBD]CheckKeyboardConnect - Keyboard enable failed!\n"));\r
-      REPORT_STATUS_CODE (\r
-        EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-        EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR\r
-        );\r
-      return FALSE;\r
-    }\r
-\r
-    Status = KeyboardWaitForValue (\r
-               BiosKeyboardPrivate,\r
-               KBC_CMDECHO_ACK,\r
-               KEYBOARD_WAITFORVALUE_TIMEOUT\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "[KBD]CheckKeyboardConnect - Timeout!\n"));\r
-      REPORT_STATUS_CODE (\r
-        EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-        EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR\r
-        );\r
-      return FALSE;\r
-    }\r
-    return TRUE;\r
-  } else {\r
-    return TRUE;\r
-  }\r
-}\r
-\r
-/**\r
-  Timer event handler: read a series of key stroke from 8042\r
-  and put them into memory key buffer.\r
-  It is registered as running under TPL_NOTIFY\r
-\r
-  @param  Event   The timer event\r
-  @param  Context A BIOS_KEYBOARD_DEV pointer\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BiosKeyboardTimerHandler (\r
-  IN EFI_EVENT    Event,\r
-  IN VOID         *Context\r
-  )\r
-{\r
-  EFI_TPL                            OldTpl;\r
-  BIOS_KEYBOARD_DEV                  *BiosKeyboardPrivate;\r
-  EFI_IA32_REGISTER_SET              Regs;\r
-  UINT8                              KbFlag1;  // 0040h:0017h - KEYBOARD - STATUS FLAGS 1\r
-  UINT8                              KbFlag2;  // 0040h:0018h - KEYBOARD - STATUS FLAGS 2\r
-  EFI_KEY_DATA                       KeyData;\r
-  LIST_ENTRY                         *Link;\r
-  BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;\r
-\r
-  BiosKeyboardPrivate = Context;\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // if there is no key present, just return\r
-  //\r
-  if (BiosKeyboardPrivate->ExtendedKeyboard) {\r
-    Regs.H.AH = 0x11;\r
-  } else {\r
-    Regs.H.AH = 0x01;\r
-  }\r
-\r
-  BiosKeyboardPrivate->LegacyBios->Int86 (\r
-                                     BiosKeyboardPrivate->LegacyBios,\r
-                                     0x16,\r
-                                     &Regs\r
-                                     );\r
-  if (Regs.X.Flags.ZF != 0) {\r
-    gBS->RestoreTPL (OldTpl);\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Read the key\r
-  //\r
-  if (BiosKeyboardPrivate->ExtendedKeyboard) {\r
-    Regs.H.AH = 0x10;\r
-  } else {\r
-    Regs.H.AH = 0x00;\r
-  }\r
-\r
-  BiosKeyboardPrivate->LegacyBios->Int86 (\r
-                                     BiosKeyboardPrivate->LegacyBios,\r
-                                     0x16,\r
-                                     &Regs\r
-                                     );\r
-\r
-  KeyData.Key.ScanCode            = (UINT16) Regs.H.AH;\r
-  KeyData.Key.UnicodeChar         = (UINT16) Regs.H.AL;\r
-  DEBUG ((\r
-    EFI_D_INFO,\r
-    "[KBD]INT16 returns EFI_INPUT_KEY.ScanCode - %x, EFI_INPUT_KEY.UnicodeChar - %x\n",\r
-    KeyData.Key.ScanCode,\r
-    KeyData.Key.UnicodeChar\r
-    ));\r
-\r
-  KeyData.KeyState.KeyShiftState  = EFI_SHIFT_STATE_VALID;\r
-  KeyData.KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;\r
-  //\r
-  // Leagcy Bios use Int 9 which is IRQ1 interrupt handler to get keystroke scancode to KB  buffer in BDA (BIOS DATE AREA),  then\r
-  // Int 16 depend  KB buffer and some key bits in BDA to translate the scancode to ASCII code, and  return both the scancode and ASCII\r
-  // code to Int 16 caller. This translation process works well if the Int 9  could response user input in time. But in Tiano enviorment,  the Int 9\r
-  // will be disabled after the thunk call finish, which means if user crazy input during int 9 being disabled, some keystrokes will be lost when\r
-  // KB device own hardware buffer overflows. And if the lost keystroke code is CTRL or ALT or SHIFT release code, these function key flags bit\r
-  // in BDA will not be updated. So the Int 16 will believe the CTRL or ALT or SHIFT is still pressed, and Int 16 will translate later scancode\r
-  // to wrong ASCII code. We can increase the Thunk frequence to let Int 9 response in time, but this way will much hurt other drivers\r
-  // performance, like USB.\r
-  //\r
-  // 1. If CTRL or ALT release code is missed,  all later input keys will be translated to wrong ASCII codes which the Tiano cannot support. In\r
-  //     this case, the KB input seems fail to work, and user input is blocked. To solve the problem, we can help to clear the CTRL or ALT flag in BDA\r
-  //    after every Int 16 finish. Thus persist to press CTRL or ALT has same effection as only press one time. It is Ok, since user not often use the\r
-  //    CTRL and ALT.\r
-  //\r
-  // 2. If SHIFT release code is missed, all later lowercase input will become capital. This is ugly, but not block user input. If user press the lost\r
-  //     SHIFT again,  the lowercase will come back to normal. Since user often use the SHIFT, it is not reasonable to help to clear the SHIFT flag in BDA,\r
-  //     which will let persist to press SHIFT has same effection as only press one time.\r
-  //\r
-  //0040h:0017h - KEYBOARD - STATUS FLAGS 1\r
-  //   7 INSert active\r
-  //   6 Caps Lock active\r
-  //   5 Num Lock active\r
-  //   4 Scroll Lock active\r
-  //   3 either Alt pressed\r
-  //   2 either Ctrl pressed\r
-  //   1 Left Shift pressed\r
-  //   0 Right Shift pressed\r
-\r
-\r
-  //\r
-  // Clear the CTRL and ALT BDA flag\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    KbFlag1 = *((UINT8 *) (UINTN) 0x417); // read the STATUS FLAGS 1\r
-    KbFlag2 = *((UINT8 *) (UINTN) 0x418); // read STATUS FLAGS 2\r
-  );\r
-\r
-  DEBUG_CODE (\r
-    {\r
-      if ((KbFlag1 & KB_CAPS_LOCK_BIT) == KB_CAPS_LOCK_BIT) {\r
-        DEBUG ((EFI_D_INFO, "[KBD]Caps Lock Key is pressed.\n"));\r
-      }\r
-      if ((KbFlag1 & KB_NUM_LOCK_BIT) == KB_NUM_LOCK_BIT) {\r
-        DEBUG ((EFI_D_INFO, "[KBD]Num Lock Key is pressed.\n"));\r
-      }\r
-      if ((KbFlag1 & KB_SCROLL_LOCK_BIT) == KB_SCROLL_LOCK_BIT) {\r
-        DEBUG ((EFI_D_INFO, "[KBD]Scroll Lock Key is pressed.\n"));\r
-      }\r
-      if ((KbFlag1 & KB_ALT_PRESSED) == KB_ALT_PRESSED) {\r
-        if ((KbFlag2 & KB_LEFT_ALT_PRESSED) == KB_LEFT_ALT_PRESSED) {\r
-          DEBUG ((EFI_D_INFO, "[KBD]Left Alt Key is pressed.\n"));\r
-        } else {\r
-          DEBUG ((EFI_D_INFO, "[KBD]Right Alt Key is pressed.\n"));\r
-        }\r
-      }\r
-      if ((KbFlag1 & KB_CTRL_PRESSED) == KB_CTRL_PRESSED) {\r
-        if ((KbFlag2 & KB_LEFT_CTRL_PRESSED) == KB_LEFT_CTRL_PRESSED) {\r
-          DEBUG ((EFI_D_INFO, "[KBD]Left Ctrl Key is pressed.\n"));\r
-        } else {\r
-          DEBUG ((EFI_D_INFO, "[KBD]Right Ctrl Key is pressed.\n"));\r
-        }\r
-      }\r
-      if ((KbFlag1 & KB_LEFT_SHIFT_PRESSED) == KB_LEFT_SHIFT_PRESSED) {\r
-        DEBUG ((EFI_D_INFO, "[KBD]Left Shift Key is pressed.\n"));\r
-      }\r
-      if ((KbFlag1 & KB_RIGHT_SHIFT_PRESSED) == KB_RIGHT_SHIFT_PRESSED) {\r
-        DEBUG ((EFI_D_INFO, "[KBD]Right Shift Key is pressed.\n"));\r
-      }\r
-    }\r
-  );\r
-\r
-  //\r
-  // Record toggle state\r
-  //\r
-  if ((KbFlag1 & KB_CAPS_LOCK_BIT) == KB_CAPS_LOCK_BIT) {\r
-    KeyData.KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;\r
-  }\r
-  if ((KbFlag1 & KB_NUM_LOCK_BIT) == KB_NUM_LOCK_BIT) {\r
-    KeyData.KeyState.KeyToggleState |= EFI_NUM_LOCK_ACTIVE;\r
-  }\r
-  if ((KbFlag1 & KB_SCROLL_LOCK_BIT) == KB_SCROLL_LOCK_BIT) {\r
-    KeyData.KeyState.KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;\r
-  }\r
-  //\r
-  // Record shift state\r
-  // BUGBUG: Need add Menu key and Left/Right Logo key state in the future\r
-  //\r
-  if ((KbFlag1 & KB_ALT_PRESSED) == KB_ALT_PRESSED) {\r
-    KeyData.KeyState.KeyShiftState  |= ((KbFlag2 & KB_LEFT_ALT_PRESSED) == KB_LEFT_ALT_PRESSED) ? EFI_LEFT_ALT_PRESSED : EFI_RIGHT_ALT_PRESSED;\r
-  }\r
-  if ((KbFlag1 & KB_CTRL_PRESSED) == KB_CTRL_PRESSED) {\r
-    KeyData.KeyState.KeyShiftState  |= ((KbFlag2 & KB_LEFT_CTRL_PRESSED) == KB_LEFT_CTRL_PRESSED) ? EFI_LEFT_CONTROL_PRESSED : EFI_RIGHT_CONTROL_PRESSED;\r
-  }\r
-  if ((KbFlag1 & KB_LEFT_SHIFT_PRESSED) == KB_LEFT_SHIFT_PRESSED) {\r
-    KeyData.KeyState.KeyShiftState  |= EFI_LEFT_SHIFT_PRESSED;\r
-  }\r
-  if ((KbFlag1 & KB_RIGHT_SHIFT_PRESSED) == KB_RIGHT_SHIFT_PRESSED) {\r
-    KeyData.KeyState.KeyShiftState  |= EFI_RIGHT_SHIFT_PRESSED;\r
-  }\r
-\r
-  //\r
-  // Clear left alt and left ctrl BDA flag\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    KbFlag2 &= ~(KB_LEFT_ALT_PRESSED | KB_LEFT_CTRL_PRESSED);\r
-    *((UINT8 *) (UINTN) 0x418) = KbFlag2;\r
-    KbFlag1 &= ~0x0C;\r
-    *((UINT8 *) (UINTN) 0x417) = KbFlag1;\r
-  );\r
-\r
-  //\r
-  // Output EFI input key and shift/toggle state\r
-  //\r
-  if (KeyData.Key.UnicodeChar == CHAR_NULL || KeyData.Key.UnicodeChar == CHAR_SCANCODE || KeyData.Key.UnicodeChar == CHAR_ESC) {\r
-    KeyData.Key.ScanCode     = ConvertToEFIScanCode (KeyData.Key.UnicodeChar, KeyData.Key.ScanCode);\r
-    KeyData.Key.UnicodeChar  = CHAR_NULL;\r
-  } else {\r
-    KeyData.Key.ScanCode     = SCAN_NULL;\r
-  }\r
-\r
-  //\r
-  // CSM16 has converted the Ctrl+[a-z] to [1-26], converted it back.\r
-  //\r
-  if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {\r
-    if (KeyData.Key.UnicodeChar >= 1 && KeyData.Key.UnicodeChar <= 26) {\r
-      if (((KeyData.KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED)) != 0) ==\r
-          ((KeyData.KeyState.KeyToggleState & EFI_CAPS_LOCK_ACTIVE) != 0)\r
-          ) {\r
-        KeyData.Key.UnicodeChar = (UINT16) (KeyData.Key.UnicodeChar + L'a' - 1);\r
-      } else {\r
-        KeyData.Key.UnicodeChar = (UINT16) (KeyData.Key.UnicodeChar + L'A' - 1);\r
-      }\r
-    }\r
-  }\r
-\r
-  DEBUG ((\r
-    EFI_D_INFO,\r
-    "[KBD]Convert to EFI Scan Code, EFI_INPUT_KEY.ScanCode - %x, EFI_INPUT_KEY.UnicodeChar - %x\n",\r
-    KeyData.Key.ScanCode,\r
-    KeyData.Key.UnicodeChar\r
-    ));\r
-\r
-  //\r
-  // Need not return associated shift state if a class of printable characters that\r
-  // are normally adjusted by shift modifiers.\r
-  // e.g. Shift Key + 'f' key = 'F'; Shift Key + 'F' key = 'f'.\r
-  //\r
-  if ((KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') ||\r
-      (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z')\r
-     ) {\r
-    DEBUG ((EFI_D_INFO, "[KBD]Shift key with a~z are pressed, remove shift state in EFI_KEY_STATE.\n"));\r
-    KeyData.KeyState.KeyShiftState &= ~(EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED);\r
-  }\r
-\r
-  //\r
-  // Signal KeyNotify process event if this key pressed matches any key registered.\r
-  //\r
-  for (Link = BiosKeyboardPrivate->NotifyList.ForwardLink; Link != &BiosKeyboardPrivate->NotifyList; Link = Link->ForwardLink) {\r
-    CurrentNotify = CR (\r
-                      Link,\r
-                      BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
-                      NotifyEntry,\r
-                      BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
-                      );\r
-    if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {\r
-      //\r
-      // The key notification function needs to run at TPL_CALLBACK\r
-      // while current TPL is TPL_NOTIFY. It will be invoked in\r
-      // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.\r
-      //\r
-      Enqueue (&BiosKeyboardPrivate->QueueForNotify, &KeyData);\r
-      gBS->SignalEvent (BiosKeyboardPrivate->KeyNotifyProcessEvent);\r
-      break;\r
-    }\r
-  }\r
-\r
-  Enqueue (&BiosKeyboardPrivate->Queue, &KeyData);\r
-\r
-  //\r
-  // Save the current key state\r
-  //\r
-  CopyMem (&BiosKeyboardPrivate->KeyState, &KeyData.KeyState, sizeof (EFI_KEY_STATE));\r
-\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Process key notify.\r
-\r
-  @param  Event                 Indicates the event that invoke this function.\r
-  @param  Context               Indicates the calling context.\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyNotifyProcessHandler (\r
-  IN  EFI_EVENT                 Event,\r
-  IN  VOID                      *Context\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  BIOS_KEYBOARD_DEV                     *BiosKeyboardPrivate;\r
-  EFI_KEY_DATA                          KeyData;\r
-  LIST_ENTRY                            *Link;\r
-  LIST_ENTRY                            *NotifyList;\r
-  BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY    *CurrentNotify;\r
-  EFI_TPL                               OldTpl;\r
-\r
-  BiosKeyboardPrivate = (BIOS_KEYBOARD_DEV *) Context;\r
-\r
-  //\r
-  // Invoke notification functions.\r
-  //\r
-  NotifyList = &BiosKeyboardPrivate->NotifyList;\r
-  while (TRUE) {\r
-    //\r
-    // Enter critical section\r
-    //\r
-    OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-    Status = Dequeue (&BiosKeyboardPrivate->QueueForNotify, &KeyData);\r
-    //\r
-    // Leave critical section\r
-    //\r
-    gBS->RestoreTPL (OldTpl);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {\r
-      CurrentNotify = CR (Link, BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);\r
-      if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {\r
-        CurrentNotify->KeyNotificationFn (&KeyData);\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Free keyboard notify list.\r
-\r
-  @param  ListHead   The list head\r
-\r
-  @retval EFI_SUCCESS           Free the notify list successfully\r
-  @retval EFI_INVALID_PARAMETER ListHead is invalid.\r
-\r
-**/\r
-EFI_STATUS\r
-BiosKeyboardFreeNotifyList (\r
-  IN OUT LIST_ENTRY           *ListHead\r
-  )\r
-{\r
-  BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;\r
-\r
-  if (ListHead == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  while (!IsListEmpty (ListHead)) {\r
-    NotifyNode = CR (\r
-                   ListHead->ForwardLink,\r
-                   BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
-                   NotifyEntry,\r
-                   BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
-                   );\r
-    RemoveEntryList (ListHead->ForwardLink);\r
-    gBS->FreePool (NotifyNode);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Check if key is registered.\r
-\r
-  @param  RegsiteredData    A pointer to a buffer that is filled in with the keystroke\r
-                            state data for the key that was registered.\r
-  @param  InputData         A pointer to a buffer that is filled in with the keystroke\r
-                            state data for the key that was pressed.\r
-\r
-  @retval TRUE              Key be pressed matches a registered key.\r
-  @retval FLASE             Match failed.\r
-\r
-**/\r
-BOOLEAN\r
-IsKeyRegistered (\r
-  IN EFI_KEY_DATA  *RegsiteredData,\r
-  IN EFI_KEY_DATA  *InputData\r
-  )\r
-{\r
-  ASSERT (RegsiteredData != NULL && InputData != NULL);\r
-\r
-  if ((RegsiteredData->Key.ScanCode    != InputData->Key.ScanCode) ||\r
-      (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.\r
-  //\r
-  if (RegsiteredData->KeyState.KeyShiftState != 0 &&\r
-      RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {\r
-    return FALSE;\r
-  }\r
-  if (RegsiteredData->KeyState.KeyToggleState != 0 &&\r
-      RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-\r
-}\r
-\r
-/**\r
-  Waiting on the keyboard event, if there's any key pressed by the user, signal the event\r
-\r
-  @param  Event    The event that be siganlled when any key has been stroked.\r
-  @param  Context  Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BiosKeyboardWaitForKeyEx (\r
-  IN  EFI_EVENT  Event,\r
-  IN  VOID       *Context\r
-  )\r
-{\r
-  BIOS_KEYBOARD_DEV                     *BiosKeyboardPrivate;\r
-\r
-  BiosKeyboardPrivate = TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS (Context);\r
-  BiosKeyboardWaitForKey (Event, &BiosKeyboardPrivate->SimpleTextIn);\r
-\r
-}\r
-\r
-/**\r
-  Reset the input device and optionaly run diagnostics\r
-\r
-  @param  This                  Protocol instance pointer.\r
-  @param  ExtendedVerification  Driver may perform diagnostics on reset.\r
-\r
-  @retval EFI_SUCCESS           The device was reset.\r
-  @retval EFI_DEVICE_ERROR      The device is not functioning properly and could\r
-                                not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardResetEx (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN BOOLEAN                            ExtendedVerification\r
-  )\r
-{\r
-  BIOS_KEYBOARD_DEV                     *BiosKeyboardPrivate;\r
-  EFI_STATUS                            Status;\r
-  EFI_TPL                               OldTpl;\r
-\r
-  BiosKeyboardPrivate = TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS (This);\r
-\r
-  Status = BiosKeyboardPrivate->SimpleTextIn.Reset (\r
-                                               &BiosKeyboardPrivate->SimpleTextIn,\r
-                                               ExtendedVerification\r
-                                               );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-/**\r
-  Reads the next keystroke from the input device. The WaitForKey Event can\r
-  be used to test for existance of a keystroke via WaitForEvent () call.\r
-\r
-  @param  This         Protocol instance pointer.\r
-  @param  KeyData      A pointer to a buffer that is filled in with the keystroke\r
-                       state data for the key that was pressed.\r
-\r
-  @retval  EFI_SUCCESS           The keystroke information was returned.\r
-  @retval  EFI_NOT_READY         There was no keystroke data availiable.\r
-  @retval  EFI_DEVICE_ERROR      The keystroke information was not returned due to\r
-                                 hardware errors.\r
-  @retval  EFI_INVALID_PARAMETER KeyData is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardReadKeyStrokeEx (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
-  OUT EFI_KEY_DATA                      *KeyData\r
-  )\r
-{\r
-  BIOS_KEYBOARD_DEV                     *BiosKeyboardPrivate;\r
-\r
-  if (KeyData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  BiosKeyboardPrivate = TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS (This);\r
-\r
-  return KeyboardReadKeyStrokeWorker (BiosKeyboardPrivate, KeyData);\r
-\r
-}\r
-\r
-/**\r
-  Set certain state for the input device.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  KeyToggleState    A pointer to the EFI_KEY_TOGGLE_STATE to set the\r
-                            state for the input device.\r
-\r
-  @retval EFI_SUCCESS           The device state was set successfully.\r
-  @retval EFI_DEVICE_ERROR      The device is not functioning correctly and could\r
-                                not have the setting adjusted.\r
-  @retval EFI_UNSUPPORTED       The device does not have the ability to set its state.\r
-  @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardSetState (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_KEY_TOGGLE_STATE               *KeyToggleState\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  BIOS_KEYBOARD_DEV                     *BiosKeyboardPrivate;\r
-  EFI_TPL                               OldTpl;\r
-  EFI_LEGACY_BIOS_PROTOCOL              *LegacyBios;\r
-  UINT8                                 Command;\r
-\r
-  if (KeyToggleState == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Thunk keyboard driver doesn't support partial keystroke.\r
-  //\r
-  if ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID ||\r
-      (*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED\r
-      ) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  BiosKeyboardPrivate = TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS (This);\r
-  //\r
-  // See if the Legacy BIOS Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiLegacyBiosProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &LegacyBios\r
-                  );\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  Command = 0;\r
-  if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {\r
-    Command |= 4;\r
-  }\r
-  if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {\r
-    Command |= 2;\r
-  }\r
-  if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {\r
-    Command |= 1;\r
-  }\r
-\r
-  Status = KeyboardWrite (BiosKeyboardPrivate, 0xed);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Exit;\r
-  }\r
-  Status = KeyboardWaitForValue (BiosKeyboardPrivate, 0xfa, KEYBOARD_WAITFORVALUE_TIMEOUT);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Exit;\r
-  }\r
-  Status = KeyboardWrite (BiosKeyboardPrivate, Command);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Exit;\r
-  }\r
-  //\r
-  // Call Legacy BIOS Protocol to set whatever is necessary\r
-  //\r
-  LegacyBios->UpdateKeyboardLedStatus (LegacyBios, Command);\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-Exit:\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-\r
-}\r
-\r
-/**\r
-  Register a notification function for a particular keystroke for the input device.\r
-\r
-  @param  This                    Protocol instance pointer.\r
-  @param  KeyData                 A pointer to a buffer that is filled in with the keystroke\r
-                                  information data for the key that was pressed. If KeyData.Key,\r
-                                  KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState\r
-                                  are 0, then any incomplete keystroke will trigger a notification of\r
-                                  the KeyNotificationFunction.\r
-  @param  KeyNotificationFunction Points to the function to be called when the key\r
-                                  sequence is typed specified by KeyData. This notification function\r
-                                  should be called at <=TPL_CALLBACK.\r
-  @param  NotifyHandle            Points to the unique handle assigned to the registered notification.\r
-\r
-  @retval EFI_SUCCESS             The notification function was registered successfully.\r
-  @retval EFI_OUT_OF_RESOURCES    Unable to allocate resources for necesssary data structures.\r
-  @retval EFI_INVALID_PARAMETER   KeyData or NotifyHandle is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardRegisterKeyNotify (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_KEY_DATA                       *KeyData,\r
-  IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,\r
-  OUT VOID                              **NotifyHandle\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  BIOS_KEYBOARD_DEV                     *BiosKeyboardPrivate;\r
-  EFI_TPL                               OldTpl;\r
-  BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY    *NewNotify;\r
-  LIST_ENTRY                            *Link;\r
-  BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY    *CurrentNotify;\r
-\r
-  if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  BiosKeyboardPrivate = TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.\r
-  //\r
-  for (Link = BiosKeyboardPrivate->NotifyList.ForwardLink; Link != &BiosKeyboardPrivate->NotifyList; Link = Link->ForwardLink) {\r
-    CurrentNotify = CR (\r
-                      Link,\r
-                      BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
-                      NotifyEntry,\r
-                      BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
-                      );\r
-    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {\r
-      if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {\r
-        *NotifyHandle = CurrentNotify;\r
-        Status = EFI_SUCCESS;\r
-        goto Exit;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Allocate resource to save the notification function\r
-  //\r
-\r
-  NewNotify = (BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY));\r
-  if (NewNotify == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Exit;\r
-  }\r
-\r
-  NewNotify->Signature         = BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE;\r
-  NewNotify->KeyNotificationFn = KeyNotificationFunction;\r
-  CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));\r
-  InsertTailList (&BiosKeyboardPrivate->NotifyList, &NewNotify->NotifyEntry);\r
-\r
-  *NotifyHandle                = NewNotify;\r
-  Status                       = EFI_SUCCESS;\r
-\r
-Exit:\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Remove a registered notification function from a particular keystroke.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  NotificationHandle   The handle of the notification function being unregistered.\r
-\r
-  @retval EFI_SUCCESS             The notification function was unregistered successfully.\r
-  @retval EFI_INVALID_PARAMETER   The NotificationHandle is invalid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardUnregisterKeyNotify (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN VOID                               *NotificationHandle\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  BIOS_KEYBOARD_DEV                     *BiosKeyboardPrivate;\r
-  EFI_TPL                               OldTpl;\r
-  LIST_ENTRY                            *Link;\r
-  BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY    *CurrentNotify;\r
-\r
-  //\r
-  // Check incoming notification handle\r
-  //\r
-  if (NotificationHandle == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (((BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature != BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  BiosKeyboardPrivate = TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  for (Link = BiosKeyboardPrivate->NotifyList.ForwardLink; Link != &BiosKeyboardPrivate->NotifyList; Link = Link->ForwardLink) {\r
-    CurrentNotify = CR (\r
-                      Link,\r
-                      BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
-                      NotifyEntry,\r
-                      BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
-                      );\r
-    if (CurrentNotify == NotificationHandle) {\r
-      //\r
-      // Remove the notification function from NotifyList and free resources\r
-      //\r
-      RemoveEntryList (&CurrentNotify->NotifyEntry);\r
-\r
-      Status = EFI_SUCCESS;\r
-      goto Exit;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Can not find the specified Notification Handle\r
-  //\r
-  Status = EFI_INVALID_PARAMETER;\r
-\r
-Exit:\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  The user Entry Point for module BiosKeyboard. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeBiosKeyboard(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gBiosKeyboardDriverBinding,\r
-             ImageHandle,\r
-             &gBiosKeyboardComponentName,\r
-             &gBiosKeyboardComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h
deleted file mode 100644 (file)
index 3c7abc2..0000000
+++ /dev/null
@@ -1,758 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _BIOS_KEYBOARD_H_\r
-#define _BIOS_KEYBOARD_H_\r
-\r
-\r
-#include <FrameworkDxe.h>\r
-#include <Pi/PiDxeCis.h>\r
-\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Protocol/SimpleTextIn.h>\r
-#include <Protocol/SimpleTextInEx.h>\r
-#include <Protocol/LegacyBios.h>\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/Ps2Policy.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-//\r
-// Driver Binding Externs\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL  gBiosKeyboardDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gBiosKeyboardComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gBiosKeyboardComponentName2;\r
-\r
-\r
-#include <IndustryStandard/Pci.h>\r
-\r
-//\r
-// BISO Keyboard Defines\r
-//\r
-#define CHAR_SCANCODE                   0xe0\r
-#define CHAR_ESC                        0x1b\r
-\r
-#define KEYBOARD_8042_DATA_REGISTER     0x60\r
-#define KEYBOARD_8042_STATUS_REGISTER   0x64\r
-#define KEYBOARD_8042_COMMAND_REGISTER  0x64\r
-\r
-#define KEYBOARD_TIMEOUT                65536   // 0.07s\r
-#define KEYBOARD_WAITFORVALUE_TIMEOUT   1000000 // 1s\r
-#define KEYBOARD_BAT_TIMEOUT            4000000 // 4s\r
-#define KEYBOARD_TIMER_INTERVAL         200000  // 0.02s\r
-//  KEYBOARD COMMAND BYTE -- read by writing command KBC_CMDREG_VIA64_CMDBYTE_R to 64H, then read from 60H\r
-//                           write by wrting command KBC_CMDREG_VIA64_CMDBYTE_W to 64H, then write to  60H\r
-//  7: Reserved\r
-//  6: PC/XT translation mode convert\r
-//  5: Disable Auxiliary device interface\r
-//  4: Disable keyboard interface\r
-//  3: Reserved\r
-//  2: System Flag: selftest successful\r
-//  1: Enable Auxiliary device interrupt\r
-//  0: Enable Keyboard interrupt )\r
-//\r
-#define KB_CMMBYTE_KSCAN2UNI_COV  (0x1 << 6)\r
-#define KB_CMMBYTE_DISABLE_AUX    (0x1 << 5)\r
-#define KB_CMMBYTE_DISABLE_KB     (0x1 << 4)\r
-#define KB_CMMBYTE_SLFTEST_SUCC   (0x1 << 2)\r
-#define KB_CMMBYTE_ENABLE_AUXINT  (0x1 << 1)\r
-#define KB_CMMBYTE_ENABLE_KBINT   (0x1 << 0)\r
-\r
-//\r
-//  KEYBOARD CONTROLLER STATUS REGISTER - read from 64h\r
-//  7: Parity error\r
-//  6: General time out\r
-//  5: Output buffer holds data for AUX\r
-//  4: Keyboard is not locked\r
-//  3: Command written via 64h  / Data written via 60h\r
-//  2: KBC self-test successful / Power-on reset\r
-//  1: Input buffer holds CPU data / empty\r
-//  0: Output buffer holds keyboard data / empty\r
-//\r
-#define KBC_STSREG_VIA64_PARE (0x1 << 7)\r
-#define KBC_STSREG_VIA64_TIM  (0x1 << 6)\r
-#define KBC_STSREG_VIA64_AUXB (0x1 << 5)\r
-#define KBC_STSREG_VIA64_KEYL (0x1 << 4)\r
-#define KBC_STSREG_VIA64_C_D  (0x1 << 3)\r
-#define KBC_STSREG_VIA64_SYSF (0x1 << 2)\r
-#define KBC_STSREG_VIA64_INPB (0x1 << 1)\r
-#define KBC_STSREG_VIA64_OUTB (0x1 << 0)\r
-\r
-//\r
-//  COMMANDs of KEYBOARD CONTROLLER COMMAND REGISTER - write to 64h\r
-//\r
-#define KBC_CMDREG_VIA64_CMDBYTE_R    0x20\r
-#define KBC_CMDREG_VIA64_CMDBYTE_W    0x60\r
-#define KBC_CMDREG_VIA64_AUX_DISABLE  0xA7\r
-#define KBC_CMDREG_VIA64_AUX_ENABLE   0xA8\r
-#define KBC_CMDREG_VIA64_KBC_SLFTEST  0xAA\r
-#define KBC_CMDREG_VIA64_KB_CKECK     0xAB\r
-#define KBC_CMDREG_VIA64_KB_DISABLE   0xAD\r
-#define KBC_CMDREG_VIA64_KB_ENABLE    0xAE\r
-#define KBC_CMDREG_VIA64_INTP_LOW_R   0xC0\r
-#define KBC_CMDREG_VIA64_INTP_HIGH_R  0xC2\r
-#define KBC_CMDREG_VIA64_OUTP_R       0xD0\r
-#define KBC_CMDREG_VIA64_OUTP_W       0xD1\r
-#define KBC_CMDREG_VIA64_OUTB_KB_W    0xD2\r
-#define KBC_CMDREG_VIA64_OUTB_AUX_W   0xD3\r
-#define KBC_CMDREG_VIA64_AUX_W        0xD4\r
-\r
-//\r
-//  echos of KEYBOARD CONTROLLER COMMAND - read from 60h\r
-//\r
-#define KBC_CMDECHO_KBCSLFTEST_OK 0x55\r
-#define KBC_CMDECHO_KBCHECK_OK    0x00\r
-#define KBC_CMDECHO_ACK           0xFA\r
-#define KBC_CMDECHO_BATTEST_OK    0xAA\r
-#define KBC_CMDECHO_BATTEST_FAILE 0xFC\r
-\r
-//\r
-// OUTPUT PORT COMMANDs - write port by writing KBC_CMDREG_VIA64_OUTP_W via 64H, then write the command to 60H\r
-// drive data and clock of KB to high for at least 500us for BAT needs\r
-//\r
-#define KBC_OUTPORT_DCHIGH_BAT  0xC0\r
-//\r
-// scan code set type\r
-//\r
-#define KBC_INPBUF_VIA60_SCODESET1  0x01\r
-#define KBC_INPBUF_VIA60_SCODESET2  0x02\r
-#define KBC_INPBUF_VIA60_SCODESET3  0x03\r
-\r
-//\r
-//  COMMANDs written to INPUT BUFFER - write to 60h\r
-//\r
-#define KBC_INPBUF_VIA60_KBECHO   0xEE\r
-#define KBC_INPBUF_VIA60_KBSCODE  0xF0\r
-#define KBC_INPBUF_VIA60_KBTYPE   0xF2\r
-#define KBC_INPBUF_VIA60_KBDELAY  0xF3\r
-#define KBC_INPBUF_VIA60_KBEN     0xF4\r
-#define KBC_INPBUF_VIA60_KBSTDDIS 0xF5\r
-#define KBC_INPBUF_VIA60_KBSTDEN  0xF6\r
-#define KBC_INPBUF_VIA60_KBRESEND 0xFE\r
-#define KBC_INPBUF_VIA60_KBRESET  0xFF\r
-\r
-//\r
-// 0040h:0017h - KEYBOARD - STATUS FLAGS 1\r
-//   7 INSert active\r
-//   6 Caps Lock active\r
-//   5 Num Lock active\r
-//   4 Scroll Lock active\r
-//   3 either Alt pressed\r
-//   2 either Ctrl pressed\r
-//   1 Left Shift pressed\r
-//   0 Right Shift pressed\r
-//\r
-// 0040h:0018h - KEYBOARD - STATUS FLAGS 2\r
-//   7: insert key is depressed\r
-//   6: caps-lock key is depressed (does not work well)\r
-//   5: num-lock key is depressed (does not work well)\r
-//   4: scroll lock key is depressed (does not work well)\r
-//   3: suspend key has been toggled (does not work well)\r
-//   2: system key is pressed and held (does not work well)\r
-//   1: left ALT key is pressed\r
-//   0: left CTRL key is pressed\r
-//\r
-#define KB_INSERT_BIT             (0x1 << 7)\r
-#define KB_CAPS_LOCK_BIT          (0x1 << 6)\r
-#define KB_NUM_LOCK_BIT           (0x1 << 5)\r
-#define KB_SCROLL_LOCK_BIT        (0x1 << 4)\r
-#define KB_ALT_PRESSED            (0x1 << 3)\r
-#define KB_CTRL_PRESSED           (0x1 << 2)\r
-#define KB_LEFT_SHIFT_PRESSED     (0x1 << 1)\r
-#define KB_RIGHT_SHIFT_PRESSED    (0x1 << 0)\r
-\r
-#define KB_SUSPEND_PRESSED        (0x1 << 3)\r
-#define KB_SYSREQ_PRESSED         (0x1 << 2)\r
-#define KB_LEFT_ALT_PRESSED       (0x1 << 1)\r
-#define KB_LEFT_CTRL_PRESSED      (0x1 << 0)\r
-\r
-//\r
-// BIOS Keyboard Device Structure\r
-//\r
-#define BIOS_KEYBOARD_DEV_SIGNATURE SIGNATURE_32 ('B', 'K', 'B', 'D')\r
-#define BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('c', 'b', 'k', 'h')\r
-\r
-typedef struct _BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY {\r
-  UINTN                                      Signature;\r
-  EFI_KEY_DATA                               KeyData;\r
-  EFI_KEY_NOTIFY_FUNCTION                    KeyNotificationFn;\r
-  LIST_ENTRY                                 NotifyEntry;\r
-} BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY;\r
-\r
-#define QUEUE_MAX_COUNT         32\r
-typedef struct {\r
-  UINTN             Front;\r
-  UINTN             Rear;\r
-  EFI_KEY_DATA      Buffer[QUEUE_MAX_COUNT];\r
-} SIMPLE_QUEUE;\r
-\r
-typedef struct {\r
-  UINTN                                       Signature;\r
-  EFI_HANDLE                                  Handle;\r
-  EFI_LEGACY_BIOS_PROTOCOL                    *LegacyBios;\r
-  EFI_ISA_IO_PROTOCOL                         *IsaIo;\r
-  EFI_SIMPLE_TEXT_INPUT_PROTOCOL              SimpleTextIn;\r
-  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL           SimpleTextInputEx;\r
-  UINT16                                      DataRegisterAddress;\r
-  UINT16                                      StatusRegisterAddress;\r
-  UINT16                                      CommandRegisterAddress;\r
-  BOOLEAN                                     ExtendedKeyboard;\r
-\r
-  EFI_KEY_STATE                               KeyState;\r
-  //\r
-  // Buffer storing EFI_KEY_DATA\r
-  //\r
-  SIMPLE_QUEUE                                Queue;\r
-  SIMPLE_QUEUE                                QueueForNotify;\r
-\r
-  //\r
-  // Notification Function List\r
-  //\r
-  LIST_ENTRY                                  NotifyList;\r
-  EFI_EVENT                                   KeyNotifyProcessEvent;\r
-  EFI_EVENT                                   TimerEvent;\r
-\r
-} BIOS_KEYBOARD_DEV;\r
-\r
-#define BIOS_KEYBOARD_DEV_FROM_THIS(a)  CR (a, BIOS_KEYBOARD_DEV, SimpleTextIn, BIOS_KEYBOARD_DEV_SIGNATURE)\r
-#define TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS(a) \\r
-  CR (a, \\r
-      BIOS_KEYBOARD_DEV, \\r
-      SimpleTextInputEx, \\r
-      BIOS_KEYBOARD_DEV_SIGNATURE \\r
-      )\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gBiosKeyboardDriverBinding;\r
-\r
-//\r
-// Driver Binding Protocol functions\r
-//\r
-\r
-/**\r
-  Check whether the driver supports this device.\r
-\r
-  @param  This                   The Udriver binding protocol.\r
-  @param  Controller             The controller handle to check.\r
-  @param  RemainingDevicePath    The remaining device path.\r
-\r
-  @retval EFI_SUCCESS            The driver supports this controller.\r
-  @retval other                  This device isn't supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Starts the device with this driver.\r
-\r
-  @param  This                   The driver binding instance.\r
-  @param  Controller             Handle of device to bind driver to.\r
-  @param  RemainingDevicePath    Optional parameter use to pick a specific child\r
-                                 device to start.\r
-\r
-  @retval EFI_SUCCESS            The controller is controlled by the driver.\r
-  @retval Other                  This controller cannot be started.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Stop the device handled by this driver.\r
-\r
-  @param  This                   The driver binding protocol.\r
-  @param  Controller             The controller to release.\r
-  @param  NumberOfChildren       The number of handles in ChildHandleBuffer.\r
-  @param  ChildHandleBuffer      The array of child handle.\r
-\r
-  @retval EFI_SUCCESS            The device was stopped.\r
-  @retval EFI_DEVICE_ERROR       The device could not be stopped due to a device error.\r
-  @retval Others                 Fail to uninstall protocols attached on the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  );\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-\r
-//\r
-// Simple Text Input Protocol functions\r
-//\r
-/**\r
-  Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE) then do some extra keyboard validations.\r
-\r
-  @param  This                  Pointer of simple text Protocol.\r
-  @param  ExtendedVerification  Whether perform the extra validation of keyboard. True: perform; FALSE: skip.\r
-\r
-  @retval EFI_SUCCESS           The command byte is written successfully.\r
-  @retval EFI_DEVICE_ERROR      Errors occurred during resetting keyboard.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardReset (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  IN  BOOLEAN                         ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Read out the scan code of the key that has just been stroked.\r
-\r
-  @param  This        Pointer of simple text Protocol.\r
-  @param  Key         Pointer for store the key that read out.\r
-\r
-  @retval EFI_SUCCESS The key is read out successfully.\r
-  @retval other       The key reading failed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardReadKeyStroke (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  OUT EFI_INPUT_KEY                   *Key\r
-  );\r
-\r
-//\r
-// Private worker functions\r
-//\r
-/**\r
-  Waiting on the keyboard event, if there's any key pressed by the user, signal the event\r
-\r
-  @param  Event       The event that be siganlled when any key has been stroked.\r
-  @param  Context     Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_PROTOCOL.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BiosKeyboardWaitForKey (\r
-  IN  EFI_EVENT  Event,\r
-  IN  VOID       *Context\r
-  );\r
-\r
-/**\r
-  Check key buffer to get the key stroke status.\r
-\r
-  @param  This         Pointer of the protocol EFI_SIMPLE_TEXT_IN_PROTOCOL.\r
-\r
-  @retval EFI_SUCCESS  A key is being pressed now.\r
-  @retval Other        No key is now pressed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardCheckForKey (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Convert unicode combined with scan code of key to the counterpart of EFIScancode of it.\r
-\r
-  @param  KeyChar      Unicode of key.\r
-  @param  ScanCode     Scan code of key.\r
-\r
-  @return The value of EFI Scancode for the key.\r
-  @retval SCAN_NULL   No corresponding value in the EFI convert table is found for the key.\r
-\r
-**/\r
-UINT16\r
-ConvertToEFIScanCode (\r
-  IN  CHAR16  KeyChar,\r
-  IN  UINT16  ScanCode\r
-  );\r
-\r
-/**\r
-  Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command\r
-  If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device\r
-  should not be in system.\r
-\r
-  @param  BiosKeyboardPrivate  Keyboard Private Data Struture\r
-\r
-  @retval TRUE  Keyboard in System.\r
-  @retval FALSE Keyboard not in System.\r
-\r
-**/\r
-BOOLEAN\r
-CheckKeyboardConnect (\r
-  IN  BIOS_KEYBOARD_DEV     *BiosKeyboardPrivate\r
-  );\r
-\r
-/**\r
-  Timer event handler: read a series of key stroke from 8042\r
-  and put them into memory key buffer.\r
-  It is registered as running under TPL_NOTIFY\r
-\r
-  @param  Event   The timer event\r
-  @param  Context A BIOS_KEYBOARD_DEV pointer\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BiosKeyboardTimerHandler (\r
-  IN EFI_EVENT    Event,\r
-  IN VOID         *Context\r
-  );\r
-\r
-/**\r
-  Process key notify.\r
-\r
-  @param  Event                 Indicates the event that invoke this function.\r
-  @param  Context               Indicates the calling context.\r
-**/\r
-VOID\r
-EFIAPI\r
-KeyNotifyProcessHandler (\r
-  IN  EFI_EVENT                 Event,\r
-  IN  VOID                      *Context\r
-  );\r
-\r
-/**\r
-  Reset the input device and optionaly run diagnostics\r
-\r
-  @param  This                  Protocol instance pointer.\r
-  @param  ExtendedVerification  Driver may perform diagnostics on reset.\r
-\r
-  @retval EFI_SUCCESS           The device was reset.\r
-  @retval EFI_DEVICE_ERROR      The device is not functioning properly and could\r
-                                not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardResetEx (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN BOOLEAN                            ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Reads the next keystroke from the input device. The WaitForKey Event can\r
-  be used to test for existance of a keystroke via WaitForEvent () call.\r
-\r
-  @param  This         Protocol instance pointer.\r
-  @param  KeyData      A pointer to a buffer that is filled in with the keystroke\r
-                       state data for the key that was pressed.\r
-\r
-  @retval  EFI_SUCCESS           The keystroke information was returned.\r
-  @retval  EFI_NOT_READY         There was no keystroke data availiable.\r
-  @retval  EFI_DEVICE_ERROR      The keystroke information was not returned due to\r
-                                 hardware errors.\r
-  @retval  EFI_INVALID_PARAMETER KeyData is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardReadKeyStrokeEx (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
-  OUT EFI_KEY_DATA                      *KeyData\r
-  );\r
-\r
-/**\r
-  Set certain state for the input device.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  KeyToggleState    A pointer to the EFI_KEY_TOGGLE_STATE to set the\r
-                            state for the input device.\r
-\r
-  @retval EFI_SUCCESS           The device state was set successfully.\r
-  @retval EFI_DEVICE_ERROR      The device is not functioning correctly and could\r
-                                not have the setting adjusted.\r
-  @retval EFI_UNSUPPORTED       The device does not have the ability to set its state.\r
-  @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardSetState (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_KEY_TOGGLE_STATE               *KeyToggleState\r
-  );\r
-\r
-/**\r
-  Register a notification function for a particular keystroke for the input device.\r
-\r
-  @param  This                    Protocol instance pointer.\r
-  @param  KeyData                 A pointer to a buffer that is filled in with the keystroke\r
-                                  information data for the key that was pressed. If KeyData.Key,\r
-                                  KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState\r
-                                  are 0, then any incomplete keystroke will trigger a notification of\r
-                                  the KeyNotificationFunction.\r
-  @param  KeyNotificationFunction Points to the function to be called when the key\r
-                                  sequence is typed specified by KeyData. This notification function\r
-                                  should be called at <=TPL_CALLBACK.\r
-  @param  NotifyHandle            Points to the unique handle assigned to the registered notification.\r
-\r
-\r
-  @retval EFI_SUCCESS             The notification function was registered successfully.\r
-  @retval EFI_OUT_OF_RESOURCES    Unable to allocate resources for necesssary data structures.\r
-  @retval EFI_INVALID_PARAMETER   KeyData or NotifyHandle is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardRegisterKeyNotify (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_KEY_DATA                       *KeyData,\r
-  IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,\r
-  OUT VOID                              **NotifyHandle\r
-  );\r
-\r
-/**\r
-  Remove a registered notification function from a particular keystroke.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  NotificationHandle   The handle of the notification function being unregistered.\r
-\r
-  @retval EFI_SUCCESS             The notification function was unregistered successfully.\r
-  @retval EFI_INVALID_PARAMETER   The NotificationHandle is invalid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardUnregisterKeyNotify (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN VOID                               *NotificationHandle\r
-  );\r
-\r
-/**\r
-  Wait for a specific value to be presented in\r
-  Data register of Keyboard Controller by keyboard and then read it,\r
-  used in keyboard commands ack\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-  @param   Value                The value to be waited for\r
-  @param   WaitForValueTimeOut  The limit of microseconds for timeout\r
-\r
-  @retval  EFI_SUCCESS          The command byte is written successfully.\r
-  @retval  EFI_TIMEOUT          Timeout occurred during writing.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardWaitForValue (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate,\r
-  IN UINT8              Value,\r
-  IN UINTN              WaitForValueTimeOut\r
-  );\r
-\r
-/**\r
-  Write data byte to input buffer or input/output ports of Keyboard Controller with delay and waiting for buffer-empty state.\r
-\r
-  @param   BiosKeyboardPrivate  Keyboard instance pointer.\r
-  @param   Data                 Data byte to write.\r
-\r
-  @retval  EFI_SUCCESS          The data byte is written successfully.\r
-  @retval  EFI_TIMEOUT          Timeout occurred during writing.\r
-\r
-**/\r
-EFI_STATUS\r
-KeyboardWrite (\r
-  IN BIOS_KEYBOARD_DEV  *BiosKeyboardPrivate,\r
-  IN UINT8              Data\r
-  );\r
-\r
-/**\r
-  Free keyboard notify list.\r
-\r
-  @param  ListHead   The list head\r
-\r
-  @retval EFI_SUCCESS           Free the notify list successfully\r
-  @retval EFI_INVALID_PARAMETER ListHead is invalid.\r
-\r
-**/\r
-EFI_STATUS\r
-BiosKeyboardFreeNotifyList (\r
-  IN OUT LIST_ENTRY           *ListHead\r
-  );\r
-\r
-/**\r
-  Check if key is registered.\r
-\r
-  @param  RegsiteredData    A pointer to a buffer that is filled in with the keystroke\r
-                            state data for the key that was registered.\r
-  @param  InputData         A pointer to a buffer that is filled in with the keystroke\r
-                            state data for the key that was pressed.\r
-\r
-  @retval TRUE              Key be pressed matches a registered key.\r
-  @retval FLASE             Match failed.\r
-\r
-**/\r
-BOOLEAN\r
-IsKeyRegistered (\r
-  IN EFI_KEY_DATA  *RegsiteredData,\r
-  IN EFI_KEY_DATA  *InputData\r
-  );\r
-\r
-/**\r
-  Waiting on the keyboard event, if there's any key pressed by the user, signal the event\r
-\r
-  @param  Event    The event that be siganlled when any key has been stroked.\r
-  @param  Context  Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BiosKeyboardWaitForKeyEx (\r
-  IN  EFI_EVENT  Event,\r
-  IN  VOID       *Context\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/ComponentName.c b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/ComponentName.c
deleted file mode 100644 (file)
index 9da3769..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosKeyboard.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gBiosKeyboardComponentName = {\r
-  BiosKeyboardComponentNameGetDriverName,\r
-  BiosKeyboardComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosKeyboardComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) BiosKeyboardComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) BiosKeyboardComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosKeyboardDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"BIOS[INT16] Keyboard Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mBiosKeyboardDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gBiosKeyboardComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/ComponentName.h b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/ComponentName.h
deleted file mode 100644 (file)
index 9edd612..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _BIOS_KEYBOARD_COMPONENT_NAME_H_\r
-#define _BIOS_KEYBOARD_COMPONENT_NAME_H_\r
-\r
-\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gBiosKeyboardComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gBiosKeyboardComponentName2;\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosKeyboardComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf
deleted file mode 100644 (file)
index a36f8c4..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-## @file\r
-# Ps2 Keyboard driver.\r
-#\r
-# Ps2 Keyboard driver by using Legacy Bios protocol service and IsaIo protocol\r
-# service. This dirver uses legacy INT16 to get the key stroke status.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = KeyboardDxe\r
-  MODULE_UNI_FILE                = KeyboardDxe.uni\r
-  FILE_GUID                      = 5479662B-6AE4-49e8-A6BD-6DE4B625811F\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeBiosKeyboard\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-#  DRIVER_BINDING                =  gBiosKeyboardDriverBinding\r
-#  COMPONENT_NAME                =  gBiosKeyboardComponentName\r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  ComponentName.h\r
-  BiosKeyboard.c\r
-  BiosKeyboard.h\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  MemoryAllocationLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  ReportStatusCodeLib\r
-  BaseMemoryLib\r
-  UefiLib\r
-  DebugLib\r
-  BaseLib\r
-  PcdLib\r
-  DxeServicesTableLib\r
-\r
-[Protocols]\r
-  gEfiIsaIoProtocolGuid                         ## TO_START\r
-  gEfiSimpleTextInProtocolGuid                  ## BY_START\r
-  gEfiSimpleTextInputExProtocolGuid             ## BY_START\r
-  gEfiLegacyBiosProtocolGuid                    ## CONSUMES\r
-  gEfiPs2PolicyProtocolGuid                     ## SOMETIMES_CONSUMES\r
-\r
-[FeaturePcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification|FALSE  ## CONSUMES\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFastPS2Detection                  ## SOMETIMES_CONSUMES\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  KeyboardDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.uni b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.uni
deleted file mode 100644 (file)
index 5af800c..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// /** @file\r
-// Ps2 Keyboard driver.\r
-//\r
-// Ps2 Keyboard driver by using Legacy Bios protocol service and IsaIo protocol\r
-// service. This dirver uses legacy INT16 to get the key stroke status.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Ps2 Keyboard Driver"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Ps2 Keyboard driver by using Legacy Bios protocol service and IsaIo protocol service. This driver uses legacy INT16 to get the key stroke status."\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxeExtra.uni b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxeExtra.uni
deleted file mode 100644 (file)
index 19435b5..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// KeyboardDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Legacy Keyboard DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.c b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.c
deleted file mode 100644 (file)
index cc618ea..0000000
+++ /dev/null
@@ -1,3515 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosSnp16.h"\r
-\r
-\r
-///\r
-/// EFI Driver Binding Protocol Instance\r
-///\r
-EFI_DRIVER_BINDING_PROTOCOL gBiosSnp16DriverBinding = {\r
-  BiosSnp16DriverBindingSupported,\r
-  BiosSnp16DriverBindingStart,\r
-  BiosSnp16DriverBindingStop,\r
-  0x3,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-///\r
-///  This boolean is used to determine if we should release the cached vector during an error condition.\r
-///\r
-BOOLEAN     mCachedInt1A = FALSE;\r
-\r
-//\r
-// Private worker functions;\r
-//\r
-\r
-/**\r
-  Start the UNDI interface.\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-  @param Ax                  PCI address of Undi device.\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to start 16 bit UNDI ROM.\r
-  @retval Others           Status of start 16 bit UNDI ROM.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkStartUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  UINT16                  Ax\r
-  );\r
-\r
-/**\r
-  Start the UNDI interface\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to start 16 bit UNDI ROM.\r
-  @retval Others           Status of start 16 bit UNDI ROM.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkStopUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice\r
-  );\r
-\r
-/**\r
-  Stop the UNDI interface\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to stop 16 bit UNDI ROM.\r
-  @retval Others           Status of stop 16 bit UNDI ROM.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkCleanupUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice\r
-  );\r
-\r
-/**\r
-  Get runtime information for Undi network interface\r
-\r
-  @param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_SUCCESS Sucess operation.\r
-  @retval Others      Fail to get runtime information for Undi network interface.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkGetInformation (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Get NIC type\r
-\r
-  @param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_SUCCESS Sucess operation.\r
-  @retval Others      Fail to get NIC type.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkGetNicType (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Get NDIS information\r
-\r
-  @param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_SUCCESS Sucess operation.\r
-  @retval Others      Fail to get NDIS information.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkGetNdisInfo (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Signal handlers for ExitBootServices event.\r
-\r
-  Clean up any Real-mode UNDI residue from the system\r
-\r
-  @param Event      ExitBootServices event\r
-  @param Context\r
-**/\r
-VOID\r
-EFIAPI\r
-Undi16SimpleNetworkEvent (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  );\r
-\r
-/**\r
-  Loads the undi driver.\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-\r
-  @retval   EFI_SUCCESS   - Successfully loads undi driver.\r
-  @retval   EFI_NOT_FOUND - Doesn't find undi driver or undi driver load failure.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkLoadUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice\r
-  );\r
-\r
-/**\r
-  Unload 16 bit UNDI Option ROM from memory\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-\r
-  @return EFI_STATUS\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkUnloadUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice\r
-  );\r
-\r
-/**\r
-  Entry point for EFI drivers.\r
-\r
-  @param ImageHandle Handle that identifies the loaded image.\r
-  @param SystemTable System Table for this image.\r
-\r
-  @return EFI_STATUS Return status from EfiLibInstallAllDriverProtocols.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16DriverEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  return EfiLibInstallDriverBindingComponentName2 (\r
-           ImageHandle,\r
-           SystemTable,\r
-           &gBiosSnp16DriverBinding,\r
-           ImageHandle,\r
-           &gBiosSnp16ComponentName,\r
-           &gBiosSnp16ComponentName2\r
-           );\r
-}\r
-\r
-//\r
-// EFI Driver Binding Protocol Functions\r
-//\r
-/**\r
-  Tests to see if this driver supports a given controller.\r
-\r
-  @param This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param Controller           The handle of the controller to test.\r
-  @param RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS    The driver supports given controller.\r
-  @retval EFI_UNSUPPORT  The driver doesn't support given controller.\r
-  @retval Other          Other errors prevent driver finishing to test\r
-                         if the driver supports given controller.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16DriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-  PCI_TYPE00                Pci;\r
-\r
-  //\r
-  // See if the Legacy BIOS Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiDevicePathProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // See if this is a PCI Network Controller by looking at the Command register and\r
-  // Class Code Register\r
-  //\r
-  Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, sizeof (Pci) / sizeof (UINT32), &Pci);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Done;\r
-  }\r
-\r
-  Status = EFI_UNSUPPORTED;\r
-  if (Pci.Hdr.ClassCode[2] == PCI_CLASS_NETWORK) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-\r
-Done:\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiPciIoProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Starts the Snp device controller\r
-\r
-  @param This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param Controller           The handle of the controller to test.\r
-  @param RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval  EFI_SUCCESS          - The device was started.\r
-  @retval  EFI_DEVICE_ERROR     - The device could not be started due to a device error.\r
-  @retval  EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16DriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-  EFI_SIMPLE_NETWORK_DEV    *SimpleNetworkDevice;\r
-  EFI_DEV_PATH              Node;\r
-  UINTN                     Index;\r
-  UINTN                     Index2;\r
-  UINTN                     Segment;\r
-  UINTN                     Bus;\r
-  UINTN                     Device;\r
-  UINTN                     Function;\r
-  UINTN                     Flags;\r
-  UINT64                    Supports;\r
-\r
-  SimpleNetworkDevice = NULL;\r
-  PciIo               = NULL;\r
-\r
-  //\r
-  // See if the Legacy BIOS Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Open the IO Abstraction(s) needed\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = PciIo->Attributes (\r
-                    PciIo,\r
-                    EfiPciIoAttributeOperationSupported,\r
-                    0,\r
-                    &Supports\r
-                    );\r
-  if (!EFI_ERROR (Status)) {\r
-    Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
-    Status = PciIo->Attributes (\r
-                      PciIo,\r
-                      EfiPciIoAttributeOperationEnable,\r
-                      Supports,\r
-                      NULL\r
-                      );\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Check to see if there is a legacy option ROM image associated with this PCI device\r
-  //\r
-  Status = LegacyBios->CheckPciRom (\r
-                         LegacyBios,\r
-                         Controller,\r
-                         NULL,\r
-                         NULL,\r
-                         &Flags\r
-                         );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Post the legacy option ROM if it is available.\r
-  //\r
-  Status = LegacyBios->InstallPciRom (\r
-                         LegacyBios,\r
-                         Controller,\r
-                         NULL,\r
-                         &Flags,\r
-                         NULL,\r
-                         NULL,\r
-                         NULL,\r
-                         NULL\r
-                         );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Allocate memory for this SimpleNetwork device instance\r
-  //\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  sizeof (EFI_SIMPLE_NETWORK_DEV),\r
-                  (VOID **) &SimpleNetworkDevice\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  ZeroMem (SimpleNetworkDevice, sizeof (EFI_SIMPLE_NETWORK_DEV));\r
-\r
-  //\r
-  // Initialize the SimpleNetwork device instance\r
-  //\r
-  SimpleNetworkDevice->Signature      = EFI_SIMPLE_NETWORK_DEV_SIGNATURE;\r
-  SimpleNetworkDevice->LegacyBios     = LegacyBios;\r
-  SimpleNetworkDevice->BaseDevicePath = DevicePath;\r
-  SimpleNetworkDevice->PciIo          = PciIo;\r
-\r
-  //\r
-  // Initialize the Nii Protocol\r
-  //\r
-  SimpleNetworkDevice->Nii.Revision = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION;\r
-  SimpleNetworkDevice->Nii.Type     = EfiNetworkInterfaceUndi;\r
-\r
-  CopyMem (&SimpleNetworkDevice->Nii.StringId, "UNDI", 4);\r
-\r
-  //\r
-  // Load 16 bit UNDI Option ROM into Memory\r
-  //\r
-  Status = Undi16SimpleNetworkLoadUndi (SimpleNetworkDevice);\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_NET, "ERROR : Could not load UNDI.  Status = %r\n", Status));\r
-    goto Done;\r
-  }\r
-\r
-  SimpleNetworkDevice->UndiLoaded = TRUE;\r
-\r
-  //\r
-  // Call PXENV_START_UNDI - Initilizes the UNID interface for use.\r
-  //\r
-  PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);\r
-  Status = Undi16SimpleNetworkStartUndi (\r
-             SimpleNetworkDevice,\r
-             (UINT16) ((Bus << 0x8) | (Device << 0x3) | (Function))\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_NET, "ERROR : Could not StartUndi.  Status = %r\n", Status));\r
-    goto Done;\r
-  }\r
-  //\r
-  // Initialize the Simple Network Protocol\r
-  //\r
-  DEBUG ((DEBUG_NET, "Initialize SimpleNetworkDevice instance\n"));\r
-\r
-  SimpleNetworkDevice->SimpleNetwork.Revision       = EFI_SIMPLE_NETWORK_PROTOCOL_REVISION;\r
-  SimpleNetworkDevice->SimpleNetwork.Start          = Undi16SimpleNetworkStart;\r
-  SimpleNetworkDevice->SimpleNetwork.Stop           = Undi16SimpleNetworkStop;\r
-  SimpleNetworkDevice->SimpleNetwork.Initialize     = Undi16SimpleNetworkInitialize;\r
-  SimpleNetworkDevice->SimpleNetwork.Reset          = Undi16SimpleNetworkReset;\r
-  SimpleNetworkDevice->SimpleNetwork.Shutdown       = Undi16SimpleNetworkShutdown;\r
-  SimpleNetworkDevice->SimpleNetwork.ReceiveFilters = Undi16SimpleNetworkReceiveFilters;\r
-  SimpleNetworkDevice->SimpleNetwork.StationAddress = Undi16SimpleNetworkStationAddress;\r
-  SimpleNetworkDevice->SimpleNetwork.Statistics     = Undi16SimpleNetworkStatistics;\r
-  SimpleNetworkDevice->SimpleNetwork.MCastIpToMac   = Undi16SimpleNetworkMCastIpToMac;\r
-  SimpleNetworkDevice->SimpleNetwork.NvData         = Undi16SimpleNetworkNvData;\r
-  SimpleNetworkDevice->SimpleNetwork.GetStatus      = Undi16SimpleNetworkGetStatus;\r
-  SimpleNetworkDevice->SimpleNetwork.Transmit       = Undi16SimpleNetworkTransmit;\r
-  SimpleNetworkDevice->SimpleNetwork.Receive        = Undi16SimpleNetworkReceive;\r
-  SimpleNetworkDevice->SimpleNetwork.Mode           = &(SimpleNetworkDevice->SimpleNetworkMode);\r
-\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_WAIT,\r
-                  TPL_NOTIFY,\r
-                  Undi16SimpleNetworkWaitForPacket,\r
-                  &SimpleNetworkDevice->SimpleNetwork,\r
-                  &SimpleNetworkDevice->SimpleNetwork.WaitForPacket\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "ERROR : Could not create event.  Status = %r\n", Status));\r
-    goto Done;\r
-  }\r
-  //\r
-  // Create an event to be signalled when ExitBootServices occurs in order\r
-  // to clean up nicely\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  Undi16SimpleNetworkEvent,\r
-                  NULL,\r
-                  &gEfiEventExitBootServicesGuid,\r
-                  &SimpleNetworkDevice->EfiBootEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "ERROR : Could not create event.  Status = %r\n", Status));\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Create an event to be signalled when Legacy Boot occurs to clean up the IVT\r
-  //\r
-  Status = EfiCreateEventLegacyBootEx(\r
-             TPL_NOTIFY,\r
-             Undi16SimpleNetworkEvent,\r
-             NULL,\r
-             &SimpleNetworkDevice->LegacyBootEvent\r
-             );\r
-\r
-  if (EFI_ERROR(Status)) {\r
-    DEBUG ((DEBUG_ERROR,"ERROR : Could not create event.  Status = %r\n",Status));\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Initialize the SimpleNetwork Mode Information\r
-  //\r
-  DEBUG ((DEBUG_NET, "Initialize Mode Information\n"));\r
-\r
-  SimpleNetworkDevice->SimpleNetworkMode.State                = EfiSimpleNetworkStopped;\r
-  SimpleNetworkDevice->SimpleNetworkMode.MediaHeaderSize      = 14;\r
-  SimpleNetworkDevice->SimpleNetworkMode.MacAddressChangeable = TRUE;\r
-  SimpleNetworkDevice->SimpleNetworkMode.MultipleTxSupported  = TRUE;\r
-  SimpleNetworkDevice->SimpleNetworkMode.ReceiveFilterMask = EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |\r
-    EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST |\r
-    EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST |\r
-    EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS |\r
-    EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r
-  SimpleNetworkDevice->SimpleNetworkMode.MaxMCastFilterCount = MAXNUM_MCADDR;\r
-\r
-  //\r
-  // Initialize the SimpleNetwork Private Information\r
-  //\r
-  DEBUG ((DEBUG_NET, "Initialize Private Information\n"));\r
-\r
-  Status = BiosSnp16AllocatePagesBelowOneMb (\r
-             sizeof (PXENV_UNDI_TBD_T) / EFI_PAGE_SIZE + 1,\r
-             (VOID **) &SimpleNetworkDevice->Xmit\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = BiosSnp16AllocatePagesBelowOneMb (\r
-             1,\r
-             &SimpleNetworkDevice->TxRealModeMediaHeader\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = BiosSnp16AllocatePagesBelowOneMb (\r
-             1,\r
-             &SimpleNetworkDevice->TxRealModeDataBuffer\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = BiosSnp16AllocatePagesBelowOneMb (\r
-             1,\r
-             &SimpleNetworkDevice->TxDestAddr\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  SimpleNetworkDevice->Xmit->XmitOffset               = (UINT16) (((UINT32)(UINTN) SimpleNetworkDevice->TxRealModeMediaHeader) & 0x000f);\r
-\r
-  SimpleNetworkDevice->Xmit->XmitSegment              = (UINT16) (((UINT32)(UINTN) SimpleNetworkDevice->TxRealModeMediaHeader) >> 4);\r
-\r
-  SimpleNetworkDevice->Xmit->DataBlkCount             = 1;\r
-\r
-  SimpleNetworkDevice->Xmit->DataBlock[0].TDPtrType   = 1;\r
-  SimpleNetworkDevice->Xmit->DataBlock[0].TDRsvdByte  = 0;\r
-\r
-  SimpleNetworkDevice->Xmit->DataBlock[0].TDDataPtrOffset = (UINT16) (((UINT32)(UINTN) SimpleNetworkDevice->TxRealModeDataBuffer) & 0x000f);\r
-\r
-  SimpleNetworkDevice->Xmit->DataBlock[0].TDDataPtrSegment = (UINT16) (((UINT32)(UINTN) SimpleNetworkDevice->TxRealModeDataBuffer) >> 4);\r
-\r
-  SimpleNetworkDevice->TxBufferFifo.First = 0;\r
-  SimpleNetworkDevice->TxBufferFifo.Last  = 0;\r
-\r
-  //\r
-  // Start() the SimpleNetwork device\r
-  //\r
-  DEBUG ((DEBUG_NET, "Start()\n"));\r
-\r
-  Status = Undi16SimpleNetworkStart (&SimpleNetworkDevice->SimpleNetwork);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // GetInformation() the SimpleNetwork device\r
-  //\r
-  DEBUG ((DEBUG_NET, "GetInformation()\n"));\r
-\r
-  Status = Undi16SimpleNetworkGetInformation (&SimpleNetworkDevice->SimpleNetwork);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Build the device path for the child device\r
-  //\r
-  ZeroMem (&Node, sizeof (Node));\r
-  Node.DevPath.Type     = MESSAGING_DEVICE_PATH;\r
-  Node.DevPath.SubType  = MSG_MAC_ADDR_DP;\r
-  SetDevicePathNodeLength (&Node.DevPath, sizeof (MAC_ADDR_DEVICE_PATH));\r
-  CopyMem (\r
-    &Node.MacAddr.MacAddress,\r
-    &SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress,\r
-    sizeof (EFI_MAC_ADDRESS)\r
-    );\r
-  SimpleNetworkDevice->DevicePath = AppendDevicePathNode (\r
-                                      SimpleNetworkDevice->BaseDevicePath,\r
-                                      &Node.DevPath\r
-                                      );\r
-\r
-  //\r
-  // GetNicType()  the SimpleNetwork device\r
-  //\r
-  DEBUG ((DEBUG_NET, "GetNicType()\n"));\r
-\r
-  Status = Undi16SimpleNetworkGetNicType (&SimpleNetworkDevice->SimpleNetwork);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // GetNdisInfo() the SimpleNetwork device\r
-  //\r
-  DEBUG ((DEBUG_NET, "GetNdisInfo()\n"));\r
-\r
-  Status = Undi16SimpleNetworkGetNdisInfo (&SimpleNetworkDevice->SimpleNetwork);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Stop() the SimpleNetwork device\r
-  //\r
-  DEBUG ((DEBUG_NET, "Stop()\n"));\r
-\r
-  Status = SimpleNetworkDevice->SimpleNetwork.Stop (&SimpleNetworkDevice->SimpleNetwork);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Print Mode information\r
-  //\r
-  DEBUG ((DEBUG_NET, "Mode->State                = %d\n", SimpleNetworkDevice->SimpleNetworkMode.State));\r
-  DEBUG ((DEBUG_NET, "Mode->HwAddressSize        = %d\n", SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize));\r
-  DEBUG ((DEBUG_NET, "Mode->MacAddressChangeable = %d\n", SimpleNetworkDevice->SimpleNetworkMode.MacAddressChangeable));\r
-  DEBUG ((DEBUG_NET, "Mode->MultiplTxSupported   = %d\n", SimpleNetworkDevice->SimpleNetworkMode.MultipleTxSupported));\r
-  DEBUG ((DEBUG_NET, "Mode->NvRamSize            = %d\n", SimpleNetworkDevice->SimpleNetworkMode.NvRamSize));\r
-  DEBUG ((DEBUG_NET, "Mode->NvRamAccessSize      = %d\n", SimpleNetworkDevice->SimpleNetworkMode.NvRamAccessSize));\r
-  DEBUG ((DEBUG_NET, "Mode->ReceiveFilterSetting = %d\n", SimpleNetworkDevice->SimpleNetworkMode.ReceiveFilterSetting));\r
-  DEBUG ((DEBUG_NET, "Mode->IfType               = %d\n", SimpleNetworkDevice->SimpleNetworkMode.IfType));\r
-  DEBUG ((DEBUG_NET, "Mode->MCastFilterCount     = %d\n", SimpleNetworkDevice->SimpleNetworkMode.MCastFilterCount));\r
-  for (Index = 0; Index < SimpleNetworkDevice->SimpleNetworkMode.MCastFilterCount; Index++) {\r
-    DEBUG ((DEBUG_NET, "  Filter[%02d] = ", Index));\r
-    for (Index2 = 0; Index2 < 16; Index2++) {\r
-      DEBUG ((DEBUG_NET, "%02x ", SimpleNetworkDevice->SimpleNetworkMode.MCastFilter[Index].Addr[Index2]));\r
-    }\r
-\r
-    DEBUG ((DEBUG_NET, "\n"));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "CurrentAddress = "));\r
-  for (Index2 = 0; Index2 < 16; Index2++) {\r
-    DEBUG ((DEBUG_NET, "%02x ", SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress.Addr[Index2]));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "\n"));\r
-\r
-  DEBUG ((DEBUG_NET, "BroadcastAddress = "));\r
-  for (Index2 = 0; Index2 < 16; Index2++) {\r
-    DEBUG ((DEBUG_NET, "%02x ", SimpleNetworkDevice->SimpleNetworkMode.BroadcastAddress.Addr[Index2]));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "\n"));\r
-\r
-  DEBUG ((DEBUG_NET, "PermanentAddress = "));\r
-  for (Index2 = 0; Index2 < 16; Index2++) {\r
-    DEBUG ((DEBUG_NET, "%02x ", SimpleNetworkDevice->SimpleNetworkMode.PermanentAddress.Addr[Index2]));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "\n"));\r
-\r
-  //\r
-  // The network device was started, information collected, and stopped.\r
-  // Install protocol interfaces for the SimpleNetwork device.\r
-  //\r
-  DEBUG ((DEBUG_NET, "Install Protocol Interfaces on network interface\n"));\r
-\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &SimpleNetworkDevice->Handle,\r
-                  &gEfiSimpleNetworkProtocolGuid,\r
-                  &SimpleNetworkDevice->SimpleNetwork,\r
-                  &gEfiNetworkInterfaceIdentifierProtocolGuid,\r
-                  &SimpleNetworkDevice->Nii,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  SimpleNetworkDevice->DevicePath,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Open PCI I/O from the newly created child handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  SimpleNetworkDevice->Handle,\r
-                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                  );\r
-\r
-  DEBUG ((DEBUG_INIT, "UNDI16 Driver : EFI_SUCCESS\n"));\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    if (SimpleNetworkDevice != NULL) {\r
-\r
-      Undi16SimpleNetworkShutdown (&SimpleNetworkDevice->SimpleNetwork);\r
-      //\r
-      // CLOSE + SHUTDOWN\r
-      //\r
-      Undi16SimpleNetworkCleanupUndi (SimpleNetworkDevice);\r
-      //\r
-      // CLEANUP\r
-      //\r
-      Undi16SimpleNetworkStopUndi (SimpleNetworkDevice);\r
-      //\r
-      // STOP\r
-      //\r
-      if (SimpleNetworkDevice->UndiLoaded) {\r
-        Undi16SimpleNetworkUnloadUndi (SimpleNetworkDevice);\r
-      }\r
-\r
-      if (SimpleNetworkDevice->SimpleNetwork.WaitForPacket != NULL) {\r
-        gBS->CloseEvent (SimpleNetworkDevice->SimpleNetwork.WaitForPacket);\r
-      }\r
-\r
-      if (SimpleNetworkDevice->LegacyBootEvent != NULL) {\r
-        gBS->CloseEvent (SimpleNetworkDevice->LegacyBootEvent);\r
-      }\r
-\r
-      if (SimpleNetworkDevice->EfiBootEvent != NULL) {\r
-        gBS->CloseEvent (SimpleNetworkDevice->EfiBootEvent);\r
-      }\r
-\r
-      if (SimpleNetworkDevice->Xmit != NULL) {\r
-        gBS->FreePages (\r
-               (EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->Xmit,\r
-               sizeof (PXENV_UNDI_TBD_T) / EFI_PAGE_SIZE + 1\r
-               );\r
-      }\r
-\r
-      if (SimpleNetworkDevice->TxRealModeMediaHeader != NULL) {\r
-        gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->TxRealModeMediaHeader, 1);\r
-      }\r
-\r
-      if (SimpleNetworkDevice->TxRealModeDataBuffer != NULL) {\r
-        gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->TxRealModeDataBuffer, 1);\r
-      }\r
-\r
-      if (SimpleNetworkDevice->TxDestAddr != NULL) {\r
-        gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->TxDestAddr, 1);\r
-      }\r
-\r
-      gBS->FreePool (SimpleNetworkDevice);\r
-\r
-      //\r
-      //  Only restore the vector if it was cached.\r
-      //\r
-      if (mCachedInt1A) {\r
-        RestoreCachedVectorAddress (0x1A);\r
-        mCachedInt1A = FALSE;\r
-      }\r
-    }\r
-\r
-    if (PciIo != NULL) {\r
-      Status = PciIo->Attributes (\r
-                        PciIo,\r
-                        EfiPciIoAttributeOperationSupported,\r
-                        0,\r
-                        &Supports\r
-                        );\r
-      if (!EFI_ERROR (Status)) {\r
-        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
-        Status = PciIo->Attributes (\r
-                          PciIo,\r
-                          EfiPciIoAttributeOperationDisable,\r
-                          Supports,\r
-                          NULL\r
-                          );\r
-      }\r
-    }\r
-\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiPciIoProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-    if (Status != EFI_OUT_OF_RESOURCES) {\r
-      Status = EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stops the device by given device controller.\r
-\r
-  @param This               A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param Controller         The handle of the controller to test.\r
-  @param NumberOfChildren   The number of child device handles in ChildHandleBuffer.\r
-  @param ChildHandleBuffer  An array of child handles to be freed. May be NULL if\r
-                            NumberOfChildren is 0.\r
-\r
-  @retval  EFI_SUCCESS      - The device was stopped.\r
-  @retval  EFI_DEVICE_ERROR - The device could not be stopped due to a device error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16DriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Controller,\r
-  IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  UINTN                       Index;\r
-  BOOLEAN                     AllChildrenStopped;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL *SimpleNetwork;\r
-  EFI_SIMPLE_NETWORK_DEV      *SimpleNetworkDevice;\r
-  EFI_PCI_IO_PROTOCOL         *PciIo;\r
-  UINT64                      Supports;\r
-\r
-  //\r
-  // Complete all outstanding transactions to Controller.\r
-  // Don't allow any new transaction to Controller to be started.\r
-  //\r
-  if (NumberOfChildren == 0) {\r
-    //\r
-    // Close the bus driver\r
-    //\r
-    Status = gBS->OpenProtocol (\r
-                    Controller,\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo,\r
-                    This->DriverBindingHandle,\r
-                    Controller,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = PciIo->Attributes (\r
-                        PciIo,\r
-                        EfiPciIoAttributeOperationSupported,\r
-                        0,\r
-                        &Supports\r
-                        );\r
-      if (!EFI_ERROR (Status)) {\r
-        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
-        Status = PciIo->Attributes (\r
-                          PciIo,\r
-                          EfiPciIoAttributeOperationDisable,\r
-                          Supports,\r
-                          NULL\r
-                          );\r
-      }\r
-    }\r
-\r
-    Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiPciIoProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    Controller\r
-                    );\r
-\r
-    Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    Controller\r
-                    );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_DEVICE_ERROR;\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  AllChildrenStopped = TRUE;\r
-\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-\r
-    Status = gBS->OpenProtocol (\r
-                    ChildHandleBuffer[Index],\r
-                    &gEfiSimpleNetworkProtocolGuid,\r
-                    (VOID **) &SimpleNetwork,\r
-                    This->DriverBindingHandle,\r
-                    Controller,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-\r
-      SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (SimpleNetwork);\r
-\r
-      Status = gBS->CloseProtocol (\r
-                      Controller,\r
-                      &gEfiPciIoProtocolGuid,\r
-                      This->DriverBindingHandle,\r
-                      ChildHandleBuffer[Index]\r
-                      );\r
-\r
-      Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                      SimpleNetworkDevice->Handle,\r
-                      &gEfiSimpleNetworkProtocolGuid,\r
-                      &SimpleNetworkDevice->SimpleNetwork,\r
-                      &gEfiNetworkInterfaceIdentifierProtocolGuid,\r
-                      &SimpleNetworkDevice->Nii,\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      SimpleNetworkDevice->DevicePath,\r
-                      NULL\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        gBS->OpenProtocol (\r
-               Controller,\r
-               &gEfiPciIoProtocolGuid,\r
-               (VOID **) &PciIo,\r
-               This->DriverBindingHandle,\r
-               ChildHandleBuffer[Index],\r
-               EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-               );\r
-      } else {\r
-\r
-        Undi16SimpleNetworkShutdown (&SimpleNetworkDevice->SimpleNetwork);\r
-        //\r
-        // CLOSE + SHUTDOWN\r
-        //\r
-        Undi16SimpleNetworkCleanupUndi (SimpleNetworkDevice);\r
-        //\r
-        // CLEANUP\r
-        //\r
-        Undi16SimpleNetworkStopUndi (SimpleNetworkDevice);\r
-        //\r
-        // STOP\r
-        //\r
-        if (SimpleNetworkDevice->UndiLoaded) {\r
-          Undi16SimpleNetworkUnloadUndi (SimpleNetworkDevice);\r
-        }\r
-\r
-        if (SimpleNetworkDevice->SimpleNetwork.WaitForPacket != NULL) {\r
-          gBS->CloseEvent (SimpleNetworkDevice->SimpleNetwork.WaitForPacket);\r
-        }\r
-\r
-        if (SimpleNetworkDevice->LegacyBootEvent != NULL) {\r
-          gBS->CloseEvent (SimpleNetworkDevice->LegacyBootEvent);\r
-        }\r
-\r
-        if (SimpleNetworkDevice->EfiBootEvent != NULL) {\r
-          gBS->CloseEvent (SimpleNetworkDevice->EfiBootEvent);\r
-        }\r
-\r
-        if (SimpleNetworkDevice->Xmit != NULL) {\r
-          gBS->FreePages (\r
-                 (EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->Xmit,\r
-                 sizeof (PXENV_UNDI_TBD_T) / EFI_PAGE_SIZE + 1\r
-                 );\r
-        }\r
-\r
-        if (SimpleNetworkDevice->TxRealModeMediaHeader != NULL) {\r
-          gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->TxRealModeMediaHeader, 1);\r
-        }\r
-\r
-        if (SimpleNetworkDevice->TxRealModeDataBuffer != NULL) {\r
-          gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->TxRealModeDataBuffer, 1);\r
-        }\r
-\r
-        if (SimpleNetworkDevice->TxDestAddr != NULL) {\r
-          gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->TxDestAddr, 1);\r
-        }\r
-\r
-        gBS->FreePool (SimpleNetworkDevice);\r
-      }\r
-\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      AllChildrenStopped = FALSE;\r
-    }\r
-  }\r
-\r
-  if (!AllChildrenStopped) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// FIFO Support Functions\r
-//\r
-/**\r
-  Judge whether transmit FIFO is full.\r
-\r
-  @param Fifo Point to trasmit FIFO structure.\r
-\r
-  @return BOOLEAN whether transmit FIFO is full.\r
-**/\r
-BOOLEAN\r
-SimpleNetworkTransmitFifoFull (\r
-  EFI_SIMPLE_NETWORK_DEV_FIFO *Fifo\r
-  )\r
-{\r
-  if (((Fifo->Last + 1) % EFI_SIMPLE_NETWORK_MAX_TX_FIFO_SIZE) == Fifo->First) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Judge whether transmit FIFO is empty.\r
-\r
-  @param Fifo Point to trasmit FIFO structure.\r
-\r
-  @return BOOLEAN whether transmit FIFO is empty.\r
-**/\r
-BOOLEAN\r
-SimpleNetworkTransmitFifoEmpty (\r
-  EFI_SIMPLE_NETWORK_DEV_FIFO *Fifo\r
-  )\r
-{\r
-  if (Fifo->Last == Fifo->First) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-\r
-/**\r
-  Add data into transmit buffer.\r
-\r
-  @param Fifo Point to trasmit FIFO structure.\r
-  @param Data The data point want to be added.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  FIFO is full\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-SimpleNetworkTransmitFifoAdd (\r
-  EFI_SIMPLE_NETWORK_DEV_FIFO *Fifo,\r
-  VOID                        *Data\r
-  )\r
-{\r
-  if (SimpleNetworkTransmitFifoFull (Fifo)) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Fifo->Data[Fifo->Last]  = Data;\r
-  Fifo->Last              = (Fifo->Last + 1) % EFI_SIMPLE_NETWORK_MAX_TX_FIFO_SIZE;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Get a data and remove it from network transmit FIFO.\r
-\r
-  @param Fifo Point to trasmit FIFO structure.\r
-  @param Data On return, point to the data point want to be got and removed.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES network transmit buffer is empty.\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-SimpleNetworkTransmitFifoRemove (\r
-  EFI_SIMPLE_NETWORK_DEV_FIFO *Fifo,\r
-  VOID                        **Data\r
-  )\r
-{\r
-  if (SimpleNetworkTransmitFifoEmpty (Fifo)) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  *Data       = Fifo->Data[Fifo->First];\r
-  Fifo->First = (Fifo->First + 1) % EFI_SIMPLE_NETWORK_MAX_TX_FIFO_SIZE;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Get recive filter setting according to EFI mask value.\r
-\r
-  @param ReceiveFilterSetting  filter setting EFI mask value.\r
-\r
-  @return UINT16 Undi filter setting value.\r
-**/\r
-UINT16\r
-Undi16GetPacketFilterSetting (\r
-  UINTN ReceiveFilterSetting\r
-  )\r
-{\r
-  UINT16  PktFilter;\r
-\r
-  PktFilter = 0;\r
-  if ((ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_UNICAST) != 0) {\r
-    PktFilter |= FLTR_DIRECTED;\r
-  }\r
-\r
-  if ((ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) {\r
-    PktFilter |= FLTR_DIRECTED;\r
-  }\r
-\r
-  if ((ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST) != 0) {\r
-    PktFilter |= FLTR_BRDCST;\r
-  }\r
-\r
-  if ((ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS) != 0) {\r
-    PktFilter |= FLTR_PRMSCS;\r
-  }\r
-\r
-  if ((ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) {\r
-    PktFilter |= FLTR_PRMSCS;\r
-    //\r
-    // @bug : Do not know if this is right????\r
-    //\r
-  }\r
-  //\r
-  // @bug : What is FLTR_SRC_RTG?\r
-  //\r
-  return PktFilter;\r
-}\r
-\r
-/**\r
-  Get filter setting from multi cast buffer .\r
-\r
-  @param Mode           Point to mode structure.\r
-  @param McastBuffer    The multi cast buffer\r
-  @param HwAddressSize  Size of filter value.\r
-\r
-**/\r
-VOID\r
-Undi16GetMCastFilters (\r
-  IN EFI_SIMPLE_NETWORK_MODE      *Mode,\r
-  IN OUT PXENV_UNDI_MCAST_ADDR_T  *McastBuffer,\r
-  IN UINTN                        HwAddressSize\r
-  )\r
-{\r
-  UINTN Index;\r
-\r
-  //\r
-  // @bug : What if Mode->MCastFilterCount > MAXNUM_MCADDR?\r
-  //\r
-  McastBuffer->MCastAddrCount = (UINT16) Mode->MCastFilterCount;\r
-  for (Index = 0; Index < MAXNUM_MCADDR; Index++) {\r
-    if (Index < McastBuffer->MCastAddrCount) {\r
-      CopyMem (&McastBuffer->MCastAddr[Index], &Mode->MCastFilter[Index], HwAddressSize);\r
-    } else {\r
-      ZeroMem (&McastBuffer->MCastAddr[Index], HwAddressSize);\r
-    }\r
-  }\r
-}\r
-//\r
-// Load 16 bit UNDI Option ROM into memory\r
-//\r
-/**\r
-  Loads the undi driver.\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-\r
-  @retval   EFI_SUCCESS   - Successfully loads undi driver.\r
-  @retval   EFI_NOT_FOUND - Doesn't find undi driver or undi driver load failure.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkLoadUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-  UINTN                     RomAddress;\r
-  PCI_EXPANSION_ROM_HEADER  *PciExpansionRomHeader;\r
-  PCI_DATA_STRUCTURE        *PciDataStructure;\r
-  PCI_TYPE00                Pci;\r
-\r
-  if (!mCachedInt1A) {\r
-    Status = CacheVectorAddress (0x1A);\r
-    if (!EFI_ERROR (Status)) {\r
-      mCachedInt1A = TRUE;\r
-    }\r
-  }\r
-\r
-  PciIo = SimpleNetworkDevice->PciIo;\r
-\r
-  PciIo->Pci.Read (\r
-               PciIo,\r
-               EfiPciIoWidthUint32,\r
-               0,\r
-               sizeof (Pci) / sizeof (UINT32),\r
-               &Pci\r
-               );\r
-\r
-  for (RomAddress = 0xc0000; RomAddress < 0xfffff; RomAddress += 0x800) {\r
-\r
-    PciExpansionRomHeader = (PCI_EXPANSION_ROM_HEADER *) RomAddress;\r
-\r
-    if (PciExpansionRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r
-      continue;\r
-    }\r
-\r
-    DEBUG ((DEBUG_INIT, "Option ROM found at %X\n", RomAddress));\r
-\r
-    //\r
-    // If the pointer to the PCI Data Structure is invalid, no further images can be located.\r
-    // The PCI Data Structure must be DWORD aligned.\r
-    //\r
-    if (PciExpansionRomHeader->PcirOffset == 0 ||\r
-        (PciExpansionRomHeader->PcirOffset & 3) != 0 ||\r
-        RomAddress + PciExpansionRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > 0x100000) {\r
-      break;\r
-    }\r
-\r
-    PciDataStructure = (PCI_DATA_STRUCTURE *) (RomAddress + PciExpansionRomHeader->PcirOffset);\r
-\r
-    if (PciDataStructure->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
-      continue;\r
-    }\r
-\r
-    DEBUG ((DEBUG_INIT, "PCI Data Structure found at %X\n", PciDataStructure));\r
-\r
-    if (PciDataStructure->VendorId != Pci.Hdr.VendorId || PciDataStructure->DeviceId != Pci.Hdr.DeviceId) {\r
-      continue;\r
-    }\r
-\r
-    DEBUG (\r
-        (DEBUG_INIT,\r
-         "PCI device with matchinng VendorId and DeviceId (%d,%d)\n",\r
-         (UINTN) PciDataStructure->VendorId,\r
-         (UINTN) PciDataStructure->DeviceId)\r
-        );\r
-\r
-    Status = LaunchBaseCode (SimpleNetworkDevice, RomAddress);\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    //\r
-    // Free resources allocated in LaunchBaseCode\r
-    //\r
-    Undi16SimpleNetworkUnloadUndi (SimpleNetworkDevice);\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Unload 16 bit UNDI Option ROM from memory\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-\r
-  @return EFI_STATUS\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkUnloadUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice\r
-  )\r
-{\r
-  if (SimpleNetworkDevice->UndiLoaderTable != NULL) {\r
-    ZeroMem (SimpleNetworkDevice->UndiLoaderTable, SimpleNetworkDevice->UndiLoaderTablePages << EFI_PAGE_SHIFT);\r
-    gBS->FreePages (\r
-          (EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->UndiLoaderTable,\r
-          SimpleNetworkDevice->UndiLoaderTablePages\r
-          );\r
-  }\r
-\r
-  if (SimpleNetworkDevice->DestinationDataSegment != NULL) {\r
-    ZeroMem (\r
-      SimpleNetworkDevice->DestinationDataSegment,\r
-      SimpleNetworkDevice->DestinationDataSegmentPages << EFI_PAGE_SHIFT\r
-      );\r
-    gBS->FreePages (\r
-          (EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->DestinationDataSegment,\r
-          SimpleNetworkDevice->DestinationDataSegmentPages\r
-          );\r
-  }\r
-\r
-  if (SimpleNetworkDevice->DestinationStackSegment != NULL) {\r
-    ZeroMem (\r
-      SimpleNetworkDevice->DestinationStackSegment,\r
-      SimpleNetworkDevice->DestinationStackSegmentPages << EFI_PAGE_SHIFT\r
-      );\r
-    gBS->FreePages (\r
-          (EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->DestinationStackSegment,\r
-          SimpleNetworkDevice->DestinationStackSegmentPages\r
-          );\r
-  }\r
-\r
-  if (SimpleNetworkDevice->DestinationCodeSegment != NULL) {\r
-    ZeroMem (\r
-      SimpleNetworkDevice->DestinationCodeSegment,\r
-      SimpleNetworkDevice->DestinationCodeSegmentPages << EFI_PAGE_SHIFT\r
-      );\r
-    gBS->FreePages (\r
-          (EFI_PHYSICAL_ADDRESS) (UINTN) SimpleNetworkDevice->DestinationCodeSegment,\r
-          SimpleNetworkDevice->DestinationCodeSegmentPages\r
-          );\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Start the UNDI interface.\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-  @param Ax                  PCI address of Undi device.\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to start 16 bit UNDI ROM.\r
-  @retval Others           Status of start 16 bit UNDI ROM.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkStartUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  UINT16                  Ax\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-  PXENV_START_UNDI_T  Start;\r
-\r
-  //\r
-  // Call 16 bit UNDI ROM to start the network interface\r
-  //\r
-  //\r
-  // @bug : What is this state supposed to be???\r
-  //\r
-  Start.Status  = INIT_PXE_STATUS;\r
-  Start.Ax      = Ax;\r
-  Start.Bx      = 0x0000;\r
-  Start.Dx      = 0x0000;\r
-  Start.Di      = 0x0000;\r
-  Start.Es      = 0x0000;\r
-\r
-  Status        = PxeStartUndi (SimpleNetworkDevice, &Start);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Start.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Stop the UNDI interface\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to stop 16 bit UNDI ROM.\r
-  @retval Others           Status of stop 16 bit UNDI ROM.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkStopUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  PXENV_STOP_UNDI_T Stop;\r
-\r
-  //\r
-  // Call 16 bit UNDI ROM to start the network interface\r
-  //\r
-  Stop.Status = INIT_PXE_STATUS;\r
-\r
-  Status      = PxeUndiStop (SimpleNetworkDevice, &Stop);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Stop.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Cleanup Unid network interface\r
-\r
-  @param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to cleanup 16 bit UNDI ROM.\r
-  @retval Others           Status of cleanup 16 bit UNDI ROM.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkCleanupUndi (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  PXENV_UNDI_CLEANUP_T  Cleanup;\r
-\r
-  //\r
-  // Call 16 bit UNDI ROM to cleanup the network interface\r
-  //\r
-  Cleanup.Status  = INIT_PXE_STATUS;\r
-\r
-  Status          = PxeUndiCleanup (SimpleNetworkDevice, &Cleanup);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Cleanup.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Get runtime information for Undi network interface\r
-\r
-  @param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_SUCCESS Sucess operation.\r
-  @retval Others      Fail to get runtime information for Undi network interface.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkGetInformation (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  UINTN                   Index;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkStarted:\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to start the network interface\r
-  //\r
-  ZeroMem (&SimpleNetworkDevice->GetInformation, sizeof (PXENV_UNDI_GET_INFORMATION_T));\r
-\r
-  SimpleNetworkDevice->GetInformation.Status  = INIT_PXE_STATUS;\r
-\r
-  Status = PxeUndiGetInformation (SimpleNetworkDevice, &SimpleNetworkDevice->GetInformation);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "  GetInformation.Status      = %d\n", SimpleNetworkDevice->GetInformation.Status));\r
-  DEBUG ((DEBUG_NET, "  GetInformation.BaseIo      = %d\n", SimpleNetworkDevice->GetInformation.BaseIo));\r
-  DEBUG ((DEBUG_NET, "  GetInformation.IntNumber   = %d\n", SimpleNetworkDevice->GetInformation.IntNumber));\r
-  DEBUG ((DEBUG_NET, "  GetInformation.MaxTranUnit = %d\n", SimpleNetworkDevice->GetInformation.MaxTranUnit));\r
-  DEBUG ((DEBUG_NET, "  GetInformation.HwType      = %d\n", SimpleNetworkDevice->GetInformation.HwType));\r
-  DEBUG ((DEBUG_NET, "  GetInformation.HwAddrLen   = %d\n", SimpleNetworkDevice->GetInformation.HwAddrLen));\r
-  DEBUG ((DEBUG_NET, "  GetInformation.ROMAddress  = %d\n", SimpleNetworkDevice->GetInformation.ROMAddress));\r
-  DEBUG ((DEBUG_NET, "  GetInformation.RxBufCt     = %d\n", SimpleNetworkDevice->GetInformation.RxBufCt));\r
-  DEBUG ((DEBUG_NET, "  GetInformation.TxBufCt     = %d\n", SimpleNetworkDevice->GetInformation.TxBufCt));\r
-\r
-  DEBUG ((DEBUG_NET, "  GetInformation.CurNodeAddr ="));\r
-  for (Index = 0; Index < 16; Index++) {\r
-    DEBUG ((DEBUG_NET, "%02x ", SimpleNetworkDevice->GetInformation.CurrentNodeAddress[Index]));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "\n"));\r
-\r
-  DEBUG ((DEBUG_NET, "  GetInformation.PermNodeAddr ="));\r
-  for (Index = 0; Index < 16; Index++) {\r
-    DEBUG ((DEBUG_NET, "%02x ", SimpleNetworkDevice->GetInformation.PermNodeAddress[Index]));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "\n"));\r
-\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (SimpleNetworkDevice->GetInformation.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // The information has been retrieved.  Fill in Mode data.\r
-  //\r
-  SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize  = SimpleNetworkDevice->GetInformation.HwAddrLen;\r
-\r
-  SimpleNetworkDevice->SimpleNetworkMode.MaxPacketSize  = SimpleNetworkDevice->GetInformation.MaxTranUnit;\r
-\r
-  SimpleNetworkDevice->SimpleNetworkMode.IfType         = (UINT8) SimpleNetworkDevice->GetInformation.HwType;\r
-\r
-  ZeroMem (\r
-    &SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress,\r
-    sizeof SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress\r
-    );\r
-\r
-  CopyMem (\r
-    &SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress,\r
-    &SimpleNetworkDevice->GetInformation.CurrentNodeAddress,\r
-    SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-    );\r
-\r
-  ZeroMem (\r
-    &SimpleNetworkDevice->SimpleNetworkMode.PermanentAddress,\r
-    sizeof SimpleNetworkDevice->SimpleNetworkMode.PermanentAddress\r
-    );\r
-\r
-  CopyMem (\r
-    &SimpleNetworkDevice->SimpleNetworkMode.PermanentAddress,\r
-    &SimpleNetworkDevice->GetInformation.PermNodeAddress,\r
-    SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-    );\r
-\r
-  //\r
-  // hard code broadcast address - not avail in PXE2.1\r
-  //\r
-  ZeroMem (\r
-    &SimpleNetworkDevice->SimpleNetworkMode.BroadcastAddress,\r
-    sizeof SimpleNetworkDevice->SimpleNetworkMode.BroadcastAddress\r
-    );\r
-\r
-  SetMem (\r
-    &SimpleNetworkDevice->SimpleNetworkMode.BroadcastAddress,\r
-    SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize,\r
-    0xff\r
-    );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Get NIC type\r
-\r
-  @param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_SUCCESS Sucess operation.\r
-  @retval Others      Fail to get NIC type.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkGetNicType (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  ZeroMem (&SimpleNetworkDevice->GetNicType, sizeof (PXENV_UNDI_GET_NIC_TYPE_T));\r
-\r
-  SimpleNetworkDevice->GetNicType.Status  = INIT_PXE_STATUS;\r
-\r
-  Status = PxeUndiGetNicType (SimpleNetworkDevice, &SimpleNetworkDevice->GetNicType);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "  GetNicType.Status      = %d\n", SimpleNetworkDevice->GetNicType.Status));\r
-  DEBUG ((DEBUG_NET, "  GetNicType.NicType     = %d\n", SimpleNetworkDevice->GetNicType.NicType));\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (SimpleNetworkDevice->GetNicType.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // The information has been retrieved.  Fill in Mode data.\r
-  //\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Get NDIS information\r
-\r
-  @param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_SUCCESS Sucess operation.\r
-  @retval Others      Fail to get NDIS information.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkGetNdisInfo (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  ZeroMem (&SimpleNetworkDevice->GetNdisInfo, sizeof (PXENV_UNDI_GET_NDIS_INFO_T));\r
-\r
-  SimpleNetworkDevice->GetNdisInfo.Status = INIT_PXE_STATUS;\r
-\r
-  Status = PxeUndiGetNdisInfo (SimpleNetworkDevice, &SimpleNetworkDevice->GetNdisInfo);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "  GetNdisInfo.Status       = %d\n", SimpleNetworkDevice->GetNdisInfo.Status));\r
-  DEBUG ((DEBUG_NET, "  GetNdisInfo.IfaceType    = %a\n", SimpleNetworkDevice->GetNdisInfo.IfaceType));\r
-  DEBUG ((DEBUG_NET, "  GetNdisInfo.LinkSpeed    = %d\n", SimpleNetworkDevice->GetNdisInfo.LinkSpeed));\r
-  DEBUG ((DEBUG_NET, "  GetNdisInfo.ServiceFlags = %08x\n", SimpleNetworkDevice->GetNdisInfo.ServiceFlags));\r
-\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (SimpleNetworkDevice->GetNdisInfo.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // The information has been retrieved.  Fill in Mode data.\r
-  //\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Call Undi ROM 16bit ISR() to check interrupt cause.\r
-\r
-  @param This               A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param FrameLength        The length of frame buffer.\r
-  @param FrameHeaderLength  The length of frame buffer's header if has.\r
-  @param Frame              The frame buffer to process network interrupt.\r
-  @param ProtType           The type network transmit protocol\r
-  @param PktType            The type of package.\r
-\r
-  @retval EFI_DEVICE_ERROR  Fail to execute 16 bit ROM's ISR, or status is invalid.\r
-  @retval EFI_SUCCESS       Success operation.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkIsr (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL * This,\r
-  IN UINTN                       *FrameLength,\r
-  IN UINTN                       *FrameHeaderLength, OPTIONAL\r
-  IN UINT8                       *Frame, OPTIONAL\r
-  IN UINT8                       *ProtType, OPTIONAL\r
-  IN UINT8                       *PktType OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  BOOLEAN                 FrameReceived;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  FrameReceived = FALSE;\r
-\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "Isr() IsrValid = %d\n", SimpleNetworkDevice->IsrValid));\r
-\r
-  if (!SimpleNetworkDevice->IsrValid) {\r
-    //\r
-    // Call 16 bit UNDI ROM to open the network interface\r
-    //\r
-    ZeroMem (&SimpleNetworkDevice->Isr, sizeof (PXENV_UNDI_ISR_T));\r
-    SimpleNetworkDevice->Isr.Status   = INIT_PXE_STATUS;\r
-    SimpleNetworkDevice->Isr.FuncFlag = PXENV_UNDI_ISR_IN_START;\r
-\r
-    DEBUG ((DEBUG_NET, "Isr() START\n"));\r
-\r
-    Status = PxeUndiIsr (SimpleNetworkDevice, &SimpleNetworkDevice->Isr);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    //\r
-    // Check the status code from the 16 bit UNDI ROM\r
-    //\r
-    if (SimpleNetworkDevice->Isr.Status != PXENV_STATUS_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-    //\r
-    // There have been no events on this UNDI interface, so return EFI_NOT_READY\r
-    //\r
-    if (SimpleNetworkDevice->Isr.FuncFlag == PXENV_UNDI_ISR_OUT_NOT_OURS) {\r
-      return EFI_SUCCESS;\r
-    }\r
-    //\r
-    // There is data to process, so call until all events processed.\r
-    //\r
-    ZeroMem (&SimpleNetworkDevice->Isr, sizeof (PXENV_UNDI_ISR_T));\r
-    SimpleNetworkDevice->Isr.Status   = INIT_PXE_STATUS;\r
-    SimpleNetworkDevice->Isr.FuncFlag = PXENV_UNDI_ISR_IN_PROCESS;\r
-\r
-    DEBUG ((DEBUG_NET, "Isr() PROCESS\n"));\r
-\r
-    Status = PxeUndiIsr (SimpleNetworkDevice, &SimpleNetworkDevice->Isr);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    SimpleNetworkDevice->IsrValid = TRUE;\r
-  }\r
-  //\r
-  // Call UNDI GET_NEXT until DONE\r
-  //\r
-  while (SimpleNetworkDevice->Isr.FuncFlag != PXENV_UNDI_ISR_OUT_DONE) {\r
-    //\r
-    // Check the status code from the 16 bit UNDI ROM\r
-    //\r
-    if (SimpleNetworkDevice->Isr.Status != PXENV_STATUS_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-    //\r
-    // UNDI is busy.  Caller will have to call again.\r
-    // This should never happen with a polled mode driver.\r
-    //\r
-    if (SimpleNetworkDevice->Isr.FuncFlag == PXENV_UNDI_ISR_OUT_BUSY) {\r
-      DEBUG ((DEBUG_NET, "  BUSY\n"));\r
-      return EFI_SUCCESS;\r
-    }\r
-    //\r
-    // Check for invalud UNDI FuncFlag\r
-    //\r
-    if (SimpleNetworkDevice->Isr.FuncFlag != PXENV_UNDI_ISR_OUT_RECEIVE &&\r
-        SimpleNetworkDevice->Isr.FuncFlag != PXENV_UNDI_ISR_OUT_TRANSMIT\r
-        ) {\r
-      DEBUG ((DEBUG_NET, "  Invalid SimpleNetworkDevice->Isr.FuncFlag value %d\n", SimpleNetworkDevice->Isr.FuncFlag));\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-    //\r
-    // Check for Transmit Event\r
-    //\r
-    if (SimpleNetworkDevice->Isr.FuncFlag == PXENV_UNDI_ISR_OUT_TRANSMIT) {\r
-      DEBUG ((DEBUG_NET, "  TRANSMIT\n"));\r
-      SimpleNetworkDevice->InterruptStatus |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;\r
-    }\r
-    //\r
-    // Check for Receive Event\r
-    //\r
-    else if (SimpleNetworkDevice->Isr.FuncFlag == PXENV_UNDI_ISR_OUT_RECEIVE) {\r
-      //\r
-      // note - this code will hang on a receive interrupt in a GetStatus loop\r
-      //\r
-      DEBUG ((DEBUG_NET, "  RECEIVE\n"));\r
-      SimpleNetworkDevice->InterruptStatus |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;\r
-\r
-      DEBUG ((DEBUG_NET, "SimpleNetworkDevice->Isr.BufferLength      = %d\n", SimpleNetworkDevice->Isr.BufferLength));\r
-      DEBUG ((DEBUG_NET, "SimpleNetworkDevice->Isr.FrameLength       = %d\n", SimpleNetworkDevice->Isr.FrameLength));\r
-      DEBUG ((DEBUG_NET, "SimpleNetworkDevice->Isr.FrameHeaderLength = %d\n", SimpleNetworkDevice->Isr.FrameHeaderLength));\r
-      DEBUG (\r
-        (\r
-        DEBUG_NET, "SimpleNetworkDevice->Isr.Frame             = %04x:%04x\n", SimpleNetworkDevice->Isr.FrameSegSel,\r
-        SimpleNetworkDevice->Isr.FrameOffset\r
-        )\r
-        );\r
-      DEBUG ((DEBUG_NET, "SimpleNetworkDevice->Isr.ProtType          = 0x%02x\n", SimpleNetworkDevice->Isr.BufferLength));\r
-      DEBUG ((DEBUG_NET, "SimpleNetworkDevice->Isr.PktType           = 0x%02x\n", SimpleNetworkDevice->Isr.BufferLength));\r
-\r
-      if (FrameReceived) {\r
-        return EFI_SUCCESS;\r
-      }\r
-\r
-      if ((Frame == NULL) || (SimpleNetworkDevice->Isr.FrameLength > *FrameLength)) {\r
-        DEBUG ((DEBUG_NET, "return EFI_BUFFER_TOO_SMALL   *FrameLength = %08x\n", *FrameLength));\r
-        *FrameLength = SimpleNetworkDevice->Isr.FrameLength;\r
-        return EFI_BUFFER_TOO_SMALL;\r
-      }\r
-\r
-      *FrameLength = SimpleNetworkDevice->Isr.FrameLength;\r
-      if (FrameHeaderLength != NULL) {\r
-        *FrameHeaderLength = SimpleNetworkDevice->Isr.FrameHeaderLength;\r
-      }\r
-\r
-      if (ProtType != NULL) {\r
-        *ProtType = SimpleNetworkDevice->Isr.ProtType;\r
-      }\r
-\r
-      if (PktType != NULL) {\r
-        *PktType = SimpleNetworkDevice->Isr.PktType;\r
-      }\r
-\r
-      CopyMem (\r
-        Frame,\r
-        (VOID *) (((UINTN) SimpleNetworkDevice->Isr.FrameSegSel << 4) + SimpleNetworkDevice->Isr.FrameOffset),\r
-        SimpleNetworkDevice->Isr.BufferLength\r
-        );\r
-      Frame = Frame + SimpleNetworkDevice->Isr.BufferLength;\r
-      if (SimpleNetworkDevice->Isr.BufferLength == SimpleNetworkDevice->Isr.FrameLength) {\r
-        FrameReceived = TRUE;\r
-      }\r
-    }\r
-    //\r
-    // There is data to process, so call until all events processed.\r
-    //\r
-    ZeroMem (&SimpleNetworkDevice->Isr, sizeof (PXENV_UNDI_ISR_T));\r
-    SimpleNetworkDevice->Isr.Status   = INIT_PXE_STATUS;\r
-    SimpleNetworkDevice->Isr.FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT;\r
-\r
-    DEBUG ((DEBUG_NET, "Isr() GET NEXT\n"));\r
-\r
-    Status = PxeUndiIsr (SimpleNetworkDevice, &SimpleNetworkDevice->Isr);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    //\r
-    // Check the status code from the 16 bit UNDI ROM\r
-    //\r
-    //        if (SimpleNetworkDevice->Isr.Status != PXENV_STATUS_SUCCESS) {\r
-    //            return EFI_DEVICE_ERROR;\r
-    //        }\r
-    //\r
-  }\r
-\r
-  SimpleNetworkDevice->IsrValid = FALSE;\r
-  return EFI_SUCCESS;\r
-}\r
-//\r
-// ///////////////////////////////////////////////////////////////////////////////////////\r
-// Simple Network Protocol Interface Functions using 16 bit UNDI Option ROMs\r
-/////////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Start()\r
-//\r
-/**\r
-  Call 16 bit UNDI ROM to start the network interface\r
-\r
-  @param This       A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_DEVICE_ERROR Network interface has not be initialized.\r
-  @retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM call.\r
-  @retval EFI_SUCESS       Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkStart (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  PXENV_UNDI_STARTUP_T    Startup;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkStopped:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  case EfiSimpleNetworkInitialized:\r
-    return EFI_ALREADY_STARTED;\r
-\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to start the network interface\r
-  //\r
-  Startup.Status  = INIT_PXE_STATUS;\r
-\r
-  Status          = PxeUndiStartup (SimpleNetworkDevice, &Startup);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Startup.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // The UNDI interface has been started, so update the State.\r
-  //\r
-  SimpleNetworkDevice->SimpleNetworkMode.State = EfiSimpleNetworkStarted;\r
-\r
-  //\r
-  //\r
-  //\r
-  SimpleNetworkDevice->SimpleNetworkMode.ReceiveFilterSetting = 0;\r
-  SimpleNetworkDevice->SimpleNetworkMode.MCastFilterCount     = 0;\r
-\r
-  return Status;\r
-}\r
-//\r
-// Stop()\r
-//\r
-/**\r
-  Call 16 bit UNDI ROM to stop the network interface\r
-\r
-  @param This       A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_DEVICE_ERROR Network interface has not be initialized.\r
-  @retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM call.\r
-  @retval EFI_SUCESS       Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkStop (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkStarted:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkInitialized:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  SimpleNetworkDevice->SimpleNetworkMode.State = EfiSimpleNetworkStopped;\r
-\r
-  return Status;\r
-}\r
-\r
-//\r
-// Initialize()\r
-//\r
-/**\r
-  Initialize network interface\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param ExtraRxBufferSize    The size of extra request receive buffer.\r
-  @param ExtraTxBufferSize    The size of extra request transmit buffer.\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM call.\r
-  @retval EFI_SUCESS       Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkInitialize (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL            *This,\r
-  IN UINTN                                  ExtraRxBufferSize  OPTIONAL,\r
-  IN UINTN                                  ExtraTxBufferSize  OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  PXENV_UNDI_INITIALIZE_T Initialize;\r
-  PXENV_UNDI_OPEN_T       Open;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-    break;\r
-\r
-  case EfiSimpleNetworkInitialized:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to start the network interface\r
-  //\r
-  Initialize.Status       = INIT_PXE_STATUS;\r
-  Initialize.ProtocolIni  = 0;\r
-\r
-  Status                  = PxeUndiInitialize (SimpleNetworkDevice, &Initialize);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "ERROR : PxeUndiInitialize() - Status = %r\n", Status));\r
-    DEBUG ((DEBUG_ERROR, "Initialize.Status == %xh\n", Initialize.Status));\r
-\r
-    if (Initialize.Status == PXENV_STATUS_UNDI_MEDIATEST_FAILED) {\r
-      Status = EFI_NO_MEDIA;\r
-    }\r
-\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Initialize.Status != PXENV_STATUS_SUCCESS) {\r
-    DEBUG ((DEBUG_ERROR, "ERROR : PxeUndiInitialize() - Initialize.Status = %04x\n", Initialize.Status));\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to open the network interface\r
-  //\r
-  Open.Status     = INIT_PXE_STATUS;\r
-  Open.OpenFlag   = 0;\r
-  Open.PktFilter  = Undi16GetPacketFilterSetting (SimpleNetworkDevice->SimpleNetworkMode.ReceiveFilterSetting);\r
-  Undi16GetMCastFilters (\r
-    &SimpleNetworkDevice->SimpleNetworkMode,\r
-    &Open.McastBuffer,\r
-    SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-    );\r
-\r
-  Status = PxeUndiOpen (SimpleNetworkDevice, &Open);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "ERROR : PxeUndiOpen() - Status = %r\n", Status));\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Open.Status != PXENV_STATUS_SUCCESS) {\r
-    DEBUG ((DEBUG_ERROR, "ERROR : PxeUndiOpen() - Open.Status = %04x\n", Open.Status));\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // The UNDI interface has been initialized, so update the State.\r
-  //\r
-  SimpleNetworkDevice->SimpleNetworkMode.State = EfiSimpleNetworkInitialized;\r
-\r
-  //\r
-  // If initialize succeeds, then assume that media is present.\r
-  //\r
-  SimpleNetworkDevice->SimpleNetworkMode.MediaPresent = TRUE;\r
-\r
-  //\r
-  // Reset the recycled transmit buffer FIFO\r
-  //\r
-  SimpleNetworkDevice->TxBufferFifo.First = 0;\r
-  SimpleNetworkDevice->TxBufferFifo.Last  = 0;\r
-  SimpleNetworkDevice->IsrValid           = FALSE;\r
-\r
-  return Status;\r
-}\r
-//\r
-// Reset()\r
-//\r
-/**\r
-  Reset network interface.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param ExtendedVerification Need extended verfication.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkReset (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL   *This,\r
-  IN BOOLEAN                       ExtendedVerification\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  PXENV_UNDI_RESET_T      Reset;\r
-  UINT16                  Rx_filter;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Reset.Status  = INIT_PXE_STATUS;\r
-\r
-  Rx_filter     = Undi16GetPacketFilterSetting (SimpleNetworkDevice->SimpleNetworkMode.ReceiveFilterSetting);\r
-\r
-  Undi16GetMCastFilters (\r
-    &SimpleNetworkDevice->SimpleNetworkMode,\r
-    &Reset.R_Mcast_Buf,\r
-    SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-    );\r
-\r
-  Status = PxeUndiResetNic (SimpleNetworkDevice, &Reset, Rx_filter);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Reset.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Reset the recycled transmit buffer FIFO\r
-  //\r
-  SimpleNetworkDevice->TxBufferFifo.First = 0;\r
-  SimpleNetworkDevice->TxBufferFifo.Last  = 0;\r
-  SimpleNetworkDevice->IsrValid           = FALSE;\r
-\r
-  return Status;\r
-}\r
-//\r
-// Shutdown()\r
-//\r
-/**\r
-  Shutdown network interface.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkShutdown (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  PXENV_UNDI_CLOSE_T      Close;\r
-  PXENV_UNDI_SHUTDOWN_T   Shutdown;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  SimpleNetworkDevice->IsrValid = FALSE;\r
-\r
-  //\r
-  // Call 16 bit UNDI ROM to start the network interface\r
-  //\r
-  Close.Status  = INIT_PXE_STATUS;\r
-\r
-  Status        = PxeUndiClose (SimpleNetworkDevice, &Close);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Close.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to open the network interface\r
-  //\r
-  Shutdown.Status = INIT_PXE_STATUS;\r
-\r
-  Status          = PxeUndiShutdown (SimpleNetworkDevice, &Shutdown);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Shutdown.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // The UNDI interface has been initialized, so update the State.\r
-  //\r
-  SimpleNetworkDevice->SimpleNetworkMode.State = EfiSimpleNetworkStarted;\r
-\r
-  //\r
-  // If shutdown succeeds, then assume that media is not present.\r
-  //\r
-  SimpleNetworkDevice->SimpleNetworkMode.MediaPresent = FALSE;\r
-\r
-  //\r
-  // Reset the recycled transmit buffer FIFO\r
-  //\r
-  SimpleNetworkDevice->TxBufferFifo.First = 0;\r
-  SimpleNetworkDevice->TxBufferFifo.Last  = 0;\r
-\r
-  //\r
-  // A short delay.  Without this an initialize immediately following\r
-  // a shutdown will cause some versions of UNDI-16 to stop operating.\r
-  //\r
-  gBS->Stall (250000);\r
-\r
-  return Status;\r
-}\r
-//\r
-// ReceiveFilters()\r
-//\r
-/**\r
-  Reset network interface.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param Enable               Enable mask value\r
-  @param Disable              Disable mask value\r
-  @param ResetMCastFilter     Whether reset multi cast filter or not\r
-  @param MCastFilterCnt       Count of mutli cast filter for different MAC address\r
-  @param MCastFilter          Buffer for mustli cast filter for different MAC address.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkReceiveFilters (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL                     * This,\r
-  IN UINT32                                          Enable,\r
-  IN UINT32                                          Disable,\r
-  IN BOOLEAN                                         ResetMCastFilter,\r
-  IN UINTN                                           MCastFilterCnt     OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                                 * MCastFilter OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  UINTN                   Index;\r
-  UINT32                  NewFilter;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  PXENV_UNDI_CLOSE_T      Close;\r
-  PXENV_UNDI_OPEN_T       Open;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // First deal with possible filter setting changes\r
-  //\r
-  if ((Enable == 0) && (Disable == 0) && !ResetMCastFilter) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  NewFilter = (SimpleNetworkDevice->SimpleNetworkMode.ReceiveFilterSetting | Enable) &~Disable;\r
-\r
-  if ((NewFilter & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) {\r
-    if ((MCastFilterCnt == 0) || (MCastFilter == 0) || MCastFilterCnt > SimpleNetworkDevice->SimpleNetworkMode.MaxMCastFilterCount) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to close the network interface\r
-  //\r
-  Close.Status  = INIT_PXE_STATUS;\r
-\r
-  Status        = PxeUndiClose (SimpleNetworkDevice, &Close);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Close.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to open the network interface\r
-  //\r
-  //\r
-  // Reset the recycled transmit buffer FIFO\r
-  //\r
-  SimpleNetworkDevice->TxBufferFifo.First = 0;\r
-  SimpleNetworkDevice->TxBufferFifo.Last  = 0;\r
-\r
-  //\r
-  // Call 16 bit UNDI ROM to open the network interface\r
-  //\r
-  ZeroMem (&Open, sizeof Open);\r
-\r
-  Open.Status     = INIT_PXE_STATUS;\r
-  Open.PktFilter  = Undi16GetPacketFilterSetting (NewFilter);\r
-\r
-  if ((NewFilter & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) {\r
-    //\r
-    // Copy the MAC addresses into the UNDI open parameter structure\r
-    //\r
-    Open.McastBuffer.MCastAddrCount = (UINT16) MCastFilterCnt;\r
-    for (Index = 0; Index < MCastFilterCnt; ++Index) {\r
-      CopyMem (\r
-        Open.McastBuffer.MCastAddr[Index],\r
-        &MCastFilter[Index],\r
-        sizeof Open.McastBuffer.MCastAddr[Index]\r
-        );\r
-    }\r
-  } else if (!ResetMCastFilter) {\r
-    for (Index = 0; Index < SimpleNetworkDevice->SimpleNetworkMode.MCastFilterCount; ++Index) {\r
-      CopyMem (\r
-        Open.McastBuffer.MCastAddr[Index],\r
-        &SimpleNetworkDevice->SimpleNetworkMode.MCastFilter[Index],\r
-        sizeof Open.McastBuffer.MCastAddr[Index]\r
-        );\r
-    }\r
-  }\r
-\r
-  Status = PxeUndiOpen (SimpleNetworkDevice, &Open);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (Open.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  SimpleNetworkDevice->IsrValid = FALSE;\r
-  SimpleNetworkDevice->SimpleNetworkMode.ReceiveFilterSetting = NewFilter;\r
-\r
-  if ((NewFilter & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) {\r
-    SimpleNetworkDevice->SimpleNetworkMode.MCastFilterCount = (UINT32) MCastFilterCnt;\r
-    for (Index = 0; Index < MCastFilterCnt; ++Index) {\r
-      CopyMem (\r
-        &SimpleNetworkDevice->SimpleNetworkMode.MCastFilter[Index],\r
-        &MCastFilter[Index],\r
-        sizeof (EFI_MAC_ADDRESS)\r
-        );\r
-    }\r
-  }\r
-  //\r
-  // Read back multicast addresses.\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-//\r
-// StationAddress()\r
-//\r
-/**\r
-  Set new MAC address.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param Reset                Whether reset station MAC address to permanent address\r
-  @param New                  A pointer to New address\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkStationAddress (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL           * This,\r
-  IN BOOLEAN                               Reset,\r
-  IN EFI_MAC_ADDRESS                       * New OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_SIMPLE_NETWORK_DEV        *SimpleNetworkDevice;\r
-  PXENV_UNDI_SET_STATION_ADDR_T SetStationAddr;\r
-  //\r
-  // EFI_DEVICE_PATH_PROTOCOL     *OldDevicePath;\r
-  //\r
-  PXENV_UNDI_CLOSE_T            Close;\r
-  PXENV_UNDI_OPEN_T             Open;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to open the network interface\r
-  //\r
-  SetStationAddr.Status = INIT_PXE_STATUS;\r
-\r
-  if (Reset) {\r
-    //\r
-    // If we are resetting the Station Address to the permanent address, and the\r
-    // Station Address is not programmable, then just return EFI_SUCCESS.\r
-    //\r
-    if (!SimpleNetworkDevice->SimpleNetworkMode.MacAddressChangeable) {\r
-      return EFI_SUCCESS;\r
-    }\r
-    //\r
-    // If the address is already the permanent address, then just return success.\r
-    //\r
-    if (CompareMem (\r
-          &SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress,\r
-          &SimpleNetworkDevice->SimpleNetworkMode.PermanentAddress,\r
-          SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-          ) == 0) {\r
-      return EFI_SUCCESS;\r
-    }\r
-    //\r
-    // Copy the adapters permanent address to the new station address\r
-    //\r
-    CopyMem (\r
-      &SetStationAddr.StationAddress,\r
-      &SimpleNetworkDevice->SimpleNetworkMode.PermanentAddress,\r
-      SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-      );\r
-  } else {\r
-    //\r
-    // If we are setting the Station Address, and the\r
-    // Station Address is not programmable, return invalid parameter.\r
-    //\r
-    if (!SimpleNetworkDevice->SimpleNetworkMode.MacAddressChangeable) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    //\r
-    // If the address is already the new address, then just return success.\r
-    //\r
-    if (CompareMem (\r
-          &SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress,\r
-          New,\r
-          SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-          ) == 0) {\r
-      return EFI_SUCCESS;\r
-    }\r
-    //\r
-    // Copy New to the new station address\r
-    //\r
-    CopyMem (\r
-      &SetStationAddr.StationAddress,\r
-      New,\r
-      SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-      );\r
-\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to stop the network interface\r
-  //\r
-  Close.Status = INIT_PXE_STATUS;\r
-\r
-  PxeUndiClose (SimpleNetworkDevice, &Close);\r
-\r
-  //\r
-  // Call 16-bit UNDI ROM to set the station address\r
-  //\r
-  SetStationAddr.Status = PXENV_STATUS_SUCCESS;\r
-\r
-  Status                = PxeUndiSetStationAddr (SimpleNetworkDevice, &SetStationAddr);\r
-\r
-  //\r
-  // Call 16-bit UNDI ROM to start the network interface\r
-  //\r
-  Open.Status     = PXENV_STATUS_SUCCESS;\r
-  Open.OpenFlag   = 0;\r
-  Open.PktFilter  = Undi16GetPacketFilterSetting (SimpleNetworkDevice->SimpleNetworkMode.ReceiveFilterSetting);\r
-  Undi16GetMCastFilters (\r
-    &SimpleNetworkDevice->SimpleNetworkMode,\r
-    &Open.McastBuffer,\r
-    SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-    );\r
-\r
-  PxeUndiOpen (SimpleNetworkDevice, &Open);\r
-\r
-  //\r
-  // Check status from station address change\r
-  //\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (SetStationAddr.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  CopyMem (\r
-    &SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress,\r
-    &SetStationAddr.StationAddress,\r
-    SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-    );\r
-\r
-#if 0 /* The device path is based on the permanent address not the current address. */\r
-  //\r
-  // The station address was changed, so update the device path with the new MAC address.\r
-  //\r
-  OldDevicePath                   = SimpleNetworkDevice->DevicePath;\r
-  SimpleNetworkDevice->DevicePath = DuplicateDevicePath (SimpleNetworkDevice->BaseDevicePath);\r
-  SimpleNetworkAppendMacAddressDevicePath (\r
-    &SimpleNetworkDevice->DevicePath,\r
-    &SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress\r
-    );\r
-\r
-  Status = LibReinstallProtocolInterfaces (\r
-            SimpleNetworkDevice->Handle,\r
-            &DevicePathProtocol,\r
-            OldDevicePath,\r
-            SimpleNetworkDevice->DevicePath,\r
-            NULL\r
-            );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "Failed to reinstall the DevicePath protocol for the Simple Network Device\n"));\r
-    DEBUG ((DEBUG_ERROR, "  Status = %r\n", Status));\r
-  }\r
-\r
-  FreePool (OldDevicePath);\r
-#endif /* 0 */\r
-\r
-  return Status;\r
-}\r
-//\r
-// Statistics()\r
-//\r
-/**\r
-  Resets or collects the statistics on a network interface.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
-  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
-                          output the size, in bytes, of the resulting table of\r
-                          statistics.\r
-  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
-                          contains the statistics.\r
-\r
-  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkStatistics (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL       * This,\r
-  IN BOOLEAN                           Reset,\r
-  IN OUT UINTN                         *StatisticsSize OPTIONAL,\r
-  OUT EFI_NETWORK_STATISTICS           * StatisticsTable OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_SIMPLE_NETWORK_DEV        *SimpleNetworkDevice;\r
-  PXENV_UNDI_CLEAR_STATISTICS_T ClearStatistics;\r
-  PXENV_UNDI_GET_STATISTICS_T   GetStatistics;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if ((StatisticsSize != NULL) && (*StatisticsSize != 0) && (StatisticsTable == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // If Reset is TRUE, then clear all the statistics.\r
-  //\r
-  if (Reset) {\r
-\r
-    DEBUG ((DEBUG_NET, "  RESET Statistics\n"));\r
-\r
-    //\r
-    // Call 16 bit UNDI ROM to open the network interface\r
-    //\r
-    ClearStatistics.Status  = INIT_PXE_STATUS;\r
-\r
-    Status                  = PxeUndiClearStatistics (SimpleNetworkDevice, &ClearStatistics);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    //\r
-    // Check the status code from the 16 bit UNDI ROM\r
-    //\r
-    if (ClearStatistics.Status != PXENV_STATUS_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    DEBUG ((DEBUG_NET, "  RESET Statistics Complete"));\r
-  }\r
-\r
-  if (StatisticsSize != NULL) {\r
-    EFI_NETWORK_STATISTICS  LocalStatisticsTable;\r
-\r
-    DEBUG ((DEBUG_NET, "  GET Statistics\n"));\r
-\r
-    //\r
-    // If the size if valid, then see if the table is valid\r
-    //\r
-    if (StatisticsTable == NULL) {\r
-      DEBUG ((DEBUG_NET, "  StatisticsTable is NULL\n"));\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    //\r
-    // Call 16 bit UNDI ROM to open the network interface\r
-    //\r
-    GetStatistics.Status            = INIT_PXE_STATUS;\r
-    GetStatistics.XmtGoodFrames     = 0;\r
-    GetStatistics.RcvGoodFrames     = 0;\r
-    GetStatistics.RcvCRCErrors      = 0;\r
-    GetStatistics.RcvResourceErrors = 0;\r
-\r
-    Status                          = PxeUndiGetStatistics (SimpleNetworkDevice, &GetStatistics);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    //\r
-    // Check the status code from the 16 bit UNDI ROM\r
-    //\r
-    if (GetStatistics.Status != PXENV_STATUS_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-    //\r
-    // Fill in the Statistics Table with the collected values.\r
-    //\r
-    SetMem (&LocalStatisticsTable, sizeof LocalStatisticsTable, 0xff);\r
-\r
-    LocalStatisticsTable.TxGoodFrames     = GetStatistics.XmtGoodFrames;\r
-    LocalStatisticsTable.RxGoodFrames     = GetStatistics.RcvGoodFrames;\r
-    LocalStatisticsTable.RxCrcErrorFrames = GetStatistics.RcvCRCErrors;\r
-    LocalStatisticsTable.RxDroppedFrames  = GetStatistics.RcvResourceErrors;\r
-\r
-    CopyMem (StatisticsTable, &LocalStatisticsTable, *StatisticsSize);\r
-\r
-    DEBUG (\r
-      (DEBUG_NET,\r
-      "  Statistics Collected : Size=%d  Buf=%08x\n",\r
-      *StatisticsSize,\r
-      StatisticsTable)\r
-      );\r
-\r
-    DEBUG ((DEBUG_NET, "  GET Statistics Complete"));\r
-\r
-    if (*StatisticsSize < sizeof LocalStatisticsTable) {\r
-      DEBUG ((DEBUG_NET, "  BUFFER TOO SMALL\n"));\r
-      Status = EFI_BUFFER_TOO_SMALL;\r
-    }\r
-\r
-    *StatisticsSize = sizeof LocalStatisticsTable;\r
-\r
-    return Status;\r
-\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-//\r
-// MCastIpToMac()\r
-//\r
-/**\r
-  Translate IP address to MAC address.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param IPv6                 IPv6 or IPv4\r
-  @param IP                   A pointer to given Ip address.\r
-  @param MAC                  On return, translated MAC address.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_INVALID_PARAMETER Invalid IP address.\r
-  @retval EFI_INVALID_PARAMETER Invalid return buffer for holding MAC address.\r
-  @retval EFI_UNSUPPORTED       Do not support IPv6\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkMCastIpToMac (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL            *This,\r
-  IN BOOLEAN                                IPv6,\r
-  IN EFI_IP_ADDRESS                         *IP,\r
-  OUT EFI_MAC_ADDRESS                       *MAC\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_SIMPLE_NETWORK_DEV      *SimpleNetworkDevice;\r
-  PXENV_UNDI_GET_MCAST_ADDR_T GetMcastAddr;\r
-\r
-  if (This == NULL || IP == NULL || MAC == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // 16 bit UNDI Option ROMS do not support IPv6.  Check for IPv6 usage.\r
-  //\r
-  if (IPv6) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Call 16 bit UNDI ROM to open the network interface\r
-  //\r
-  GetMcastAddr.Status = INIT_PXE_STATUS;\r
-  CopyMem (&GetMcastAddr.InetAddr, IP, 4);\r
-\r
-  Status = PxeUndiGetMcastAddr (SimpleNetworkDevice, &GetMcastAddr);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  if (GetMcastAddr.Status != PXENV_STATUS_SUCCESS) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Copy the MAC address from the returned data structure.\r
-  //\r
-  CopyMem (\r
-    MAC,\r
-    &GetMcastAddr.MediaAddr,\r
-    SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-    );\r
-\r
-  return Status;\r
-}\r
-//\r
-// NvData()\r
-//\r
-/**\r
-  Performs read and write operations on the NVRAM device attached to a\r
-  network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  ReadWrite  TRUE for read operations, FALSE for write operations.\r
-  @param  Offset     Byte offset in the NVRAM device at which to start the read or\r
-                     write operation. This must be a multiple of NvRamAccessSize and\r
-                     less than NvRamSize.\r
-  @param  BufferSize The number of bytes to read or write from the NVRAM device.\r
-                     This must also be a multiple of NvramAccessSize.\r
-  @param  Buffer     A pointer to the data buffer.\r
-\r
-  @retval EFI_SUCCESS           The NVRAM access was performed.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkNvData (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This,\r
-  IN BOOLEAN                      ReadWrite,\r
-  IN UINTN                        Offset,\r
-  IN UINTN                        BufferSize,\r
-  IN OUT VOID                     *Buffer\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-//\r
-// GetStatus()\r
-//\r
-/**\r
-  Reads the current interrupt status and recycled transmit buffer status from\r
-  a network interface.\r
-\r
-  @param  This            The protocol instance pointer.\r
-  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
-                          If this is NULL, the interrupt status will not be read from\r
-                          the device. If this is not NULL, the interrupt status will\r
-                          be read from the device. When the  interrupt status is read,\r
-                          it will also be cleared. Clearing the transmit  interrupt\r
-                          does not empty the recycled transmit buffer array.\r
-  @param  TxBuf           Recycled transmit buffer address. The network interface will\r
-                          not transmit if its internal recycled transmit buffer array\r
-                          is full. Reading the transmit buffer does not clear the\r
-                          transmit interrupt. If this is NULL, then the transmit buffer\r
-                          status will not be read. If there are no transmit buffers to\r
-                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
-\r
-  @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkGetStatus (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  * This,\r
-  OUT UINT32                      *InterruptStatus OPTIONAL,\r
-  OUT VOID                        **TxBuf OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  UINTN                   FrameLength;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (InterruptStatus == NULL && TxBuf == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  FrameLength = 0;\r
-  Status      = Undi16SimpleNetworkIsr (This, &FrameLength, NULL, NULL, NULL, NULL);\r
-\r
-  if (Status != EFI_BUFFER_TOO_SMALL) {\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-  //\r
-  // See if the caller wants interrupt info.\r
-  //\r
-  if (InterruptStatus != NULL) {\r
-    *InterruptStatus                      = SimpleNetworkDevice->InterruptStatus;\r
-    SimpleNetworkDevice->InterruptStatus  = 0;\r
-  }\r
-  //\r
-  // See if the caller wants transmit buffer status info.\r
-  //\r
-  if (TxBuf != NULL) {\r
-    *TxBuf = 0;\r
-    SimpleNetworkTransmitFifoRemove (&(SimpleNetworkDevice->TxBufferFifo), TxBuf);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Places a packet in the transmit queue of a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
-                     the Transmit() function. If HeaderSize is non-zero, then it\r
-                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
-                     and Protocol parameters must not be NULL.\r
-  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
-                     data) to be transmitted through the network interface.\r
-  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
-                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
-                     then the media header in Buffer must already be filled in by the\r
-                     caller. If HeaderSize is non-zero, then the media header will be\r
-                     filled in by the Transmit() function.\r
-  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
-                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
-                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
-  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
-                     parameter is ignored.\r
-  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
-                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
-                     examples.\r
-\r
-  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.\r
-  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkTransmit (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL           *This,\r
-  IN UINTN                                 HeaderSize,\r
-  IN UINTN                                 BufferSize,\r
-  IN VOID                                  *Buffer,\r
-  IN EFI_MAC_ADDRESS                       *SrcAddr OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                       *DestAddr OPTIONAL,\r
-  IN UINT16                                *Protocol OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  PXENV_UNDI_TRANSMIT_T   XmitInfo;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferSize < SimpleNetworkDevice->SimpleNetworkMode.MediaHeaderSize) {\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  }\r
-\r
-  if (HeaderSize != 0) {\r
-    if (HeaderSize != SimpleNetworkDevice->SimpleNetworkMode.MediaHeaderSize) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (DestAddr == NULL || Protocol == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (DestAddr != NULL) {\r
-      CopyMem (\r
-        Buffer,\r
-        DestAddr,\r
-        SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-        );\r
-    }\r
-\r
-    if (SrcAddr == NULL) {\r
-      SrcAddr = &SimpleNetworkDevice->SimpleNetworkMode.CurrentAddress;\r
-    }\r
-\r
-    CopyMem (\r
-      (UINT8 *) Buffer + SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize,\r
-      SrcAddr,\r
-      SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-      );\r
-\r
-    if (Protocol != NULL) {\r
-      *(UINT16 *) ((UINT8 *) Buffer + 2 * SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize) = (UINT16) (((*Protocol & 0xFF) << 8) | ((*Protocol >> 8) & 0xFF));\r
-    }\r
-  }\r
-  //\r
-  // See if the recycled transmit buffer FIFO is full.\r
-  // If it is full, then we can not transmit until the caller calls GetStatus() to pull\r
-  // off recycled transmit buffers.\r
-  //\r
-  if (SimpleNetworkTransmitFifoFull (&(SimpleNetworkDevice->TxBufferFifo))) {\r
-    return EFI_NOT_READY;\r
-  }\r
-  //\r
-  //  Output debug trace message.\r
-  //\r
-  DEBUG ((DEBUG_NET, "Undi16SimpleNetworkTransmit\n\r "));\r
-\r
-  //\r
-  // Initialize UNDI WRITE parameter structure.\r
-  //\r
-  XmitInfo.Status           = INIT_PXE_STATUS;\r
-  XmitInfo.Protocol         = P_UNKNOWN;\r
-  XmitInfo.XmitFlag         = XMT_DESTADDR;\r
-  XmitInfo.DestAddrOffset   = (UINT16) ((UINT32)(UINTN) SimpleNetworkDevice->TxDestAddr & 0x000f);\r
-  XmitInfo.DestAddrSegment  = (UINT16) ((UINT32)(UINTN) SimpleNetworkDevice->TxDestAddr >> 4);\r
-  XmitInfo.TBDOffset        = (UINT16) ((UINT32)(UINTN) SimpleNetworkDevice->Xmit & 0x000f);\r
-  XmitInfo.TBDSegment       = (UINT16) ((UINT32)(UINTN) SimpleNetworkDevice->Xmit >> 4);\r
-  XmitInfo.Reserved[0]      = 0;\r
-  XmitInfo.Reserved[1]      = 0;\r
-\r
-  CopyMem (\r
-    SimpleNetworkDevice->TxDestAddr,\r
-    Buffer,\r
-    SimpleNetworkDevice->SimpleNetworkMode.HwAddressSize\r
-    );\r
-\r
-  CopyMem (\r
-    SimpleNetworkDevice->TxRealModeMediaHeader,\r
-    Buffer,\r
-    SimpleNetworkDevice->SimpleNetworkMode.MediaHeaderSize\r
-    );\r
-\r
-  SimpleNetworkDevice->Xmit->ImmedLength            = (UINT16) SimpleNetworkDevice->SimpleNetworkMode.MediaHeaderSize;\r
-\r
-  SimpleNetworkDevice->Xmit->DataBlock[0].TDDataLen = (UINT16) (BufferSize - SimpleNetworkDevice->Xmit->ImmedLength);\r
-\r
-  CopyMem (\r
-    SimpleNetworkDevice->TxRealModeDataBuffer,\r
-    (UINT8 *) Buffer + SimpleNetworkDevice->SimpleNetworkMode.MediaHeaderSize,\r
-    SimpleNetworkDevice->Xmit->DataBlock[0].TDDataLen\r
-    );\r
-\r
-  //\r
-  // Make API call to UNDI TRANSMIT\r
-  //\r
-  XmitInfo.Status = 0;\r
-\r
-  Status          = PxeUndiTransmit (SimpleNetworkDevice, &XmitInfo);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the status code from the 16 bit UNDI ROM\r
-  //\r
-  switch (XmitInfo.Status) {\r
-  case PXENV_STATUS_OUT_OF_RESOURCES:\r
-    return EFI_NOT_READY;\r
-\r
-  case PXENV_STATUS_SUCCESS:\r
-    break;\r
-\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Add address of Buffer to the recycled transmit buffer FIFO\r
-  //\r
-  SimpleNetworkTransmitFifoAdd (&(SimpleNetworkDevice->TxBufferFifo), Buffer);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Receives a packet from a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header received on the network\r
-                     interface. If this parameter is NULL, then the media header size\r
-                     will not be returned.\r
-  @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
-                     bytes, of the packet that was received on the network interface.\r
-  @param  Buffer     A pointer to the data buffer to receive both the media header and\r
-                     the data.\r
-  @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the\r
-                     HW MAC source address will not be extracted from the media\r
-                     header.\r
-  @param  DestAddr   The destination HW MAC address. If this parameter is NULL,\r
-                     the HW MAC destination address will not be extracted from the\r
-                     media header.\r
-  @param  Protocol   The media header type. If this parameter is NULL, then the\r
-                     protocol will not be extracted from the media header. See\r
-                     RFC 1700 section "Ether Types" for examples.\r
-\r
-  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
-                                 been updated to the number of bytes received.\r
-  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
-                                 request.\r
-  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkReceive (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL            *This,\r
-  OUT UINTN                                 *HeaderSize OPTIONAL,\r
-  IN OUT UINTN                              *BufferSize,\r
-  OUT VOID                                  *Buffer,\r
-  OUT EFI_MAC_ADDRESS                       *SrcAddr OPTIONAL,\r
-  OUT EFI_MAC_ADDRESS                       *DestAddr OPTIONAL,\r
-  OUT UINT16                                *Protocol OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  UINTN                   MediaAddrSize;\r
-  UINT8                   ProtType;\r
-\r
-  if (This == NULL || BufferSize == NULL || Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Status = Undi16SimpleNetworkIsr (\r
-            This,\r
-            BufferSize,\r
-            HeaderSize,\r
-            Buffer,\r
-            &ProtType,\r
-            NULL\r
-            );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if ((SimpleNetworkDevice->InterruptStatus & EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT) == 0) {\r
-    return EFI_NOT_READY;\r
-\r
-  }\r
-\r
-  SimpleNetworkDevice->InterruptStatus &= ~EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;\r
-\r
-  MediaAddrSize = This->Mode->HwAddressSize;\r
-\r
-  if (SrcAddr != NULL) {\r
-    CopyMem (SrcAddr, (UINT8 *) Buffer + MediaAddrSize, MediaAddrSize);\r
-  }\r
-\r
-  if (DestAddr != NULL) {\r
-    CopyMem (DestAddr, Buffer, MediaAddrSize);\r
-  }\r
-\r
-  if (Protocol != NULL) {\r
-    *((UINT8 *) Protocol)     = *((UINT8 *) Buffer + (2 * MediaAddrSize) + 1);\r
-    *((UINT8 *) Protocol + 1) = *((UINT8 *) Buffer + (2 * MediaAddrSize));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "Packet Received: BufferSize=%d  HeaderSize = %d\n", *BufferSize, *HeaderSize));\r
-\r
-  return Status;\r
-\r
-}\r
-//\r
-// WaitForPacket()\r
-//\r
-/**\r
-  wait for a packet to be received.\r
-\r
-  @param Event      Event used with WaitForEvent() to wait for a packet to be received.\r
-  @param Context    Event Context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-Undi16SimpleNetworkWaitForPacket (\r
-  IN EFI_EVENT               Event,\r
-  IN VOID                    *Context\r
-  )\r
-{\r
-  //\r
-  // Someone is waiting on the receive packet event, if there's\r
-  // a packet pending, signal the event\r
-  //\r
-  if (!EFI_ERROR (Undi16SimpleNetworkCheckForPacket (Context))) {\r
-    gBS->SignalEvent (Event);\r
-  }\r
-}\r
-//\r
-// CheckForPacket()\r
-//\r
-/**\r
-  Check whether packet is ready for receive.\r
-\r
-  @param This The protocol instance pointer.\r
-\r
-  @retval  EFI_SUCCESS           Receive data is ready.\r
-  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
-                                 request.\r
-  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkCheckForPacket (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice;\r
-  UINTN                   FrameLength;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status              = EFI_SUCCESS;\r
-  SimpleNetworkDevice = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  if (SimpleNetworkDevice == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Verify that the current state of the adapter is valid for this call.\r
-  //\r
-  switch (SimpleNetworkDevice->SimpleNetworkMode.State) {\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    return EFI_NOT_STARTED;\r
-\r
-  case EfiSimpleNetworkStarted:\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  FrameLength = 0;\r
-  Status = Undi16SimpleNetworkIsr (\r
-            This,\r
-            &FrameLength,\r
-            NULL,\r
-            NULL,\r
-            NULL,\r
-            NULL\r
-            );\r
-\r
-  if (Status != EFI_BUFFER_TOO_SMALL) {\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  return ((SimpleNetworkDevice->InterruptStatus & EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT) != 0) ? EFI_SUCCESS : EFI_NOT_READY;\r
-}\r
-\r
-/**\r
-  Signal handlers for ExitBootServices event.\r
-\r
-  Clean up any Real-mode UNDI residue from the system\r
-\r
-  @param Event      ExitBootServices event\r
-  @param Context\r
-**/\r
-VOID\r
-EFIAPI\r
-Undi16SimpleNetworkEvent (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  //\r
-  // NOTE:  This is not the only way to effect this cleanup.  The prescribed mechanism\r
-  //        would be to perform an UNDI STOP command.  This strategam has been attempted\r
-  //        but results in problems making some of the EFI core services from TPL_CALLBACK.\r
-  //        This issue needs to be resolved, but the other alternative has been to perform\r
-  //        the unchain logic explicitly, as done below.\r
-  //\r
-  RestoreCachedVectorAddress (0x1A);\r
-}\r
-\r
-/**\r
-  Allocate buffer below 1M for real mode.\r
-\r
-  @param NumPages     The number pages want to be allocated.\r
-  @param Buffer       On return, allocated buffer.\r
-\r
-  @return Status of allocating pages.\r
-**/\r
-EFI_STATUS\r
-BiosSnp16AllocatePagesBelowOneMb (\r
-  UINTN  NumPages,\r
-  VOID   **Buffer\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-\r
-  PhysicalAddress = 0x000fffff;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiRuntimeServicesData,\r
-                  NumPages,\r
-                  &PhysicalAddress\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  *Buffer = (VOID *) (UINTN) PhysicalAddress;\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.h b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.h
deleted file mode 100644 (file)
index 9e5e496..0000000
+++ /dev/null
@@ -1,1468 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _BIOS_SNP_16_H_\r
-#define _BIOS_SNP_16_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/LegacyBios.h>\r
-#include <Protocol/SimpleNetwork.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/NetworkInterfaceIdentifier.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-#include <Guid/EventGroup.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-\r
-#include "Pxe.h"\r
-\r
-//\r
-// BIOS Simple Network Protocol Device Structure\r
-//\r
-#define EFI_SIMPLE_NETWORK_DEV_SIGNATURE    SIGNATURE_32 ('s', 'n', '1', '6')\r
-\r
-#define INIT_PXE_STATUS                     0xabcd\r
-\r
-#define EFI_SIMPLE_NETWORK_MAX_TX_FIFO_SIZE 64\r
-\r
-typedef struct {\r
-  UINT32  First;\r
-  UINT32  Last;\r
-  VOID *  Data[EFI_SIMPLE_NETWORK_MAX_TX_FIFO_SIZE];\r
-} EFI_SIMPLE_NETWORK_DEV_FIFO;\r
-\r
-typedef struct {\r
-  UINTN                                     Signature;\r
-  EFI_HANDLE                                Handle;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL               SimpleNetwork;\r
-  EFI_SIMPLE_NETWORK_MODE                   SimpleNetworkMode;\r
-  EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL Nii;\r
-  EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;\r
-  EFI_PCI_IO_PROTOCOL                       *PciIo;\r
-  EFI_LEGACY_BIOS_PROTOCOL                  *LegacyBios;\r
-\r
-  //\r
-  // Local Data for Simple Network Protocol interface goes here\r
-  //\r
-  BOOLEAN                                   UndiLoaded;\r
-  EFI_EVENT                                 EfiBootEvent;\r
-  EFI_EVENT                                 LegacyBootEvent;\r
-  UINT16                                    PxeEntrySegment;\r
-  UINT16                                    PxeEntryOffset;\r
-  EFI_SIMPLE_NETWORK_DEV_FIFO               TxBufferFifo;\r
-  EFI_DEVICE_PATH_PROTOCOL                  *BaseDevicePath;\r
-  PXE_T                                     *Pxe;                   ///< Pointer to !PXE structure\r
-  PXENV_UNDI_GET_INFORMATION_T              GetInformation;         ///< Data from GET INFORMATION\r
-  PXENV_UNDI_GET_NIC_TYPE_T                 GetNicType;             ///< Data from GET NIC TYPE\r
-  PXENV_UNDI_GET_NDIS_INFO_T                GetNdisInfo;            ///< Data from GET NDIS INFO\r
-  BOOLEAN                                   IsrValid;               ///< TRUE if Isr contains valid data\r
-  PXENV_UNDI_ISR_T                          Isr;                    ///< Data from ISR\r
-  PXENV_UNDI_TBD_T                          *Xmit;                  //\r
-  VOID                                      *TxRealModeMediaHeader; ///< < 1 MB Size = 0x100\r
-  VOID                                      *TxRealModeDataBuffer;  ///< < 1 MB Size = GetInformation.MaxTranUnit\r
-  VOID                                      *TxDestAddr;            ///< < 1 MB Size = 16\r
-  UINT8                                     InterruptStatus;        ///< returned/cleared by GetStatus, set in ISR\r
-  UINTN                                     UndiLoaderTablePages;\r
-  UINTN                                     DestinationDataSegmentPages;\r
-  UINTN                                     DestinationStackSegmentPages;\r
-  UINTN                                     DestinationCodeSegmentPages;\r
-  VOID                                      *UndiLoaderTable;\r
-  VOID                                      *DestinationDataSegment;\r
-  VOID                                      *DestinationStackSegment;\r
-  VOID                                      *DestinationCodeSegment;\r
-} EFI_SIMPLE_NETWORK_DEV;\r
-\r
-#define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) \\r
-  CR (a, \\r
-      EFI_SIMPLE_NETWORK_DEV, \\r
-      SimpleNetwork, \\r
-      EFI_SIMPLE_NETWORK_DEV_SIGNATURE \\r
-      )\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL  gBiosSnp16DriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gBiosSnp16ComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gBiosSnp16ComponentName2;\r
-\r
-\r
-//\r
-// Driver Binding Protocol functions\r
-//\r
-/**\r
-  Tests to see if this driver supports a given controller.\r
-\r
-  @param This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param Controller           The handle of the controller to test.\r
-  @param RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval EFI_SUCCESS    The driver supports given controller.\r
-  @retval EFI_UNSUPPORT  The driver doesn't support given controller.\r
-  @retval Other          Other errors prevent driver finishing to test\r
-                         if the driver supports given controller.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16DriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-;\r
-\r
-/**\r
-  Starts the Snp device controller\r
-\r
-  @param This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param Controller           The handle of the controller to test.\r
-  @param RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-\r
-  @retval  EFI_SUCCESS          - The device was started.\r
-  @retval  EFI_DEVICE_ERROR     - The device could not be started due to a device error.\r
-  @retval  EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16DriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-;\r
-\r
-/**\r
-  Stops the device by given device controller.\r
-\r
-  @param This               A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param Controller         The handle of the controller to test.\r
-  @param NumberOfChildren   The number of child device handles in ChildHandleBuffer.\r
-  @param ChildHandleBuffer  An array of child handles to be freed. May be NULL if\r
-                            NumberOfChildren is 0.\r
-\r
-  @retval  EFI_SUCCESS      - The device was stopped.\r
-  @retval  EFI_DEVICE_ERROR - The device could not be stopped due to a device error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16DriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-;\r
-\r
-//\r
-// Simple Network Protocol functions\r
-//\r
-/**\r
-  Call 16 bit UNDI ROM to start the network interface\r
-\r
-  @param This       A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_DEVICE_ERROR Network interface has not be initialized.\r
-  @retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM call.\r
-  @retval EFI_SUCESS       Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkStart (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  )\r
-;\r
-\r
-/**\r
-  Call 16 bit UNDI ROM to stop the network interface\r
-\r
-  @param This       A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_DEVICE_ERROR Network interface has not be initialized.\r
-  @retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM call.\r
-  @retval EFI_SUCESS       Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkStop (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  )\r
-;\r
-\r
-/**\r
-  Initialize network interface\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param ExtraRxBufferSize    The size of extra request receive buffer.\r
-  @param ExtraTxBufferSize    The size of extra request transmit buffer.\r
-\r
-  @retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM call.\r
-  @retval EFI_SUCESS       Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkInitialize (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL                     *This,\r
-  IN UINTN                                           ExtraRxBufferSize  OPTIONAL,\r
-  IN UINTN                                           ExtraTxBufferSize  OPTIONAL\r
-  )\r
-;\r
-\r
-/**\r
-  Reset network interface.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param ExtendedVerification Need extended verfication.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkReset (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This,\r
-  IN BOOLEAN                      ExtendedVerification\r
-  )\r
-;\r
-\r
-/**\r
-  Shutdown network interface.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkShutdown (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This\r
-  )\r
-;\r
-\r
-/**\r
-  Reset network interface.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param Enable               Enable mask value\r
-  @param Disable              Disable mask value\r
-  @param ResetMCastFilter     Whether reset multi cast filter or not\r
-  @param MCastFilterCnt       Count of mutli cast filter for different MAC address\r
-  @param MCastFilter          Buffer for mustli cast filter for different MAC address.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkReceiveFilters (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL                     * This,\r
-  IN UINT32                                          Enable,\r
-  IN UINT32                                          Disable,\r
-  IN BOOLEAN                                         ResetMCastFilter,\r
-  IN UINTN                                           MCastFilterCnt     OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                                 * MCastFilter OPTIONAL\r
-  )\r
-;\r
-\r
-/**\r
-  Set new MAC address.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param Reset                Whether reset station MAC address to permanent address\r
-  @param New                  A pointer to New address\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkStationAddress (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  * This,\r
-  IN BOOLEAN                      Reset,\r
-  IN EFI_MAC_ADDRESS              * New OPTIONAL\r
-  )\r
-;\r
-\r
-/**\r
-  Collect statistics.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param Reset                Whether cleanup old statistics data.\r
-  @param StatisticsSize       The buffer of statistics table.\r
-  @param StatisticsTable      A pointer to statistics buffer.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkStatistics (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  * This,\r
-  IN BOOLEAN                      Reset,\r
-  IN OUT UINTN                    *StatisticsSize OPTIONAL,\r
-  OUT EFI_NETWORK_STATISTICS      * StatisticsTable OPTIONAL\r
-  )\r
-;\r
-\r
-/**\r
-  Translate IP address to MAC address.\r
-\r
-  @param This                 A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @param IPv6                 IPv6 or IPv4\r
-  @param IP                   A pointer to given Ip address.\r
-  @param MAC                  On return, translated MAC address.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
-  @retval EFI_INVALID_PARAMETER Invalid IP address.\r
-  @retval EFI_INVALID_PARAMETER Invalid return buffer for holding MAC address.\r
-  @retval EFI_UNSUPPORTED       Do not support IPv6\r
-  @retval EFI_DEVICE_ERROR      Network device has not been initialized.\r
-  @retval EFI_NOT_STARTED       Network device has been stopped.\r
-  @retval EFI_DEVICE_ERROR      Invalid status for network device\r
-  @retval EFI_SUCCESS           Success operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkMCastIpToMac (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This,\r
-  IN BOOLEAN                      IPv6,\r
-  IN EFI_IP_ADDRESS               *IP,\r
-  OUT EFI_MAC_ADDRESS             *MAC\r
-  )\r
-;\r
-\r
-/**\r
-  Performs read and write operations on the NVRAM device attached to a\r
-  network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  ReadWrite  TRUE for read operations, FALSE for write operations.\r
-  @param  Offset     Byte offset in the NVRAM device at which to start the read or\r
-                     write operation. This must be a multiple of NvRamAccessSize and\r
-                     less than NvRamSize.\r
-  @param  BufferSize The number of bytes to read or write from the NVRAM device.\r
-                     This must also be a multiple of NvramAccessSize.\r
-  @param  Buffer     A pointer to the data buffer.\r
-\r
-  @retval EFI_SUCCESS           The NVRAM access was performed.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkNvData (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This,\r
-  IN BOOLEAN                      Write,\r
-  IN UINTN                        Offset,\r
-  IN UINTN                        BufferSize,\r
-  IN OUT VOID                     *Buffer\r
-  )\r
-;\r
-\r
-/**\r
-  Reads the current interrupt status and recycled transmit buffer status from\r
-  a network interface.\r
-\r
-  @param  This            The protocol instance pointer.\r
-  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
-                          If this is NULL, the interrupt status will not be read from\r
-                          the device. If this is not NULL, the interrupt status will\r
-                          be read from the device. When the  interrupt status is read,\r
-                          it will also be cleared. Clearing the transmit  interrupt\r
-                          does not empty the recycled transmit buffer array.\r
-  @param  TxBuf           Recycled transmit buffer address. The network interface will\r
-                          not transmit if its internal recycled transmit buffer array\r
-                          is full. Reading the transmit buffer does not clear the\r
-                          transmit interrupt. If this is NULL, then the transmit buffer\r
-                          status will not be read. If there are no transmit buffers to\r
-                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
-\r
-  @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkGetStatus (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  * This,\r
-  OUT UINT32                      *InterruptStatus OPTIONAL,\r
-  OUT VOID                        **TxBuf OPTIONAL\r
-  )\r
-;\r
-\r
-/**\r
-  Places a packet in the transmit queue of a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
-                     the Transmit() function. If HeaderSize is non-zero, then it\r
-                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
-                     and Protocol parameters must not be NULL.\r
-  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
-                     data) to be transmitted through the network interface.\r
-  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
-                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
-                     then the media header in Buffer must already be filled in by the\r
-                     caller. If HeaderSize is non-zero, then the media header will be\r
-                     filled in by the Transmit() function.\r
-  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
-                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
-                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
-  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
-                     parameter is ignored.\r
-  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
-                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
-                     examples.\r
-\r
-  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.\r
-  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkTransmit (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This,\r
-  IN UINTN                        HeaderSize,\r
-  IN UINTN                        BufferSize,\r
-  IN VOID                         *Buffer,\r
-  IN EFI_MAC_ADDRESS              *SrcAddr OPTIONAL,\r
-  IN EFI_MAC_ADDRESS              *DestAddr OPTIONAL,\r
-  IN UINT16                       *Protocol OPTIONAL\r
-  )\r
-;\r
-\r
-/**\r
-  Receives a packet from a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header received on the network\r
-                     interface. If this parameter is NULL, then the media header size\r
-                     will not be returned.\r
-  @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
-                     bytes, of the packet that was received on the network interface.\r
-  @param  Buffer     A pointer to the data buffer to receive both the media header and\r
-                     the data.\r
-  @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the\r
-                     HW MAC source address will not be extracted from the media\r
-                     header.\r
-  @param  DestAddr   The destination HW MAC address. If this parameter is NULL,\r
-                     the HW MAC destination address will not be extracted from the\r
-                     media header.\r
-  @param  Protocol   The media header type. If this parameter is NULL, then the\r
-                     protocol will not be extracted from the media header. See\r
-                     RFC 1700 section "Ether Types" for examples.\r
-\r
-  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
-                                 been updated to the number of bytes received.\r
-  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
-                                 request.\r
-  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Undi16SimpleNetworkReceive (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL  *This,\r
-  OUT UINTN                       *HeaderSize OPTIONAL,\r
-  IN OUT UINTN                    *BufferSize,\r
-  OUT VOID                        *Buffer,\r
-  OUT EFI_MAC_ADDRESS             *SrcAddr OPTIONAL,\r
-  OUT EFI_MAC_ADDRESS             *DestAddr OPTIONAL,\r
-  OUT UINT16                      *Protocol OPTIONAL\r
-  )\r
-;\r
-\r
-/**\r
-  wait for a packet to be received.\r
-\r
-  @param Event      Event used with WaitForEvent() to wait for a packet to be received.\r
-  @param Context    Event Context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-Undi16SimpleNetworkWaitForPacket (\r
-  IN EFI_EVENT               Event,\r
-  IN VOID                    *Context\r
-  )\r
-;\r
-\r
-/**\r
-  Check whether packet is ready for receive.\r
-\r
-  @param This The protocol instance pointer.\r
-\r
-  @retval  EFI_SUCCESS           Receive data is ready.\r
-  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
-                                 request.\r
-  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-**/\r
-EFI_STATUS\r
-Undi16SimpleNetworkCheckForPacket (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
-  )\r
-;\r
-\r
-/**\r
- Cache Interrupt verctor address converted from IVT number.\r
-\r
- @param VectorNumber  IVT number\r
-\r
- @retval EFI_SUCCESS Success to operation.\r
-**/\r
-EFI_STATUS\r
-CacheVectorAddress (\r
-  UINT8   VectorNumber\r
-  )\r
-;\r
-\r
-/**\r
- Get interrupt vector address according to IVT number.\r
-\r
- @param VectorNumber    Given IVT number\r
-\r
- @return cached interrupt vector address.\r
-**/\r
-EFI_STATUS\r
-RestoreCachedVectorAddress (\r
-  UINT8   VectorNumber\r
-  )\r
-;\r
-\r
-/**\r
-  If available, launch the BaseCode from a NIC option ROM.\r
-  This should install the !PXE and PXENV+ structures in memory for\r
-  subsequent use.\r
-\r
-\r
-  @param SimpleNetworkDevice    Simple network device instance\r
-  @param RomAddress             The ROM base address for NIC rom.\r
-\r
-  @retval EFI_NOT_FOUND         The check sum does not match\r
-  @retval EFI_NOT_FOUND         Rom ID offset is wrong\r
-  @retval EFI_NOT_FOUND         No Rom ID structure is found\r
-**/\r
-EFI_STATUS\r
-LaunchBaseCode (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  UINTN                   RomAddress\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  START UNDI\r
-  Op-Code: PXENV_START_UNDI (0000h)\r
-  Input: Far pointer to a PXENV_START_UNDI_T parameter structure that has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This service is used to pass the BIOS parameter registers to the UNDI driver. The UNDI driver is\r
-  responsible for saving the information it needs to communicate with the hardware.\r
-  This service is also responsible for hooking the Int 1Ah service routine\r
-  Note: This API service must be called only once during UNDI Option ROM boot.\r
-  The UNDI driver is responsible for saving this information and using it every time\r
-  PXENV_UNDI_STARTUP is called.\r
-  Service cannot be used in protected mode.\r
-  typedef struct  {\r
-      PXENV_STATUS Status;\r
-      UINT16 AX;\r
-      UINT16 BX;\r
-      UINT16 DX;\r
-      UINT16 DI;\r
-      UINT16 ES;\r
-  } PXENV_START_UNDI_T;\r
-  Set before calling API service\r
-  AX, BX, DX, DI, ES: BIOS initialization parameter registers. These\r
-  fields should contain the same information passed to the option ROM\r
-  initialization routine by the Host System BIOS. Information about the\r
-  contents of these registers can be found in the [PnP], [PCI] and\r
-  [BBS] specifications.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeStartUndi (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_START_UNDI_T               *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI STARTUP\r
-  Op-Code: PXENV_UNDI_STARTUP (0001h)\r
-  Input: Far pointer to a PXENV_UNDI_STARTUP_T parameter structure that has been initialized by the\r
-  caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This API is responsible for initializing the contents of the UNDI code & data segment for proper\r
-  operation. Information from the !PXE structure and the first PXENV_START_UNDI API call is used\r
-  to complete this initialization. The rest of the UNDI APIs will not be available until this call has\r
-  been completed.\r
-  Note: PXENV_UNDI_STARTUP must not be called again without first calling\r
-  PXENV_UNDI_SHUTDOWN.\r
-  PXENV_UNDI_STARTUP and PXENV_UNDI_SHUTDOWN are no longer responsible for\r
-  chaining interrupt 1Ah. This must be done by the PXENV_START_UNDI and\r
-  PXENV_STOP_UNDI API calls.\r
-  This service cannot be used in protected mode.\r
-  typedef struct\r
-  {\r
-      PXENV_STATUS Status;\r
-  } PXENV_UNDI_STARTUP_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiStartup (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_STARTUP_T             *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI CLEANUP\r
-  Op-Code: PXENV_UNDI_CLEANUP (0002h)\r
-  Input: Far pointer to a PXENV_UNDI_CLEANUP_T parameter structure.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field\r
-  in the parameter structure must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This call will prepare the network adapter driver to be unloaded from memory. This call must be\r
-  made just before unloading the Universal NIC Driver. The rest of the API will not be available\r
-  after this call executes.\r
-  This service cannot be used in protected mode.\r
-  typedef struct {\r
-      PXENX_STATUS Status;\r
-  } PXENV_UNDI_CLEANUP_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiCleanup (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_CLEANUP_T             *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI INITIALIZE\r
-  Op-Code: PXENV_UNDI_INITIALIZE (0003h)\r
-  Input: Far pointer to a PXENV_UNDI_INITIALIZE_T parameter structure that has been initialized by the\r
-  caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call resets the adapter and programs it with default parameters. The default parameters used\r
-  are those supplied to the most recent UNDI_STARTUP call. This routine does not enable the\r
-  receive and transmit units of the network adapter to readily receive or transmit packets. The\r
-  application must call PXENV_UNDI_OPEN to logically connect the network adapter to the network.\r
-  This call must be made by an application to establish an interface to the network adapter driver.\r
-  Note: When the PXE code makes this call to initialize the network adapter, it passes a NULL pointer for\r
-  the Protocol field in the parameter structure.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    ADDR32 ProtocolIni;\r
-    UINT8 reserved[8];\r
-  } PXENV_UNDI_INITIALIZE_T;\r
-  Set before calling API service\r
-  ProtocolIni: Physical address of a memory copy of the driver\r
-  module from the protocol.ini file obtained from the protocol manager\r
-  driver (refer to the NDIS 2.0 specification). This parameter is\r
-  supported for the universal NDIS driver to pass the information\r
-  contained in the protocol.ini file to the NIC driver for any specific\r
-  configuration of the NIC. (Note that the module identification in the\r
-  protocol.ini file was done by NDIS.) This value can be NULL for any\r
-  other application interfacing to the universal NIC driver\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance.\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiInitialize (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_INITIALIZE_T          *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  Wrapper routine for reset adapter.\r
-\r
-  PXE\r
-  UNDI RESET ADAPTER\r
-  Op-Code: PXENV_UNDI_RESET_ADAPTER (0004h)\r
-  Input: Far pointer to a PXENV_UNDI_RESET_ADAPTER_t parameter structure that has been initialized\r
-  by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call resets and reinitializes the network adapter with the same set of parameters supplied to\r
-  Initialize Routine. Unlike Initialize, this call opens the adapter that is, it connects logically to the\r
-  network. This routine cannot be used to replace Initialize or Shutdown calls.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    PXENV_UNDI_MCAST_ADDRESS_t    R_Mcast_Buf;\r
-  } PXENV_UNDI_RESET_T;\r
-\r
-  #define MAXNUM_MCADDR 8\r
-\r
-  typedef struct {\r
-    UINT16 MCastAddrCount;\r
-    MAC_ADDR McastAddr[MAXNUM_MCADDR];\r
-  } PXENV_UNDI_MCAST_ADDRESS_t;\r
-\r
-  Set before calling API service\r
-  R_Mcast_Buf: This is a structure of MCastAddrCount and\r
-  McastAddr.\r
-  MCastAddrCount: Number of multicast MAC addresses in the\r
-  buffer.\r
-  McastAddr: List of up to MAXNUM_MCADDR multicast MAC\r
-  addresses.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance.\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-  @param  RxFilter             Filter setting mask value for PXE recive .\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiResetNic (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_RESET_T               *PxeUndiTable,\r
-  IN UINT16                               RxFilter\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI SHUTDOWN\r
-  Op-Code: PXENV_UNDI_SHUTDOWN (0005h)\r
-  Input: Far pointer to a PXENV_UNDI_SHUTDOWN_T parameter.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call resets the network adapter and leaves it in a safe state for another driver to program it.\r
-  Note: The contents of the PXENV_UNDI_STARTUP parameter structure need to be saved by the\r
-  Universal NIC Driver in case PXENV_UNDI_INITIALIZE is called again.\r
-  typedef struct\r
-  {\r
-    PXENV_STATUS Status;\r
-  } PXENV_UNDI_SHUTDOWN_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiShutdown (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_SHUTDOWN_T            *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI OPEN\r
-  Op-Code: PXENV_UNDI_OPEN (0006h)\r
-  Input: Far pointer to a PXENV_UNDI_OPEN_T parameter structure that has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call activates the adapter network connection and sets the adapter ready to accept packets\r
-  for transmit and receive.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    UINT16 OpenFlag;\r
-    UINT16 PktFilter;\r
-      #define FLTR_DIRECTED 0x0001\r
-      #define FLTR_BRDCST 0x0002\r
-      #define FLTR_PRMSCS 0x0004\r
-      #define FLTR_SRC_RTG 0x0008\r
-    PXENV_UNDI_MCAST_ADDRESS_t R_Mcast_Buf;\r
-  } PXENV_UNDI_OPEN_T;\r
-  Set before calling API service\r
-  OpenFlag: This is an adapter specific input parameter. This is\r
-  supported for the universal NDIS 2.0 driver to pass in the open flags\r
-  provided by the protocol driver. (See the NDIS 2.0 specification.)\r
-  This can be zero.\r
-  PktFilter: Filter for receiving packets. This can be one, or more, of\r
-  the FLTR_xxx constants. Multiple values are arithmetically or-ed\r
-  together.\r
-  directed packets are packets that may come to your MAC address\r
-  or the multicast MAC address.\r
-  R_Mcast_Buf: See definition in UNDI RESET ADAPTER (0004h).\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiOpen (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_OPEN_T                *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI CLOSE\r
-  Op-Code: PXENV_UNDI_CLOSE (0007h)\r
-  Input: Far pointer to a PXENV_UNDI_CLOSE_T parameter.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call disconnects the network adapter from the network. Packets cannot be transmitted or\r
-  received until the network adapter is open again.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-  } PXENV_UNDI_CLOSE_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiClose (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_CLOSE_T               *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI TRANSMIT PACKET\r
-  Op-Code: PXENV_UNDI_TRANSMIT (0008h)\r
-  Input: Far pointer to a PXENV_UNDI_TRANSMIT_T parameter structure that\r
-  has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX.\r
-  The status code must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This call transmits a buffer to the network. The media header\r
-  for the packet can be filled by the calling protocol, but it might not be.\r
-  The network adapter driver will fill it if required by the values in the\r
-  parameter block. The packet is buffered for transmission provided there is\r
-  an available buffer, and the function returns PXENV_EXIT_SUCCESS. If no\r
-  buffer is available the function returns PXENV_EXIT_FAILURE with a status\r
-  code of PXE_UNDI_STATUS__OUT OF_RESOURCE. The number of buffers is\r
-  implementation-dependent. An interrupt is generated on completion of the\r
-  transmission of one or more packets. A call to PXENV_UNDI_TRANSMIT is\r
-  permitted in the context of a transmit complete interrupt.\r
-\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    UINT8 Protocol;\r
-      #define P_UNKNOWN 0\r
-      #define P_IP 1\r
-      #define P_ARP 2\r
-      #define P_RARP 3\r
-    UINT8 XmitFlag;\r
-      #define XMT_DESTADDR 0x0000\r
-      #define XMT_BROADCAST 0x0001\r
-    SEGOFF16 DestAddr;\r
-    SEGOFF16 TBD;\r
-    UINT32 Reserved[2];\r
-  } t_PXENV_UNDI_TRANSMIT;\r
-\r
-  #define MAX_DATA_BLKS 8\r
-\r
-  typedef struct {\r
-    UINT16 ImmedLength;\r
-    SEGOFF16 Xmit;\r
-    UINT16 DataBlkCount;\r
-    struct DataBlk {\r
-      UINT8 TDPtrType;\r
-      UINT8 TDRsvdByte;\r
-      UINT16 TDDataLen;\r
-      SEGOFF16 TDDataPtr;\r
-    } DataBlock[MAX_DATA_BLKS];\r
-  } PXENV_UNDI_TBD_T\r
-\r
-  Set before calling API service\r
-  Protocol: This is the protocol of the upper layer that is calling UNDI\r
-  TRANSMIT call. If the upper layer has filled the media header, this\r
-  field must be P_UNKNOWN.\r
-  XmitFlag: If this flag is XMT_DESTADDR, the NIC driver expects a\r
-  pointer to the destination media address in the field DestAddr. If\r
-  XMT_BROADCAST, the NIC driver fills the broadcast address for the\r
-  destination.\r
-  TBD: Segment:Offset address of the transmit buffer descriptor.\r
-  ImmedLength: Length of the immediate transmit buffer: Xmit.\r
-  Xmit: Segment:Offset of the immediate transmit buffer.\r
-  DataBlkCount: Number of blocks in this transmit buffer.\r
-  TDPtrType:\r
-  0 => 32-bit physical address in TDDataPtr (not supported in this\r
-  version of PXE)\r
-  1 => segment:offset in TDDataPtr which can be a real mode or 16-bit\r
-  protected mode pointer\r
-  TDRsvdByte: Reserved must be zero.\r
-  TDDatalen: Data block length in bytes.\r
-  TDDataPtr: Segment:Offset of the transmit block.\r
-  DataBlock: Array of transmit data blocks.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiTransmit (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_TRANSMIT_T            *PxeUndiTable\r
-  )\r
-;\r
-\r
-\r
-/**\r
-  PXE\r
-  UNDI SET STATION ADDRESS\r
-  Op-Code: PXENV_UNDI_SET_STATION_ADDRESS (000Ah)\r
-  Input: Far pointer to a PXENV_UNDI_SET_STATION_ADDRESS_t parameter structure that has been\r
-  initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call sets the MAC address to be the input value and is called before opening the network\r
-  adapter. Later, the open call uses this variable as a temporary MAC address to program the\r
-  adapter individual address registers.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    MAC_ADDR StationAddress;\r
-  } PXENV_UNDI_SET_STATION_ADDR_T;\r
-  Set before calling API service\r
-  StationAddress: Temporary MAC address to be used for\r
-  transmit and receive.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiSetStationAddr (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_SET_STATION_ADDR_T    *PxeUndiTable\r
-  )\r
-;\r
-\r
-\r
-/**\r
-  PXE\r
-  UNDI GET INFORMATION\r
-  Op-Code: PXENV_UNDI_GET_INFORMATION (000Ch)\r
-  Input: Far pointer to a PXENV_UNDI_GET_INFORMATION_T parameter structure that has been\r
-  initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This call copies the network adapter variables, including the MAC address, into the input buffer.\r
-  Note: The PermNodeAddress field must be valid after PXENV_START_UNDI and\r
-  PXENV_UNDI_STARTUP have been issued. All other fields must be valid after\r
-  PXENV_START_UNDI, PXENV_UNDI_STARTUP and PXENV_UNDI_INITIALIZE have been\r
-  called.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    UINT16 BaseIo;\r
-    UINT16 IntNumber;\r
-    UINT16 MaxTranUnit;\r
-    UINT16 HwType;\r
-      #define ETHER_TYPE 1\r
-      #define EXP_ETHER_TYPE 2\r
-      #define IEEE_TYPE 6\r
-      #define ARCNET_TYPE 7\r
-    UINT16 HwAddrLen;\r
-    MAC_ADDR CurrentNodeAddress;\r
-    MAC_ADDR PermNodeAddress;\r
-    SEGSEL ROMAddress;\r
-    UINT16 RxBufCt;\r
-    UINT16 TxBufCt;\r
-  } PXENV_UNDI_GET_INFORMATION_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  BaseIO: Adapter base I/O address.\r
-  IntNumber: Adapter IRQ number.\r
-  MaxTranUnit: Adapter maximum transmit unit.\r
-  HWType: Type of protocol at the hardware level.\r
-  HWAddrLen: Length of the hardware address.\r
-  CurrentNodeAddress: Current hardware address.\r
-  PermNodeAddress: Permanent hardware address.\r
-  ROMAddress: Real mode ROM segment address.\r
-  RxBufCnt: Receive queue length.\r
-  TxBufCnt: Transmit queue length.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetInformation (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_INFORMATION_T     *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI GET STATISTICS\r
-  Op-Code: PXENV_UNDI_GET_STATISTICS (000Dh)\r
-  Input: Far pointer to a PXENV_UNDI_GET_STATISTICS_T parameter structure that has been initialized\r
-  by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call reads statistical information from the network adapter, and returns.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    UINT32 XmtGoodFrames;\r
-    UINT32 RcvGoodFrames;\r
-    UINT32 RcvCRCErrors;\r
-    UINT32 RcvResourceErrors;\r
-  } PXENV_UNDI_GET_STATISTICS_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  XmtGoodFrames: Number of successful transmissions.\r
-  RcvGoodFrames: Number of good frames received.\r
-  RcvCRCErrors: Number of frames received with CRC\r
-  error.\r
-  RcvResourceErrors: Number of frames discarded\r
-  because receive queue was full.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetStatistics (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_STATISTICS_T      *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI CLEAR STATISTICS\r
-  Op-Code: PXENV_UNDI_CLEAR_STATISTICS (000Eh)\r
-  Input: Far pointer to a PXENV_UNDI_CLEAR_STATISTICS_T parameter.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This call clears the statistical information from the network adapter.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-  } PXENV_UNDI_CLEAR_STATISTICS_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiClearStatistics (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_CLEAR_STATISTICS_T    *PxeUndiTable\r
-  )\r
-;\r
-\r
-\r
-/**\r
-  PXE\r
-  UNDI GET MULTICAST ADDRESS\r
-  Op-Code: PXENV_UNDI_GET_MCAST_ADDRESS (0011h)\r
-  Input: Far pointer to a PXENV_GET_MCAST_ADDRESS_t parameter structure that has been initialized\r
-  by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call converts the given IP multicast address to a hardware multicast address.\r
-  typedef struct  {\r
-    PXENV_STATUS Status;\r
-    IP4 InetAddr;\r
-    MAC_ADDR MediaAddr;\r
-  } PXENV_UNDI_GET_MCAST_ADDR_T;\r
-  Set before calling API service\r
-  InetAddr: IP multicast address.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  MediaAddr: MAC multicast address.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetMcastAddr (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_MCAST_ADDR_T      *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI GET NIC TYPE\r
-  Op-Code: PXENV_UNDI_GET_NIC_TYPE (0012h)\r
-  Input: Far pointer to a PXENV_UNDI_GET_NIC_TYPE_T parameter structure that has been initialized by\r
-  the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants. If the PXENV_EXIT_SUCCESS is returned the parameter structure must contain the\r
-  NIC information.\r
-  Description: This call, if successful, provides the NIC-specific information necessary to identify the network\r
-  adapter that is used to boot the system.\r
-  Note: The application first gets the DHCPDISCOVER packet using GET_CACHED_INFO and checks if\r
-  the UNDI is supported before making this call. If the UNDI is not supported, the NIC-specific\r
-  information can be obtained from the DHCPDISCOVER packet itself.\r
-  PXENV_START_UNDI, PXENV_UNDI_STARTUP and PXENV_UNDI_INITIALIZE must be called\r
-  before the information provided is valid.\r
-  typedef {\r
-    PXENV_STATUS Status;\r
-    UINT8 NicType;\r
-      #define PCI_NIC 2\r
-      #define PnP_NIC 3\r
-      #define CardBus_NIC 4\r
-    Union {\r
-      Struct {\r
-        UINT16 Vendor_ID;\r
-        UINT16 Dev_ID;\r
-        UINT8 Base_Class;\r
-        UINT8 Sub_Class;\r
-        UINT8 Prog_Intf;\r
-        UINT8 Rev;\r
-        UINT16 BusDevFunc;\r
-        UINT16 SubVendor_ID;\r
-        UINT16 SubDevice_ID;\r
-      } pci, cardbus;\r
-      struct {\r
-        UINT32 EISA_Dev_ID;\r
-        UINT8 Base_Class;\r
-        UINT8 Sub_Class;\r
-        UINT8 Prog_Intf;\r
-        UINT16 CardSelNum;\r
-      } pnp;\r
-    } info;\r
-  } PXENV_UNDI_GET_NIC_TYPE_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  NICType: Type of NIC information stored in the parameter\r
-  structure.\r
-  Info: Information about the fields in this union can be found\r
-  in the [PnP] and [PCI] specifications\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetNicType (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_NIC_TYPE_T        *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI GET IFACE INFO\r
-  Op-Code: PXENV_UNDI_GET_IFACE_INFO (0013h)\r
-  Input: Far pointer to a PXENV_UNDI_GET_IFACE_INFO_t parameter structure that has been initialized\r
-  by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants. If the PXENV_EXIT_SUCCESS is returned, the parameter structure must contain the\r
-  interface specific information.\r
-  Description: This call, if successful, provides the network interface specific information such as the interface\r
-  type at the link layer (Ethernet, Tokenring) and the link speed. This information can be used in the\r
-  universal drivers such as NDIS or Miniport to communicate to the upper protocol modules.\r
-  Note: UNDI follows the NDIS2 specification in giving this information. It is the responsibility of the\r
-  universal driver to translate/convert this information into a format that is required in its specification\r
-  or to suit the expectation of the upper level protocol modules.\r
-  PXENV_START_UNDI, PXENV_UNDI_STARTUP and PXENV_UNDI_INITIALIZE must be called\r
-  before the information provided is valid.\r
-  typedef struct {\r
-    PXENV_STATUS Status\r
-    UINT8 IfaceType[16];\r
-    UINT32 LinkSpeed;\r
-    UINT32 ServiceFlags;\r
-    UINT32 Reserved[4];\r
-  } PXENV_UNDI_GET_NDIS_INFO_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  IfaceType: Name of MAC type in ASCIIZ format. This is\r
-  used by the universal NDIS driver to specify its driver type\r
-  to the protocol driver.\r
-  LinkSpeed: Defined in the NDIS 2.0 specification.\r
-  ServiceFlags: Defined in the NDIS 2.0 specification.\r
-  Reserved: Must be zero.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetNdisInfo (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_NDIS_INFO_T       *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  UNDI ISR\r
-  Op-Code: PXENV_UNDI_ISR (0014h)\r
-  Input: Far pointer to a PXENV_UNDI_ISR_T parameter structure that has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This API function will be called at different levels of processing the interrupt. The FuncFlag field in\r
-  the parameter block indicates the operation to be performed for the call. This field is filled with the\r
-  status of that operation on return.\r
-  Note: Interrupt Service Routine Operation:\r
-  In this design the UNDI does not hook the interrupt for the Network Interface. Instead, the\r
-  application or the protocol driver hooks the interrupt and calls UNDI with the PXENV_UNDI_ISR\r
-  API call for interrupt verification (PXENV_UNDI_ISR_IN_START) and processing\r
-  (PXENV_UNDI_ISR_IN_PROCESS and PXENV_UNDI_ISR_GET_NEXT).\r
-  When the Network Interface HW generates an interrupt the protocol driver interrupt service\r
-  routine (ISR) gets control and takes care of the interrupt processing at the PIC level. The ISR then\r
-  calls the UNDI using the PXENV_UNDI_ISR API with the value PXENV_UNDI_ISR_IN_START for\r
-  the FuncFlag parameter. At this time UNDI must disable the interrupts at the Network Interface\r
-  level and read any status values required to further process the interrupt. UNDI must return as\r
-  quickly as possible with one of the two values, PXENV_UNDI_ISR_OUT_OURS or\r
-  PXENV_UNDI_ISR_OUT_NOT_OURS, for the parameter FuncFlag depending on whether the\r
-  interrupt was generated by this particular Network Interface or not.\r
-  If the value returned in FuncFlag is PXENV_UNDI_ISR_OUT_NOT_OURS, then the interrupt was\r
-  not generated by our NIC, and interrupt processing is complete.\r
-  If the value returned in FuncFlag is PXENV_UNDI_ISR_OUT_OURS, the protocol driver must start\r
-  a handler thread and send an end-of-interrupt (EOI) command to the PIC. Interrupt processing is\r
-  now complete.\r
-  The protocol driver strategy routine will call UNDI using this same API with FuncFlag equal to\r
-  PXENV_UNDI_ISR_IN_PROCESS. At this time UNDI must find the cause of this interrupt and\r
-  return the status in the FuncFlag. It first checks if there is a frame received and if so it returns the\r
-  first buffer pointer of that frame in the parameter block.\r
-  The protocol driver calls UNDI repeatedly with the FuncFlag equal to\r
-  PXENV_UNDI_ISR_IN_GET_NEXT to get all the buffers in a frame and also all the received\r
-  frames in the queue. On this call, UNDI must remember the previous buffer given to the protoco,l\r
-  remove it from the receive queue and recycle it. In case of a multi-buffered frame, if the previous\r
-  buffer is not the last buffer in the frame it must return the next buffer in the frame in the parameter\r
-  block. Otherwise it must return the first buffer in the next frame.\r
-  If there is no received frame pending to be processed, UNDI processes the transmit completes and\r
-  if there is no other interrupt status to be processed, UNDI re-enables the interrupt at the\r
-  NETWORK INTERFACE level and returns PXENV_UNDI_ISR_OUT_DONE in the FuncFlag.\r
-  IMPORTANT: It is possible for the protocol driver to be interrupted again while in the\r
-  strategy routine when the UNDI re-enables interrupts.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiIsr (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_ISR_T                 *PxeUndiTable\r
-  )\r
-;\r
-\r
-/**\r
-  PXE\r
-  STOP UNDI\r
-  Op-Code: PXENV_STOP_UNDI (0015h)\r
-  Input: Far pointer to a PXENV_STOP_UNDI_T parameter structure that has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This routine is responsible for unhooking the Int 1Ah service routine.\r
-  Note: This API service must be called only once at the end of UNDI Option ROM boot. One of the valid\r
-  status codes is PXENV_STATUS_KEEP. If this status is returned, UNDI must not be removed from\r
-  base memory. Also, UNDI must not be removed from base memory if BC is not removed from base\r
-  memory.\r
-  Service cannot be used in protected mode.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-  } PXENV_STOP_UNDI_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiStop (\r
-  IN EFI_SIMPLE_NETWORK_DEV               *SimpleNetworkDevice,\r
-  IN OUT PXENV_STOP_UNDI_T                *PxeUndiTable\r
-  )\r
-;\r
-\r
-\r
-/**\r
-  Effect the Far Call into the PXE Layer\r
-\r
-  Note: When using a 32-bit stack segment do not push 32-bit words onto the stack. The PXE API\r
-  services will not work, unless there are three 16-bit parameters pushed onto the stack.\r
-      push DS                                 ;Far pointer to parameter structure\r
-      push offset pxe_data_call_struct        ;is pushed onto stack.\r
-      push Index                              ;UINT16 is pushed onto stack.\r
-      call dword ptr (s_PXE ptr es:[di]).EntryPointSP\r
-      add sp, 6 ;Caller cleans up stack.\r
-\r
-  @param SimpleNetworkDevice    Device instance for simple network\r
-  @param Table                 Point to parameter/retun value table for legacy far call\r
-  @param TableSize              The size of parameter/return value table\r
-  @param CallIndex              The index of legacy call.\r
-\r
-  @return EFI_STATUS\r
-**/\r
-EFI_STATUS\r
-MakePxeCall (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT VOID             *Table,\r
-  IN UINTN                TableSize,\r
-  IN UINT16               CallIndex\r
-  )\r
-;\r
-\r
-/**\r
-  Allocate buffer below 1M for real mode.\r
-\r
-  @param NumPages     The number pages want to be allocated.\r
-  @param Buffer       On return, allocated buffer.\r
-\r
-  @return Status of allocating pages.\r
-**/\r
-EFI_STATUS\r
-BiosSnp16AllocatePagesBelowOneMb (\r
-  UINTN  NumPages,\r
-  VOID   **Buffer\r
-  )\r
-;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.uni b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.uni
deleted file mode 100644 (file)
index 705a9a5..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// SNP driver On Legacy NIC ROM.\r
-//\r
-// Thunk wrapper UEFI driver to produce EFI SNP protocol based on legacy 16 NIC ROM.\r
-//\r
-// Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "SNP driver On Legacy NIC ROM"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Thunk wrapper UEFI driver to produce the EFI SNP protocol based on legacy 16 NIC ROM."\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16Extra.uni b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16Extra.uni
deleted file mode 100644 (file)
index a32f88c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// BiosSnp16 Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Legacy Simple Network Protocol DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/ComponentName.c b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/ComponentName.c
deleted file mode 100644 (file)
index 4fd6e62..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 1999 - 2011, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosSnp16.h"\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16ComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16ComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gBiosSnp16ComponentName = {\r
-  BiosSnp16ComponentNameGetDriverName,\r
-  BiosSnp16ComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosSnp16ComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) BiosSnp16ComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) BiosSnp16ComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosSnp16DriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"BIOS[UNDI] Simple Network Protocol Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16ComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mBiosSnp16DriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gBiosSnp16ComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosSnp16ComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Misc.c b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Misc.c
deleted file mode 100644 (file)
index 393065d..0000000
+++ /dev/null
@@ -1,955 +0,0 @@
-/** @file\r
-  Helper Routines that use a PXE-enabled NIC option ROM.\r
-\r
-Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosSnp16.h"\r
-\r
-#define TO_SEGMENT(x)   ((UINT16) (RShiftU64 ((UINT32)(UINTN) (x), 4) & 0xF000))\r
-#define TO_OFFSET(x)    ((UINT16) ((UINT32)(UINTN) (x) & 0xFFFF))\r
-#define PARAGRAPH_SIZE  0x10\r
-#define IVT_BASE        0x00000000\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  UINT16  Signature;          ///< 0xaa55\r
-  UINT8   ROMlength;          ///< size of this ROM in 512 byte blocks\r
-  UINT8   InitEntryPoint[4];  ///< a jump to the initialization routine\r
-  UINT8   Reserved[0xf];      ///< various\r
-  UINT16  PxeRomIdOffset;     ///< offset of UNDI, $BC$, or BUSD ROM ID structure\r
-  UINT16  PcirHeaderOffset;   ///< offset of PCI Expansion Header\r
-  UINT16  PnpHeaderOffset;    ///< offset of Plug and Play Expansion Header\r
-} OPTION_ROM_HEADER;\r
-#pragma pack()\r
-\r
-UINT32 CachedVectorAddress[0x100];\r
-\r
-/**\r
- Cache Interrupt verctor address converted from IVT number.\r
-\r
- @param VectorNumber  IVT number\r
-\r
- @retval EFI_SUCCESS Success to operation.\r
-**/\r
-EFI_STATUS\r
-CacheVectorAddress (\r
-  UINT8   VectorNumber\r
-  )\r
-{\r
-  UINT32  *Address;\r
-\r
-  Address                          = (UINT32 *) ((UINTN) IVT_BASE + VectorNumber * 4);\r
-  CachedVectorAddress[VectorNumber] = *Address;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Get interrupt vector address according to IVT number.\r
-\r
- @param VectorNumber    Given IVT number\r
-\r
- @return cached interrupt vector address.\r
-**/\r
-EFI_STATUS\r
-RestoreCachedVectorAddress (\r
-  UINT8   VectorNumber\r
-  )\r
-{\r
-  UINT32  *Address;\r
-\r
-  Address  = (UINT32 *) ((UINTN) IVT_BASE + VectorNumber * 4);\r
-  *Address = CachedVectorAddress[VectorNumber];\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Print Undi loader table.\r
-\r
- @param UndiLoaderStructure Point to Undi Loader table structure.\r
-\r
-**/\r
-VOID\r
-Print_Undi_Loader_Table (\r
-  VOID *UndiLoaderStructure\r
-  )\r
-{\r
-  UNDI_LOADER_T *DisplayPointer;\r
-\r
-  DisplayPointer = (UNDI_LOADER_T *) UndiLoaderStructure;\r
-\r
-  DEBUG ((DEBUG_NET, "Before Parsing the table contents, the table itself lives\n"));\r
-  DEBUG ((DEBUG_NET, "\tat the address 0x%X\n\r", (UINT32)(UINTN) UndiLoaderStructure));\r
-\r
-  DEBUG ((DEBUG_NET, "\n\rStatus = 0x%X\n\r", DisplayPointer->Status));\r
-  DEBUG ((DEBUG_NET, "\t_AX_= 0x%X\n\r", DisplayPointer->Ax));\r
-  DEBUG ((DEBUG_NET, "\t_BX_= 0x%X\n\r", DisplayPointer->Bx));\r
-  DEBUG ((DEBUG_NET, "\t_DX_= 0x%X\n\r", DisplayPointer->Dx));\r
-  DEBUG ((DEBUG_NET, "\t_DI_= 0x%X\n\r", DisplayPointer->Di));\r
-  DEBUG ((DEBUG_NET, "\t_ES_= 0x%X\n\r", DisplayPointer->Es));\r
-  DEBUG ((DEBUG_NET, "\tUNDI_DS= 0x%X\n\r", DisplayPointer->Undi_Ds));\r
-  DEBUG ((DEBUG_NET, "\tUNDI_CS= 0x%X\n\r", DisplayPointer->Undi_Cs));\r
-  DEBUG ((DEBUG_NET, "\tPXEptr:SEG= 0x%X\n\r", (UINT16) DisplayPointer->PXEptr.Segment));\r
-  DEBUG ((DEBUG_NET, "\tPXEptr:OFF= 0x%X\n\r", (UINT16) DisplayPointer->PXEptr.Offset));\r
-  DEBUG ((DEBUG_NET, "\tPXENVptr:SEG= 0x%X\n\r", (UINT16) DisplayPointer->PXENVptr.Segment));\r
-  DEBUG ((DEBUG_NET, "\tPXENVptr:OFF= 0x%X\n\r", (UINT16) DisplayPointer->PXENVptr.Offset));\r
-}\r
-\r
-/**\r
-  Simple table dumper.  The ROMID table is necessary in order to effect\r
-  the "Early UNDI" trick.  Herein, the UNDI layer can be loaded in the\r
-  pre-boot phase without having to download a Network Boot Program\r
-  across the wire.  It is required in the implementation in that we\r
-  are not using PXE.\r
-\r
-  @param RomIDStructure Point to RomID structure.\r
-\r
-**/\r
-VOID\r
-Print_ROMID_Table (\r
-  IN VOID *RomIDStructure\r
-  )\r
-{\r
-  UNDI_ROMID_T  *DisplayPointer;\r
-\r
-  DisplayPointer = (UNDI_ROMID_T *) RomIDStructure;\r
-\r
-  DEBUG ((DEBUG_NET, "Before Parsing the table contents, the table itself lives\n"));\r
-  DEBUG ((DEBUG_NET, "\tat the address 0x%X\n\r", (UINT32)(UINTN) RomIDStructure));\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "\n\rROMID %c%c%c%c\n\r",\r
-    DisplayPointer->Signature[0],\r
-    DisplayPointer->Signature[1],\r
-    DisplayPointer->Signature[2],\r
-    DisplayPointer->Signature[3])\r
-    );\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Length of this structure in bytes = 0x%X\n\r",\r
-    DisplayPointer->StructLength)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Use to make byte checksum of this structure == zero is = 0x%X\n\r",\r
-    DisplayPointer->StructCksum)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Structure format revision number= 0x%X\n\r",\r
-    DisplayPointer->StructRev)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "API Revision number = 0x%X 0x%X 0x%X\n\r",\r
-    DisplayPointer->UNDI_Rev[0],\r
-    DisplayPointer->UNDI_Rev[1],\r
-    DisplayPointer->UNDI_Rev[2])\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Offset of UNDI loader routine in the option ROM image= 0x%X\n\r",\r
-    DisplayPointer->UNDI_Loader)\r
-    );\r
-  DEBUG ((DEBUG_NET, "From the data above, the absolute entry point of the UNDI loader is\n\r"));\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "\tat address 0x%X\n\r",\r
-    (UINT32) (DisplayPointer->UNDI_Loader + ((UINT32) (UINTN)(DisplayPointer - 0x20) & 0xFFFF0)))\r
-    );\r
-  DEBUG ((DEBUG_NET, "Minimum stack segment size, in bytes,\n\r"));\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "needed to load and run the UNDI= 0x%X \n\r",\r
-    DisplayPointer->StackSize)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "UNDI runtime code and data = 0x%X\n\r",\r
-    DisplayPointer->DataSize)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Segment size = 0x%X\n\r",\r
-    DisplayPointer->CodeSize)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "\n\rBus Type =  %c%c%c%c\n\r",\r
-    DisplayPointer->BusType[0],\r
-    DisplayPointer->BusType[1],\r
-    DisplayPointer->BusType[2],\r
-    DisplayPointer->BusType[3])\r
-    );\r
-}\r
-\r
-/**\r
-  Print PXE table.\r
-\r
-  @param PxeTable Point to PXE table structure\r
-\r
-**/\r
-VOID\r
-Print_PXE_Table (\r
-  IN VOID*  PxeTable\r
-  )\r
-{\r
-  PXE_T *DisplayPointer;\r
-  UINTN Index;\r
-  UINT8 *Dptr;\r
-\r
-  DisplayPointer  = (PXE_T *) PxeTable;\r
-  Dptr            = (UINT8 *) PxeTable;\r
-\r
-  DEBUG ((DEBUG_NET, "This is the PXE table at address 0x%X\n\r", PxeTable));\r
-\r
-  DEBUG ((DEBUG_NET, "A dump of the 0x%X bytes is:\n\r", sizeof (PXE_T)));\r
-\r
-  for (Index = 0; Index < sizeof (PXE_T); Index++) {\r
-    if ((Index % 0x10) == 0) {\r
-      DEBUG ((DEBUG_NET, "\t\n\r"));\r
-    }\r
-\r
-    DEBUG ((DEBUG_NET, " 0x%X  ", *Dptr++));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "\n\r"));\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "\n\rPXE %c%c%c%c%c%c\n\r",\r
-    DisplayPointer->Signature[0],\r
-    DisplayPointer->Signature[1],\r
-    DisplayPointer->Signature[2],\r
-    DisplayPointer->Signature[3])\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Length of this structure in bytes = 0x%X\n\r",\r
-    DisplayPointer->StructLength)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Use to make byte checksum of this  structure == zero is = 0x%X\n\r",\r
-    DisplayPointer->StructCksum)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Structure format revision number = 0x%X\n\r",\r
-    DisplayPointer->StructRev)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Must be zero, is equal to 0x%X\n\r",\r
-    DisplayPointer->Reserved1)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Far pointer to UNDI ROMID = 0x%X\n\r",\r
-    (UINT32) (DisplayPointer->Undi.Segment << 0x4 | DisplayPointer->Undi.Offset))\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Far pointer to base-code ROMID = 0x%X\n\r",\r
-    (UINT32) ((DisplayPointer->Base.Segment << 0x04) | DisplayPointer->Base.Offset))\r
-    );\r
-  DEBUG ((DEBUG_NET, "16bit stack segment API entry point.  This will be seg:off in \n\r"));\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "real mode and sel:off in 16:16 protected mode = 0x%X:0x%X\n\r",\r
-    DisplayPointer->EntryPointSP.Segment,\r
-    DisplayPointer->EntryPointSP.Offset)\r
-    );\r
-\r
-  DEBUG ((DEBUG_NET, "\n\tNOTE to the implementer\n\tThis is the entry to use for call-ins\n\r"));\r
-\r
-  DEBUG ((DEBUG_NET, "32bit stack Segment API entry point.  This will be sel:off. \n\r"));\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "In real mode, sel == 0 = 0x%X:0x%X\n\r",\r
-    DisplayPointer->EntryPointESP.Segment,\r
-    DisplayPointer->EntryPointESP.Offset)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Reserved2 value, must be zero, is equal to 0x%X\n\r",\r
-    DisplayPointer->Reserved2)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Number of segment descriptors in this structur = 0x%X\n\r",\r
-    (UINT8) DisplayPointer->SegDescCnt)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "First segment descriptor in GDT assigned to PXE = 0x%X\n\r",\r
-    (UINT16) DisplayPointer->FirstSelector)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The Stack is \n\r\tSegment Addr = 0x%X\n\r\tPhysical Addr = 0x%X\n\r\tSeg Size = 0x%X\n\r",\r
-    (UINT16) DisplayPointer->Stack.Seg_Addr,\r
-    (UINT32) DisplayPointer->Stack.Phy_Addr,\r
-    (UINT16) DisplayPointer->Stack.Seg_Size)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The UNDIData is \n\r\tSegment Addr = 0x%X\n\r\tPhysical Addr = 0x%X\n\r\tSeg Size = 0x%X\n\r",\r
-    (UINT16) DisplayPointer->UNDIData.Seg_Addr,\r
-    (UINT32) DisplayPointer->UNDIData.Phy_Addr,\r
-    (UINT16) DisplayPointer->UNDIData.Seg_Size)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The UNDICodeWrite is \n\r\tSegment Addr = 0x%X\n\r\tPhysical Addr = 0x%X\n\r\tSeg Size = 0x%X\n\r",\r
-    (UINT16) DisplayPointer->UNDICode.Seg_Addr,\r
-    (UINT32) DisplayPointer->UNDICode.Phy_Addr,\r
-    (UINT16) DisplayPointer->UNDICode.Seg_Size)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The Stack is \n\r\tSegment Addr = 0x%X\n\r\tPhysical Addr = 0x%X\n\r\tSeg Size = 0x%X\n\r",\r
-    (UINT16) DisplayPointer->UNDICodeWrite.Seg_Addr,\r
-    (UINT32) DisplayPointer->UNDICodeWrite.Phy_Addr,\r
-    (UINT16) DisplayPointer->UNDICodeWrite.Seg_Size)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The BC_Data is \n\r\tSegment Addr = 0x%X\n\r\tPhysical Addr = 0x%X\n\r\tSeg Size = 0x%X\n\r",\r
-    (UINT16) DisplayPointer->BC_Data.Seg_Addr,\r
-    (UINT32) DisplayPointer->BC_Data.Phy_Addr,\r
-    (UINT16) DisplayPointer->BC_Data.Seg_Size)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The BC_Code is \n\r\tSegment Addr = 0x%X\n\r\tPhysical Addr = 0x%X\n\r\tSeg Size = 0x%X\n\r",\r
-    (UINT16) DisplayPointer->BC_Code.Seg_Addr,\r
-    (UINT32) DisplayPointer->BC_Code.Phy_Addr,\r
-    (UINT16) DisplayPointer->BC_Code.Seg_Size)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The BC_CodeWrite is \n\r\tSegment Addr = 0x%X\n\r\tPhysical Addr = 0x%X\n\r\tSeg Size = 0x%X\n\r",\r
-    (UINT16) DisplayPointer->BC_CodeWrite.Seg_Addr,\r
-    (UINT32) DisplayPointer->BC_CodeWrite.Phy_Addr,\r
-    (UINT16) DisplayPointer->BC_CodeWrite.Seg_Size)\r
-    );\r
-}\r
-\r
-/**\r
-  Print PXENV table.\r
-\r
-  @param PxenvTable Point to PXENV\r
-\r
-**/\r
-VOID\r
-Print_PXENV_Table (\r
-  IN VOID *PxenvTable\r
-  )\r
-{\r
-  PXENV_T *DisplayPointer;\r
-\r
-  DisplayPointer = (PXENV_T *) PxenvTable;\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "\n\rPXENV+ %c%c%c%c%c%c\n\r",\r
-    DisplayPointer->Signature[0],\r
-    DisplayPointer->Signature[1],\r
-    DisplayPointer->Signature[2],\r
-    DisplayPointer->Signature[3],\r
-    DisplayPointer->Signature[4],\r
-    DisplayPointer->Signature[5])\r
-    );\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "PXE version number.  \n\r\tLSB is minor version.  \n\r\tMSB is major version = 0x%X\n\r",\r
-    DisplayPointer->Version)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Length of PXE-2.0 Entry Point structure in bytes = 0x%X\n\r",\r
-    DisplayPointer->StructLength)\r
-    );\r
-  DEBUG ((DEBUG_NET, "Used to make structure checksum equal zero is now = 0x%X\n\r", DisplayPointer->StructCksum));\r
-  DEBUG ((DEBUG_NET, "Real mode API entry point  segment:Offset.  = 0x%X\n\r", DisplayPointer->RMEntry));\r
-  DEBUG ((DEBUG_NET, "Protected mode API entry point = 0x%X\n\r", DisplayPointer->PMEntryOff));\r
-  DEBUG ((DEBUG_NET, " segment:Offset.  This will always be zero.  \n\r"));\r
-  DEBUG ((DEBUG_NET, "Protected mode API calls = 0x%X\n\r", DisplayPointer->PMEntrySeg));\r
-  DEBUG ((DEBUG_NET, "Real mode stack segment = 0x%X\n\r", DisplayPointer->StackSeg));\r
-  DEBUG ((DEBUG_NET, "Stack segment size in bytes = 0x%X\n\r", DisplayPointer->StackSize));\r
-  DEBUG ((DEBUG_NET, "Real mode base-code code segment = 0x%X\n\r", DisplayPointer->BaseCodeSeg));\r
-  DEBUG ((DEBUG_NET, "Base-code code segment size = 0x%X\n\r", DisplayPointer->BaseCodeSize));\r
-  DEBUG ((DEBUG_NET, "Real mode base-code data segment = 0x%X\n\r", DisplayPointer->BaseDataSeg));\r
-  DEBUG ((DEBUG_NET, "Base-code data segment size = 0x%X\n\r", DisplayPointer->BaseDataSize));\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "UNDI code segment size in bytes = 0x%X\n\r",\r
-    DisplayPointer->UNDICodeSize)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "Real mode segment:Offset pointer \n\r\tto PXE Runtime ID structure, address = 0x%X\n\r",\r
-    DisplayPointer->RuntimePtr)\r
-    );\r
-  DEBUG (\r
-    (\r
-    DEBUG_NET,\r
-    "From above, we have a linear address of 0x%X\n\r",\r
-    (UINT32)\r
-    (\r
-    ((UINT32)(UINTN)(DisplayPointer->RuntimePtr) & 0xFFFF) +\r
-    (((UINT32)(UINTN)(DisplayPointer->RuntimePtr) & 0xFFFF0000) >> 12)\r
-    )\r
-    )\r
-    );\r
-}\r
-\r
-\r
-#define OPTION_ROM_PTR  ((OPTION_ROM_HEADER *) RomAddress)\r
-\r
-/**\r
-  If available, launch the BaseCode from a NIC option ROM.\r
-  This should install the !PXE and PXENV+ structures in memory for\r
-  subsequent use.\r
-\r
-\r
-  @param SimpleNetworkDevice    Simple network device instance\r
-  @param RomAddress             The ROM base address for NIC rom.\r
-\r
-  @retval EFI_NOT_FOUND         The check sum does not match\r
-  @retval EFI_NOT_FOUND         Rom ID offset is wrong\r
-  @retval EFI_NOT_FOUND         No Rom ID structure is found\r
-**/\r
-EFI_STATUS\r
-LaunchBaseCode (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  UINTN                   RomAddress\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_IA32_REGISTER_SET InOutRegs;\r
-  UNDI_ROMID_T          *RomIdTableAddress;\r
-  UNDI_LOADER_T         *UndiLoaderTable;\r
-  UINT16                Segment;\r
-  UINT16                *StackPointer;\r
-  VOID                  *Buffer;\r
-  UINTN                 Size;\r
-  PXE_T                 *Pxe;\r
-  UINT32                RomLength;\r
-  UINTN                 PciSegment;\r
-  UINTN                 Bus;\r
-  UINTN                 Device;\r
-  UINTN                 Function;\r
-  BOOLEAN               ThunkFailed;\r
-\r
-  DEBUG ((DEBUG_NET, "\n\r\n\rCheck for the UNDI ROMID Signature\n\r"));\r
-\r
-  //\r
-  // paranoia - check structures for validity\r
-  //\r
-  RomLength = OPTION_ROM_PTR->ROMlength << 9;\r
-  if (CalculateSum8 ((UINT8 *) RomAddress, RomLength) != 0) {\r
-    DEBUG ((DEBUG_ERROR, "ROM Header Checksum Error\n\r"));\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  RomIdTableAddress = (UNDI_ROMID_T *) (RomAddress + OPTION_ROM_PTR->PxeRomIdOffset);\r
-\r
-  if (((UINT32)OPTION_ROM_PTR->PxeRomIdOffset + RomIdTableAddress->StructLength) > RomLength) {\r
-    DEBUG ((DEBUG_ERROR, "ROM ID Offset Error\n\r"));\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // see if this is a header for an UNDI ROM ID structure (vs. a $BC$ or BUSD type)\r
-  //\r
-  if (CompareMem (RomIdTableAddress->Signature, UNDI_ROMID_SIG, sizeof RomIdTableAddress->Signature) != 0) {\r
-    DEBUG ((DEBUG_ERROR, "No ROM ID Structure found....\n\r"));\r
-    return EFI_NOT_FOUND;\r
-    //\r
-    // its not - keep looking\r
-    //\r
-  }\r
-\r
-  if (CalculateSum8 ((UINT8 *) RomIdTableAddress, RomIdTableAddress->StructLength) != 0) {\r
-    DEBUG ((DEBUG_ERROR, "ROM ID Checksum Error\n\r"));\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  Print_ROMID_Table (RomIdTableAddress);\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The ROM ID is located at 0x%X\n\r",\r
-    RomIdTableAddress)\r
-    );\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "With an UNDI Loader located at 0x%X\n\r",\r
-    RomAddress + RomIdTableAddress->UNDI_Loader)\r
-    );\r
-\r
-  //\r
-  // found an UNDI ROM ID structure\r
-  //\r
-  SimpleNetworkDevice->Nii.ImageAddr  = RomAddress;\r
-  SimpleNetworkDevice->Nii.ImageSize  = RomLength;\r
-  SimpleNetworkDevice->Nii.MajorVer   = RomIdTableAddress->UNDI_Rev[2];\r
-  SimpleNetworkDevice->Nii.MinorVer   = RomIdTableAddress->UNDI_Rev[1];\r
-\r
-  DEBUG ((DEBUG_NET, "Allocate area for the UNDI_LOADER_T structure\n\r"));\r
-  //\r
-  // Allocate 1 page below 1MB to put real mode thunk code in\r
-  //\r
-  // Undi Loader Table is a PXE Specification prescribed data structure\r
-  // that is used to transfer information into and out of the Undi layer.\r
-  // Note how it must be located below 1 MB.\r
-  //\r
-  SimpleNetworkDevice->UndiLoaderTablePages = EFI_SIZE_TO_PAGES (PARAGRAPH_SIZE + sizeof (UNDI_LOADER_T));\r
-  Status = BiosSnp16AllocatePagesBelowOneMb (\r
-            SimpleNetworkDevice->UndiLoaderTablePages,\r
-            &SimpleNetworkDevice->UndiLoaderTable\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "We had a failure in AllocatePages, status code = 0x%X\n", Status));\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  UndiLoaderTable = SimpleNetworkDevice->UndiLoaderTable;\r
-\r
-  DEBUG ((DEBUG_NET, "Allocate area for the real-mode stack whose sole purpose\n\r"));\r
-  DEBUG ((DEBUG_NET, "in life right now is to store a SEG:OFFSET combo pair that\n\r"));\r
-  DEBUG ((DEBUG_NET, "points to an Undi_Loader_t table structure\n\r"));\r
-\r
-  Size    = 0x100;\r
-  Status  = gBS->AllocatePool (EfiLoaderData, Size, &Buffer);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Now we want to put a pointer to the Under Loader Table in our MemPage\r
-  // Buffer.  This will be the argument stack for the call into the Undi Loader\r
-  //\r
-  StackPointer    = (UINT16 *) Buffer;\r
-  *StackPointer++ = TO_OFFSET (UndiLoaderTable);\r
-  //\r
-  // push the OFFSET\r
-  //\r
-  *StackPointer++ = TO_SEGMENT (UndiLoaderTable);\r
-  //\r
-  // push the SEGMENT\r
-  //\r
-  StackPointer = (UINT16 *) Buffer;\r
-  //\r
-  // reset the stack pointer\r
-  //\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "After the fixups, the stack pointer is 0x%X\n\r",\r
-    (UINT64)(UINTN) StackPointer)\r
-    );\r
-\r
-  //\r
-  // Allocate memory for the Deployed UNDI.\r
-  // The UNDI is essentially telling us how much space it needs, and\r
-  // it is up to the EFI driver to allocate sufficient, boot-time\r
-  // persistent resources for the call\r
-  //\r
-  SimpleNetworkDevice->DestinationDataSegmentPages = EFI_SIZE_TO_PAGES (RomIdTableAddress->DataSize);\r
-  Status = BiosSnp16AllocatePagesBelowOneMb (\r
-            SimpleNetworkDevice->DestinationDataSegmentPages,\r
-            &SimpleNetworkDevice->DestinationDataSegment\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "We had a failure in AllocatePages, status code = 0x%X\n", Status));\r
-    return Status;\r
-  }\r
-\r
-  UndiLoaderTable->Undi_Ds = (UINT16) ((UINTN) SimpleNetworkDevice->DestinationDataSegment >> 4);\r
-\r
-  //\r
-  // Allocate memory for the Deployed UNDI stack\r
-  // The UNDI is essentially telling us how much space it needs, and\r
-  // it is up to the EFI driver to allocate sufficient, boot-time\r
-  // persistent resources for the call\r
-  //\r
-  SimpleNetworkDevice->DestinationStackSegmentPages = EFI_SIZE_TO_PAGES (RomIdTableAddress->StackSize);\r
-  Status = BiosSnp16AllocatePagesBelowOneMb (\r
-            SimpleNetworkDevice->DestinationStackSegmentPages,\r
-            &SimpleNetworkDevice->DestinationStackSegment\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "We had a failure in AllocatePages, status code = 0x%X\n", Status));\r
-    return Status;\r
-  }\r
-  //\r
-  // Allocate memory for the Deployed UNDI.\r
-  // The UNDI is essentially telling us how much space it needs, and\r
-  // it is up to the EFI driver to allocate sufficient, boot-time\r
-  // persistent resources for the call\r
-  //\r
-  SimpleNetworkDevice->DestinationCodeSegmentPages = EFI_SIZE_TO_PAGES (RomIdTableAddress->CodeSize);\r
-  Status = BiosSnp16AllocatePagesBelowOneMb (\r
-            SimpleNetworkDevice->DestinationCodeSegmentPages,\r
-            &SimpleNetworkDevice->DestinationCodeSegment\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "We had a failure in AllocatePages, status code = 0x%X\n", Status));\r
-    return Status;\r
-  }\r
-\r
-  UndiLoaderTable->Undi_Cs = (UINT16) ((UINTN) SimpleNetworkDevice->DestinationCodeSegment >> 4);\r
-\r
-  //\r
-  // these are in the Input and Output Parameter to be sent to the UNDI Loader code\r
-  //\r
-  UndiLoaderTable->Status = 0xAA55;\r
-  //\r
-  // -------------------- Changed by Michael_Huang@3Com.com -----------------\r
-  // UndiLoaderTable->_AX is AX value when UNDI ROM is initialized by BIOS, it is the PCI bus device\r
-  // function of the NIC. Please refer to PXE Spec for detail info.\r
-  // old code is:\r
-  // UndiLoaderTable->Ax       = 0x0;\r
-  // -----------------------------------------------------------------------\r
-  //\r
-  SimpleNetworkDevice->PciIo->GetLocation (\r
-                                SimpleNetworkDevice->PciIo,\r
-                                &PciSegment,\r
-                                &Bus,\r
-                                &Device,\r
-                                &Function\r
-                                );\r
-  UndiLoaderTable->Ax = (UINT16) ((Bus << 0x8) | (Device << 0x3) | (Function));\r
-  UndiLoaderTable->Bx = 0x0;\r
-  UndiLoaderTable->Dx = 0x0;\r
-  UndiLoaderTable->Di = 0x0;\r
-  UndiLoaderTable->Es = 0x0;\r
-\r
-  //\r
-  // set these OUT values to zero in order to ensure that\r
-  // uninitialized memory is not mistaken for display data\r
-  //\r
-  UndiLoaderTable->PXEptr.Offset    = 0;\r
-  UndiLoaderTable->PXEptr.Segment   = 0;\r
-  UndiLoaderTable->PXENVptr.Segment = 0;\r
-  UndiLoaderTable->PXENVptr.Offset  = 0;\r
-\r
-  DEBUG (\r
-    (DEBUG_INIT,\r
-    "The NIC is located at Bus 0x%X, Device 0x%X, Function 0x%X\n\r",\r
-    Bus,\r
-    Device,\r
-    Function)\r
-    );\r
-\r
-  //\r
-  // These are the values that set up the ACTUAL IA32 machine state, whether in\r
-  // Real16 in EFI32 or the IVE for IA64\r
-  // register values are unused except for CS:IP and SS:SP\r
-  //\r
-  InOutRegs.X.AX  = 0;\r
-  InOutRegs.X.BX  = 0;\r
-  InOutRegs.X.CX  = 0;\r
-  InOutRegs.X.DX  = 0;\r
-  InOutRegs.X.SI  = 0;\r
-  InOutRegs.X.DI  = 0;\r
-  InOutRegs.X.BP  = 0;\r
-  InOutRegs.X.DS  = 0;\r
-  InOutRegs.X.ES  = 0;\r
-  //\r
-  // just to be clean\r
-  //\r
-  DEBUG ((DEBUG_NET, "The way this game works is that the SS:SP +4 should point\n\r"));\r
-  DEBUG ((DEBUG_NET, "to the contents of the UndiLoaderTable\n\r"));\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The Undi Loader Table is at address = 0x%X\n\r",\r
-    (UINT32)(UINTN) UndiLoaderTable)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The segment and offsets are 0x%X and 0x%X, resp\n",\r
-    TO_SEGMENT (UndiLoaderTable),\r
-    TO_OFFSET (UndiLoaderTable))\r
-    );\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The Linear Address of the UNDI Loader entry is 0x%X\n",\r
-    RomAddress + RomIdTableAddress->UNDI_Loader)\r
-    );\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The Address offset of the UNDI Loader entry is 0x%X\n",\r
-    RomIdTableAddress->UNDI_Loader)\r
-    );\r
-\r
-  DEBUG ((DEBUG_NET, "Before the call, we have...\n\r"));\r
-  Print_Undi_Loader_Table (UndiLoaderTable);\r
-\r
-  Segment = ((UINT16) (RShiftU64 (RomAddress, 4) & 0xFFFF));\r
-  DEBUG ((DEBUG_NET, "The Segment of the call is 0x%X\n\r", Segment));\r
-\r
-  //\r
-  // make the call into the UNDI Code\r
-  //\r
-  DEBUG ((DEBUG_INIT, "Make the call into the UNDI code now\n\r"));\r
-\r
-  DEBUG ((DEBUG_NET, "\nThe 20-BIt address of the Call, and the location \n\r"));\r
-  DEBUG ((DEBUG_NET, "\twhere we should be able to set a breakpoint is \n\r"));\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "\t\t0x%X, from SEG:OFF 0x%X:0x%X\n\r\n\r",\r
-    Segment * 0x10 + RomIdTableAddress->UNDI_Loader,\r
-    Segment,\r
-    RomIdTableAddress->UNDI_Loader)\r
-    );\r
-\r
-  ThunkFailed = SimpleNetworkDevice->LegacyBios->FarCall86 (\r
-                                                   SimpleNetworkDevice->LegacyBios,\r
-                                                   Segment,  // Input segment\r
-                                                   (UINT16) RomIdTableAddress->UNDI_Loader,  // Offset\r
-                                                   &InOutRegs,                               // Ptr to Regs\r
-                                                   Buffer,                                   // Reference to Stack\r
-                                                   Size                                      // Size of the Stack\r
-                                                   );\r
-  if (ThunkFailed) {\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "The return code UndiLoaderTable->Status is = 0x%X\n\r",\r
-    UndiLoaderTable->Status)\r
-    );\r
-  DEBUG (\r
-    (DEBUG_NET,\r
-    "This error code should match eax, which is = 0x%X\n\r",\r
-    InOutRegs.X.AX)\r
-    );\r
-\r
-  if ((UndiLoaderTable->Status != 0) || (InOutRegs.X.AX != PXENV_EXIT_SUCCESS)) {\r
-    DEBUG ((DEBUG_NET, "LaunchBaseCode exits with error, RomAddress = 0x%X\n\r", RomAddress));\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "Now returned from the UNDI code\n\r"));\r
-\r
-  DEBUG ((DEBUG_NET, "After the call, we have...\n\r"));\r
-  Print_Undi_Loader_Table (UndiLoaderTable);\r
-\r
-  DEBUG ((DEBUG_NET, "Display the PXENV+ and !PXE tables exported by NIC\n\r"));\r
-  Print_PXENV_Table ((VOID *)(((UINTN)UndiLoaderTable->PXENVptr.Segment << 4) | UndiLoaderTable->PXENVptr.Offset));\r
-  Print_PXE_Table ((VOID *)(((UINTN)UndiLoaderTable->PXEptr.Segment << 4) + UndiLoaderTable->PXEptr.Offset));\r
-\r
-  Pxe = (PXE_T *)(((UINTN)UndiLoaderTable->PXEptr.Segment << 4) + UndiLoaderTable->PXEptr.Offset);\r
-  SimpleNetworkDevice->Nii.Id = (UINT64)(UINTN) Pxe;\r
-\r
-  gBS->FreePool (Buffer);\r
-\r
-  //\r
-  // paranoia - make sure a valid !PXE structure\r
-  //\r
-  if (CompareMem (Pxe->Signature, PXE_SIG, sizeof Pxe->Signature) != 0) {\r
-    DEBUG ((DEBUG_ERROR, "!PXE Structure not found....\n\r"));\r
-    return EFI_NOT_FOUND;\r
-    //\r
-    // its not - keep looking\r
-    //\r
-  }\r
-\r
-  if (CalculateSum8 ((UINT8 *) Pxe, Pxe->StructLength) != 0) {\r
-    DEBUG ((DEBUG_ERROR, "!PXE Checksum Error\n\r"));\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if (Pxe->StructLength < (UINT8 *) &Pxe->FirstSelector - (UINT8 *) Pxe->Signature) {\r
-    DEBUG ((DEBUG_ERROR, "!PXE Length Error\n\r"));\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if ((((UINTN) Pxe->Undi.Segment) << 4) + Pxe->Undi.Offset != (UINTN) RomIdTableAddress) {\r
-    DEBUG ((DEBUG_ERROR, "!PXE RomId Address Error\n\r"));\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // This is the magic to bind the global PXE interface\r
-  // This dirtiness is for non-protocol shrouded access\r
-  //\r
-  SimpleNetworkDevice->PxeEntrySegment = Pxe->EntryPointSP.Segment;\r
-\r
-  if (SimpleNetworkDevice->PxeEntrySegment == 0) {\r
-    DEBUG ((DEBUG_ERROR, "!PXE EntryPointSP segment Error\n\r"));\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  SimpleNetworkDevice->PxeEntryOffset = Pxe->EntryPointSP.Offset;\r
-\r
-  DEBUG (\r
-    (\r
-    DEBUG_NET, "The entry point is 0x%X:0x%X\n\r", SimpleNetworkDevice->PxeEntrySegment, SimpleNetworkDevice->\r
-    PxeEntryOffset\r
-    )\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Effect the Far Call into the PXE Layer\r
-\r
-  Note: When using a 32-bit stack segment do not push 32-bit words onto the stack. The PXE API\r
-  services will not work, unless there are three 16-bit parameters pushed onto the stack.\r
-      push DS                                 ;Far pointer to parameter structure\r
-      push offset pxe_data_call_struct        ;is pushed onto stack.\r
-      push Index                              ;UINT16 is pushed onto stack.\r
-      call dword ptr (s_PXE ptr es:[di]).EntryPointSP\r
-      add sp, 6 ;Caller cleans up stack.\r
-\r
-  @param SimpleNetworkDevice    Device instance for simple network\r
-  @param Table                 Point to parameter/retun value table for legacy far call\r
-  @param TableSize              The size of parameter/return value table\r
-  @param CallIndex              The index of legacy call.\r
-\r
-  @return EFI_STATUS\r
-**/\r
-EFI_STATUS\r
-MakePxeCall (\r
-  EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT VOID             *Table,\r
-  IN UINTN                TableSize,\r
-  IN UINT16               CallIndex\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_IA32_REGISTER_SET InOutRegs;\r
-  UINT16                *BPtr;\r
-  VOID                  *Buffer;\r
-  UINTN                 Size;\r
-  VOID                  *MemPageAddress;\r
-  UINTN                 Index;\r
-  BOOLEAN               ThunkFailed;\r
-\r
-  DEBUG ((DEBUG_NET, "MakePxeCall(CallIndex = %02x, Table = %X, TableSize = %d)\n", CallIndex, Table, TableSize));\r
-\r
-  if (SimpleNetworkDevice->PxeEntrySegment == 0 && SimpleNetworkDevice->PxeEntryOffset == 0) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  //\r
-  // Allocate a transient data structure for the argument table\r
-  // This table needs to have the input XXX_t structure copied into here.\r
-  // The PXE UNDI can only grab this table when it's below one-MB, and\r
-  // this implementation will not try to push this table on the stack\r
-  // (although this is a possible optimization path since EFI always allocates\r
-  // 4K as a minimum page size...............)\r
-  //\r
-  Status = BiosSnp16AllocatePagesBelowOneMb (\r
-            TableSize / EFI_PAGE_SIZE + 1,\r
-            &MemPageAddress\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_ERROR, "We had a failure in AllocatePages, status code = 0x%X\n", Status));\r
-    return Status;\r
-  }\r
-  //\r
-  // Copy the > 1MB pool table to a sub-1MB buffer\r
-  //\r
-  CopyMem (MemPageAddress, Table, TableSize);\r
-\r
-  //\r
-  // Allocate space for IA-32 register context\r
-  //\r
-  ZeroMem (&InOutRegs, sizeof (InOutRegs));\r
-  InOutRegs.X.ES  = SimpleNetworkDevice->PxeEntrySegment;\r
-  InOutRegs.X.DI  = SimpleNetworkDevice->PxeEntryOffset;\r
-\r
-  //\r
-  // The game here is to build the stack which will subsequently\r
-  // get copied down below 1 MB by the FarCall primitive.\r
-  // This is now our working stack\r
-  //\r
-  Size = 6;\r
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  Size,\r
-                  &Buffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  BPtr    = (UINT16 *) Buffer;\r
-  *BPtr++ = CallIndex;\r
-  //\r
-  // SP + 2\r
-  //\r
-  *BPtr++ = TO_OFFSET (MemPageAddress);\r
-  *BPtr++ = TO_SEGMENT (MemPageAddress);\r
-\r
-  DEBUG ((DEBUG_NET, "State before FarCall86\n"));\r
-  DEBUG ((DEBUG_NET, "The Buffer is at 0x%X\n\r", Buffer));\r
-  BPtr = (UINT16 *) Buffer;\r
-  DEBUG ((DEBUG_NET, "  Buffer  = %04X %04X %04X", *BPtr, *(BPtr + 1), *(BPtr + 2)));\r
-  DEBUG ((DEBUG_NET, "  MemPage = "));\r
-  for (Index = 0; Index < TableSize; Index++) {\r
-    DEBUG ((DEBUG_NET, " %02x", *((UINT8 *) MemPageAddress + Index)));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "\n"));\r
-\r
-  ThunkFailed = SimpleNetworkDevice->LegacyBios->FarCall86 (\r
-                                                   SimpleNetworkDevice->LegacyBios,\r
-                                                   SimpleNetworkDevice->PxeEntrySegment, // Input segment\r
-                                                   SimpleNetworkDevice->PxeEntryOffset,\r
-                                                   &InOutRegs,                           // Ptr to Regs\r
-                                                   Buffer,                               // Reference to Stack\r
-                                                   6                                     // Size of the Stack\r
-                                                   );\r
-  if (ThunkFailed) {\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "State after FarCall86\n"));\r
-  DEBUG ((DEBUG_NET, "The Buffer is at 0x%X\n\r", Buffer));\r
-  BPtr = (UINT16 *) Buffer;\r
-  DEBUG ((DEBUG_NET, "  Buffer  = %04X %04X %04X", *BPtr, *(BPtr + 1), *(BPtr + 2)));\r
-  DEBUG ((DEBUG_NET, "  MemPage = "));\r
-  for (Index = 0; Index < TableSize; Index++) {\r
-    DEBUG ((DEBUG_NET, " %02x", *((UINT8 *) MemPageAddress + Index)));\r
-  }\r
-\r
-  DEBUG ((DEBUG_NET, "\n"));\r
-\r
-  //\r
-  // Copy the sub 1MB table to > 1MB table\r
-  //\r
-  CopyMem (Table, MemPageAddress, TableSize);\r
-\r
-  //\r
-  // For PXE UNDI call, AX contains the return status.\r
-  // Convert the PXE UNDI Status to EFI_STATUS type\r
-  //\r
-  if (InOutRegs.X.AX == PXENV_EXIT_SUCCESS) {\r
-    Status = EFI_SUCCESS;\r
-  } else {\r
-    Status = EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Clean up house\r
-  //\r
-  gBS->FreePool (Buffer);\r
-  gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) MemPageAddress, TableSize / EFI_PAGE_SIZE + 1);\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Pxe.h b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Pxe.h
deleted file mode 100644 (file)
index 6cecfc4..0000000
+++ /dev/null
@@ -1,606 +0,0 @@
-/** @file\r
-  These are PXE Specification 2.1-compliant data structures and defines.\r
-\r
-  This file relies upon the existence of a PXE-compliant ROM\r
-  in memory, as defined by the Preboot Execution Environment\r
-  Specification (PXE), Version 2.1, located at\r
-\r
-  http://developer.intel.com/ial/wfm/wfmspecs.htm\r
-\r
-Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _PXEDEF_H_\r
-#define _PXEDEF_H_\r
-\r
-#pragma pack(1)\r
-\r
-//\r
-//    PXE structure signatures\r
-//\r
-#define BC_ROMID_SIG        "$BC$"\r
-#define UNDI_ROMID_SIG      "UNDI"\r
-#define BUSD_ROMID_SIG      "BUSD"\r
-\r
-#define PXE_SIG             "!PXE"\r
-#define PXENV_SIG           "PXENV+"\r
-\r
-#define BC_ROMID_REV        0x00\r
-#define UNDI_ROMID_REV      0x00\r
-#define BUSD_ROMID_REV      0x00\r
-\r
-#define PXE_REV             0x00\r
-#define PXENV_REV           0x0201\r
-\r
-#define PXENV_PTR           SIGNATURE_32 ('P', 'X', 'E', 'N')\r
-#define PXE_PTR             SIGNATURE_32 ('!', 'P', 'X', 'E')\r
-#define UNDI_ROMID_SIG_PTR  SIGNATURE_32 ('U', 'N', 'D', 'I')\r
-\r
-typedef UINT16  SEGSEL; // Real mode segment or protected mode selector.\r
-typedef UINT16  OFF16;  // Unsigned 16bit offset.\r
-typedef UINT32  ADDR32;\r
-\r
-//\r
-//    Bus types\r
-//\r
-#define PXENV_BUS_ISA     0\r
-#define PXENV_BUS_EISA    1\r
-#define PXENV_BUS_MCA     2\r
-#define PXENV_BUS_PCI     3\r
-#define PXENV_BUS_VESA    4\r
-#define PXENV_BUS_PCMCIA  5\r
-\r
-//\r
-//\r
-//    Result codes returned in AX by a PXENV API service.\r
-//\r
-#define PXENV_EXIT_SUCCESS  0x0000\r
-#define PXENV_EXIT_FAILURE  0x0001\r
-\r
-//\r
-//    Status codes returned in the status word of PXENV API parameter structures.\r
-//\r
-//    Generic API errors - these do not match up with the M0x or E0x messages\r
-//    that are reported by the loader.\r
-//\r
-#define PXENV_STATUS_SUCCESS          0x00\r
-#define PXENV_STATUS_FAILURE          0x01\r
-#define PXENV_STATUS_BAD_FUNC         0x02\r
-#define PXENV_STATUS_UNSUPPORTED      0x03\r
-#define PXENV_STATUS_KEEP_UNDI        0x04\r
-#define PXENV_STATUS_KEEP_ALL         0x05\r
-#define PXENV_STATUS_OUT_OF_RESOURCES 0x06\r
-\r
-typedef enum {\r
-  PxeEnvStatus_Success,\r
-  PxeEnvStatus_Failure,\r
-  PxeEnvStatus_BadFunc,\r
-  PxeEnvStatus_Unsupported,\r
-  PxeEnvStatus_KeepUndi,\r
-  PxeEnvStatus_KeepAll\r
-} EFI_PXE_STATUS;\r
-\r
-/* Driver errors (0x60 to 0x6F) */\r
-\r
-// These errors are for UNDI compatible NIC drivers.\r
-#define PXENV_STATUS_UNDI_INVALID_FUNCTION          0x60\r
-#define PXENV_STATUS_UNDI_MEDIATEST_FAILED          0x61\r
-#define PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST 0x62\r
-#define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC     0x63\r
-#define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY     0x64\r
-#define PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA   0x65\r
-#define PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA     0x66\r
-#define PXENV_STATUS_UNDI_BAD_MAC_ADDR              0x67\r
-#define PXENV_STATUS_UNDI_BAD_EEPROM_CKSUM          0x68\r
-#define PXENV_STATUS_UNDI_ERROR_SETTING_ISR         0x69\r
-#define PXENV_STATUS_UNDI_INVALID_STATE             0x6A\r
-#define PXENV_STATUS_UNDI_TRANSMIT_ERROR            0x6B\r
-#define PXENV_STATUS_UNDI_INVALID_PARAMETER         0x6C\r
-\r
-typedef struct {\r
-  UINT16  Seg_Addr;\r
-  UINT32  Phy_Addr;\r
-  UINT16  Seg_Size;\r
-} NEWSEGDESC_T;\r
-\r
-typedef struct {\r
-  OFF16   Offset;\r
-  SEGSEL  Segment;\r
-} SEGOFF16;\r
-\r
-typedef struct {\r
-  UINT8   Signature[4]; ///< Structure signature is not NULL terminated.\r
-  UINT8   StructLength; ///< Length of this structure in bytes.\r
-  UINT8   StructCksum;  ///< Use to make byte checksum of this structure == zero.\r
-  UINT8   StructRev;    ///< Structure format revision number.\r
-  UINT8   UNDI_Rev[3];  ///< API revision number stored in Intel order.\r
-  //\r
-  // Revision 2.1.0 == 0x00, 0x01, 0x02\r
-  //\r
-  UINT16  UNDI_Loader;  ///< Offset of UNDI loader routine in the option ROM image.\r
-  UINT16  StackSize;    ///< Minimum stack segment size, in bytes, needed to load and run the UNDI.\r
-  UINT16  DataSize;     ///< UNDI runtime code and data\r
-  UINT16  CodeSize;     ///< segment sizes.\r
-  UINT8   BusType[4];   ///< 'ISAR', 'EISA', 'PCIR', 'PCCR'\r
-} UNDI_ROMID_T;\r
-\r
-typedef struct {\r
-  UINT8   Signature[4]; ///< Structure signature is not NULL terminated.\r
-  UINT8   StructLength; ///< Length of this structure in bytes.\r
-  UINT8   StructCksum;  ///< Use to make byte checksum of this structure == zero.\r
-  UINT8   StructRev;    ///< Structure format revision number.\r
-  UINT8   BC_Rev[3];    ///< API revision number stored in Intel order.\r
-  //\r
-  // Revision 2.1.0 == 0x00, 0x01, 0x02\r
-  //\r
-  UINT16  BC_Loader;          ///< Offset of base-code loader routine in the option ROM image.\r
-  UINT16  StackSize;          ///< Minimum stack segment size (bytes) needed to load/run base-code.\r
-  UINT16  DataSize;           ///< Base-code runtime code and data\r
-  UINT16  CodeSize;           ///< segment sizes.\r
-} BC_ROMID_T;\r
-\r
-typedef struct {\r
-  UINT8         Signature[4]; ///< Structure signature is not NULL terminated.\r
-  UINT8         StructLength; ///< Length of this structure in bytes.\r
-  UINT8         StructCksum;  ///< Use to make byte checksum of this  structure == zero.\r
-  UINT8         StructRev;    ///< Structure format revision number.\r
-  UINT8         Reserved1;    ///< must be zero\r
-  ///\r
-  ///   UNDI_ROMID_T __FAR *UNDI;// Far pointer to UNDI ROMID\r
-  ///\r
-  SEGOFF16      Undi;\r
-\r
-  ///\r
-  ///    BC_ROMID_T __FAR *Base;  //   Far pointer to base-code ROMID\r
-  ///\r
-  SEGOFF16      Base;\r
-\r
-  ///\r
-  ///    UINT16 (__FAR __CDECL *EntryPointSP)(UINT16 func, VOID __FAR *param);\r
-  /// 16bit stack segment API entry point.  This will be seg:off in\r
-  /// real mode and sel:off in 16:16 protected mode.\r
-  ///\r
-  SEGOFF16      EntryPointSP;\r
-\r
-  ///\r
-  ///    UINT16 (__FAR __CDECL *EntryPointESP)(UINT16 func, VOID __FAR *param);\r
-  /// 32bit stack segment API entry point.  This will be sel:off.\r
-  /// In real mode, sel == 0\r
-  ///\r
-  SEGOFF16      EntryPointESP;\r
-  ///\r
-  ///    UINT16 (__FAR __CDECL *StatusCallout)(UINT16 param);\r
-  /// Address of DHCP/TFTP status callout routine.\r
-  ///\r
-  SEGOFF16      StatusCallout;\r
-  UINT8         Reserved2;      ///< must be zero\r
-  UINT8         SegDescCnt;     ///< Number of segment descriptors in this structure.\r
-  UINT16        FirstSelector;  ///< First segment descriptor in GDT assigned to PXE.\r
-  NEWSEGDESC_T  Stack;\r
-  NEWSEGDESC_T  UNDIData;\r
-  NEWSEGDESC_T  UNDICode;\r
-  NEWSEGDESC_T  UNDICodeWrite;\r
-  NEWSEGDESC_T  BC_Data;\r
-  NEWSEGDESC_T  BC_Code;\r
-  NEWSEGDESC_T  BC_CodeWrite;\r
-} PXE_T;\r
-\r
-typedef struct {\r
-  CHAR8       Signature[6];     ///< "PXENV+"\r
-  UINT16      Version;          ///< PXE version number.  LSB is minor version.  MSB is major version.\r
-  UINT8       StructLength;     ///< Length of PXE-2.0 Entry Point structure in bytes.\r
-  UINT8       StructCksum;      ///< Used to make structure checksum equal zero.\r
-  UINT32      RMEntry;          ///< Real mode API entry point  segment:offset.\r
-  UINT32      PMEntryOff;       ///< Protected mode API entry point\r
-  UINT16      PMEntrySeg;       ///< segment:offset.  This will always be zero.  Protected mode API calls\r
-                                ///< must be made through the API entry points in the PXE Runtime ID structure.\r
-\r
-  UINT16      StackSeg;     ///< Real mode stack segment.\r
-  UINT16      StackSize;    ///< Stack segment size in bytes.\r
-  UINT16      BaseCodeSeg;  ///< Real mode base-code code segment.\r
-  UINT16      BaseCodeSize; ///< Base-code code segment size\r
-  UINT16      BaseDataSeg;  ///< Real mode base-code data segment.\r
-  UINT16      BaseDataSize; ///< Base-code data segment size\r
-  UINT16      UNDIDataSeg;  ///< Real mode UNDI data segment.\r
-  UINT16      UNDIDataSize; ///< UNDI data segment size in bytes.\r
-  UINT16      UNDICodeSeg;  ///< Real mode UNDI code segment.\r
-  UINT16      UNDICodeSize; ///< UNDI code segment size in bytes.\r
-  PXE_T       *RuntimePtr;  ///< Real mode segment:offset pointer to PXE Runtime ID structure.\r
-} PXENV_T;\r
-\r
-typedef struct {\r
-  OUT UINT16    Status;\r
-  IN OUT UINT16 Ax;\r
-  IN OUT UINT16 Bx;\r
-  IN OUT UINT16 Dx;\r
-  IN OUT UINT16 Di;\r
-  IN OUT UINT16 Es;\r
-  IN OUT UINT16 Undi_Ds;\r
-  IN OUT UINT16 Undi_Cs;\r
-  OUT SEGOFF16  PXEptr;\r
-  OUT SEGOFF16  PXENVptr;\r
-} UNDI_LOADER_T;\r
-\r
-//\r
-//  Put in some UNDI-specific arguments\r
-//\r
-#define PXENV_START_UNDI              0x0000\r
-#define PXENV_UNDI_STARTUP            0x0001\r
-#define PXENV_UNDI_CLEANUP            0x0002\r
-#define PXENV_UNDI_INITIALIZE         0x0003\r
-#define PXENV_UNDI_RESET_NIC          0x0004\r
-#define PXENV_UNDI_SHUTDOWN           0x0005\r
-#define PXENV_UNDI_OPEN               0x0006\r
-#define PXENV_UNDI_CLOSE              0x0007\r
-#define PXENV_UNDI_TRANSMIT           0x0008\r
-#define PXENV_UNDI_SET_MCAST_ADDR     0x0009\r
-#define PXENV_UNDI_SET_STATION_ADDR   0x000A\r
-#define PXENV_UNDI_SET_PACKET_FILTER  0x000B\r
-#define PXENV_UNDI_GET_INFORMATION    0x000C\r
-#define PXENV_UNDI_GET_STATISTICS     0x000D\r
-#define PXENV_UNDI_CLEAR_STATISTICS   0x000E\r
-#define PXENV_UNDI_INITIATE_DIAGS     0x000F\r
-#define PXENV_UNDI_FORCE_INTERRUPT    0x0010\r
-#define PXENV_UNDI_GET_MCAST_ADDR     0x0011\r
-#define PXENV_UNDI_GET_NIC_TYPE       0x0012\r
-#define PXENV_UNDI_GET_NDIS_INFO      0x0013\r
-#define PXENV_UNDI_ISR                0x0014\r
-#define PXENV_STOP_UNDI               0x0015\r
-#define PXENV_UNDI_GET_STATE          0x0016\r
-\r
-#define ADDR_LEN                      16\r
-#define MAXNUM_MCADDR                 8\r
-#define IPLEN                         4       ///< length of an IP address\r
-#define XMT_DESTADDR                  0x0000  ///< destination address given\r
-#define XMT_BROADCAST                 0x0001  ///< use broadcast address\r
-\r
-typedef struct {\r
-  UINT16  MCastAddrCount;                     ///< In: Number of multi-cast\r
-\r
-  /* addresses. */\r
-  UINT8   MCastAddr[MAXNUM_MCADDR][ADDR_LEN]; /* In: */\r
-\r
-  /* list of multi-cast addresses. */\r
-\r
-  /* Each address can take up to */\r
-\r
-  /* ADDR_LEN bytes and a maximum */\r
-\r
-  /* of MAXNUM_MCADDR address can */\r
-\r
-  /* be provided*/\r
-} PXENV_UNDI_MCAST_ADDR_T;\r
-\r
-/* Definitions of TFTP API parameter structures.\r
- */\r
-typedef struct {\r
-  OUT UINT16  Status;       ///< Out: PXENV_STATUS_xxx\r
-  IN UINT16   Ax;           ///< In: These register fields must be\r
-  IN UINT16   Bx;           ///<     filled in with the same data\r
-  IN UINT16   Dx;           ///<     that was passed to the MLID\r
-  IN UINT16   Di;           ///<     option ROM boot code by the\r
-  IN UINT16   Es;           ///<     system BIOS.\r
-} PXENV_START_UNDI_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;       ///< Out: PXENV_STATUS_xxx\r
-} PXENV_UNDI_STARTUP_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;       ///< Out: PXENV_STATUS_xxx\r
-} PXENV_UNDI_CLEANUP_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;       ///< Out: PXENV_STATUS_xxx\r
-\r
-  ///\r
-  ///  This is an input parameter and is a 32-bit physical address of\r
-  ///  a memory  copy of the  driver module in  the protocol.ini file\r
-  ///  obtained from the  Protocol Manager  driver(refer to  NDIS 2.0\r
-  ///  specifications).   This parameter  is basically  supported for\r
-  ///  the universal NDIS driver to pass the information contained in\r
-  ///  protocol.ini   file  to  the  NIC   driver  for  any  specific\r
-  ///  configuration of   the   NIC.      (Note   that   the   module\r
-  ///  identification in the  protocol.ini  file  was  done  by  NDIS\r
-  ///  itself.)  This value can be NULL for for any other application\r
-  ///  interfacing to the Universal NIC Driver.\r
-  ///\r
-  IN UINT32   ProtocolIni;\r
-  UINT8       Reserved[8];\r
-} PXENV_UNDI_INITIALIZE_T;\r
-\r
-typedef struct {\r
-  OUT UINT16                  Status;       ///< Out: PXENV_STATUS_xxx\r
-  IN PXENV_UNDI_MCAST_ADDR_T  R_Mcast_Buf;  ///< multicast address list\r
-  /* see note below  */\r
-} PXENV_UNDI_RESET_T;\r
-\r
-/*++\r
-    Note: The  NIC  driver  does  not  remember  the  multicast\r
-    addresses provided in any  call.    So  the  application  must\r
-    provide the multicast address  list with all  the calls that\r
-    reset the receive unit of the adapter.\r
-  --*/\r
-typedef struct {\r
-  OUT UINT16  Status;                     ///< Out: PXENV_STATUS_xxx\r
-} PXENV_UNDI_SHUTDOWN_T;\r
-\r
-typedef struct {\r
-  OUT UINT16                  Status;     ///< Out: PXENV_STATUS_xxx\r
-\r
-  ///\r
-  ///  This is  an input parameter and is  adapter specific.  This is\r
-  ///  supported  for Universal NDIS 2.0 driver to pass down the Open\r
-  ///  flags  provided  by   the  protocol   driver  (See   NDIS  2.0\r
-  ///  specifications).  This can be zero.\r
-  ///\r
-  IN UINT16                   OpenFlag;   ///< In: See description below\r
-  IN UINT16                   PktFilter;  ///< In: Filter for receiving\r
-\r
-  /* packet. It takes the following */\r
-\r
-  /* values, multiple values can be */\r
-\r
-  /* ORed together. */\r
-#define FLTR_DIRECTED 0x0001                ///< directed/multicast\r
-#define FLTR_BRDCST   0x0002                ///< broadcast packets\r
-#define FLTR_PRMSCS   0x0004                ///< any packet on LAN\r
-#define FLTR_SRC_RTG  0x0008                ///< source routing packet\r
-  IN PXENV_UNDI_MCAST_ADDR_T  McastBuffer;  /* In: */\r
-  /* See t_PXENV_UNDI_MCAST_ADDR. */\r
-} PXENV_UNDI_OPEN_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status; ///< Out: PXENV_STATUS_xxx\r
-} PXENV_UNDI_CLOSE_T;\r
-\r
-#define MAX_DATA_BLKS 8\r
-\r
-typedef struct {\r
-  IN UINT16 ImmedLength;  ///< In: Data buffer length in\r
-\r
-  /* bytes. */\r
-  UINT16    XmitOffset;   ///< 16-bit segment & offset of the\r
-  UINT16    XmitSegment;  ///< immediate data buffer.\r
-  UINT16    DataBlkCount; ///< In: Number of data blocks.\r
-  struct DataBlk {\r
-    UINT8   TDPtrType;    ///< 0 => 32 bit Phys pointer in TDDataPtr, not supported in this version of LSA\r
-                          ///< 1 => seg:offser in TDDataPtr which can be a real mode or 16-bit protected mode pointer\r
-    UINT8   TDRsvdByte;         ///< Reserved, must be zero.\r
-    UINT16  TDDataLen;          ///< Data block length in bytes.\r
-    UINT16  TDDataPtrOffset;    ///< Far pointer to data buffer.\r
-    UINT16  TDDataPtrSegment;   ///< Far pointer to data buffer.\r
-  } DataBlock[MAX_DATA_BLKS];\r
-}\r
-PXENV_UNDI_TBD_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;           ///< Out: PXENV_STATUS_xxx\r
-\r
-  ///\r
-  ///  This is the protocol  of  the  upper  layer  that  is  calling\r
-  ///  NICTransmit call.   If the  upper layer  has filled  the media\r
-  ///  header this field must be 0.\r
-  ///\r
-  IN UINT8    Protocol;\r
-#define P_UNKNOWN 0\r
-#define P_IP      1\r
-#define P_ARP     2\r
-#define P_RARP    3\r
-\r
-  ///\r
-  ///  If  this flag is  0, the NIC  driver expects a  pointer to the\r
-  ///  destination media  address in the field  DestMediaAddr.  If 1,\r
-  ///  the   NIC  driver   fills  the   broadcast  address   for  the\r
-  ///  destination.\r
-  ///\r
-  IN UINT8    XmitFlag;\r
-#define XMT_DESTADDR  0x0000    ///< destination address given\r
-#define XMT_BROADCAST 0x0001    ///< use broadcast address\r
-\r
-  ///\r
-  ///  This  is a pointer to the  hardware address of the destination\r
-  ///  media.  It  can be  null if  the destination  is not  known in\r
-  ///  which case the XmitFlag contains 1 for broadcast.  Destination\r
-  ///  media address  must be  obtained by  the upper  level protocol\r
-  ///  (with  Address Resolution Protocol) and NIC driver does not do\r
-  ///  any address resolution.\r
-  ///\r
-  IN UINT16   DestAddrOffset;   ///< 16-bit segment & offset of the\r
-  IN UINT16   DestAddrSegment;  ///< destination media address\r
-\r
-\r
-  IN UINT16   TBDOffset;  ///< 16-bit segment & offset of the\r
-  IN UINT16   TBDSegment; ///< transmit buffer descriptor of type\r
-\r
-  /// XmitBufferDesc\r
-  IN UINT32   Reserved[2];\r
-} PXENV_UNDI_TRANSMIT_T;\r
-\r
-\r
-typedef struct {\r
-  OUT UINT16                  Status;       ///<  Out: PXENV_STATUS_xxx\r
-  IN PXENV_UNDI_MCAST_ADDR_T  McastBuffer;  ///<  In:\r
-} PXENV_UNDI_SET_MCAST_ADDR_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;                   ///< Out: PXENV_STATUS_xxx\r
-  IN UINT8    StationAddress[ADDR_LEN]; ///< new address to be set\r
-} PXENV_UNDI_SET_STATION_ADDR_T;\r
-\r
-typedef struct s_PXENV_UNDI_SET_PACKET_FILTER {\r
-  OUT UINT16  Status;                   ///< Out: PXENV_STATUS_xxx\r
-  IN UINT8    Filter;                   ///< In: Receive filter value.\r
-} PXENV_UNDI_SET_PACKET_FILTER_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;       ///< Out: PXENV_STATUS_xxx\r
-  OUT UINT16  BaseIo;       ///< Out: Adapter's Base IO\r
-  OUT UINT16  IntNumber;    ///< Out: IRQ number\r
-  OUT UINT16  MaxTranUnit;  ///< Out: MTU\r
-  OUT UINT16  HwType;       ///< Out: type of protocol at hardware level\r
-\r
-#define ETHER_TYPE      1\r
-#define EXP_ETHER_TYPE  2\r
-#define IEEE_TYPE       6\r
-#define ARCNET_TYPE     7\r
-  /*++\r
-        other numbers can  be obtained from  rfc1010 for "Assigned\r
-        Numbers".  This number may not be validated by the application\r
-        and hence adding new numbers to the list should be fine at any\r
-        time.\r
-    --*/\r
-  OUT UINT16  HwAddrLen;                    ///< Out: actual length of hardware address\r
-  OUT UINT8   CurrentNodeAddress[ADDR_LEN]; ///< Out: Current hardware address\r
-  OUT UINT8   PermNodeAddress[ADDR_LEN];    ///< Out: Permanent hardware address\r
-  OUT UINT16  ROMAddress;                   ///< Out: ROM address\r
-  OUT UINT16  RxBufCt;                      ///< Out: receive Queue length\r
-  OUT UINT16  TxBufCt;                      ///< Out: Transmit Queue length\r
-} PXENV_UNDI_GET_INFORMATION_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;                       ///< Out: PXENV_STATUS_xxx\r
-  OUT UINT32  XmtGoodFrames;                ///< Out: No. of good transmissions\r
-  OUT UINT32  RcvGoodFrames;                ///< Out: No. of good frames received\r
-  OUT UINT32  RcvCRCErrors;                 ///< Out: No. of frames with CRC error\r
-  OUT UINT32  RcvResourceErrors;            ///< Out: no. of frames discarded\r
-  /* Out: receive Queue full */\r
-} PXENV_UNDI_GET_STATISTICS_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;               ///< Out: PXENV_STATUS_xxx\r
-} PXENV_UNDI_CLEAR_STATISTICS_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;               ///< Out: PXENV_STATUS_xxx\r
-} PXENV_UNDI_INITIATE_DIAGS_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;               ///< Out: PXENV_STATUS_xxx\r
-} PXENV_UNDI_FORCE_INTERRUPT_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;               ///< Out: PXENV_STATUS_xxx\r
-  IN UINT32   InetAddr;             ///< In: IP Multicast Address\r
-  OUT UINT8   MediaAddr[ADDR_LEN];  ///< Out: corresponding hardware\r
-  /*      multicast address */\r
-} PXENV_UNDI_GET_MCAST_ADDR_T;\r
-\r
-typedef struct {\r
-    OUT UINT16  Vendor_ID;  ///< OUT:\r
-    OUT UINT16  Dev_ID;     ///< OUT:\r
-    OUT UINT8   Base_Class; ///< OUT:\r
-    OUT UINT8   Sub_Class;  ///< OUT:\r
-    OUT UINT8   Prog_Intf;  ///< OUT: program interface\r
-    OUT UINT8   Rev;        ///< OUT: Revision number\r
-    OUT UINT16  BusDevFunc; ///< OUT: Bus, Device  & Function numbers\r
-    OUT UINT16  SubVendor_ID; ///< OUT:\r
-    OUT UINT16  SubDevice_ID; ///< OUT:\r
-} PCI_INFO_T;\r
-\r
-typedef struct {\r
-    OUT UINT32  EISA_Dev_ID;  ///< Out:\r
-    OUT UINT8   Base_Class;   ///< OUT:\r
-    OUT UINT8   Sub_Class;    ///< OUT:\r
-    OUT UINT8   Prog_Intf;    ///< OUT: program interface\r
-    OUT UINT16  CardSelNum;   ///< OUT: Card Selector Number\r
-    OUT UINT8   Reserved;     ///< to make it 10 bytes\r
-} PNP_INFO_T;\r
-\r
-\r
-typedef union {\r
-  PCI_INFO_T Pci;\r
-  PNP_INFO_T Pnp;\r
-} PCI_PNP_INFO_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;         ///< OUT: PXENV_STATUS_xxx\r
-  OUT UINT8   NicType;        ///< OUT: 2=PCI, 3=PnP\r
-  PCI_PNP_INFO_T PciPnpInfo;\r
-} PXENV_UNDI_GET_NIC_TYPE_T;\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;           ///< OUT: PXENV_STATUS_xxx\r
-  OUT UINT8   IfaceType[16];    ///< OUT: Type name of MAC, AsciiZ\r
-\r
-  /*      format.  This is used by the */\r
-\r
-  /*      Universal NDIS Driver to fill */\r
-\r
-  /*      the driver type in it's MAC */\r
-\r
-  /*      Service specific */\r
-\r
-  /*      characteristic table */\r
-  OUT UINT32  LinkSpeed;    ///< OUT:\r
-  OUT UINT32  ServiceFlags; ///< OUT: as defined in NDIS Spec 2.0X\r
-  OUT UINT32  Reserved[4];  ///< OUT: will be filled with 0s till defined\r
-} PXENV_UNDI_GET_NDIS_INFO_T;\r
-\r
-typedef struct {\r
-  OUT UINT16    Status;   ///< OUT: PXENV_STATUS_xxx\r
-  IN OUT UINT16 FuncFlag; ///< In: PXENV_UNDI_ISR_IN_xxx\r
-\r
-  /* Out: PXENV_UNDI_ISR_OUT_xxx */\r
-  OUT UINT16    BufferLength;\r
-  OUT UINT16    FrameLength;\r
-  OUT UINT16    FrameHeaderLength;\r
-  OUT UINT16    FrameOffset;\r
-  OUT UINT16    FrameSegSel;\r
-  OUT UINT8     ProtType;\r
-  OUT UINT8     PktType;\r
-} PXENV_UNDI_ISR_T;\r
-\r
-#define PXENV_UNDI_ISR_IN_START 1 /* This function must be first */\r
-\r
-/* when an interrupt is received. */\r
-\r
-/* It will tell us if the intr */\r
-\r
-/* was generated by our device. */\r
-#define PXENV_UNDI_ISR_IN_PROCESS 2 /* Call to start processing one of */\r
-\r
-/* our interrupts. */\r
-#define PXENV_UNDI_ISR_IN_GET_NEXT  3 /* Call to start/continue receiving */\r
-\r
-/* data from receive buffer(s). */\r
-\r
-/*++\r
-\r
-     Possible responses from PXENV_UNDI_ISR_IN_START\r
-\r
- --*/\r
-#define PXENV_UNDI_ISR_OUT_OURS 0 ///< This is our interrupt.  Deal  with it.\r
-#define PXENV_UNDI_ISR_OUT_NOT_OURS 1 ///< This is not our interrupt.\r
-\r
-/*++\r
-\r
-     Possible responses from PXENV_UNDI_ISR_IN_PROCESS and\r
-     PXENV_UNDI_ISR_IN_PROCESS\r
-\r
---*/\r
-#define PXENV_UNDI_ISR_OUT_DONE 0       ///< We are done processing this  interrupt.\r
-#define PXENV_UNDI_ISR_OUT_TRANSMIT 2   ///< We completed a transmit interrupt.\r
-#define PXENV_UNDI_ISR_OUT_RECEIVE  3   ///< Get data from receive buffer.\r
-\r
-#define PXENV_UNDI_ISR_OUT_BUSY     4 /* ? */\r
-\r
-typedef struct {\r
-  UINT16  Status;                     ///< Out: PXENV_STATUS_xxx\r
-} PXENV_STOP_UNDI_T;\r
-\r
-#define PXENV_UNDI_STARTED      1     ///< not even initialized\r
-#define PXENV_UNDI_INITIALIZED  2     ///< initialized and closed (not opened)\r
-#define PXENV_UNDI_OPENED       3     ///< initialized & opened\r
-\r
-typedef struct {\r
-  OUT UINT16  Status;                 ///< Out: PXENV_STATUS_xxx\r
-  UINT16      UNDI_State;\r
-} PXENV_UNDI_GET_STATE_T;\r
-\r
-#pragma pack()\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/PxeUndi.c b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/PxeUndi.c
deleted file mode 100644 (file)
index 5926185..0000000
+++ /dev/null
@@ -1,1156 +0,0 @@
-/** @file\r
-  Wrapper routines that use a PXE-enabled NIC option ROM to\r
-  supply internal routines for an EFI SNI (Simple Network\r
-  Interface) Protocol.\r
-\r
-  This file relies upon the existence of a PXE-compliant ROM\r
-  in memory, as defined by the Preboot Execution Environment\r
-  Specification (PXE), Version 2.1, located at\r
-\r
-  http://developer.intel.com/ial/wfm/wfmspecs.htm\r
-\r
-Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosSnp16.h"\r
-\r
-/**\r
-  PXE\r
-  START UNDI\r
-  Op-Code: PXENV_START_UNDI (0000h)\r
-  Input: Far pointer to a PXENV_START_UNDI_T parameter structure that has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This service is used to pass the BIOS parameter registers to the UNDI driver. The UNDI driver is\r
-  responsible for saving the information it needs to communicate with the hardware.\r
-  This service is also responsible for hooking the Int 1Ah service routine\r
-  Note: This API service must be called only once during UNDI Option ROM boot.\r
-  The UNDI driver is responsible for saving this information and using it every time\r
-  PXENV_UNDI_STARTUP is called.\r
-  Service cannot be used in protected mode.\r
-  typedef struct  {\r
-      PXENV_STATUS Status;\r
-      UINT16 AX;\r
-      UINT16 BX;\r
-      UINT16 DX;\r
-      UINT16 DI;\r
-      UINT16 ES;\r
-  } PXENV_START_UNDI_T;\r
-  Set before calling API service\r
-  AX, BX, DX, DI, ES: BIOS initialization parameter registers. These\r
-  fields should contain the same information passed to the option ROM\r
-  initialization routine by the Host System BIOS. Information about the\r
-  contents of these registers can be found in the [PnP], [PCI] and\r
-  [BBS] specifications.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeStartUndi (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_START_UNDI_T      *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_START_UNDI_T),\r
-          PXENV_START_UNDI\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI STARTUP\r
-  Op-Code: PXENV_UNDI_STARTUP (0001h)\r
-  Input: Far pointer to a PXENV_UNDI_STARTUP_T parameter structure that has been initialized by the\r
-  caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This API is responsible for initializing the contents of the UNDI code & data segment for proper\r
-  operation. Information from the !PXE structure and the first PXENV_START_UNDI API call is used\r
-  to complete this initialization. The rest of the UNDI APIs will not be available until this call has\r
-  been completed.\r
-  Note: PXENV_UNDI_STARTUP must not be called again without first calling\r
-  PXENV_UNDI_SHUTDOWN.\r
-  PXENV_UNDI_STARTUP and PXENV_UNDI_SHUTDOWN are no longer responsible for\r
-  chaining interrupt 1Ah. This must be done by the PXENV_START_UNDI and\r
-  PXENV_STOP_UNDI API calls.\r
-  This service cannot be used in protected mode.\r
-  typedef struct\r
-  {\r
-      PXENV_STATUS Status;\r
-  } PXENV_UNDI_STARTUP_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiStartup (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_STARTUP_T    *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_STARTUP_T),\r
-          PXENV_UNDI_STARTUP\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI CLEANUP\r
-  Op-Code: PXENV_UNDI_CLEANUP (0002h)\r
-  Input: Far pointer to a PXENV_UNDI_CLEANUP_T parameter structure.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field\r
-  in the parameter structure must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This call will prepare the network adapter driver to be unloaded from memory. This call must be\r
-  made just before unloading the Universal NIC Driver. The rest of the API will not be available\r
-  after this call executes.\r
-  This service cannot be used in protected mode.\r
-  typedef struct {\r
-      PXENX_STATUS Status;\r
-  } PXENV_UNDI_CLEANUP_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiCleanup (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_CLEANUP_T    *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_CLEANUP_T),\r
-          PXENV_UNDI_CLEANUP\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI INITIALIZE\r
-  Op-Code: PXENV_UNDI_INITIALIZE (0003h)\r
-  Input: Far pointer to a PXENV_UNDI_INITIALIZE_T parameter structure that has been initialized by the\r
-  caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call resets the adapter and programs it with default parameters. The default parameters used\r
-  are those supplied to the most recent UNDI_STARTUP call. This routine does not enable the\r
-  receive and transmit units of the network adapter to readily receive or transmit packets. The\r
-  application must call PXENV_UNDI_OPEN to logically connect the network adapter to the network.\r
-  This call must be made by an application to establish an interface to the network adapter driver.\r
-  Note: When the PXE code makes this call to initialize the network adapter, it passes a NULL pointer for\r
-  the Protocol field in the parameter structure.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    ADDR32 ProtocolIni;\r
-    UINT8 reserved[8];\r
-  } PXENV_UNDI_INITIALIZE_T;\r
-  Set before calling API service\r
-  ProtocolIni: Physical address of a memory copy of the driver\r
-  module from the protocol.ini file obtained from the protocol manager\r
-  driver (refer to the NDIS 2.0 specification). This parameter is\r
-  supported for the universal NDIS driver to pass the information\r
-  contained in the protocol.ini file to the NIC driver for any specific\r
-  configuration of the NIC. (Note that the module identification in the\r
-  protocol.ini file was done by NDIS.) This value can be NULL for any\r
-  other application interfacing to the universal NIC driver\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiInitialize (\r
-  IN     EFI_SIMPLE_NETWORK_DEV   *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_INITIALIZE_T  *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_INITIALIZE_T),\r
-          PXENV_UNDI_INITIALIZE\r
-          );\r
-}\r
-\r
-/**\r
-  Wrapper routine for reset adapter.\r
-\r
-  PXE\r
-  UNDI RESET ADAPTER\r
-  Op-Code: PXENV_UNDI_RESET_ADAPTER (0004h)\r
-  Input: Far pointer to a PXENV_UNDI_RESET_ADAPTER_t parameter structure that has been initialized\r
-  by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call resets and reinitializes the network adapter with the same set of parameters supplied to\r
-  Initialize Routine. Unlike Initialize, this call opens the adapter that is, it connects logically to the\r
-  network. This routine cannot be used to replace Initialize or Shutdown calls.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    PXENV_UNDI_MCAST_ADDRESS_t    R_Mcast_Buf;\r
-  } PXENV_UNDI_RESET_T;\r
-\r
-  #define MAXNUM_MCADDR 8\r
-\r
-  typedef struct {\r
-    UINT16 MCastAddrCount;\r
-    MAC_ADDR McastAddr[MAXNUM_MCADDR];\r
-  } PXENV_UNDI_MCAST_ADDRESS_t;\r
-\r
-  Set before calling API service\r
-  R_Mcast_Buf: This is a structure of MCastAddrCount and\r
-  McastAddr.\r
-  MCastAddrCount: Number of multicast MAC addresses in the\r
-  buffer.\r
-  McastAddr: List of up to MAXNUM_MCADDR multicast MAC\r
-  addresses.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance.\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-  @param  RxFilter             Filter setting mask value for PXE recive .\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiResetNic (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_RESET_T      *PxeUndiTable,\r
-  IN     UINT16                  RxFilter\r
-  )\r
-{\r
-  PXENV_UNDI_OPEN_T   Open;\r
-  PXENV_UNDI_CLOSE_T  Close;\r
-  UINTN               Status;\r
-\r
-  Status = MakePxeCall (\r
-            SimpleNetworkDevice,\r
-            PxeUndiTable,\r
-            sizeof (PXENV_UNDI_RESET_T),\r
-            PXENV_UNDI_RESET_NIC\r
-            );\r
-  if (!EFI_ERROR(Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Close.Status = PXENV_STATUS_SUCCESS;\r
-\r
-  Status = MakePxeCall (\r
-            SimpleNetworkDevice,\r
-            &Close,\r
-            sizeof (Close),\r
-            PXENV_UNDI_CLOSE\r
-            );\r
-  if (EFI_ERROR(Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Status = MakePxeCall (\r
-            SimpleNetworkDevice,\r
-            PxeUndiTable,\r
-            sizeof (PXENV_UNDI_RESET_T),\r
-            PXENV_UNDI_RESET_NIC\r
-            );\r
-  if (EFI_ERROR(Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Open.Status       = PXENV_STATUS_SUCCESS;\r
-  Open.OpenFlag     = 0;\r
-  Open.PktFilter    = RxFilter;\r
-  CopyMem (\r
-    &Open.McastBuffer,\r
-    &PxeUndiTable->R_Mcast_Buf,\r
-    sizeof (PXENV_UNDI_MCAST_ADDR_T)\r
-    );\r
-\r
-\r
-  Status = MakePxeCall (\r
-            SimpleNetworkDevice,\r
-            &Open,\r
-            sizeof (Open),\r
-            PXENV_UNDI_OPEN\r
-            );\r
-  if (EFI_ERROR(Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI SHUTDOWN\r
-  Op-Code: PXENV_UNDI_SHUTDOWN (0005h)\r
-  Input: Far pointer to a PXENV_UNDI_SHUTDOWN_T parameter.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call resets the network adapter and leaves it in a safe state for another driver to program it.\r
-  Note: The contents of the PXENV_UNDI_STARTUP parameter structure need to be saved by the\r
-  Universal NIC Driver in case PXENV_UNDI_INITIALIZE is called again.\r
-  typedef struct\r
-  {\r
-    PXENV_STATUS Status;\r
-  } PXENV_UNDI_SHUTDOWN_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiShutdown (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_SHUTDOWN_T   *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_SHUTDOWN_T),\r
-          PXENV_UNDI_SHUTDOWN\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI OPEN\r
-  Op-Code: PXENV_UNDI_OPEN (0006h)\r
-  Input: Far pointer to a PXENV_UNDI_OPEN_T parameter structure that has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call activates the adapter network connection and sets the adapter ready to accept packets\r
-  for transmit and receive.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    UINT16 OpenFlag;\r
-    UINT16 PktFilter;\r
-      #define FLTR_DIRECTED 0x0001\r
-      #define FLTR_BRDCST 0x0002\r
-      #define FLTR_PRMSCS 0x0004\r
-      #define FLTR_SRC_RTG 0x0008\r
-    PXENV_UNDI_MCAST_ADDRESS_t R_Mcast_Buf;\r
-  } PXENV_UNDI_OPEN_T;\r
-  Set before calling API service\r
-  OpenFlag: This is an adapter specific input parameter. This is\r
-  supported for the universal NDIS 2.0 driver to pass in the open flags\r
-  provided by the protocol driver. (See the NDIS 2.0 specification.)\r
-  This can be zero.\r
-  PktFilter: Filter for receiving packets. This can be one, or more, of\r
-  the FLTR_xxx constants. Multiple values are arithmetically or-ed\r
-  together.\r
-  directed packets are packets that may come to your MAC address\r
-  or the multicast MAC address.\r
-  R_Mcast_Buf: See definition in UNDI RESET ADAPTER (0004h).\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiOpen (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_OPEN_T       *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_OPEN_T),\r
-          PXENV_UNDI_OPEN\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI CLOSE\r
-  Op-Code: PXENV_UNDI_CLOSE (0007h)\r
-  Input: Far pointer to a PXENV_UNDI_CLOSE_T parameter.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call disconnects the network adapter from the network. Packets cannot be transmitted or\r
-  received until the network adapter is open again.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-  } PXENV_UNDI_CLOSE_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiClose (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_CLOSE_T      *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_CLOSE_T),\r
-          PXENV_UNDI_CLOSE\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI TRANSMIT PACKET\r
-  Op-Code: PXENV_UNDI_TRANSMIT (0008h)\r
-  Input: Far pointer to a PXENV_UNDI_TRANSMIT_T parameter structure that\r
-  has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX.\r
-  The status code must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This call transmits a buffer to the network. The media header\r
-  for the packet can be filled by the calling protocol, but it might not be.\r
-  The network adapter driver will fill it if required by the values in the\r
-  parameter block. The packet is buffered for transmission provided there is\r
-  an available buffer, and the function returns PXENV_EXIT_SUCCESS. If no\r
-  buffer is available the function returns PXENV_EXIT_FAILURE with a status\r
-  code of PXE_UNDI_STATUS__OUT OF_RESOURCE. The number of buffers is\r
-  implementation-dependent. An interrupt is generated on completion of the\r
-  transmission of one or more packets. A call to PXENV_UNDI_TRANSMIT is\r
-  permitted in the context of a transmit complete interrupt.\r
-\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    UINT8 Protocol;\r
-      #define P_UNKNOWN 0\r
-      #define P_IP 1\r
-      #define P_ARP 2\r
-      #define P_RARP 3\r
-    UINT8 XmitFlag;\r
-      #define XMT_DESTADDR 0x0000\r
-      #define XMT_BROADCAST 0x0001\r
-    SEGOFF16 DestAddr;\r
-    SEGOFF16 TBD;\r
-    UINT32 Reserved[2];\r
-  } t_PXENV_UNDI_TRANSMIT;\r
-\r
-  #define MAX_DATA_BLKS 8\r
-\r
-  typedef struct {\r
-    UINT16 ImmedLength;\r
-    SEGOFF16 Xmit;\r
-    UINT16 DataBlkCount;\r
-    struct DataBlk {\r
-      UINT8 TDPtrType;\r
-      UINT8 TDRsvdByte;\r
-      UINT16 TDDataLen;\r
-      SEGOFF16 TDDataPtr;\r
-    } DataBlock[MAX_DATA_BLKS];\r
-  } PXENV_UNDI_TBD_T\r
-\r
-  Set before calling API service\r
-  Protocol: This is the protocol of the upper layer that is calling UNDI\r
-  TRANSMIT call. If the upper layer has filled the media header, this\r
-  field must be P_UNKNOWN.\r
-  XmitFlag: If this flag is XMT_DESTADDR, the NIC driver expects a\r
-  pointer to the destination media address in the field DestAddr. If\r
-  XMT_BROADCAST, the NIC driver fills the broadcast address for the\r
-  destination.\r
-  TBD: Segment:Offset address of the transmit buffer descriptor.\r
-  ImmedLength: Length of the immediate transmit buffer: Xmit.\r
-  Xmit: Segment:Offset of the immediate transmit buffer.\r
-  DataBlkCount: Number of blocks in this transmit buffer.\r
-  TDPtrType:\r
-  0 => 32-bit physical address in TDDataPtr (not supported in this\r
-  version of PXE)\r
-  1 => segment:offset in TDDataPtr which can be a real mode or 16-bit\r
-  protected mode pointer\r
-  TDRsvdByte: Reserved must be zero.\r
-  TDDatalen: Data block length in bytes.\r
-  TDDataPtr: Segment:Offset of the transmit block.\r
-  DataBlock: Array of transmit data blocks.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiTransmit (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_TRANSMIT_T   *PxeUndiTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = MakePxeCall (\r
-            SimpleNetworkDevice,\r
-            PxeUndiTable,\r
-            sizeof (PXENV_UNDI_TRANSMIT_T),\r
-            PXENV_UNDI_TRANSMIT\r
-            );\r
-  if (Status == EFI_SUCCESS) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  switch (PxeUndiTable->Status) {\r
-  case PXENV_STATUS_OUT_OF_RESOURCES:\r
-    return EFI_NOT_READY;\r
-\r
-  default:\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-}\r
-\r
-\r
-\r
-/**\r
-  PXE\r
-  UNDI SET STATION ADDRESS\r
-  Op-Code: PXENV_UNDI_SET_STATION_ADDRESS (000Ah)\r
-  Input: Far pointer to a PXENV_UNDI_SET_STATION_ADDRESS_t parameter structure that has been\r
-  initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call sets the MAC address to be the input value and is called before opening the network\r
-  adapter. Later, the open call uses this variable as a temporary MAC address to program the\r
-  adapter individual address registers.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    MAC_ADDR StationAddress;\r
-  } PXENV_UNDI_SET_STATION_ADDR_T;\r
-  Set before calling API service\r
-  StationAddress: Temporary MAC address to be used for\r
-  transmit and receive.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiSetStationAddr (\r
-  IN     EFI_SIMPLE_NETWORK_DEV         *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_SET_STATION_ADDR_T  *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_SET_STATION_ADDR_T),\r
-          PXENV_UNDI_SET_STATION_ADDR\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI SET PACKET FILTER\r
-  Op-Code: PXENV_UNDI_SET_PACKET_FILTER (000Bh)\r
-  Input: Far pointer to a PXENV_UNDI_SET_PACKET_FILTER_T parameter structure that has been\r
-  initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call resets the adapter's receive unit to accept a new filter, different from the one provided with\r
-  the open call.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    UINT8 filter;\r
-  } PXENV_UNDI_SET_PACKET_FILTER_T;\r
-  Set before calling API service\r
-  Filter: See the receive filter values in the UNDI OPEN\r
-  (0006h) API description.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-\r
-/**\r
-  PXE\r
-  UNDI GET INFORMATION\r
-  Op-Code: PXENV_UNDI_GET_INFORMATION (000Ch)\r
-  Input: Far pointer to a PXENV_UNDI_GET_INFORMATION_T parameter structure that has been\r
-  initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This call copies the network adapter variables, including the MAC address, into the input buffer.\r
-  Note: The PermNodeAddress field must be valid after PXENV_START_UNDI and\r
-  PXENV_UNDI_STARTUP have been issued. All other fields must be valid after\r
-  PXENV_START_UNDI, PXENV_UNDI_STARTUP and PXENV_UNDI_INITIALIZE have been\r
-  called.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    UINT16 BaseIo;\r
-    UINT16 IntNumber;\r
-    UINT16 MaxTranUnit;\r
-    UINT16 HwType;\r
-      #define ETHER_TYPE 1\r
-      #define EXP_ETHER_TYPE 2\r
-      #define IEEE_TYPE 6\r
-      #define ARCNET_TYPE 7\r
-    UINT16 HwAddrLen;\r
-    MAC_ADDR CurrentNodeAddress;\r
-    MAC_ADDR PermNodeAddress;\r
-    SEGSEL ROMAddress;\r
-    UINT16 RxBufCt;\r
-    UINT16 TxBufCt;\r
-  } PXENV_UNDI_GET_INFORMATION_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  BaseIO: Adapter base I/O address.\r
-  IntNumber: Adapter IRQ number.\r
-  MaxTranUnit: Adapter maximum transmit unit.\r
-  HWType: Type of protocol at the hardware level.\r
-  HWAddrLen: Length of the hardware address.\r
-  CurrentNodeAddress: Current hardware address.\r
-  PermNodeAddress: Permanent hardware address.\r
-  ROMAddress: Real mode ROM segment address.\r
-  RxBufCnt: Receive queue length.\r
-  TxBufCnt: Transmit queue length.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetInformation (\r
-  IN     EFI_SIMPLE_NETWORK_DEV        *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_INFORMATION_T  *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_GET_INFORMATION_T),\r
-          PXENV_UNDI_GET_INFORMATION\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI GET STATISTICS\r
-  Op-Code: PXENV_UNDI_GET_STATISTICS (000Dh)\r
-  Input: Far pointer to a PXENV_UNDI_GET_STATISTICS_T parameter structure that has been initialized\r
-  by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call reads statistical information from the network adapter, and returns.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-    UINT32 XmtGoodFrames;\r
-    UINT32 RcvGoodFrames;\r
-    UINT32 RcvCRCErrors;\r
-    UINT32 RcvResourceErrors;\r
-  } PXENV_UNDI_GET_STATISTICS_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  XmtGoodFrames: Number of successful transmissions.\r
-  RcvGoodFrames: Number of good frames received.\r
-  RcvCRCErrors: Number of frames received with CRC\r
-  error.\r
-  RcvResourceErrors: Number of frames discarded\r
-  because receive queue was full.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetStatistics (\r
-  IN     EFI_SIMPLE_NETWORK_DEV       *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_STATISTICS_T  *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_GET_STATISTICS_T),\r
-          PXENV_UNDI_GET_STATISTICS\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI CLEAR STATISTICS\r
-  Op-Code: PXENV_UNDI_CLEAR_STATISTICS (000Eh)\r
-  Input: Far pointer to a PXENV_UNDI_CLEAR_STATISTICS_T parameter.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This call clears the statistical information from the network adapter.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-  } PXENV_UNDI_CLEAR_STATISTICS_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiClearStatistics (\r
-  IN     EFI_SIMPLE_NETWORK_DEV         *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_CLEAR_STATISTICS_T  *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_CLEAR_STATISTICS_T),\r
-          PXENV_UNDI_CLEAR_STATISTICS\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI INITIATE DIAGS\r
-  Op-Code: PXENV_UNDI_INITIATE_DIAGS (000Fh)\r
-  Input: Far pointer to a PXENV_UNDI_INITIATE_DIAGS_T parameter.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the\r
-  PXENV_STATUS_xxx constants.\r
-  Description: This call can be used to initiate the run-time diagnostics. It causes the network adapter to run\r
-  hardware diagnostics and to update its status information.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-  } PXENV_UNDI_INITIATE_DIAGS_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-\r
-/**\r
-  PXE\r
-  UNDI FORCE INTERRUPT\r
-  Op-Code: PXENV_UNDI_FORCE_INTERRUPT (0010h)\r
-  Input: Far pointer to a PXENV_UNDI_FORCE_INTERRUPT_T parameter structure that has been\r
-  initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call forces the network adapter to generate an interrupt. When a receive interrupt occurs, the\r
-  network adapter driver usually queues the packet and calls the application's callback receive\r
-  routine with a pointer to the packet received. Then, the callback routine either can copy the packet\r
-  to its buffer or can decide to delay the copy to a later time. If the packet is not immediately copied,\r
-  the network adapter driver does not remove it from the input queue. When the application wants to\r
-  copy the packet, it can call the PXENV_UNDI_FORCE_INTERRUPT routine to simulate the receive\r
-  interrupt.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-  } PXENV_UNDI_FORCE_INTERRUPT_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-\r
-/**\r
-  PXE\r
-  UNDI GET MULTICAST ADDRESS\r
-  Op-Code: PXENV_UNDI_GET_MCAST_ADDRESS (0011h)\r
-  Input: Far pointer to a PXENV_GET_MCAST_ADDRESS_t parameter structure that has been initialized\r
-  by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This call converts the given IP multicast address to a hardware multicast address.\r
-  typedef struct  {\r
-    PXENV_STATUS Status;\r
-    IP4 InetAddr;\r
-    MAC_ADDR MediaAddr;\r
-  } PXENV_UNDI_GET_MCAST_ADDR_T;\r
-  Set before calling API service\r
-  InetAddr: IP multicast address.\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  MediaAddr: MAC multicast address.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetMcastAddr (\r
-  IN     EFI_SIMPLE_NETWORK_DEV       *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_MCAST_ADDR_T  *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_GET_MCAST_ADDR_T),\r
-          PXENV_UNDI_GET_MCAST_ADDR\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI GET NIC TYPE\r
-  Op-Code: PXENV_UNDI_GET_NIC_TYPE (0012h)\r
-  Input: Far pointer to a PXENV_UNDI_GET_NIC_TYPE parameter structure that has been initialized by\r
-  the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants. If the PXENV_EXIT_SUCCESS is returned the parameter structure must contain the\r
-  NIC information.\r
-  Description: This call, if successful, provides the NIC-specific information necessary to identify the network\r
-  adapter that is used to boot the system.\r
-  Note: The application first gets the DHCPDISCOVER packet using GET_CACHED_INFO and checks if\r
-  the UNDI is supported before making this call. If the UNDI is not supported, the NIC-specific\r
-  information can be obtained from the DHCPDISCOVER packet itself.\r
-  PXENV_START_UNDI, PXENV_UNDI_STARTUP and PXENV_UNDI_INITIALIZE must be called\r
-  before the information provided is valid.\r
-  typedef {\r
-    PXENV_STATUS Status;\r
-    UINT8 NicType;\r
-      #define PCI_NIC 2\r
-      #define PnP_NIC 3\r
-      #define CardBus_NIC 4\r
-    Union {\r
-      Struct {\r
-        UINT16 Vendor_ID;\r
-        UINT16 Dev_ID;\r
-        UINT8 Base_Class;\r
-        UINT8 Sub_Class;\r
-        UINT8 Prog_Intf;\r
-        UINT8 Rev;\r
-        UINT16 BusDevFunc;\r
-        UINT16 SubVendor_ID;\r
-        UINT16 SubDevice_ID;\r
-      } pci, cardbus;\r
-      struct {\r
-        UINT32 EISA_Dev_ID;\r
-        UINT8 Base_Class;\r
-        UINT8 Sub_Class;\r
-        UINT8 Prog_Intf;\r
-        UINT16 CardSelNum;\r
-      } pnp;\r
-    } info;\r
-  } PXENV_UNDI_GET_NIC_TYPE_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  NICType: Type of NIC information stored in the parameter\r
-  structure.\r
-  Info: Information about the fields in this union can be found\r
-  in the [PnP] and [PCI] specifications\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetNicType (\r
-  IN     EFI_SIMPLE_NETWORK_DEV     *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_NIC_TYPE_T  *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_GET_NIC_TYPE_T),\r
-          PXENV_UNDI_GET_NIC_TYPE\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI GET IFACE INFO\r
-  Op-Code: PXENV_UNDI_GET_IFACE_INFO (0013h)\r
-  Input: Far pointer to a PXENV_UNDI_GET_IFACE_INFO_t parameter structure that has been initialized\r
-  by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants. If the PXENV_EXIT_SUCCESS is returned, the parameter structure must contain the\r
-  interface specific information.\r
-  Description: This call, if successful, provides the network interface specific information such as the interface\r
-  type at the link layer (Ethernet, Tokenring) and the link speed. This information can be used in the\r
-  universal drivers such as NDIS or Miniport to communicate to the upper protocol modules.\r
-  Note: UNDI follows the NDIS2 specification in giving this information. It is the responsibility of the\r
-  universal driver to translate/convert this information into a format that is required in its specification\r
-  or to suit the expectation of the upper level protocol modules.\r
-  PXENV_START_UNDI, PXENV_UNDI_STARTUP and PXENV_UNDI_INITIALIZE must be called\r
-  before the information provided is valid.\r
-  typedef struct {\r
-    PXENV_STATUS Status\r
-    UINT8 IfaceType[16];\r
-    UINT32 LinkSpeed;\r
-    UINT32 ServiceFlags;\r
-    UINT32 Reserved[4];\r
-  } PXENV_UNDI_GET_NDIS_INFO_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  IfaceType: Name of MAC type in ASCIIZ format. This is\r
-  used by the universal NDIS driver to specify its driver type\r
-  to the protocol driver.\r
-  LinkSpeed: Defined in the NDIS 2.0 specification.\r
-  ServiceFlags: Defined in the NDIS 2.0 specification.\r
-  Reserved: Must be zero.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiGetNdisInfo (\r
-  IN     EFI_SIMPLE_NETWORK_DEV      *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_GET_NDIS_INFO_T  *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_GET_NDIS_INFO_T),\r
-          PXENV_UNDI_GET_NDIS_INFO\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI ISR\r
-  Op-Code: PXENV_UNDI_ISR (0014h)\r
-  Input: Far pointer to a PXENV_UNDI_ISR_T parameter structure that has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This API function will be called at different levels of processing the interrupt. The FuncFlag field in\r
-  the parameter block indicates the operation to be performed for the call. This field is filled with the\r
-  status of that operation on return.\r
-  Note: Interrupt Service Routine Operation:\r
-  In this design the UNDI does not hook the interrupt for the Network Interface. Instead, the\r
-  application or the protocol driver hooks the interrupt and calls UNDI with the PXENV_UNDI_ISR\r
-  API call for interrupt verification (PXENV_UNDI_ISR_IN_START) and processing\r
-  (PXENV_UNDI_ISR_IN_PROCESS and PXENV_UNDI_ISR_GET_NEXT).\r
-  When the Network Interface HW generates an interrupt the protocol driver interrupt service\r
-  routine (ISR) gets control and takes care of the interrupt processing at the PIC level. The ISR then\r
-  calls the UNDI using the PXENV_UNDI_ISR API with the value PXENV_UNDI_ISR_IN_START for\r
-  the FuncFlag parameter. At this time UNDI must disable the interrupts at the Network Interface\r
-  level and read any status values required to further process the interrupt. UNDI must return as\r
-  quickly as possible with one of the two values, PXENV_UNDI_ISR_OUT_OURS or\r
-  PXENV_UNDI_ISR_OUT_NOT_OURS, for the parameter FuncFlag depending on whether the\r
-  interrupt was generated by this particular Network Interface or not.\r
-  If the value returned in FuncFlag is PXENV_UNDI_ISR_OUT_NOT_OURS, then the interrupt was\r
-  not generated by our NIC, and interrupt processing is complete.\r
-  If the value returned in FuncFlag is PXENV_UNDI_ISR_OUT_OURS, the protocol driver must start\r
-  a handler thread and send an end-of-interrupt (EOI) command to the PIC. Interrupt processing is\r
-  now complete.\r
-  The protocol driver strategy routine will call UNDI using this same API with FuncFlag equal to\r
-  PXENV_UNDI_ISR_IN_PROCESS. At this time UNDI must find the cause of this interrupt and\r
-  return the status in the FuncFlag. It first checks if there is a frame received and if so it returns the\r
-  first buffer pointer of that frame in the parameter block.\r
-  The protocol driver calls UNDI repeatedly with the FuncFlag equal to\r
-  PXENV_UNDI_ISR_IN_GET_NEXT to get all the buffers in a frame and also all the received\r
-  frames in the queue. On this call, UNDI must remember the previous buffer given to the protoco,l\r
-  remove it from the receive queue and recycle it. In case of a multi-buffered frame, if the previous\r
-  buffer is not the last buffer in the frame it must return the next buffer in the frame in the parameter\r
-  block. Otherwise it must return the first buffer in the next frame.\r
-  If there is no received frame pending to be processed, UNDI processes the transmit completes and\r
-  if there is no other interrupt status to be processed, UNDI re-enables the interrupt at the\r
-  NETWORK INTERFACE level and returns PXENV_UNDI_ISR_OUT_DONE in the FuncFlag.\r
-  IMPORTANT: It is possible for the protocol driver to be interrupted again while in the\r
-  strategy routine when the UNDI re-enables interrupts.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiIsr (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_UNDI_ISR_T        *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_UNDI_ISR_T),\r
-          PXENV_UNDI_ISR\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  STOP UNDI\r
-  Op-Code: PXENV_STOP_UNDI (0015h)\r
-  Input: Far pointer to a PXENV_STOP_UNDI_T parameter structure that has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This routine is responsible for unhooking the Int 1Ah service routine.\r
-  Note: This API service must be called only once at the end of UNDI Option ROM boot. One of the valid\r
-  status codes is PXENV_STATUS_KEEP. If this status is returned, UNDI must not be removed from\r
-  base memory. Also, UNDI must not be removed from base memory if BC is not removed from base\r
-  memory.\r
-  Service cannot be used in protected mode.\r
-  typedef struct {\r
-    PXENV_STATUS Status;\r
-  } PXENV_STOP_UNDI_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
-EFI_STATUS\r
-PxeUndiStop (\r
-  IN     EFI_SIMPLE_NETWORK_DEV  *SimpleNetworkDevice,\r
-  IN OUT PXENV_STOP_UNDI_T       *PxeUndiTable\r
-  )\r
-{\r
-  return MakePxeCall (\r
-          SimpleNetworkDevice,\r
-          PxeUndiTable,\r
-          sizeof (PXENV_STOP_UNDI_T),\r
-          PXENV_STOP_UNDI\r
-          );\r
-}\r
-\r
-/**\r
-  PXE\r
-  UNDI GET STATE\r
-  Op-Code: PXENV_UNDI_GET_STATE (0015h)\r
-  Input: Far pointer to a PXENV_UNDI_GET_STATE_T parameter.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants. The UNDI_STATE field in the parameter structure must be set to one of the valid state\r
-  constants\r
-  Description: This call can be used to obtain state of the UNDI engine in order to avoid issuing adverse call\r
-  sequences\r
-  typedef struct {\r
-    #define PXE_UNDI_GET_STATE_STARTED 1\r
-    #define PXE_UNDI_GET_STATE_INITIALIZED 2\r
-    #define PXE_UNDI_GET_STATE_OPENED 3\r
-    PXENV_STATUS Status;\r
-    UINT8 UNDIstate;\r
-  } PXENV_UNDI_GET_STATE_T;\r
-  Set before calling API service\r
-  N/A\r
-  Returned from API service\r
-  Status: See the PXENV_STATUS_xxx constants.\r
-  State: See definitions of the state constants.\r
-  Note. UNDI implementation is responsible for maintaining\r
-  internal state machine.\r
-  UNDI ISR\r
-  Op-Code: PXENV_UNDI_ISR (0014h)\r
-  Input: Far pointer to a t_PXENV_UNDI_ISR parameter structure that has been initialized by the caller.\r
-  Output: PXENV_EXIT_SUCCESS or PXENV_EXIT_FAILURE must be returned in AX. The status field in\r
-  the parameter structure must be set to one of the values represented by the PXENV_STATUS_xxx\r
-  constants.\r
-  Description: This API function will be called at different levels of processing the interrupt. The FuncFlag field in\r
-  the parameter block indicates the operation to be performed for the call. This field is filled with the\r
-  status of that operation on return.\r
-\r
-  @param  SimpleNetworkDevice   Device instance\r
-  @param  PxeUndiTable          Point to structure which hold parameter and return value\r
-                                for option ROM call.\r
-\r
-  @return Return value of PXE option ROM far call.\r
-**/\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Snp16Dxe.inf b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Snp16Dxe.inf
deleted file mode 100644 (file)
index bf7c6b0..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-## @file\r
-# SNP driver On Legacy NIC ROM.\r
-#\r
-# Thunk wrapper UEFI driver to produce EFI SNP protocol based on legacy 16 NIC ROM.\r
-#\r
-# Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  BASE_NAME                            = BiosSnp16\r
-  MODULE_UNI_FILE                      = BiosSnp16.uni\r
-  FILE_GUID                            = D0CAA91E-2DE4-4b0d-B3DC-09C67E854E34\r
-  MODULE_TYPE                          = UEFI_DRIVER\r
-  INF_VERSION                          = 0x00010005\r
-  VERSION_STRING                       = 1.0\r
-\r
-  ENTRY_POINT                          = BiosSnp16DriverEntryPoint\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-#  DRIVER_BINDING                =  gBiosSnp16DriverBinding\r
-#  COMPONENT_NAME                =  gBiosSnp16ComponentName\r
-#\r
-\r
-[Sources]\r
-  BiosSnp16.h\r
-  BiosSnp16.c\r
-  Misc.c\r
-  Pxe.h\r
-  PxeUndi.c\r
-  ComponentName.c\r
-\r
-\r
-[Libraryclasses]\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  BaseMemoryLib\r
-  UefiBootServicesTableLib\r
-  UefiLib\r
-  BaseLib\r
-  DevicePathLib\r
-  MemoryAllocationLib\r
-\r
-[Guids]\r
-  gEfiEventExitBootServicesGuid         ##CONSUMES  ##Event\r
-\r
-[Protocols]\r
-  gEfiNetworkInterfaceIdentifierProtocolGuid  ##BY_START\r
-  gEfiDevicePathProtocolGuid                  ##BY_START\r
-  gEfiDevicePathProtocolGuid                  ##TO_START\r
-  gEfiSimpleNetworkProtocolGuid               ##BY_START\r
-  gEfiPciIoProtocolGuid                       ##TO_START\r
-  gEfiLegacyBiosProtocolGuid                  ##CONSUMES\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  BiosSnp16Extra.uni\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideo.c b/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideo.c
deleted file mode 100644 (file)
index 0640656..0000000
+++ /dev/null
@@ -1,3289 +0,0 @@
-/** @file\r
-  ConsoleOut Routines that speak VGA.\r
-\r
-Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosVideo.h"\r
-\r
-//\r
-// EFI Driver Binding Protocol Instance\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding = {\r
-  BiosVideoDriverBindingSupported,\r
-  BiosVideoDriverBindingStart,\r
-  BiosVideoDriverBindingStop,\r
-  0x3,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-//\r
-// Global lookup tables for VGA graphics modes\r
-//\r
-UINT8                          mVgaLeftMaskTable[]   = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };\r
-\r
-UINT8                          mVgaRightMaskTable[]  = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };\r
-\r
-UINT8                          mVgaBitMaskTable[]    = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };\r
-\r
-//\r
-// Save controller attributes during first start\r
-//\r
-UINT64                         mOriginalPciAttributes;\r
-BOOLEAN                        mPciAttributesSaved = FALSE;\r
-\r
-EFI_GRAPHICS_OUTPUT_BLT_PIXEL  mVgaColorToGraphicsOutputColor[] = {\r
-  { 0x00, 0x00, 0x00, 0x00 },\r
-  { 0x98, 0x00, 0x00, 0x00 },\r
-  { 0x00, 0x98, 0x00, 0x00 },\r
-  { 0x98, 0x98, 0x00, 0x00 },\r
-  { 0x00, 0x00, 0x98, 0x00 },\r
-  { 0x98, 0x00, 0x98, 0x00 },\r
-  { 0x00, 0x98, 0x98, 0x00 },\r
-  { 0x98, 0x98, 0x98, 0x00 },\r
-  { 0x10, 0x10, 0x10, 0x00 },\r
-  { 0xff, 0x10, 0x10, 0x00 },\r
-  { 0x10, 0xff, 0x10, 0x00 },\r
-  { 0xff, 0xff, 0x10, 0x00 },\r
-  { 0x10, 0x10, 0xff, 0x00 },\r
-  { 0xf0, 0x10, 0xff, 0x00 },\r
-  { 0x10, 0xff, 0xff, 0x00 },\r
-  { 0xff, 0xff, 0xff, 0x00 }\r
-};\r
-\r
-//\r
-// Standard timing defined by VESA EDID\r
-//\r
-VESA_BIOS_EXTENSIONS_EDID_TIMING mEstablishedEdidTiming[] = {\r
-  //\r
-  // Established Timing I\r
-  //\r
-  {800, 600, 60},\r
-  {800, 600, 56},\r
-  {640, 480, 75},\r
-  {640, 480, 72},\r
-  {640, 480, 67},\r
-  {640, 480, 60},\r
-  {720, 400, 88},\r
-  {720, 400, 70},\r
-  //\r
-  // Established Timing II\r
-  //\r
-  {1280, 1024, 75},\r
-  {1024,  768, 75},\r
-  {1024,  768, 70},\r
-  {1024,  768, 60},\r
-  {1024,  768, 87},\r
-  {832,   624, 75},\r
-  {800,   600, 75},\r
-  {800,   600, 72},\r
-  //\r
-  // Established Timing III\r
-  //\r
-  {1152, 870, 75}\r
-};\r
-\r
-/**\r
-  Supported.\r
-\r
-  @param  This                   Pointer to driver binding protocol\r
-  @param  Controller             Controller handle to connect\r
-  @param  RemainingDevicePath    A pointer to the remaining portion of a device\r
-                                 path\r
-\r
-  @retval EFI_STATUS             EFI_SUCCESS:This controller can be managed by this\r
-                                 driver, Otherwise, this controller cannot be\r
-                                 managed by this driver\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-  PCI_TYPE00                Pci;\r
-  EFI_DEV_PATH              *Node;\r
-\r
-  //\r
-  // See if the Legacy BIOS Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
-    return Status;\r
-  }\r
-\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    //\r
-    // If VgaMiniPort protocol is installed, EFI_ALREADY_STARTED indicates failure,\r
-    // because VgaMiniPort protocol is installed on controller handle directly.\r
-    //\r
-    Status = gBS->OpenProtocol (\r
-                    Controller,\r
-                    &gEfiVgaMiniPortProtocolGuid,\r
-                    NULL,\r
-                    NULL,\r
-                    NULL,\r
-                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      return EFI_ALREADY_STARTED;\r
-    }\r
-  }\r
-  //\r
-  // See if this is a PCI Graphics Controller by looking at the Command register and\r
-  // Class Code Register\r
-  //\r
-  Status = PciIo->Pci.Read (\r
-                        PciIo,\r
-                        EfiPciIoWidthUint32,\r
-                        0,\r
-                        sizeof (Pci) / sizeof (UINT32),\r
-                        &Pci\r
-                        );\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Done;\r
-  }\r
-\r
-  Status = EFI_UNSUPPORTED;\r
-  if (Pci.Hdr.ClassCode[2] == 0x03 || (Pci.Hdr.ClassCode[2] == 0x00 && Pci.Hdr.ClassCode[1] == 0x01)) {\r
-\r
-    Status = EFI_SUCCESS;\r
-    //\r
-    // If this is a graphics controller,\r
-    // go further check RemainingDevicePath validation\r
-    //\r
-    if (RemainingDevicePath != NULL) {\r
-      Node = (EFI_DEV_PATH *) RemainingDevicePath;\r
-      //\r
-      // Check if RemainingDevicePath is the End of Device Path Node,\r
-      // if yes, return EFI_SUCCESS\r
-      //\r
-      if (!IsDevicePathEnd (Node)) {\r
-        //\r
-        // If RemainingDevicePath isn't the End of Device Path Node,\r
-        // check its validation\r
-        //\r
-        if (Node->DevPath.Type != ACPI_DEVICE_PATH ||\r
-            Node->DevPath.SubType != ACPI_ADR_DP ||\r
-            DevicePathNodeLength(&Node->DevPath) < sizeof(ACPI_ADR_DEVICE_PATH)) {\r
-          Status = EFI_UNSUPPORTED;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-Done:\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiPciIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Install Graphics Output Protocol onto VGA device handles.\r
-\r
-  @param  This                   Pointer to driver binding protocol\r
-  @param  Controller             Controller handle to connect\r
-  @param  RemainingDevicePath    A pointer to the remaining portion of a device\r
-                                 path\r
-\r
-  @return EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  UINTN                     Flags;\r
-  UINT64                    Supports;\r
-\r
-  //\r
-  // Initialize local variables\r
-  //\r
-  PciIo            = NULL;\r
-  ParentDevicePath = NULL;\r
-\r
-  //\r
-  //\r
-  // See if the Legacy BIOS Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Prepare for status code\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Save original PCI attributes\r
-  //\r
-  if (!mPciAttributesSaved) {\r
-    Status = PciIo->Attributes (\r
-                      PciIo,\r
-                      EfiPciIoAttributeOperationGet,\r
-                      0,\r
-                      &mOriginalPciAttributes\r
-                      );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-    mPciAttributesSaved = TRUE;\r
-  }\r
-\r
-  //\r
-  // Get supported PCI attributes\r
-  //\r
-  Status = PciIo->Attributes (\r
-                    PciIo,\r
-                    EfiPciIoAttributeOperationSupported,\r
-                    0,\r
-                    &Supports\r
-                    );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Supports &= (UINT64)(EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16);\r
-  if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Done;\r
-  }\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_ENABLE,\r
-    ParentDevicePath\r
-    );\r
-  //\r
-  // Enable the device and make sure VGA cycles are being forwarded to this VGA device\r
-  //\r
-  Status = PciIo->Attributes (\r
-             PciIo,\r
-             EfiPciIoAttributeOperationEnable,\r
-             EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | Supports,\r
-             NULL\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_RESOURCE_CONFLICT,\r
-      ParentDevicePath\r
-      );\r
-    goto Done;\r
-  }\r
-  //\r
-  // Check to see if there is a legacy option ROM image associated with this PCI device\r
-  //\r
-  Status = LegacyBios->CheckPciRom (\r
-                         LegacyBios,\r
-                         Controller,\r
-                         NULL,\r
-                         NULL,\r
-                         &Flags\r
-                         );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Post the legacy option ROM if it is available.\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_P_PC_RESET,\r
-    ParentDevicePath\r
-    );\r
-  Status = LegacyBios->InstallPciRom (\r
-                         LegacyBios,\r
-                         Controller,\r
-                         NULL,\r
-                         &Flags,\r
-                         NULL,\r
-                         NULL,\r
-                         NULL,\r
-                         NULL\r
-                         );\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR,\r
-      ParentDevicePath\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  if (RemainingDevicePath != NULL) {\r
-    if (IsDevicePathEnd (RemainingDevicePath) &&\r
-        (FeaturePcdGet (PcdBiosVideoCheckVbeEnable) || FeaturePcdGet (PcdBiosVideoCheckVgaEnable))) {\r
-      //\r
-      // If RemainingDevicePath is the End of Device Path Node,\r
-      // don't create any child device and return EFI_SUCESS\r
-      Status = EFI_SUCCESS;\r
-      goto Done;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Create child handle and install GraphicsOutputProtocol on it\r
-  //\r
-  Status = BiosVideoChildHandleInstall (\r
-             This,\r
-             Controller,\r
-             PciIo,\r
-             LegacyBios,\r
-             ParentDevicePath,\r
-             RemainingDevicePath\r
-             );\r
-\r
-Done:\r
-  if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_PROGRESS_CODE,\r
-      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_DISABLE,\r
-      ParentDevicePath\r
-      );\r
-\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_PROGRESS_CODE,\r
-      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_NOT_DETECTED,\r
-      ParentDevicePath\r
-      );\r
-    if (!HasChildHandle (Controller)) {\r
-      if (mPciAttributesSaved) {\r
-        //\r
-        // Restore original PCI attributes\r
-        //\r
-        PciIo->Attributes (\r
-                        PciIo,\r
-                        EfiPciIoAttributeOperationSet,\r
-                        mOriginalPciAttributes,\r
-                        NULL\r
-                        );\r
-      }\r
-    }\r
-    //\r
-    // Release PCI I/O Protocols on the controller handle.\r
-    //\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiPciIoProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Stop.\r
-\r
-  @param  This                   Pointer to driver binding protocol\r
-  @param  Controller             Controller handle to connect\r
-  @param  NumberOfChildren       Number of children handle created by this driver\r
-  @param  ChildHandleBuffer      Buffer containing child handle created\r
-\r
-  @retval EFI_SUCCESS            Driver disconnected successfully from controller\r
-  @retval EFI_UNSUPPORTED        Cannot find BIOS_VIDEO_DEV structure\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Controller,\r
-  IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                   Status;\r
-  BOOLEAN                      AllChildrenStopped;\r
-  UINTN                        Index;\r
-  EFI_PCI_IO_PROTOCOL          *PciIo;\r
-\r
-  AllChildrenStopped = TRUE;\r
-\r
-  if (NumberOfChildren == 0) {\r
-    //\r
-    // Close PCI I/O protocol on the controller handle\r
-    //\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiPciIoProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-    Status = BiosVideoChildHandleUninstall (This, Controller, ChildHandleBuffer[Index]);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      AllChildrenStopped = FALSE;\r
-    }\r
-  }\r
-\r
-  if (!AllChildrenStopped) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (!HasChildHandle (Controller)) {\r
-    if (mPciAttributesSaved) {\r
-      Status = gBS->HandleProtocol (\r
-                      Controller,\r
-                      &gEfiPciIoProtocolGuid,\r
-                      (VOID **) &PciIo\r
-                      );\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-      //\r
-      // Restore original PCI attributes\r
-      //\r
-      Status = PciIo->Attributes (\r
-                        PciIo,\r
-                        EfiPciIoAttributeOperationSet,\r
-                        mOriginalPciAttributes,\r
-                        NULL\r
-                        );\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Install child handles if the Handle supports MBR format.\r
-\r
-  @param  This                   Calling context.\r
-  @param  ParentHandle           Parent Handle\r
-  @param  ParentPciIo            Parent PciIo interface\r
-  @param  ParentLegacyBios       Parent LegacyBios interface\r
-  @param  ParentDevicePath       Parent Device Path\r
-  @param  RemainingDevicePath    Remaining Device Path\r
-\r
-  @retval EFI_SUCCESS            If a child handle was added\r
-  @retval other                  A child handle was not added\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoChildHandleInstall (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ParentHandle,\r
-  IN  EFI_PCI_IO_PROTOCOL          *ParentPciIo,\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL     *ParentLegacyBios,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *ParentDevicePath,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS               Status;\r
-  BIOS_VIDEO_DEV           *BiosVideoPrivate;\r
-  PCI_TYPE00               Pci;\r
-  ACPI_ADR_DEVICE_PATH     AcpiDeviceNode;\r
-  BOOLEAN                  ProtocolInstalled;\r
-\r
-  //\r
-  // Allocate the private device structure for video device\r
-  //\r
-  BiosVideoPrivate = (BIOS_VIDEO_DEV *) AllocateZeroPool (\r
-                                          sizeof (BIOS_VIDEO_DEV)\r
-                                          );\r
-  if (NULL == BiosVideoPrivate) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // See if this is a VGA compatible controller or not\r
-  //\r
-  Status = ParentPciIo->Pci.Read (\r
-                          ParentPciIo,\r
-                          EfiPciIoWidthUint32,\r
-                          0,\r
-                          sizeof (Pci) / sizeof (UINT32),\r
-                          &Pci\r
-                          );\r
-  if (EFI_ERROR (Status)) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR,\r
-      ParentDevicePath\r
-      );\r
-    goto Done;\r
-  }\r
-  BiosVideoPrivate->VgaCompatible = FALSE;\r
-  if (Pci.Hdr.ClassCode[2] == 0x00 && Pci.Hdr.ClassCode[1] == 0x01) {\r
-    BiosVideoPrivate->VgaCompatible = TRUE;\r
-  }\r
-\r
-  if (Pci.Hdr.ClassCode[2] == 0x03 && Pci.Hdr.ClassCode[1] == 0x00 && Pci.Hdr.ClassCode[0] == 0x00) {\r
-    BiosVideoPrivate->VgaCompatible = TRUE;\r
-  }\r
-\r
- if (PcdGetBool (PcdBiosVideoSetTextVgaModeEnable)) {\r
-    //\r
-    // Create EXIT_BOOT_SERIVES Event\r
-    //\r
-    Status = gBS->CreateEventEx (\r
-                    EVT_NOTIFY_SIGNAL,\r
-                    TPL_NOTIFY,\r
-                    BiosVideoNotifyExitBootServices,\r
-                    BiosVideoPrivate,\r
-                    &gEfiEventExitBootServicesGuid,\r
-                    &BiosVideoPrivate->ExitBootServicesEvent\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Initialize the child private structure\r
-  //\r
-  BiosVideoPrivate->Signature = BIOS_VIDEO_DEV_SIGNATURE;\r
-\r
-  //\r
-  // Fill in Graphics Output specific mode structures\r
-  //\r
-  BiosVideoPrivate->HardwareNeedsStarting = TRUE;\r
-  BiosVideoPrivate->ModeData              = NULL;\r
-  BiosVideoPrivate->LineBuffer            = NULL;\r
-  BiosVideoPrivate->VgaFrameBuffer        = NULL;\r
-  BiosVideoPrivate->VbeFrameBuffer        = NULL;\r
-\r
-  //\r
-  // Fill in the Graphics Output Protocol\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.QueryMode = BiosVideoGraphicsOutputQueryMode;\r
-  BiosVideoPrivate->GraphicsOutput.SetMode   = BiosVideoGraphicsOutputSetMode;\r
-\r
-\r
-  //\r
-  // Allocate buffer for Graphics Output Protocol mode information\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.Mode = (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *) AllocatePool (\r
-                                             sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE)\r
-                                             );\r
-  if (NULL == BiosVideoPrivate->GraphicsOutput.Mode) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  BiosVideoPrivate->GraphicsOutput.Mode->Info = (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) AllocatePool (\r
-                                             sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)\r
-                                             );\r
-  if (NULL ==  BiosVideoPrivate->GraphicsOutput.Mode->Info) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Assume that Graphics Output Protocol will be produced until proven otherwise\r
-  //\r
-  BiosVideoPrivate->ProduceGraphicsOutput = TRUE;\r
-\r
-  //\r
-  // Set Gop Device Path, here RemainingDevicePath will not be one End of Device Path Node.\r
-  //\r
-  if ((RemainingDevicePath == NULL) || (!IsDevicePathEnd (RemainingDevicePath))) {\r
-    if (RemainingDevicePath == NULL) {\r
-      ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));\r
-      AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;\r
-      AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;\r
-      AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);\r
-      SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH));\r
-\r
-      BiosVideoPrivate->GopDevicePath = AppendDevicePathNode (\r
-                                          ParentDevicePath,\r
-                                          (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode\r
-                                          );\r
-    } else {\r
-      BiosVideoPrivate->GopDevicePath = AppendDevicePathNode (ParentDevicePath, RemainingDevicePath);\r
-    }\r
-\r
-    //\r
-    // Creat child handle and device path protocol firstly\r
-    //\r
-    BiosVideoPrivate->Handle = NULL;\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &BiosVideoPrivate->Handle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    BiosVideoPrivate->GopDevicePath,\r
-                    NULL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Fill in the VGA Mini Port Protocol fields\r
-  //\r
-  BiosVideoPrivate->VgaMiniPort.SetMode                   = BiosVideoVgaMiniPortSetMode;\r
-  BiosVideoPrivate->VgaMiniPort.VgaMemoryOffset           = 0xb8000;\r
-  BiosVideoPrivate->VgaMiniPort.CrtcAddressRegisterOffset = 0x3d4;\r
-  BiosVideoPrivate->VgaMiniPort.CrtcDataRegisterOffset    = 0x3d5;\r
-  BiosVideoPrivate->VgaMiniPort.VgaMemoryBar              = EFI_PCI_IO_PASS_THROUGH_BAR;\r
-  BiosVideoPrivate->VgaMiniPort.CrtcAddressRegisterBar    = EFI_PCI_IO_PASS_THROUGH_BAR;\r
-  BiosVideoPrivate->VgaMiniPort.CrtcDataRegisterBar       = EFI_PCI_IO_PASS_THROUGH_BAR;\r
-\r
-  //\r
-  // Child handle need to consume the Legacy Bios protocol\r
-  //\r
-  BiosVideoPrivate->LegacyBios = ParentLegacyBios;\r
-\r
-  //\r
-  // When check for VBE, PCI I/O protocol is needed, so use parent's protocol interface temporally\r
-  //\r
-  BiosVideoPrivate->PciIo                 = ParentPciIo;\r
-\r
-  //\r
-  // Check for VESA BIOS Extensions for modes that are compatible with Graphics Output\r
-  //\r
-  if (FeaturePcdGet (PcdBiosVideoCheckVbeEnable)) {\r
-    Status = BiosVideoCheckForVbe (BiosVideoPrivate);\r
-    DEBUG ((EFI_D_INFO, "BiosVideoCheckForVbe - %r\n", Status));\r
-  } else {\r
-    Status = EFI_UNSUPPORTED;\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // The VESA BIOS Extensions are not compatible with Graphics Output, so check for support\r
-    // for the standard 640x480 16 color VGA mode\r
-    //\r
-    DEBUG ((EFI_D_INFO, "VgaCompatible - %x\n", BiosVideoPrivate->VgaCompatible));\r
-    if (BiosVideoPrivate->VgaCompatible) {\r
-      if (FeaturePcdGet (PcdBiosVideoCheckVgaEnable)) {\r
-        Status = BiosVideoCheckForVga (BiosVideoPrivate);\r
-        DEBUG ((EFI_D_INFO, "BiosVideoCheckForVga - %r\n", Status));\r
-      } else {\r
-        Status = EFI_UNSUPPORTED;\r
-      }\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Free GOP mode structure if it is not freed before\r
-      // VgaMiniPort does not need this structure any more\r
-      //\r
-      if (BiosVideoPrivate->GraphicsOutput.Mode != NULL) {\r
-        if (BiosVideoPrivate->GraphicsOutput.Mode->Info != NULL) {\r
-          FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);\r
-          BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL;\r
-        }\r
-        FreePool (BiosVideoPrivate->GraphicsOutput.Mode);\r
-        BiosVideoPrivate->GraphicsOutput.Mode = NULL;\r
-      }\r
-\r
-      //\r
-      // Neither VBE nor the standard 640x480 16 color VGA mode are supported, so do\r
-      // not produce the Graphics Output protocol.  Instead, produce the VGA MiniPort Protocol.\r
-      //\r
-      BiosVideoPrivate->ProduceGraphicsOutput = FALSE;\r
-\r
-      //\r
-      // INT services are available, so on the 80x25 and 80x50 text mode are supported\r
-      //\r
-      BiosVideoPrivate->VgaMiniPort.MaxMode = 2;\r
-    }\r
-  }\r
-\r
-  ProtocolInstalled = FALSE;\r
-\r
-  if (BiosVideoPrivate->ProduceGraphicsOutput) {\r
-    //\r
-    // Creat child handle and install Graphics Output Protocol,EDID Discovered/Active Protocol\r
-    //\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &BiosVideoPrivate->Handle,\r
-                    &gEfiGraphicsOutputProtocolGuid,\r
-                    &BiosVideoPrivate->GraphicsOutput,\r
-                    &gEfiEdidDiscoveredProtocolGuid,\r
-                    &BiosVideoPrivate->EdidDiscovered,\r
-                    &gEfiEdidActiveProtocolGuid,\r
-                    &BiosVideoPrivate->EdidActive,\r
-                    NULL\r
-                    );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Open the Parent Handle for the child\r
-      //\r
-      Status = gBS->OpenProtocol (\r
-                      ParentHandle,\r
-                      &gEfiPciIoProtocolGuid,\r
-                      (VOID **) &BiosVideoPrivate->PciIo,\r
-                      This->DriverBindingHandle,\r
-                      BiosVideoPrivate->Handle,\r
-                      EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-      ProtocolInstalled = TRUE;\r
-    }\r
-  }\r
-\r
-  if (!ProtocolInstalled) {\r
-    //\r
-    // Install VGA Mini Port Protocol\r
-    //\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &ParentHandle,\r
-                    &gEfiVgaMiniPortProtocolGuid,\r
-                    &BiosVideoPrivate->VgaMiniPort,\r
-                    NULL\r
-                    );\r
-  }\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    if ((BiosVideoPrivate != NULL) && (BiosVideoPrivate->ExitBootServicesEvent != NULL)) {\r
-      gBS->CloseEvent (BiosVideoPrivate->ExitBootServicesEvent);\r
-    }\r
-    //\r
-    // Free private data structure\r
-    //\r
-    BiosVideoDeviceReleaseResource (BiosVideoPrivate);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Deregister an video child handle and free resources.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  Controller             Video controller handle\r
-  @param  Handle                 Video child handle\r
-\r
-  @return EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoChildHandleUninstall (\r
-  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  EFI_HANDLE                     Controller,\r
-  EFI_HANDLE                     Handle\r
-  )\r
-{\r
-  EFI_STATUS                   Status;\r
-  EFI_IA32_REGISTER_SET        Regs;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
-  EFI_VGA_MINI_PORT_PROTOCOL   *VgaMiniPort;\r
-  BIOS_VIDEO_DEV               *BiosVideoPrivate;\r
-  EFI_PCI_IO_PROTOCOL          *PciIo;\r
-\r
-  BiosVideoPrivate = NULL;\r
-  GraphicsOutput   = NULL;\r
-  PciIo            = NULL;\r
-  Status           = EFI_UNSUPPORTED;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID **) &GraphicsOutput,\r
-                  This->DriverBindingHandle,\r
-                  Handle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-      BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    Status = gBS->OpenProtocol (\r
-                   Handle,\r
-                   &gEfiVgaMiniPortProtocolGuid,\r
-                   (VOID **) &VgaMiniPort,\r
-                   This->DriverBindingHandle,\r
-                   Handle,\r
-                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                   );\r
-    if (!EFI_ERROR (Status)) {\r
-      BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS (VgaMiniPort);\r
-    }\r
-  }\r
-\r
-  if (BiosVideoPrivate == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Set the 80x25 Text VGA Mode\r
-  //\r
-  Regs.H.AH = 0x00;\r
-  Regs.H.AL = 0x03;\r
-  BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-  Regs.H.AH = 0x11;\r
-  Regs.H.AL = 0x14;\r
-  Regs.H.BL = 0;\r
-  BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-  //\r
-  // Close PCI I/O protocol that opened by child handle\r
-  //\r
-  Status = gBS->CloseProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  This->DriverBindingHandle,\r
-                  Handle\r
-                  );\r
-\r
-  //\r
-  // Uninstall protocols on child handle\r
-  //\r
-  if (BiosVideoPrivate->ProduceGraphicsOutput) {\r
-    Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                    BiosVideoPrivate->Handle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    BiosVideoPrivate->GopDevicePath,\r
-                    &gEfiGraphicsOutputProtocolGuid,\r
-                    &BiosVideoPrivate->GraphicsOutput,\r
-                    &gEfiEdidDiscoveredProtocolGuid,\r
-                    &BiosVideoPrivate->EdidDiscovered,\r
-                    &gEfiEdidActiveProtocolGuid,\r
-                    &BiosVideoPrivate->EdidActive,\r
-                    NULL\r
-                    );\r
-  }\r
-  if (!BiosVideoPrivate->ProduceGraphicsOutput) {\r
-    Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                    Controller,\r
-                    &gEfiVgaMiniPortProtocolGuid,\r
-                    &BiosVideoPrivate->VgaMiniPort,\r
-                    NULL\r
-                    );\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->OpenProtocol (\r
-           Controller,\r
-           &gEfiPciIoProtocolGuid,\r
-           (VOID **) &PciIo,\r
-           This->DriverBindingHandle,\r
-           Handle,\r
-           EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-           );\r
-    return Status;\r
-  }\r
-\r
-  if (PcdGetBool (PcdBiosVideoSetTextVgaModeEnable)) {\r
-    //\r
-    // Close EXIT_BOOT_SERIVES Event\r
-    //\r
-    gBS->CloseEvent (BiosVideoPrivate->ExitBootServicesEvent);\r
-  }\r
-\r
-  //\r
-  // Release all allocated resources\r
-  //\r
-  BiosVideoDeviceReleaseResource (BiosVideoPrivate);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Release resource for biso video instance.\r
-\r
-  @param  BiosVideoPrivate       Video child device private data structure\r
-\r
-**/\r
-VOID\r
-BiosVideoDeviceReleaseResource (\r
-  BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  )\r
-{\r
-  if (BiosVideoPrivate == NULL) {\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Release all the resourses occupied by the BIOS_VIDEO_DEV\r
-  //\r
-\r
-  //\r
-  // Free VGA Frame Buffer\r
-  //\r
-  if (BiosVideoPrivate->VgaFrameBuffer != NULL) {\r
-    FreePool (BiosVideoPrivate->VgaFrameBuffer);\r
-  }\r
-  //\r
-  // Free VBE Frame Buffer\r
-  //\r
-  if (BiosVideoPrivate->VbeFrameBuffer != NULL) {\r
-    FreePool (BiosVideoPrivate->VbeFrameBuffer);\r
-  }\r
-  //\r
-  // Free line buffer\r
-  //\r
-  if (BiosVideoPrivate->LineBuffer != NULL) {\r
-    FreePool (BiosVideoPrivate->LineBuffer);\r
-  }\r
-  //\r
-  // Free mode data\r
-  //\r
-  if (BiosVideoPrivate->ModeData != NULL) {\r
-    FreePool (BiosVideoPrivate->ModeData);\r
-  }\r
-  //\r
-  // Free memory allocated below 1MB\r
-  //\r
-  if (BiosVideoPrivate->PagesBelow1MB != 0) {\r
-    gBS->FreePages (BiosVideoPrivate->PagesBelow1MB, BiosVideoPrivate->NumberOfPagesBelow1MB);\r
-  }\r
-\r
-  if (BiosVideoPrivate->VbeSaveRestorePages != 0) {\r
-    gBS->FreePages (BiosVideoPrivate->VbeSaveRestoreBuffer, BiosVideoPrivate->VbeSaveRestorePages);\r
-  }\r
-\r
-  //\r
-  // Free graphics output protocol occupied resource\r
-  //\r
-  if (BiosVideoPrivate->GraphicsOutput.Mode != NULL) {\r
-    if (BiosVideoPrivate->GraphicsOutput.Mode->Info != NULL) {\r
-        FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);\r
-        BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL;\r
-    }\r
-    FreePool (BiosVideoPrivate->GraphicsOutput.Mode);\r
-    BiosVideoPrivate->GraphicsOutput.Mode = NULL;\r
-  }\r
-  //\r
-  // Free EDID discovered protocol occupied resource\r
-  //\r
-  if (BiosVideoPrivate->EdidDiscovered.Edid != NULL) {\r
-    FreePool (BiosVideoPrivate->EdidDiscovered.Edid);\r
-  }\r
-  //\r
-  // Free EDID active protocol occupied resource\r
-  //\r
-  if (BiosVideoPrivate->EdidActive.Edid != NULL) {\r
-    FreePool (BiosVideoPrivate->EdidActive.Edid);\r
-  }\r
-\r
-  if (BiosVideoPrivate->GopDevicePath!= NULL) {\r
-    FreePool (BiosVideoPrivate->GopDevicePath);\r
-  }\r
-\r
-  FreePool (BiosVideoPrivate);\r
-\r
-  return ;\r
-}\r
-\r
-\r
-/**\r
-  Generate a search key for a specified timing data.\r
-\r
-  @param  EdidTiming             Pointer to EDID timing\r
-\r
-  @return The 32 bit unique key for search.\r
-\r
-**/\r
-UINT32\r
-CalculateEdidKey (\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING       *EdidTiming\r
-  )\r
-{\r
-  UINT32 Key;\r
-\r
-  //\r
-  // Be sure no conflicts for all standard timing defined by VESA.\r
-  //\r
-  Key = (EdidTiming->HorizontalResolution * 2) + EdidTiming->VerticalResolution;\r
-  return Key;\r
-}\r
-\r
-\r
-/**\r
-  Parse the Established Timing and Standard Timing in EDID data block.\r
-\r
-  @param  EdidBuffer             Pointer to EDID data block\r
-  @param  ValidEdidTiming        Valid EDID timing information\r
-\r
-  @retval TRUE                   The EDID data is valid.\r
-  @retval FALSE                  The EDID data is invalid.\r
-\r
-**/\r
-BOOLEAN\r
-ParseEdidData (\r
-  UINT8                                      *EdidBuffer,\r
-  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING     *ValidEdidTiming\r
-  )\r
-{\r
-  UINT8  CheckSum;\r
-  UINT32 Index;\r
-  UINT32 ValidNumber;\r
-  UINT32 TimingBits;\r
-  UINT8  *BufferIndex;\r
-  UINT16 HorizontalResolution;\r
-  UINT16 VerticalResolution;\r
-  UINT8  AspectRatio;\r
-  UINT8  RefreshRate;\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING     TempTiming;\r
-  VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *EdidDataBlock;\r
-\r
-  EdidDataBlock = (VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *) EdidBuffer;\r
-\r
-  //\r
-  // Check the checksum of EDID data\r
-  //\r
-  CheckSum = 0;\r
-  for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE; Index ++) {\r
-    CheckSum = (UINT8) (CheckSum + EdidBuffer[Index]);\r
-  }\r
-  if (CheckSum != 0) {\r
-    return FALSE;\r
-  }\r
-\r
-  ValidNumber = 0;\r
-  gBS->SetMem (ValidEdidTiming, sizeof (VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING), 0);\r
-\r
-  if ((EdidDataBlock->EstablishedTimings[0] != 0) ||\r
-      (EdidDataBlock->EstablishedTimings[1] != 0) ||\r
-      (EdidDataBlock->EstablishedTimings[2] != 0)\r
-      ) {\r
-    //\r
-    // Established timing data\r
-    //\r
-    TimingBits = EdidDataBlock->EstablishedTimings[0] |\r
-                 (EdidDataBlock->EstablishedTimings[1] << 8) |\r
-                 ((EdidDataBlock->EstablishedTimings[2] & 0x80) << 9) ;\r
-    for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER; Index ++) {\r
-      if ((TimingBits & 0x1) != 0) {\r
-        DEBUG ((EFI_D_INFO, "Established Timing: %d x %d\n",\r
-        mEstablishedEdidTiming[Index].HorizontalResolution, mEstablishedEdidTiming[Index].VerticalResolution));\r
-        ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&mEstablishedEdidTiming[Index]);\r
-        ValidNumber ++;\r
-      }\r
-      TimingBits = TimingBits >> 1;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Parse the standard timing data\r
-  //\r
-  BufferIndex = &EdidDataBlock->StandardTimingIdentification[0];\r
-  for (Index = 0; Index < 8; Index ++) {\r
-    //\r
-    // Check if this is a valid Standard Timing entry\r
-    // VESA documents unused fields should be set to 01h\r
-    //\r
-    if ((BufferIndex[0] != 0x1) && (BufferIndex[1] != 0x1)){\r
-      //\r
-      // A valid Standard Timing\r
-      //\r
-      HorizontalResolution = (UINT16) (BufferIndex[0] * 8 + 248);\r
-      AspectRatio = (UINT8) (BufferIndex[1] >> 6);\r
-      switch (AspectRatio) {\r
-        case 0:\r
-          VerticalResolution = (UINT16) (HorizontalResolution / 16 * 10);\r
-          break;\r
-        case 1:\r
-          VerticalResolution = (UINT16) (HorizontalResolution / 4 * 3);\r
-          break;\r
-        case 2:\r
-          VerticalResolution = (UINT16) (HorizontalResolution / 5 * 4);\r
-          break;\r
-        case 3:\r
-          VerticalResolution = (UINT16) (HorizontalResolution / 16 * 9);\r
-          break;\r
-        default:\r
-          VerticalResolution = (UINT16) (HorizontalResolution / 4 * 3);\r
-          break;\r
-      }\r
-      RefreshRate = (UINT8) ((BufferIndex[1] & 0x1f) + 60);\r
-      DEBUG ((EFI_D_INFO, "Standard Timing: %d x %d\n", HorizontalResolution, VerticalResolution));\r
-      TempTiming.HorizontalResolution = HorizontalResolution;\r
-      TempTiming.VerticalResolution = VerticalResolution;\r
-      TempTiming.RefreshRate = RefreshRate;\r
-      ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&TempTiming);\r
-      ValidNumber ++;\r
-    }\r
-    BufferIndex += 2;\r
-  }\r
-\r
-  //\r
-  // Parse the Detailed Timing data\r
-  //\r
-  BufferIndex = &EdidDataBlock->DetailedTimingDescriptions[0];\r
-  for (Index = 0; Index < 4; Index ++, BufferIndex += VESA_BIOS_EXTENSIONS_DETAILED_TIMING_EACH_DESCRIPTOR_SIZE) {\r
-    if ((BufferIndex[0] == 0x0) && (BufferIndex[1] == 0x0)) {\r
-      //\r
-      // Check if this is a valid Detailed Timing Descriptor\r
-      // If first 2 bytes are zero, it is monitor descriptor other than detailed timing descriptor\r
-      //\r
-      continue;\r
-    }\r
-    //\r
-    // Calculate Horizontal and Vertical resolution\r
-    //\r
-    TempTiming.HorizontalResolution = ((UINT16)(BufferIndex[4] & 0xF0) << 4) | (BufferIndex[2]);\r
-    TempTiming.VerticalResolution = ((UINT16)(BufferIndex[7] & 0xF0) << 4) | (BufferIndex[5]);\r
-    DEBUG ((EFI_D_INFO, "Detailed Timing %d: %d x %d\n",\r
-            Index, TempTiming.HorizontalResolution, TempTiming.VerticalResolution));\r
-    ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&TempTiming);\r
-    ValidNumber ++;\r
-  }\r
-\r
-  ValidEdidTiming->ValidNumber = ValidNumber;\r
-  return TRUE;\r
-}\r
-\r
-\r
-/**\r
-  Search a specified Timing in all the valid EDID timings.\r
-\r
-  @param  ValidEdidTiming        All valid EDID timing information.\r
-  @param  EdidTiming             The Timing to search for.\r
-\r
-  @retval TRUE                   Found.\r
-  @retval FALSE                  Not found.\r
-\r
-**/\r
-BOOLEAN\r
-SearchEdidTiming (\r
-  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING *ValidEdidTiming,\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING       *EdidTiming\r
-  )\r
-{\r
-  UINT32 Index;\r
-  UINT32 Key;\r
-\r
-  Key = CalculateEdidKey (EdidTiming);\r
-\r
-  for (Index = 0; Index < ValidEdidTiming->ValidNumber; Index ++) {\r
-    if (Key == ValidEdidTiming->Key[Index]) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Check if all video child handles have been uninstalled.\r
-\r
-  @param  Controller             Video controller handle\r
-\r
-  @return TRUE                   Child handles exist.\r
-  @return FALSE                  All video child handles have been uninstalled.\r
-\r
-**/\r
-BOOLEAN\r
-HasChildHandle (\r
-  IN EFI_HANDLE  Controller\r
-  )\r
-{\r
-  UINTN                                Index;\r
-  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY  *OpenInfoBuffer;\r
-  UINTN                                EntryCount;\r
-  BOOLEAN                              HasChild;\r
-\r
-  EntryCount = 0;\r
-  HasChild   = FALSE;\r
-  gBS->OpenProtocolInformation (\r
-         Controller,\r
-         &gEfiPciIoProtocolGuid,\r
-         &OpenInfoBuffer,\r
-         &EntryCount\r
-         );\r
-  for (Index = 0; Index < EntryCount; Index++) {\r
-    if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
-      HasChild = TRUE;\r
-    }\r
-  }\r
-\r
-  return HasChild;\r
-}\r
-\r
-/**\r
-  Check for VBE device.\r
-\r
-  @param  BiosVideoPrivate       Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  @retval EFI_SUCCESS            VBE device found\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoCheckForVbe (\r
-  IN OUT BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  )\r
-{\r
-  EFI_STATUS                             Status;\r
-  EFI_IA32_REGISTER_SET                  Regs;\r
-  UINT16                                 *ModeNumberPtr;\r
-  UINT16                                 VbeModeNumber;\r
-  BOOLEAN                                ModeFound;\r
-  BOOLEAN                                EdidFound;\r
-  BIOS_VIDEO_MODE_DATA                   *ModeBuffer;\r
-  BIOS_VIDEO_MODE_DATA                   *CurrentModeData;\r
-  UINTN                                  PreferMode;\r
-  UINTN                                  ModeNumber;\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING       Timing;\r
-  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING ValidEdidTiming;\r
-  EFI_EDID_OVERRIDE_PROTOCOL             *EdidOverride;\r
-  UINT32                                 EdidAttributes;\r
-  BOOLEAN                                EdidOverrideFound;\r
-  UINTN                                  EdidOverrideDataSize;\r
-  UINT8                                  *EdidOverrideDataBlock;\r
-  UINTN                                  EdidActiveDataSize;\r
-  UINT8                                  *EdidActiveDataBlock;\r
-  UINT32                                 HighestHorizontalResolution;\r
-  UINT32                                 HighestVerticalResolution;\r
-  UINTN                                  HighestResolutionMode;\r
-\r
-  EdidFound             = TRUE;\r
-  EdidOverrideFound     = FALSE;\r
-  EdidOverrideDataBlock = NULL;\r
-  EdidActiveDataSize    = 0;\r
-  EdidActiveDataBlock   = NULL;\r
-  HighestHorizontalResolution = 0;\r
-  HighestVerticalResolution   = 0;\r
-  HighestResolutionMode       = 0;\r
-\r
-  //\r
-  // Allocate buffer under 1MB for VBE data structures\r
-  //\r
-  BiosVideoPrivate->NumberOfPagesBelow1MB = EFI_SIZE_TO_PAGES (\r
-                                              sizeof (VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK) +\r
-                                              sizeof (VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK) +\r
-                                              sizeof (VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK) +\r
-                                              sizeof (VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK)\r
-                                              );\r
-\r
-  BiosVideoPrivate->PagesBelow1MB = 0x00100000 - 1;\r
-\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiBootServicesData,\r
-                  BiosVideoPrivate->NumberOfPagesBelow1MB,\r
-                  &BiosVideoPrivate->PagesBelow1MB\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  ZeroMem (&ValidEdidTiming, sizeof (VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING));\r
-\r
-  //\r
-  // Fill in the VBE related data structures\r
-  //\r
-  BiosVideoPrivate->VbeInformationBlock = (VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK *) (UINTN) (BiosVideoPrivate->PagesBelow1MB);\r
-  BiosVideoPrivate->VbeModeInformationBlock = (VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK *) (BiosVideoPrivate->VbeInformationBlock + 1);\r
-  BiosVideoPrivate->VbeEdidDataBlock = (VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *) (BiosVideoPrivate->VbeModeInformationBlock + 1);\r
-  BiosVideoPrivate->VbeCrtcInformationBlock = (VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK *) (BiosVideoPrivate->VbeEdidDataBlock + 1);\r
-  BiosVideoPrivate->VbeSaveRestorePages   = 0;\r
-  BiosVideoPrivate->VbeSaveRestoreBuffer  = 0;\r
-\r
-  //\r
-  // Test to see if the Video Adapter is compliant with VBE 3.0\r
-  //\r
-  gBS->SetMem (&Regs, sizeof (Regs), 0);\r
-  Regs.X.AX = VESA_BIOS_EXTENSIONS_RETURN_CONTROLLER_INFORMATION;\r
-  gBS->SetMem (BiosVideoPrivate->VbeInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK), 0);\r
-  BiosVideoPrivate->VbeInformationBlock->VESASignature  = VESA_BIOS_EXTENSIONS_VBE2_SIGNATURE;\r
-  Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeInformationBlock);\r
-  Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeInformationBlock);\r
-\r
-  BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-  Status = EFI_DEVICE_ERROR;\r
-\r
-  //\r
-  // See if the VESA call succeeded\r
-  //\r
-  if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check for 'VESA' signature\r
-  //\r
-  if (BiosVideoPrivate->VbeInformationBlock->VESASignature != VESA_BIOS_EXTENSIONS_VESA_SIGNATURE) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check to see if this is VBE 2.0 or higher\r
-  //\r
-  if (BiosVideoPrivate->VbeInformationBlock->VESAVersion < VESA_BIOS_EXTENSIONS_VERSION_2_0) {\r
-    return Status;\r
-  }\r
-\r
-  EdidFound            = FALSE;\r
-  EdidAttributes       = 0xff;\r
-  EdidOverrideDataSize = 0;\r
-\r
-  //\r
-  // Find EDID Override protocol firstly, this protocol is installed by platform if needed.\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                   &gEfiEdidOverrideProtocolGuid,\r
-                   NULL,\r
-                   (VOID **) &EdidOverride\r
-                   );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Allocate double size of VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE to avoid overflow\r
-    //\r
-    EdidOverrideDataBlock = AllocatePool (VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE * 2);\r
-    if (NULL == EdidOverrideDataBlock) {\r
-      Status = EFI_OUT_OF_RESOURCES;\r
-      goto Done;\r
-    }\r
-\r
-    Status = EdidOverride->GetEdid (\r
-                             EdidOverride,\r
-                             BiosVideoPrivate->Handle,\r
-                             &EdidAttributes,\r
-                             &EdidOverrideDataSize,\r
-                             (UINT8 **) &EdidOverrideDataBlock\r
-                             );\r
-    if (!EFI_ERROR (Status)  &&\r
-         EdidAttributes == 0 &&\r
-         EdidOverrideDataSize != 0) {\r
-      //\r
-      // Succeeded to get EDID Override Data\r
-      //\r
-      EdidOverrideFound = TRUE;\r
-    }\r
-  }\r
-\r
-  if (!EdidOverrideFound || EdidAttributes == EFI_EDID_OVERRIDE_DONT_OVERRIDE) {\r
-    //\r
-    // If EDID Override data doesn't exist or EFI_EDID_OVERRIDE_DONT_OVERRIDE returned,\r
-    // read EDID information through INT10 call\r
-    //\r
-\r
-    gBS->SetMem (&Regs, sizeof (Regs), 0);\r
-    Regs.X.AX = VESA_BIOS_EXTENSIONS_EDID;\r
-    Regs.X.BX = 1;\r
-    Regs.X.CX = 0;\r
-    Regs.X.DX = 0;\r
-    Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeEdidDataBlock);\r
-    Regs.X.DI = EFI_OFFSET  ((UINTN) BiosVideoPrivate->VbeEdidDataBlock);\r
-\r
-    BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-    //\r
-    // See if the VESA call succeeded\r
-    //\r
-    if (Regs.X.AX == VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {\r
-      //\r
-      // Set EDID Discovered Data\r
-      //\r
-      BiosVideoPrivate->EdidDiscovered.SizeOfEdid = VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE;\r
-       BiosVideoPrivate->EdidDiscovered.Edid = (UINT8 *) AllocateCopyPool (\r
-                                                          VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE,\r
-                                                          BiosVideoPrivate->VbeEdidDataBlock\r
-                                                           );\r
-\r
-      if (NULL == BiosVideoPrivate->EdidDiscovered.Edid) {\r
-         Status = EFI_OUT_OF_RESOURCES;\r
-        goto Done;\r
-      }\r
-\r
-      EdidFound = TRUE;\r
-    }\r
-  }\r
-\r
-  if (EdidFound) {\r
-    EdidActiveDataSize  = VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE;\r
-    EdidActiveDataBlock = BiosVideoPrivate->EdidDiscovered.Edid;\r
-  } else if (EdidOverrideFound) {\r
-    EdidActiveDataSize  = EdidOverrideDataSize;\r
-    EdidActiveDataBlock = EdidOverrideDataBlock;\r
-    EdidFound = TRUE;\r
-   }\r
-\r
-   if (EdidFound) {\r
-    //\r
-    // Parse EDID data structure to retrieve modes supported by monitor\r
-    //\r
-    if (ParseEdidData ((UINT8 *) EdidActiveDataBlock, &ValidEdidTiming)) {\r
-      //\r
-      // Copy EDID Override Data to EDID Active Data\r
-      //\r
-      BiosVideoPrivate->EdidActive.SizeOfEdid = (UINT32) EdidActiveDataSize;\r
-      BiosVideoPrivate->EdidActive.Edid = (UINT8 *) AllocateCopyPool (\r
-                                                      EdidActiveDataSize,\r
-                                                      EdidActiveDataBlock\r
-                                                      );\r
-      if (NULL ==  BiosVideoPrivate->EdidActive.Edid) {\r
-         Status = EFI_OUT_OF_RESOURCES;\r
-        goto Done;\r
-      }\r
-    }\r
-  } else {\r
-    BiosVideoPrivate->EdidActive.SizeOfEdid = 0;\r
-    BiosVideoPrivate->EdidActive.Edid = NULL;\r
-    EdidFound = FALSE;\r
-  }\r
-\r
-  //\r
-  // Walk through the mode list to see if there is at least one mode the is compatible with the EDID mode\r
-  //\r
-  ModeNumberPtr = (UINT16 *)\r
-    (\r
-      (((UINTN) BiosVideoPrivate->VbeInformationBlock->VideoModePtr & 0xffff0000) >> 12) |\r
-        ((UINTN) BiosVideoPrivate->VbeInformationBlock->VideoModePtr & 0x0000ffff)\r
-    );\r
-\r
-  PreferMode = 0;\r
-  ModeNumber = 0;\r
-\r
-  //\r
-  // ModeNumberPtr may be not 16-byte aligned, so ReadUnaligned16 is used to access the buffer pointed by ModeNumberPtr.\r
-  //\r
-  for (VbeModeNumber = ReadUnaligned16 (ModeNumberPtr);\r
-       VbeModeNumber != VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST;\r
-       VbeModeNumber = ReadUnaligned16 (++ModeNumberPtr)) {\r
-    //\r
-    // Make sure this is a mode number defined by the VESA VBE specification.  If it isn'tm then skip this mode number.\r
-    //\r
-    if ((VbeModeNumber & VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA) == 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // Get the information about the mode\r
-    //\r
-    gBS->SetMem (&Regs, sizeof (Regs), 0);\r
-    Regs.X.AX = VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION;\r
-    Regs.X.CX = VbeModeNumber;\r
-    gBS->SetMem (BiosVideoPrivate->VbeModeInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK), 0);\r
-    Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);\r
-    Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);\r
-\r
-    BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-    //\r
-    // See if the call succeeded.  If it didn't, then try the next mode.\r
-    //\r
-    if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the mode supports color.  If it doesn't then try the next mode.\r
-    //\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_COLOR) == 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the mode supports graphics.  If it doesn't then try the next mode.\r
-    //\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_GRAPHICS) == 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the mode supports a linear frame buffer.  If it doesn't then try the next mode.\r
-    //\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER) == 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the mode supports 32 bit color.  If it doesn't then try the next mode.\r
-    // 32 bit mode can be implemented by 24 Bits Per Pixels. Also make sure the\r
-    // number of bits per pixel is a multiple of 8 or more than 32 bits per pixel\r
-    //\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel < 24) {\r
-      continue;\r
-    }\r
-\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel > 32) {\r
-      continue;\r
-    }\r
-\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel % 8) != 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the physical base pointer for the linear mode is valid.  If it isn't then try the next mode.\r
-    //\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->PhysBasePtr == 0) {\r
-      continue;\r
-    }\r
-\r
-    DEBUG ((EFI_D_INFO, "Video Controller Mode 0x%x: %d x %d\n",\r
-            VbeModeNumber, BiosVideoPrivate->VbeModeInformationBlock->XResolution, BiosVideoPrivate->VbeModeInformationBlock->YResolution));\r
-\r
-    if (EdidFound && (ValidEdidTiming.ValidNumber > 0)) {\r
-      //\r
-      // EDID exist, check whether this mode match with any mode in EDID\r
-      //\r
-      Timing.HorizontalResolution = BiosVideoPrivate->VbeModeInformationBlock->XResolution;\r
-      Timing.VerticalResolution = BiosVideoPrivate->VbeModeInformationBlock->YResolution;\r
-      if (!SearchEdidTiming (&ValidEdidTiming, &Timing)) {\r
-        //\r
-        // When EDID comes from INT10 call, EDID does not include 800x600, 640x480 and 1024x768,\r
-        // but INT10 can support these modes, we add them into GOP mode.\r
-        //\r
-        if ((BiosVideoPrivate->EdidDiscovered.SizeOfEdid != 0) &&\r
-            !((Timing.HorizontalResolution) == 1024 && (Timing.VerticalResolution == 768)) &&\r
-            !((Timing.HorizontalResolution) == 800 && (Timing.VerticalResolution == 600)) &&\r
-            !((Timing.HorizontalResolution) == 640 && (Timing.VerticalResolution == 480))) {\r
-        continue;\r
-        }\r
-      }\r
-    }\r
-\r
-    //\r
-    // Select a reasonable mode to be set for current display mode\r
-    //\r
-    ModeFound = FALSE;\r
-\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 1024 &&\r
-        BiosVideoPrivate->VbeModeInformationBlock->YResolution == 768\r
-        ) {\r
-      ModeFound = TRUE;\r
-    }\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 800 &&\r
-        BiosVideoPrivate->VbeModeInformationBlock->YResolution == 600\r
-        ) {\r
-      ModeFound = TRUE;\r
-      PreferMode = ModeNumber;\r
-    }\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 640 &&\r
-        BiosVideoPrivate->VbeModeInformationBlock->YResolution == 480\r
-        ) {\r
-      ModeFound = TRUE;\r
-    }\r
-\r
-    if ((!EdidFound) && (!ModeFound)) {\r
-      //\r
-      // When no EDID exist, only select three possible resolutions, i.e. 1024x768, 800x600, 640x480\r
-      //\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Record the highest resolution mode to set later\r
-    //\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution > HighestHorizontalResolution) ||\r
-        ((BiosVideoPrivate->VbeModeInformationBlock->XResolution == HighestHorizontalResolution) &&\r
-         (BiosVideoPrivate->VbeModeInformationBlock->YResolution > HighestVerticalResolution))) {\r
-      HighestHorizontalResolution = BiosVideoPrivate->VbeModeInformationBlock->XResolution;\r
-      HighestVerticalResolution = BiosVideoPrivate->VbeModeInformationBlock->YResolution;\r
-      HighestResolutionMode = ModeNumber;\r
-    }\r
-\r
-    //\r
-    // Add mode to the list of available modes\r
-    //\r
-    ModeNumber ++;\r
-    ModeBuffer = (BIOS_VIDEO_MODE_DATA *) AllocatePool (\r
-                                            ModeNumber * sizeof (BIOS_VIDEO_MODE_DATA)\r
-                                            );\r
-    if (NULL == ModeBuffer) {\r
-      Status = EFI_OUT_OF_RESOURCES;\r
-      goto Done;\r
-    }\r
-\r
-    if (ModeNumber > 1) {\r
-      CopyMem (\r
-        ModeBuffer,\r
-        BiosVideoPrivate->ModeData,\r
-        (ModeNumber - 1) * sizeof (BIOS_VIDEO_MODE_DATA)\r
-        );\r
-    }\r
-\r
-    if (BiosVideoPrivate->ModeData != NULL) {\r
-      FreePool (BiosVideoPrivate->ModeData);\r
-    }\r
-\r
-    CurrentModeData = &ModeBuffer[ModeNumber - 1];\r
-    CurrentModeData->VbeModeNumber = VbeModeNumber;\r
-    if (BiosVideoPrivate->VbeInformationBlock->VESAVersion >= VESA_BIOS_EXTENSIONS_VERSION_3_0) {\r
-      CurrentModeData->BytesPerScanLine = BiosVideoPrivate->VbeModeInformationBlock->LinBytesPerScanLine;\r
-      CurrentModeData->Red.Position = BiosVideoPrivate->VbeModeInformationBlock->LinRedFieldPosition;\r
-      CurrentModeData->Red.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->LinRedMaskSize) - 1);\r
-      CurrentModeData->Blue.Position = BiosVideoPrivate->VbeModeInformationBlock->LinBlueFieldPosition;\r
-      CurrentModeData->Blue.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->LinBlueMaskSize) - 1);\r
-      CurrentModeData->Green.Position = BiosVideoPrivate->VbeModeInformationBlock->LinGreenFieldPosition;\r
-      CurrentModeData->Green.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->LinGreenMaskSize) - 1);\r
-      CurrentModeData->Reserved.Position = BiosVideoPrivate->VbeModeInformationBlock->LinRsvdFieldPosition;\r
-      CurrentModeData->Reserved.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->LinRsvdMaskSize) - 1);\r
-    } else {\r
-      CurrentModeData->BytesPerScanLine = BiosVideoPrivate->VbeModeInformationBlock->BytesPerScanLine;\r
-      CurrentModeData->Red.Position = BiosVideoPrivate->VbeModeInformationBlock->RedFieldPosition;\r
-      CurrentModeData->Red.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->RedMaskSize) - 1);\r
-      CurrentModeData->Blue.Position = BiosVideoPrivate->VbeModeInformationBlock->BlueFieldPosition;\r
-      CurrentModeData->Blue.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->BlueMaskSize) - 1);\r
-      CurrentModeData->Green.Position = BiosVideoPrivate->VbeModeInformationBlock->GreenFieldPosition;\r
-      CurrentModeData->Green.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->GreenMaskSize) - 1);\r
-      CurrentModeData->Reserved.Position = BiosVideoPrivate->VbeModeInformationBlock->RsvdFieldPosition;\r
-      CurrentModeData->Reserved.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->RsvdMaskSize) - 1);\r
-    }\r
-\r
-    CurrentModeData->PixelFormat = PixelBitMask;\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel == 32) &&\r
-        (CurrentModeData->Red.Mask == 0xff) && (CurrentModeData->Green.Mask == 0xff) && (CurrentModeData->Blue.Mask == 0xff)) {\r
-      if ((CurrentModeData->Red.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Blue.Position == 16)) {\r
-        CurrentModeData->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;\r
-      } else if ((CurrentModeData->Blue.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Red.Position == 16)) {\r
-        CurrentModeData->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;\r
-      }\r
-    }\r
-\r
-    CurrentModeData->PixelBitMask.RedMask = ((UINT32) CurrentModeData->Red.Mask) << CurrentModeData->Red.Position;\r
-    CurrentModeData->PixelBitMask.GreenMask = ((UINT32) CurrentModeData->Green.Mask) << CurrentModeData->Green.Position;\r
-    CurrentModeData->PixelBitMask.BlueMask = ((UINT32) CurrentModeData->Blue.Mask) << CurrentModeData->Blue.Position;\r
-    CurrentModeData->PixelBitMask.ReservedMask = ((UINT32) CurrentModeData->Reserved.Mask) << CurrentModeData->Reserved.Position;\r
-\r
-    CurrentModeData->LinearFrameBuffer = (VOID *) (UINTN)BiosVideoPrivate->VbeModeInformationBlock->PhysBasePtr;\r
-    CurrentModeData->HorizontalResolution = BiosVideoPrivate->VbeModeInformationBlock->XResolution;\r
-    CurrentModeData->VerticalResolution = BiosVideoPrivate->VbeModeInformationBlock->YResolution;\r
-\r
-    CurrentModeData->BitsPerPixel  = BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel;\r
-    CurrentModeData->FrameBufferSize = CurrentModeData->BytesPerScanLine * CurrentModeData->VerticalResolution;\r
-    //\r
-    // Make sure the FrameBufferSize does not exceed the max available frame buffer size reported by VEB.\r
-    //\r
-    ASSERT (CurrentModeData->FrameBufferSize <= ((UINT32)BiosVideoPrivate->VbeInformationBlock->TotalMemory * 64 * 1024));\r
-\r
-    BiosVideoPrivate->ModeData = ModeBuffer;\r
-  }\r
-  //\r
-  // Check to see if we found any modes that are compatible with GRAPHICS OUTPUT\r
-  //\r
-  if (ModeNumber == 0) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Assign Gop's Blt function\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.Blt     = BiosVideoGraphicsOutputVbeBlt;\r
-\r
-  BiosVideoPrivate->GraphicsOutput.Mode->MaxMode = (UINT32) ModeNumber;\r
-  //\r
-  // Current mode is unknow till now, set it to an invalid mode.\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;\r
-\r
-  //\r
-  // Find the best mode to initialize\r
-  //\r
-  if ((PcdGet32 (PcdVideoHorizontalResolution) == 0x0) || (PcdGet32 (PcdVideoVerticalResolution) == 0x0)) {\r
-    DEBUG_CODE (\r
-      BIOS_VIDEO_MODE_DATA    *ModeData;\r
-      ModeData = &BiosVideoPrivate->ModeData[HighestResolutionMode];\r
-      DEBUG ((EFI_D_INFO, "BiosVideo set highest resolution %d x %d\n",\r
-              ModeData->HorizontalResolution, ModeData->VerticalResolution));\r
-    );\r
-    PreferMode = HighestResolutionMode;\r
-  }\r
-  Status = BiosVideoGraphicsOutputSetMode (&BiosVideoPrivate->GraphicsOutput, (UINT32) PreferMode);\r
-  if (EFI_ERROR (Status)) {\r
-    for (PreferMode = 0; PreferMode < ModeNumber; PreferMode ++) {\r
-      Status = BiosVideoGraphicsOutputSetMode (\r
-                &BiosVideoPrivate->GraphicsOutput,\r
-                (UINT32) PreferMode\r
-                );\r
-      if (!EFI_ERROR (Status)) {\r
-        break;\r
-      }\r
-    }\r
-    if (PreferMode == ModeNumber) {\r
-      //\r
-      // None mode is set successfully.\r
-      //\r
-      goto Done;\r
-    }\r
-  }\r
-\r
-Done:\r
-  //\r
-  // If there was an error, then free the mode structure\r
-  //\r
-  if (EFI_ERROR (Status)) {\r
-    if (BiosVideoPrivate->ModeData != NULL) {\r
-      FreePool (BiosVideoPrivate->ModeData);\r
-      BiosVideoPrivate->ModeData  = NULL;\r
-      BiosVideoPrivate->MaxMode   = 0;\r
-    }\r
-    if (EdidOverrideDataBlock != NULL) {\r
-      FreePool (EdidOverrideDataBlock);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Check for VGA device.\r
-\r
-  @param  BiosVideoPrivate       Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  @retval EFI_SUCCESS            Standard VGA device found\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoCheckForVga (\r
-  IN OUT BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  BIOS_VIDEO_MODE_DATA  *ModeBuffer;\r
-\r
-  Status = EFI_UNSUPPORTED;\r
-\r
-  //\r
-  // Assign Gop's Blt function\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.Blt     = BiosVideoGraphicsOutputVgaBlt;\r
-\r
-  //\r
-  // Add mode to the list of available modes\r
-  // caller should guarantee that Mode has been allocated.\r
-  //\r
-  ASSERT (BiosVideoPrivate->GraphicsOutput.Mode != NULL);\r
-  BiosVideoPrivate->GraphicsOutput.Mode->MaxMode = 1;\r
-\r
-  ModeBuffer = (BIOS_VIDEO_MODE_DATA *) AllocatePool (\r
-                                          sizeof (BIOS_VIDEO_MODE_DATA)\r
-                                          );\r
-  if (NULL == ModeBuffer) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  ModeBuffer->VbeModeNumber         = 0x0012;\r
-  ModeBuffer->BytesPerScanLine      = 640;\r
-  ModeBuffer->LinearFrameBuffer     = (VOID *) (UINTN) (0xa0000);\r
-  ModeBuffer->HorizontalResolution  = 640;\r
-  ModeBuffer->VerticalResolution    = 480;\r
-  ModeBuffer->PixelFormat           = PixelBltOnly;\r
-  ModeBuffer->BitsPerPixel          = 8;\r
-  ModeBuffer->ColorDepth            = 32;\r
-  ModeBuffer->RefreshRate           = 60;\r
-\r
-  BiosVideoPrivate->ModeData = ModeBuffer;\r
-\r
-  //\r
-  // Test to see if the Video Adapter support the 640x480 16 color mode\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;\r
-  Status = BiosVideoGraphicsOutputSetMode (&BiosVideoPrivate->GraphicsOutput, 0);\r
-\r
-Done:\r
-  //\r
-  // If there was an error, then free the mode structure\r
-  //\r
-  if (EFI_ERROR (Status)) {\r
-    if (BiosVideoPrivate->ModeData != NULL) {\r
-      FreePool (BiosVideoPrivate->ModeData);\r
-      BiosVideoPrivate->ModeData = NULL;\r
-    }\r
-    if (BiosVideoPrivate->GraphicsOutput.Mode != NULL) {\r
-      if (BiosVideoPrivate->GraphicsOutput.Mode->Info != NULL) {\r
-        FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);\r
-        BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL;\r
-      }\r
-      FreePool (BiosVideoPrivate->GraphicsOutput.Mode);\r
-      BiosVideoPrivate->GraphicsOutput.Mode = NULL;\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r
-//\r
-// Graphics Output Protocol Member Functions for VESA BIOS Extensions\r
-//\r
-\r
-/**\r
-  Graphics Output protocol interface to get video mode.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  ModeNumber             The mode number to return information on.\r
-  @param  SizeOfInfo             A pointer to the size, in bytes, of the Info\r
-                                 buffer.\r
-  @param  Info                   Caller allocated buffer that returns information\r
-                                 about ModeNumber.\r
-\r
-  @retval EFI_SUCCESS            Mode information returned.\r
-  @retval EFI_DEVICE_ERROR       A hardware error occurred trying to retrieve the\r
-                                 video mode.\r
-  @retval EFI_NOT_STARTED        Video display is not initialized. Call SetMode ()\r
-  @retval EFI_INVALID_PARAMETER  One of the input args was NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputQueryMode (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,\r
-  IN  UINT32                                ModeNumber,\r
-  OUT UINTN                                 *SizeOfInfo,\r
-  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info\r
-  )\r
-{\r
-  BIOS_VIDEO_DEV        *BiosVideoPrivate;\r
-  BIOS_VIDEO_MODE_DATA  *ModeData;\r
-\r
-  BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
-\r
-  if (BiosVideoPrivate->HardwareNeedsStarting) {\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_OUTPUT_ERROR,\r
-      BiosVideoPrivate->GopDevicePath\r
-      );\r
-    return EFI_NOT_STARTED;\r
-  }\r
-\r
-  if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *Info = (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) AllocatePool (\r
-                                                    sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)\r
-                                                    );\r
-  if (NULL == *Info) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
-\r
-  ModeData = &BiosVideoPrivate->ModeData[ModeNumber];\r
-  (*Info)->Version = 0;\r
-  (*Info)->HorizontalResolution = ModeData->HorizontalResolution;\r
-  (*Info)->VerticalResolution   = ModeData->VerticalResolution;\r
-  (*Info)->PixelFormat = ModeData->PixelFormat;\r
-  CopyMem (&((*Info)->PixelInformation), &(ModeData->PixelBitMask), sizeof(ModeData->PixelBitMask));\r
-\r
-  (*Info)->PixelsPerScanLine =  (ModeData->BytesPerScanLine * 8) / ModeData->BitsPerPixel;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Worker function to set video mode.\r
-\r
-  @param  BiosVideoPrivate       Instance of BIOS_VIDEO_DEV.\r
-  @param  ModeData               The mode data to be set.\r
-  @param  DevicePath             Pointer to Device Path Protocol.\r
-\r
-  @retval EFI_SUCCESS            Graphics mode was changed.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the\r
-                                 request.\r
-  @retval EFI_UNSUPPORTED        ModeNumber is not supported by this device.\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoSetModeWorker (\r
-  IN  BIOS_VIDEO_DEV               *BiosVideoPrivate,\r
-  IN  BIOS_VIDEO_MODE_DATA         *ModeData,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_IA32_REGISTER_SET   Regs;\r
-\r
-  if (BiosVideoPrivate->LineBuffer != NULL) {\r
-    FreePool (BiosVideoPrivate->LineBuffer);\r
-  }\r
-\r
-  if (BiosVideoPrivate->VgaFrameBuffer != NULL) {\r
-    FreePool (BiosVideoPrivate->VgaFrameBuffer);\r
-  }\r
-\r
-  if (BiosVideoPrivate->VbeFrameBuffer != NULL) {\r
-    FreePool (BiosVideoPrivate->VbeFrameBuffer);\r
-  }\r
-\r
-  BiosVideoPrivate->LineBuffer = (UINT8 *) AllocatePool (\r
-                                             ModeData->BytesPerScanLine\r
-                                             );\r
-  if (NULL == BiosVideoPrivate->LineBuffer) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Clear all registers\r
-  //\r
-  ZeroMem (&Regs, sizeof (Regs));\r
-\r
-  if (ModeData->VbeModeNumber < 0x100) {\r
-    //\r
-    // Allocate a working buffer for BLT operations to the VGA frame buffer\r
-    //\r
-    BiosVideoPrivate->VgaFrameBuffer = (UINT8 *) AllocatePool (4 * 480 * 80);\r
-    if (NULL == BiosVideoPrivate->VgaFrameBuffer) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    //\r
-    // Set VGA Mode\r
-    //\r
-    Regs.X.AX = ModeData->VbeModeNumber;\r
-    BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-  } else {\r
-    //\r
-    // Allocate a working buffer for BLT operations to the VBE frame buffer\r
-    //\r
-    BiosVideoPrivate->VbeFrameBuffer =\r
-      (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocatePool (\r
-                                          ModeData->BytesPerScanLine * ModeData->VerticalResolution\r
-                                          );\r
-    if (NULL == BiosVideoPrivate->VbeFrameBuffer) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    //\r
-    // Set VBE mode\r
-    //\r
-    Regs.X.AX = VESA_BIOS_EXTENSIONS_SET_MODE;\r
-    Regs.X.BX = (UINT16) (ModeData->VbeModeNumber | VESA_BIOS_EXTENSIONS_MODE_NUMBER_LINEAR_FRAME_BUFFER);\r
-    ZeroMem (BiosVideoPrivate->VbeCrtcInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK));\r
-    Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeCrtcInformationBlock);\r
-    Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeCrtcInformationBlock);\r
-    BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-    //\r
-    // Check to see if the call succeeded\r
-    //\r
-    if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {\r
-      REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-        EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-        EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_OUTPUT_ERROR,\r
-        DevicePath\r
-        );\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-    //\r
-    // Initialize the state of the VbeFrameBuffer\r
-    //\r
-    Status = BiosVideoPrivate->PciIo->Mem.Read (\r
-                                            BiosVideoPrivate->PciIo,\r
-                                            EfiPciIoWidthUint32,\r
-                                            EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                            (UINT64) (UINTN) ModeData->LinearFrameBuffer,\r
-                                            (ModeData->BytesPerScanLine * ModeData->VerticalResolution) >> 2,\r
-                                            BiosVideoPrivate->VbeFrameBuffer\r
-                                            );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Graphics Output protocol interface to set video mode.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  ModeNumber             The mode number to be set.\r
-\r
-  @retval EFI_SUCCESS            Graphics mode was changed.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the\r
-                                 request.\r
-  @retval EFI_UNSUPPORTED        ModeNumber is not supported by this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputSetMode (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
-  IN  UINT32                       ModeNumber\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  BIOS_VIDEO_DEV          *BiosVideoPrivate;\r
-  BIOS_VIDEO_MODE_DATA    *ModeData;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
-\r
-  ModeData = &BiosVideoPrivate->ModeData[ModeNumber];\r
-\r
-  if (ModeNumber >= This->Mode->MaxMode) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (ModeNumber == This->Mode->Mode) {\r
-    //\r
-    // Clear screen to black\r
-    //\r
-    ZeroMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-    BiosVideoGraphicsOutputVbeBlt (\r
-                        This,\r
-                        &Background,\r
-                        EfiBltVideoFill,\r
-                        0,\r
-                        0,\r
-                        0,\r
-                        0,\r
-                        ModeData->HorizontalResolution,\r
-                        ModeData->VerticalResolution,\r
-                        0\r
-    );\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Status = BiosVideoSetModeWorker (BiosVideoPrivate, ModeData, BiosVideoPrivate->GopDevicePath);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  This->Mode->Mode = ModeNumber;\r
-  This->Mode->Info->Version = 0;\r
-  This->Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;\r
-  This->Mode->Info->VerticalResolution = ModeData->VerticalResolution;\r
-  This->Mode->Info->PixelFormat = ModeData->PixelFormat;\r
-  CopyMem (&(This->Mode->Info->PixelInformation), &(ModeData->PixelBitMask), sizeof (ModeData->PixelBitMask));\r
-  This->Mode->Info->PixelsPerScanLine =  (ModeData->BytesPerScanLine * 8) / ModeData->BitsPerPixel;\r
-  This->Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
-  This->Mode->FrameBufferSize = ModeData->FrameBufferSize;\r
-  This->Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) ModeData->LinearFrameBuffer;\r
-\r
-  BiosVideoPrivate->HardwareNeedsStarting = FALSE;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Update physical frame buffer, copy 4 bytes block, then copy remaining bytes.\r
-\r
-  @param   PciIo              The pointer of EFI_PCI_IO_PROTOCOL\r
-  @param   VbeBuffer          The data to transfer to screen\r
-  @param   MemAddress         Physical frame buffer base address\r
-  @param   DestinationX       The X coordinate of the destination for BltOperation\r
-  @param   DestinationY       The Y coordinate of the destination for BltOperation\r
-  @param   TotalBytes         The total bytes of copy\r
-  @param   VbePixelWidth      Bytes per pixel\r
-  @param   BytesPerScanLine   Bytes per scan line\r
-\r
-**/\r
-VOID\r
-CopyVideoBuffer (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT8                 *VbeBuffer,\r
-  IN  VOID                  *MemAddress,\r
-  IN  UINTN                 DestinationX,\r
-  IN  UINTN                 DestinationY,\r
-  IN  UINTN                 TotalBytes,\r
-  IN  UINT32                VbePixelWidth,\r
-  IN  UINTN                 BytesPerScanLine\r
-  )\r
-{\r
-  UINTN                 FrameBufferAddr;\r
-  UINTN                 CopyBlockNum;\r
-  UINTN                 RemainingBytes;\r
-  UINTN                 UnalignedBytes;\r
-  EFI_STATUS            Status;\r
-\r
-  FrameBufferAddr = (UINTN) MemAddress + (DestinationY * BytesPerScanLine) + DestinationX * VbePixelWidth;\r
-\r
-  //\r
-  // If TotalBytes is less than 4 bytes, only start byte copy.\r
-  //\r
-  if (TotalBytes < 4) {\r
-    Status = PciIo->Mem.Write (\r
-                     PciIo,\r
-                     EfiPciIoWidthUint8,\r
-                     EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                     (UINT64) FrameBufferAddr,\r
-                     TotalBytes,\r
-                     VbeBuffer\r
-                     );\r
-    ASSERT_EFI_ERROR (Status);\r
-    return;\r
-  }\r
-\r
-  //\r
-  // If VbeBuffer is not 4-byte aligned, start byte copy.\r
-  //\r
-  UnalignedBytes  = (4 - ((UINTN) VbeBuffer & 0x3)) & 0x3;\r
-\r
-  if (UnalignedBytes != 0) {\r
-    Status = PciIo->Mem.Write (\r
-                     PciIo,\r
-                     EfiPciIoWidthUint8,\r
-                     EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                     (UINT64) FrameBufferAddr,\r
-                     UnalignedBytes,\r
-                     VbeBuffer\r
-                     );\r
-    ASSERT_EFI_ERROR (Status);\r
-    FrameBufferAddr += UnalignedBytes;\r
-    VbeBuffer       += UnalignedBytes;\r
-  }\r
-\r
-  //\r
-  // Calculate 4-byte block count and remaining bytes.\r
-  //\r
-  CopyBlockNum   = (TotalBytes - UnalignedBytes) >> 2;\r
-  RemainingBytes = (TotalBytes - UnalignedBytes) &  3;\r
-\r
-  //\r
-  // Copy 4-byte block and remaining bytes to physical frame buffer.\r
-  //\r
-  if (CopyBlockNum != 0) {\r
-    Status = PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint32,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) FrameBufferAddr,\r
-                    CopyBlockNum,\r
-                    VbeBuffer\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  if (RemainingBytes != 0) {\r
-    FrameBufferAddr += (CopyBlockNum << 2);\r
-    VbeBuffer       += (CopyBlockNum << 2);\r
-    Status = PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) FrameBufferAddr,\r
-                    RemainingBytes,\r
-                    VbeBuffer\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-}\r
-\r
-/**\r
-  Worker function to block transfer for VBE device.\r
-\r
-  @param  BiosVideoPrivate       Instance of BIOS_VIDEO_DEV\r
-  @param  BltBuffer              The data to transfer to screen\r
-  @param  BltOperation           The operation to perform\r
-  @param  SourceX                The X coordinate of the source for BltOperation\r
-  @param  SourceY                The Y coordinate of the source for BltOperation\r
-  @param  DestinationX           The X coordinate of the destination for\r
-                                 BltOperation\r
-  @param  DestinationY           The Y coordinate of the destination for\r
-                                 BltOperation\r
-  @param  Width                  The width of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Height                 The height of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Delta                  Not used for EfiBltVideoFill and\r
-                                 EfiBltVideoToVideo operation. If a Delta of 0 is\r
-                                 used, the entire BltBuffer will be operated on. If\r
-                                 a subrectangle of the BltBuffer is used, then\r
-                                 Delta represents the number of bytes in a row of\r
-                                 the BltBuffer.\r
-  @param  Mode                   Mode data.\r
-\r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter passed in\r
-  @retval EFI_SUCCESS            Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoVbeBltWorker (\r
-  IN  BIOS_VIDEO_DEV                     *BiosVideoPrivate,\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION  BltOperation,\r
-  IN  UINTN                              SourceX,\r
-  IN  UINTN                              SourceY,\r
-  IN  UINTN                              DestinationX,\r
-  IN  UINTN                              DestinationY,\r
-  IN  UINTN                              Width,\r
-  IN  UINTN                              Height,\r
-  IN  UINTN                              Delta,\r
-  IN  BIOS_VIDEO_MODE_DATA               *Mode\r
-  )\r
-{\r
-  EFI_PCI_IO_PROTOCOL            *PciIo;\r
-  EFI_TPL                        OriginalTPL;\r
-  UINTN                          DstY;\r
-  UINTN                          SrcY;\r
-  UINTN                          DstX;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *Blt;\r
-  VOID                           *MemAddress;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *VbeFrameBuffer;\r
-  UINTN                          BytesPerScanLine;\r
-  UINTN                          Index;\r
-  UINT8                          *VbeBuffer;\r
-  UINT8                          *VbeBuffer1;\r
-  UINT8                          *BltUint8;\r
-  UINT32                         VbePixelWidth;\r
-  UINT32                         Pixel;\r
-  UINTN                          TotalBytes;\r
-\r
-  PciIo             = BiosVideoPrivate->PciIo;\r
-\r
-  VbeFrameBuffer    = BiosVideoPrivate->VbeFrameBuffer;\r
-  MemAddress        = Mode->LinearFrameBuffer;\r
-  BytesPerScanLine  = Mode->BytesPerScanLine;\r
-  VbePixelWidth     = Mode->BitsPerPixel / 8;\r
-  BltUint8          = (UINT8 *) BltBuffer;\r
-  TotalBytes        = Width * VbePixelWidth;\r
-\r
-  if (((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Width == 0 || Height == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // We need to fill the Virtual Screen buffer with the blt data.\r
-  // The virtual screen is upside down, as the first row is the bootom row of\r
-  // the image.\r
-  //\r
-  if (BltOperation == EfiBltVideoToBltBuffer) {\r
-    //\r
-    // Video to BltBuffer: Source is Video, destination is BltBuffer\r
-    //\r
-    if (SourceY + Height > Mode->VerticalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (SourceX + Width > Mode->HorizontalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  } else {\r
-    //\r
-    // BltBuffer to Video: Source is BltBuffer, destination is Video\r
-    //\r
-    if (DestinationY + Height > Mode->VerticalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (DestinationX + Width > Mode->HorizontalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // If Delta is zero, then the entire BltBuffer is being used, so Delta\r
-  // is the number of bytes in each row of BltBuffer.  Since BltBuffer is Width pixels size,\r
-  // the number of bytes in each row can be computed.\r
-  //\r
-  if (Delta == 0) {\r
-    Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
-  }\r
-  //\r
-  // We have to raise to TPL Notify, so we make an atomic write the frame buffer.\r
-  // We would not want a timer based event (Cursor, ...) to come in while we are\r
-  // doing this operation.\r
-  //\r
-  OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  switch (BltOperation) {\r
-  case EfiBltVideoToBltBuffer:\r
-    for (SrcY = SourceY, DstY = DestinationY; DstY < (Height + DestinationY); SrcY++, DstY++) {\r
-      Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) (BltUint8 + DstY * Delta + DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-      //\r
-      // Shuffle the packed bytes in the hardware buffer to match EFI_GRAPHICS_OUTPUT_BLT_PIXEL\r
-      //\r
-      VbeBuffer = ((UINT8 *) VbeFrameBuffer + (SrcY * BytesPerScanLine + SourceX * VbePixelWidth));\r
-      for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {\r
-        Pixel         = VbeBuffer[0] | VbeBuffer[1] << 8 | VbeBuffer[2] << 16 | VbeBuffer[3] << 24;\r
-        Blt->Red      = (UINT8) ((Pixel >> Mode->Red.Position) & Mode->Red.Mask);\r
-        Blt->Blue     = (UINT8) ((Pixel >> Mode->Blue.Position) & Mode->Blue.Mask);\r
-        Blt->Green    = (UINT8) ((Pixel >> Mode->Green.Position) & Mode->Green.Mask);\r
-        Blt->Reserved = 0;\r
-        Blt++;\r
-        VbeBuffer += VbePixelWidth;\r
-      }\r
-\r
-    }\r
-    break;\r
-\r
-  case EfiBltVideoToVideo:\r
-    for (Index = 0; Index < Height; Index++) {\r
-      if (DestinationY <= SourceY) {\r
-        SrcY  = SourceY + Index;\r
-        DstY  = DestinationY + Index;\r
-      } else {\r
-        SrcY  = SourceY + Height - Index - 1;\r
-        DstY  = DestinationY + Height - Index - 1;\r
-      }\r
-\r
-      VbeBuffer   = ((UINT8 *) VbeFrameBuffer + DstY * BytesPerScanLine + DestinationX * VbePixelWidth);\r
-      VbeBuffer1  = ((UINT8 *) VbeFrameBuffer + SrcY * BytesPerScanLine + SourceX * VbePixelWidth);\r
-\r
-      gBS->CopyMem (\r
-            VbeBuffer,\r
-            VbeBuffer1,\r
-            TotalBytes\r
-            );\r
-\r
-      //\r
-      // Update physical frame buffer.\r
-      //\r
-      CopyVideoBuffer (\r
-        PciIo,\r
-        VbeBuffer,\r
-        MemAddress,\r
-        DestinationX,\r
-        DstY,\r
-        TotalBytes,\r
-        VbePixelWidth,\r
-        BytesPerScanLine\r
-        );\r
-    }\r
-    break;\r
-\r
-  case EfiBltVideoFill:\r
-    VbeBuffer = (UINT8 *) ((UINTN) VbeFrameBuffer + (DestinationY * BytesPerScanLine) + DestinationX * VbePixelWidth);\r
-    Blt       = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltUint8;\r
-    //\r
-    // Shuffle the RGB fields in EFI_GRAPHICS_OUTPUT_BLT_PIXEL to match the hardware buffer\r
-    //\r
-    Pixel = ((Blt->Red & Mode->Red.Mask) << Mode->Red.Position) |\r
-      (\r
-        (Blt->Green & Mode->Green.Mask) <<\r
-        Mode->Green.Position\r
-      ) |\r
-          ((Blt->Blue & Mode->Blue.Mask) << Mode->Blue.Position);\r
-\r
-    for (Index = 0; Index < Width; Index++) {\r
-      gBS->CopyMem (\r
-            VbeBuffer,\r
-            &Pixel,\r
-            VbePixelWidth\r
-            );\r
-      VbeBuffer += VbePixelWidth;\r
-    }\r
-\r
-    VbeBuffer = (UINT8 *) ((UINTN) VbeFrameBuffer + (DestinationY * BytesPerScanLine) + DestinationX * VbePixelWidth);\r
-    for (DstY = DestinationY + 1; DstY < (Height + DestinationY); DstY++) {\r
-      gBS->CopyMem (\r
-            (VOID *) ((UINTN) VbeFrameBuffer + (DstY * BytesPerScanLine) + DestinationX * VbePixelWidth),\r
-            VbeBuffer,\r
-            TotalBytes\r
-            );\r
-    }\r
-\r
-    for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {\r
-      //\r
-      // Update physical frame buffer.\r
-      //\r
-      CopyVideoBuffer (\r
-        PciIo,\r
-        VbeBuffer,\r
-        MemAddress,\r
-        DestinationX,\r
-        DstY,\r
-        TotalBytes,\r
-        VbePixelWidth,\r
-        BytesPerScanLine\r
-        );\r
-    }\r
-    break;\r
-\r
-  case EfiBltBufferToVideo:\r
-    for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) {\r
-      Blt       = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) (BltUint8 + (SrcY * Delta) + (SourceX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-      VbeBuffer = ((UINT8 *) VbeFrameBuffer + (DstY * BytesPerScanLine + DestinationX * VbePixelWidth));\r
-      for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {\r
-        //\r
-        // Shuffle the RGB fields in EFI_GRAPHICS_OUTPUT_BLT_PIXEL to match the hardware buffer\r
-        //\r
-        Pixel = ((Blt->Red & Mode->Red.Mask) << Mode->Red.Position) |\r
-          ((Blt->Green & Mode->Green.Mask) << Mode->Green.Position) |\r
-            ((Blt->Blue & Mode->Blue.Mask) << Mode->Blue.Position);\r
-        gBS->CopyMem (\r
-              VbeBuffer,\r
-              &Pixel,\r
-              VbePixelWidth\r
-              );\r
-        Blt++;\r
-        VbeBuffer += VbePixelWidth;\r
-      }\r
-\r
-      VbeBuffer = ((UINT8 *) VbeFrameBuffer + (DstY * BytesPerScanLine + DestinationX * VbePixelWidth));\r
-\r
-      //\r
-      // Update physical frame buffer.\r
-      //\r
-      CopyVideoBuffer (\r
-        PciIo,\r
-        VbeBuffer,\r
-        MemAddress,\r
-        DestinationX,\r
-        DstY,\r
-        TotalBytes,\r
-        VbePixelWidth,\r
-        BytesPerScanLine\r
-        );\r
-    }\r
-    break;\r
-\r
-    default: ;\r
-  }\r
-\r
-  gBS->RestoreTPL (OriginalTPL);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Graphics Output protocol instance to block transfer for VBE device.\r
-\r
-  @param  This                   Pointer to Graphics Output protocol instance\r
-  @param  BltBuffer              The data to transfer to screen\r
-  @param  BltOperation           The operation to perform\r
-  @param  SourceX                The X coordinate of the source for BltOperation\r
-  @param  SourceY                The Y coordinate of the source for BltOperation\r
-  @param  DestinationX           The X coordinate of the destination for\r
-                                 BltOperation\r
-  @param  DestinationY           The Y coordinate of the destination for\r
-                                 BltOperation\r
-  @param  Width                  The width of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Height                 The height of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Delta                  Not used for EfiBltVideoFill and\r
-                                 EfiBltVideoToVideo operation. If a Delta of 0 is\r
-                                 used, the entire BltBuffer will be operated on. If\r
-                                 a subrectangle of the BltBuffer is used, then\r
-                                 Delta represents the number of bytes in a row of\r
-                                 the BltBuffer.\r
-\r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter passed in\r
-  @retval EFI_SUCCESS            Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVbeBlt (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL       *This,\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION  BltOperation,\r
-  IN  UINTN                              SourceX,\r
-  IN  UINTN                              SourceY,\r
-  IN  UINTN                              DestinationX,\r
-  IN  UINTN                              DestinationY,\r
-  IN  UINTN                              Width,\r
-  IN  UINTN                              Height,\r
-  IN  UINTN                              Delta\r
-  )\r
-{\r
-  BIOS_VIDEO_DEV                 *BiosVideoPrivate;\r
-  BIOS_VIDEO_MODE_DATA           *Mode;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  BiosVideoPrivate  = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
-  Mode              = &BiosVideoPrivate->ModeData[This->Mode->Mode];\r
-\r
-  return BiosVideoVbeBltWorker (\r
-           BiosVideoPrivate,\r
-           BltBuffer,\r
-           BltOperation,\r
-           SourceX,\r
-           SourceY,\r
-           DestinationX,\r
-           DestinationY,\r
-           Width,\r
-           Height,\r
-           Delta,\r
-           Mode\r
-           );\r
-}\r
-\r
-/**\r
-  Write graphics controller registers.\r
-\r
-  @param  PciIo                  Pointer to PciIo protocol instance of the\r
-                                 controller\r
-  @param  Address                Register address\r
-  @param  Data                   Data to be written to register\r
-\r
-  @return None\r
-\r
-**/\r
-VOID\r
-WriteGraphicsController (\r
-  IN  EFI_PCI_IO_PROTOCOL  *PciIo,\r
-  IN  UINTN                Address,\r
-  IN  UINTN                Data\r
-  )\r
-{\r
-  Address = Address | (Data << 8);\r
-  PciIo->Io.Write (\r
-              PciIo,\r
-              EfiPciIoWidthUint16,\r
-              EFI_PCI_IO_PASS_THROUGH_BAR,\r
-              VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER,\r
-              1,\r
-              &Address\r
-              );\r
-}\r
-\r
-\r
-/**\r
-  Read the four bit plane of VGA frame buffer.\r
-\r
-  @param  PciIo                  Pointer to PciIo protocol instance of the\r
-                                 controller\r
-  @param  HardwareBuffer         Hardware VGA frame buffer address\r
-  @param  MemoryBuffer           Memory buffer address\r
-  @param  WidthInBytes           Number of bytes in a line to read\r
-  @param  Height                 Height of the area to read\r
-\r
-  @return None\r
-\r
-**/\r
-VOID\r
-VgaReadBitPlanes (\r
-  EFI_PCI_IO_PROTOCOL  *PciIo,\r
-  UINT8                *HardwareBuffer,\r
-  UINT8                *MemoryBuffer,\r
-  UINTN                WidthInBytes,\r
-  UINTN                Height\r
-  )\r
-{\r
-  UINTN BitPlane;\r
-  UINTN Rows;\r
-  UINTN FrameBufferOffset;\r
-  UINT8 *Source;\r
-  UINT8 *Destination;\r
-\r
-  //\r
-  // Program the Mode Register Write mode 0, Read mode 0\r
-  //\r
-  WriteGraphicsController (\r
-    PciIo,\r
-    VGA_GRAPHICS_CONTROLLER_MODE_REGISTER,\r
-    VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRITE_MODE_0\r
-    );\r
-\r
-  for (BitPlane = 0, FrameBufferOffset = 0;\r
-       BitPlane < VGA_NUMBER_OF_BIT_PLANES;\r
-       BitPlane++, FrameBufferOffset += VGA_BYTES_PER_BIT_PLANE\r
-      ) {\r
-    //\r
-    // Program the Read Map Select Register to select the correct bit plane\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER,\r
-      BitPlane\r
-      );\r
-\r
-    Source      = HardwareBuffer;\r
-    Destination = MemoryBuffer + FrameBufferOffset;\r
-\r
-    for (Rows = 0; Rows < Height; Rows++, Source += VGA_BYTES_PER_SCAN_LINE, Destination += VGA_BYTES_PER_SCAN_LINE) {\r
-      PciIo->Mem.Read (\r
-                  PciIo,\r
-                  EfiPciIoWidthUint8,\r
-                  EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                  (UINT64) (UINTN) Source,\r
-                  WidthInBytes,\r
-                  (VOID *) Destination\r
-                  );\r
-    }\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Internal routine to convert VGA color to Grahpics Output color.\r
-\r
-  @param  MemoryBuffer           Buffer containing VGA color\r
-  @param  CoordinateX            The X coordinate of pixel on screen\r
-  @param  CoordinateY            The Y coordinate of pixel on screen\r
-  @param  BltBuffer              Buffer to contain converted Grahpics Output color\r
-\r
-  @return None\r
-\r
-**/\r
-VOID\r
-VgaConvertToGraphicsOutputColor (\r
-  UINT8                          *MemoryBuffer,\r
-  UINTN                          CoordinateX,\r
-  UINTN                          CoordinateY,\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer\r
-  )\r
-{\r
-  UINTN Mask;\r
-  UINTN Bit;\r
-  UINTN Color;\r
-\r
-  MemoryBuffer += ((CoordinateY << 6) + (CoordinateY << 4) + (CoordinateX >> 3));\r
-  Mask = mVgaBitMaskTable[CoordinateX & 0x07];\r
-  for (Bit = 0x01, Color = 0; Bit < 0x10; Bit <<= 1, MemoryBuffer += VGA_BYTES_PER_BIT_PLANE) {\r
-    if ((*MemoryBuffer & Mask) != 0) {\r
-      Color |= Bit;\r
-    }\r
-  }\r
-\r
-  *BltBuffer = mVgaColorToGraphicsOutputColor[Color];\r
-}\r
-\r
-/**\r
-  Internal routine to convert Grahpics Output color to VGA color.\r
-\r
-  @param  BltBuffer              buffer containing Grahpics Output color\r
-\r
-  @return Converted VGA color\r
-\r
-**/\r
-UINT8\r
-VgaConvertColor (\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL          *BltBuffer\r
-  )\r
-{\r
-  UINT8 Color;\r
-\r
-  Color = (UINT8) ((BltBuffer->Blue >> 7) | ((BltBuffer->Green >> 6) & 0x02) | ((BltBuffer->Red >> 5) & 0x04));\r
-  if ((BltBuffer->Red + BltBuffer->Green + BltBuffer->Blue) > 0x180) {\r
-    Color |= 0x08;\r
-  }\r
-\r
-  return Color;\r
-}\r
-\r
-\r
-/**\r
-  Grahpics Output protocol instance to block transfer for VGA device.\r
-\r
-  @param  This                   Pointer to Grahpics Output protocol instance\r
-  @param  BltBuffer              The data to transfer to screen\r
-  @param  BltOperation           The operation to perform\r
-  @param  SourceX                The X coordinate of the source for BltOperation\r
-  @param  SourceY                The Y coordinate of the source for BltOperation\r
-  @param  DestinationX           The X coordinate of the destination for\r
-                                 BltOperation\r
-  @param  DestinationY           The Y coordinate of the destination for\r
-                                 BltOperation\r
-  @param  Width                  The width of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Height                 The height of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Delta                  Not used for EfiBltVideoFill and\r
-                                 EfiBltVideoToVideo operation. If a Delta of 0 is\r
-                                 used, the entire BltBuffer will be operated on. If\r
-                                 a subrectangle of the BltBuffer is used, then\r
-                                 Delta represents the number of bytes in a row of\r
-                                 the BltBuffer.\r
-\r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter passed in\r
-  @retval EFI_SUCCESS            Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVgaBlt (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL       *This,\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION  BltOperation,\r
-  IN  UINTN                              SourceX,\r
-  IN  UINTN                              SourceY,\r
-  IN  UINTN                              DestinationX,\r
-  IN  UINTN                              DestinationY,\r
-  IN  UINTN                              Width,\r
-  IN  UINTN                              Height,\r
-  IN  UINTN                              Delta\r
-  )\r
-{\r
-  BIOS_VIDEO_DEV      *BiosVideoPrivate;\r
-  EFI_TPL             OriginalTPL;\r
-  UINT8               *MemAddress;\r
-  UINTN               BytesPerScanLine;\r
-  UINTN               Bit;\r
-  UINTN               Index;\r
-  UINTN               Index1;\r
-  UINTN               StartAddress;\r
-  UINTN               Bytes;\r
-  UINTN               Offset;\r
-  UINT8               LeftMask;\r
-  UINT8               RightMask;\r
-  UINTN               Address;\r
-  UINTN               AddressFix;\r
-  UINT8               *Address1;\r
-  UINT8               *SourceAddress;\r
-  UINT8               *DestinationAddress;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-  UINT8               Data;\r
-  UINT8               PixelColor;\r
-  UINT8               *VgaFrameBuffer;\r
-  UINTN               SourceOffset;\r
-  UINTN               SourceWidth;\r
-  UINTN               Rows;\r
-  UINTN               Columns;\r
-  UINTN               CoordinateX;\r
-  UINTN               CoordinateY;\r
-  UINTN               CurrentMode;\r
-\r
-  if (This == NULL || ((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  BiosVideoPrivate  = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
-\r
-  CurrentMode = This->Mode->Mode;\r
-  PciIo             = BiosVideoPrivate->PciIo;\r
-  MemAddress        = BiosVideoPrivate->ModeData[CurrentMode].LinearFrameBuffer;\r
-  BytesPerScanLine  = BiosVideoPrivate->ModeData[CurrentMode].BytesPerScanLine >> 3;\r
-  VgaFrameBuffer    = BiosVideoPrivate->VgaFrameBuffer;\r
-\r
-\r
-  if (Width == 0 || Height == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // We need to fill the Virtual Screen buffer with the blt data.\r
-  // The virtual screen is upside down, as the first row is the bootom row of\r
-  // the image.\r
-  //\r
-  if (BltOperation == EfiBltVideoToBltBuffer) {\r
-    //\r
-    // Video to BltBuffer: Source is Video, destination is BltBuffer\r
-    //\r
-    if (SourceY + Height > BiosVideoPrivate->ModeData[CurrentMode].VerticalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (SourceX + Width > BiosVideoPrivate->ModeData[CurrentMode].HorizontalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  } else {\r
-    //\r
-    // BltBuffer to Video: Source is BltBuffer, destination is Video\r
-    //\r
-    if (DestinationY + Height > BiosVideoPrivate->ModeData[CurrentMode].VerticalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (DestinationX + Width > BiosVideoPrivate->ModeData[CurrentMode].HorizontalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // If Delta is zero, then the entire BltBuffer is being used, so Delta\r
-  // is the number of bytes in each row of BltBuffer.  Since BltBuffer is Width pixels size,\r
-  // the number of bytes in each row can be computed.\r
-  //\r
-  if (Delta == 0) {\r
-    Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
-  }\r
-  //\r
-  // We have to raise to TPL Notify, so we make an atomic write the frame buffer.\r
-  // We would not want a timer based event (Cursor, ...) to come in while we are\r
-  // doing this operation.\r
-  //\r
-  OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // Compute some values we need for VGA\r
-  //\r
-  switch (BltOperation) {\r
-  case EfiBltVideoToBltBuffer:\r
-\r
-    SourceOffset  = (SourceY << 6) + (SourceY << 4) + (SourceX >> 3);\r
-    SourceWidth   = ((SourceX + Width - 1) >> 3) - (SourceX >> 3) + 1;\r
-\r
-    //\r
-    // Read all the pixels in the 4 bit planes into a memory buffer that looks like the VGA buffer\r
-    //\r
-    VgaReadBitPlanes (\r
-      PciIo,\r
-      MemAddress + SourceOffset,\r
-      VgaFrameBuffer + SourceOffset,\r
-      SourceWidth,\r
-      Height\r
-      );\r
-\r
-    //\r
-    // Convert VGA Bit Planes to a Graphics Output 32-bit color value\r
-    //\r
-    BltBuffer += (DestinationY * (Delta >> 2) + DestinationX);\r
-    for (Rows = 0, CoordinateY = SourceY; Rows < Height; Rows++, CoordinateY++, BltBuffer += (Delta >> 2)) {\r
-      for (Columns = 0, CoordinateX = SourceX; Columns < Width; Columns++, CoordinateX++, BltBuffer++) {\r
-        VgaConvertToGraphicsOutputColor (VgaFrameBuffer, CoordinateX, CoordinateY, BltBuffer);\r
-      }\r
-\r
-      BltBuffer -= Width;\r
-    }\r
-\r
-    break;\r
-\r
-  case EfiBltVideoToVideo:\r
-    //\r
-    // Check for an aligned Video to Video operation\r
-    //\r
-    if ((SourceX & 0x07) == 0x00 && (DestinationX & 0x07) == 0x00 && (Width & 0x07) == 0x00) {\r
-      //\r
-      // Program the Mode Register Write mode 1, Read mode 0\r
-      //\r
-      WriteGraphicsController (\r
-        PciIo,\r
-        VGA_GRAPHICS_CONTROLLER_MODE_REGISTER,\r
-        VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRITE_MODE_1\r
-        );\r
-\r
-      SourceAddress       = (UINT8 *) (MemAddress + (SourceY << 6) + (SourceY << 4) + (SourceX >> 3));\r
-      DestinationAddress  = (UINT8 *) (MemAddress + (DestinationY << 6) + (DestinationY << 4) + (DestinationX >> 3));\r
-      Bytes               = Width >> 3;\r
-      for (Index = 0, Offset = 0; Index < Height; Index++, Offset += BytesPerScanLine) {\r
-        PciIo->CopyMem (\r
-                PciIo,\r
-                EfiPciIoWidthUint8,\r
-                EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                (UINT64) (UINTN) (DestinationAddress + Offset),\r
-                EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                (UINT64) (UINTN) (SourceAddress + Offset),\r
-                Bytes\r
-                );\r
-      }\r
-    } else {\r
-      SourceOffset  = (SourceY << 6) + (SourceY << 4) + (SourceX >> 3);\r
-      SourceWidth   = ((SourceX + Width - 1) >> 3) - (SourceX >> 3) + 1;\r
-\r
-      //\r
-      // Read all the pixels in the 4 bit planes into a memory buffer that looks like the VGA buffer\r
-      //\r
-      VgaReadBitPlanes (\r
-        PciIo,\r
-        MemAddress + SourceOffset,\r
-        VgaFrameBuffer + SourceOffset,\r
-        SourceWidth,\r
-        Height\r
-        );\r
-    }\r
-\r
-    break;\r
-\r
-  case EfiBltVideoFill:\r
-    StartAddress  = (UINTN) (MemAddress + (DestinationY << 6) + (DestinationY << 4) + (DestinationX >> 3));\r
-    Bytes         = ((DestinationX + Width - 1) >> 3) - (DestinationX >> 3);\r
-    LeftMask      = mVgaLeftMaskTable[DestinationX & 0x07];\r
-    RightMask     = mVgaRightMaskTable[(DestinationX + Width - 1) & 0x07];\r
-    if (Bytes == 0) {\r
-      LeftMask = (UINT8) (LeftMask & RightMask);\r
-      RightMask = 0;\r
-    }\r
-\r
-    if (LeftMask == 0xff) {\r
-      StartAddress--;\r
-      Bytes++;\r
-      LeftMask = 0;\r
-    }\r
-\r
-    if (RightMask == 0xff) {\r
-      Bytes++;\r
-      RightMask = 0;\r
-    }\r
-\r
-    PixelColor = VgaConvertColor (BltBuffer);\r
-\r
-    //\r
-    // Program the Mode Register Write mode 2, Read mode 0\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_MODE_REGISTER,\r
-      VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2\r
-      );\r
-\r
-    //\r
-    // Program the Data Rotate/Function Select Register to replace\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER,\r
-      VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE\r
-      );\r
-\r
-    if (LeftMask != 0) {\r
-      //\r
-      // Program the BitMask register with the Left column mask\r
-      //\r
-      WriteGraphicsController (\r
-        PciIo,\r
-        VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER,\r
-        LeftMask\r
-        );\r
-\r
-      for (Index = 0, Address = StartAddress; Index < Height; Index++, Address += BytesPerScanLine) {\r
-        //\r
-        // Read data from the bit planes into the latches\r
-        //\r
-        PciIo->Mem.Read (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) (UINTN) Address,\r
-                    1,\r
-                    &Data\r
-                    );\r
-        //\r
-        // Write the lower 4 bits of PixelColor to the bit planes in the pixels enabled by BitMask\r
-        //\r
-        PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) (UINTN) Address,\r
-                    1,\r
-                    &PixelColor\r
-                    );\r
-      }\r
-    }\r
-\r
-    if (Bytes > 1) {\r
-      //\r
-      // Program the BitMask register with the middle column mask of 0xff\r
-      //\r
-      WriteGraphicsController (\r
-        PciIo,\r
-        VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER,\r
-        0xff\r
-        );\r
-\r
-      for (Index = 0, Address = StartAddress + 1; Index < Height; Index++, Address += BytesPerScanLine) {\r
-        PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthFillUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) (UINTN) Address,\r
-                    Bytes - 1,\r
-                    &PixelColor\r
-                    );\r
-      }\r
-    }\r
-\r
-    if (RightMask != 0) {\r
-      //\r
-      // Program the BitMask register with the Right column mask\r
-      //\r
-      WriteGraphicsController (\r
-        PciIo,\r
-        VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER,\r
-        RightMask\r
-        );\r
-\r
-      for (Index = 0, Address = StartAddress + Bytes; Index < Height; Index++, Address += BytesPerScanLine) {\r
-        //\r
-        // Read data from the bit planes into the latches\r
-        //\r
-        PciIo->Mem.Read (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) (UINTN) Address,\r
-                    1,\r
-                    &Data\r
-                    );\r
-        //\r
-        // Write the lower 4 bits of PixelColor to the bit planes in the pixels enabled by BitMask\r
-        //\r
-        PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) (UINTN) Address,\r
-                    1,\r
-                    &PixelColor\r
-                    );\r
-      }\r
-    }\r
-    break;\r
-\r
-  case EfiBltBufferToVideo:\r
-    StartAddress  = (UINTN) (MemAddress + (DestinationY << 6) + (DestinationY << 4) + (DestinationX >> 3));\r
-    LeftMask      = mVgaBitMaskTable[DestinationX & 0x07];\r
-\r
-    //\r
-    // Program the Mode Register Write mode 2, Read mode 0\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_MODE_REGISTER,\r
-      VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2\r
-      );\r
-\r
-    //\r
-    // Program the Data Rotate/Function Select Register to replace\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER,\r
-      VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE\r
-      );\r
-\r
-    for (Index = 0, Address = StartAddress; Index < Height; Index++, Address += BytesPerScanLine) {\r
-      for (Index1 = 0; Index1 < Width; Index1++) {\r
-        BiosVideoPrivate->LineBuffer[Index1] = VgaConvertColor (&BltBuffer[(SourceY + Index) * (Delta >> 2) + SourceX + Index1]);\r
-      }\r
-      AddressFix = Address;\r
-\r
-      for (Bit = 0; Bit < 8; Bit++) {\r
-        //\r
-        // Program the BitMask register with the Left column mask\r
-        //\r
-        WriteGraphicsController (\r
-          PciIo,\r
-          VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER,\r
-          LeftMask\r
-          );\r
-\r
-        for (Index1 = Bit, Address1 = (UINT8 *) AddressFix; Index1 < Width; Index1 += 8, Address1++) {\r
-          //\r
-          // Read data from the bit planes into the latches\r
-          //\r
-          PciIo->Mem.Read (\r
-                      PciIo,\r
-                      EfiPciIoWidthUint8,\r
-                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                      (UINT64) (UINTN) Address1,\r
-                      1,\r
-                      &Data\r
-                      );\r
-\r
-          PciIo->Mem.Write (\r
-                      PciIo,\r
-                      EfiPciIoWidthUint8,\r
-                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                      (UINT64) (UINTN) Address1,\r
-                      1,\r
-                      &BiosVideoPrivate->LineBuffer[Index1]\r
-                      );\r
-        }\r
-\r
-        LeftMask = (UINT8) (LeftMask >> 1);\r
-        if (LeftMask == 0) {\r
-          LeftMask = 0x80;\r
-          AddressFix++;\r
-        }\r
-      }\r
-    }\r
-\r
-    break;\r
-\r
-    default: ;\r
-  }\r
-\r
-  gBS->RestoreTPL (OriginalTPL);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// VGA Mini Port Protocol Functions\r
-//\r
-\r
-/**\r
-  VgaMiniPort protocol interface to set mode.\r
-\r
-  @param  This                   Pointer to VgaMiniPort protocol instance\r
-  @param  ModeNumber             The index of the mode\r
-\r
-  @retval EFI_UNSUPPORTED        The requested mode is not supported\r
-  @retval EFI_SUCCESS            The requested mode is set successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoVgaMiniPortSetMode (\r
-  IN  EFI_VGA_MINI_PORT_PROTOCOL  *This,\r
-  IN  UINTN                       ModeNumber\r
-  )\r
-{\r
-  BIOS_VIDEO_DEV        *BiosVideoPrivate;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Make sure the ModeNumber is a valid value\r
-  //\r
-  if (ModeNumber >= This->MaxMode) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Get the device structure for this device\r
-  //\r
-  BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS (This);\r
-\r
-  switch (ModeNumber) {\r
-  case 0:\r
-    //\r
-    // Set the 80x25 Text VGA Mode\r
-    //\r
-    Regs.H.AH = 0x00;\r
-    Regs.H.AL = 0x83;\r
-    BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-    Regs.H.AH = 0x11;\r
-    Regs.H.AL = 0x14;\r
-    Regs.H.BL = 0;\r
-    BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-    break;\r
-\r
-  case 1:\r
-    //\r
-    // Set the 80x50 Text VGA Mode\r
-    //\r
-    Regs.H.AH = 0x00;\r
-    Regs.H.AL = 0x83;\r
-    BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-    Regs.H.AH = 0x11;\r
-    Regs.H.AL = 0x12;\r
-    Regs.H.BL = 0;\r
-    BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-    break;\r
-\r
-  default:\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Event handler for Exit Boot Service.\r
-\r
-  @param  Event       The event that be siganlled when exiting boot service.\r
-  @param  Context     Pointer to instance of BIOS_VIDEO_DEV.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BiosVideoNotifyExitBootServices (\r
-  IN  EFI_EVENT Event,\r
-  IN  VOID      *Context\r
-  )\r
-{\r
-  BIOS_VIDEO_DEV         *BiosVideoPrivate;\r
-  EFI_IA32_REGISTER_SET  Regs;\r
-\r
-  BiosVideoPrivate  = (BIOS_VIDEO_DEV *)Context;\r
-\r
-  //\r
-  // Set the 80x25 Text VGA Mode\r
-  //\r
-  Regs.H.AH = 0x00;\r
-  Regs.H.AL = 0x03;\r
-  BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-  Regs.H.AH = 0x00;\r
-  Regs.H.AL = 0x83;\r
-  BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-\r
-  Regs.H.AH = 0x11;\r
-  Regs.H.AL = 0x04;\r
-  Regs.H.BL = 0;\r
-  BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);\r
-}\r
-\r
-/**\r
-  The user Entry Point for module UefiBiosVideo. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoEntryPoint(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gBiosVideoDriverBinding,\r
-             ImageHandle,\r
-             &gBiosVideoComponentName,\r
-             &gBiosVideoComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Install Legacy BIOS GUID to mark this driver as a BIOS Thunk Driver\r
-  //\r
-  return gBS->InstallMultipleProtocolInterfaces (\r
-                &ImageHandle,\r
-                &gEfiLegacyBiosGuid,\r
-                NULL,\r
-                NULL\r
-                );\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideo.h b/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideo.h
deleted file mode 100644 (file)
index 951f4e6..0000000
+++ /dev/null
@@ -1,532 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _BIOS_GRAPHICS_OUTPUT_H_\r
-#define _BIOS_GRAPHICS_OUTPUT_H_\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/EdidActive.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/EdidDiscovered.h>\r
-#include <Protocol/LegacyBios.h>\r
-#include <Protocol/VgaMiniPort.h>\r
-#include <Protocol/GraphicsOutput.h>\r
-#include <Protocol/EdidOverride.h>\r
-\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/LegacyBios.h>\r
-#include <Guid/EventGroup.h>\r
-\r
-#include <Library/PcdLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-#include "VesaBiosExtensions.h"\r
-\r
-//\r
-// Packed format support: The number of bits reserved for each of the colors and the actual\r
-// position of RGB in the frame buffer is specified in the VBE Mode information\r
-//\r
-typedef struct {\r
-  UINT8 Position; // Position of the color\r
-  UINT8 Mask;     // The number of bits expressed as a mask\r
-} BIOS_VIDEO_COLOR_PLACEMENT;\r
-\r
-//\r
-// BIOS Graphics Output Graphical Mode Data\r
-//\r
-typedef struct {\r
-  UINT16                      VbeModeNumber;\r
-  UINT16                      BytesPerScanLine;\r
-  VOID                        *LinearFrameBuffer;\r
-  UINTN                       FrameBufferSize;\r
-  UINT32                      HorizontalResolution;\r
-  UINT32                      VerticalResolution;\r
-  UINT32                      ColorDepth;\r
-  UINT32                      RefreshRate;\r
-  UINT32                      BitsPerPixel;\r
-  BIOS_VIDEO_COLOR_PLACEMENT  Red;\r
-  BIOS_VIDEO_COLOR_PLACEMENT  Green;\r
-  BIOS_VIDEO_COLOR_PLACEMENT  Blue;\r
-  BIOS_VIDEO_COLOR_PLACEMENT  Reserved;\r
-  EFI_GRAPHICS_PIXEL_FORMAT   PixelFormat;\r
-  EFI_PIXEL_BITMASK           PixelBitMask;\r
-} BIOS_VIDEO_MODE_DATA;\r
-\r
-//\r
-// BIOS video child handle private data Structure\r
-//\r
-#define BIOS_VIDEO_DEV_SIGNATURE    SIGNATURE_32 ('B', 'V', 'M', 'p')\r
-\r
-typedef struct {\r
-  UINTN                                       Signature;\r
-  EFI_HANDLE                                  Handle;\r
-\r
-  //\r
-  // Consumed Protocols\r
-  //\r
-  EFI_PCI_IO_PROTOCOL                         *PciIo;\r
-  EFI_LEGACY_BIOS_PROTOCOL                    *LegacyBios;\r
-\r
-  //\r
-  // Produced Protocols\r
-  //\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL                GraphicsOutput;\r
-  EFI_EDID_DISCOVERED_PROTOCOL                EdidDiscovered;\r
-  EFI_EDID_ACTIVE_PROTOCOL                    EdidActive;\r
-  EFI_VGA_MINI_PORT_PROTOCOL                  VgaMiniPort;\r
-\r
-  //\r
-  // General fields\r
-  //\r
-  BOOLEAN                                     VgaCompatible;\r
-  BOOLEAN                                     ProduceGraphicsOutput;\r
-\r
-  //\r
-  // Graphics Output Protocol related fields\r
-  //\r
-  BOOLEAN                                     HardwareNeedsStarting;\r
-  UINTN                                       CurrentMode;\r
-  UINTN                                       MaxMode;\r
-  BIOS_VIDEO_MODE_DATA                        *ModeData;\r
-  UINT8                                       *LineBuffer;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL               *VbeFrameBuffer;\r
-  UINT8                                       *VgaFrameBuffer;\r
-\r
-  //\r
-  // VESA Bios Extensions related fields\r
-  //\r
-  UINTN                                       NumberOfPagesBelow1MB;     // Number of 4KB pages in PagesBelow1MB\r
-  EFI_PHYSICAL_ADDRESS                        PagesBelow1MB;             // Buffer for all VBE Information Blocks\r
-  VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK      *VbeInformationBlock;      // 0x200 bytes.  Must be allocated below 1MB\r
-  VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK *VbeModeInformationBlock;  // 0x100 bytes.  Must be allocated below 1MB\r
-  VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK        *VbeEdidDataBlock;         // 0x80  bytes.  Must be allocated below 1MB\r
-  VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK *VbeCrtcInformationBlock;  // 59 bytes.  Must be allocated below 1MB\r
-  UINTN                                       VbeSaveRestorePages;       // Number of 4KB pages in VbeSaveRestoreBuffer\r
-  EFI_PHYSICAL_ADDRESS                        VbeSaveRestoreBuffer;      // Must be allocated below 1MB\r
-  //\r
-  // Status code\r
-  //\r
-  EFI_DEVICE_PATH_PROTOCOL                    *GopDevicePath;\r
-\r
-  EFI_EVENT                                   ExitBootServicesEvent;\r
-} BIOS_VIDEO_DEV;\r
-\r
-#define BIOS_VIDEO_DEV_FROM_PCI_IO_THIS(a)           CR (a, BIOS_VIDEO_DEV, PciIo, BIOS_VIDEO_DEV_SIGNATURE)\r
-#define BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS(a)  CR (a, BIOS_VIDEO_DEV, GraphicsOutput, BIOS_VIDEO_DEV_SIGNATURE)\r
-#define BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS(a)    CR (a, BIOS_VIDEO_DEV, VgaMiniPort, BIOS_VIDEO_DEV_SIGNATURE)\r
-\r
-#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER  0xffff\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gBiosVideoDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gBiosVideoComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gBiosVideoComponentName2;\r
-\r
-//\r
-// Driver Binding Protocol functions\r
-//\r
-\r
-/**\r
-  Supported.\r
-\r
-  @param  This                   Pointer to driver binding protocol\r
-  @param  Controller             Controller handle to connect\r
-  @param  RemainingDevicePath    A pointer to the remaining portion of a device\r
-                                 path\r
-\r
-  @retval EFI_STATUS             EFI_SUCCESS:This controller can be managed by this\r
-                                 driver, Otherwise, this controller cannot be\r
-                                 managed by this driver\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-\r
-/**\r
-  Install Graphics Output Protocol onto VGA device handles.\r
-\r
-  @param  This                   Pointer to driver binding protocol\r
-  @param  Controller             Controller handle to connect\r
-  @param  RemainingDevicePath    A pointer to the remaining portion of a device\r
-                                 path\r
-\r
-  @return EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-\r
-/**\r
-  Stop.\r
-\r
-  @param  This                   Pointer to driver binding protocol\r
-  @param  Controller             Controller handle to connect\r
-  @param  NumberOfChildren       Number of children handle created by this driver\r
-  @param  ChildHandleBuffer      Buffer containing child handle created\r
-\r
-  @retval EFI_SUCCESS            Driver disconnected successfully from controller\r
-  @retval EFI_UNSUPPORTED        Cannot find BIOS_VIDEO_DEV structure\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// Private worker functions\r
-//\r
-\r
-/**\r
-  Check for VBE device.\r
-\r
-  @param  BiosVideoPrivate       Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  @retval EFI_SUCCESS            VBE device found\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoCheckForVbe (\r
-  IN OUT BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  );\r
-\r
-\r
-/**\r
-  Check for VGA device.\r
-\r
-  @param  BiosVideoPrivate       Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  @retval EFI_SUCCESS            Standard VGA device found\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoCheckForVga (\r
-  IN OUT BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  );\r
-\r
-\r
-\r
-\r
-/**\r
-  Release resource for biso video instance.\r
-\r
-  @param  BiosVideoPrivate       Video child device private data structure\r
-\r
-**/\r
-VOID\r
-BiosVideoDeviceReleaseResource (\r
-  BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  );\r
-\r
-//\r
-// BIOS Graphics Output Protocol functions\r
-//\r
-\r
-/**\r
-  Graphics Output protocol interface to get video mode.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  ModeNumber             The mode number to return information on.\r
-  @param  SizeOfInfo             A pointer to the size, in bytes, of the Info\r
-                                 buffer.\r
-  @param  Info                   Caller allocated buffer that returns information\r
-                                 about ModeNumber.\r
-\r
-  @retval EFI_SUCCESS            Mode information returned.\r
-  @retval EFI_BUFFER_TOO_SMALL   The Info buffer was too small.\r
-  @retval EFI_DEVICE_ERROR       A hardware error occurred trying to retrieve the\r
-                                 video mode.\r
-  @retval EFI_NOT_STARTED        Video display is not initialized. Call SetMode ()\r
-  @retval EFI_INVALID_PARAMETER  One of the input args was NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputQueryMode (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,\r
-  IN  UINT32                                ModeNumber,\r
-  OUT UINTN                                 *SizeOfInfo,\r
-  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info\r
-  );\r
-\r
-\r
-/**\r
-  Graphics Output protocol interface to set video mode.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  ModeNumber             The mode number to be set.\r
-\r
-  @retval EFI_SUCCESS            Graphics mode was changed.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the\r
-                                 request.\r
-  @retval EFI_UNSUPPORTED        ModeNumber is not supported by this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputSetMode (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
-  IN  UINT32                       ModeNumber\r
-  );\r
-\r
-\r
-/**\r
-  Graphics Output protocol instance to block transfer for VBE device.\r
-\r
-  @param  This                   Pointer to Graphics Output protocol instance\r
-  @param  BltBuffer              The data to transfer to screen\r
-  @param  BltOperation           The operation to perform\r
-  @param  SourceX                The X coordinate of the source for BltOperation\r
-  @param  SourceY                The Y coordinate of the source for BltOperation\r
-  @param  DestinationX           The X coordinate of the destination for\r
-                                 BltOperation\r
-  @param  DestinationY           The Y coordinate of the destination for\r
-                                 BltOperation\r
-  @param  Width                  The width of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Height                 The height of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Delta                  Not used for EfiBltVideoFill and\r
-                                 EfiBltVideoToVideo operation. If a Delta of 0 is\r
-                                 used, the entire BltBuffer will be operated on. If\r
-                                 a subrectangle of the BltBuffer is used, then\r
-                                 Delta represents the number of bytes in a row of\r
-                                 the BltBuffer.\r
-\r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter passed in\r
-  @retval EFI_SUCCESS            Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVbeBlt (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL       *This,\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION  BltOperation,\r
-  IN  UINTN                              SourceX,\r
-  IN  UINTN                              SourceY,\r
-  IN  UINTN                              DestinationX,\r
-  IN  UINTN                              DestinationY,\r
-  IN  UINTN                              Width,\r
-  IN  UINTN                              Height,\r
-  IN  UINTN                              Delta\r
-  );\r
-\r
-\r
-/**\r
-  Grahpics Output protocol instance to block transfer for VGA device.\r
-\r
-  @param  This                   Pointer to Grahpics Output protocol instance\r
-  @param  BltBuffer              The data to transfer to screen\r
-  @param  BltOperation           The operation to perform\r
-  @param  SourceX                The X coordinate of the source for BltOperation\r
-  @param  SourceY                The Y coordinate of the source for BltOperation\r
-  @param  DestinationX           The X coordinate of the destination for\r
-                                 BltOperation\r
-  @param  DestinationY           The Y coordinate of the destination for\r
-                                 BltOperation\r
-  @param  Width                  The width of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Height                 The height of a rectangle in the blt rectangle in\r
-                                 pixels\r
-  @param  Delta                  Not used for EfiBltVideoFill and\r
-                                 EfiBltVideoToVideo operation. If a Delta of 0 is\r
-                                 used, the entire BltBuffer will be operated on. If\r
-                                 a subrectangle of the BltBuffer is used, then\r
-                                 Delta represents the number of bytes in a row of\r
-                                 the BltBuffer.\r
-\r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter passed in\r
-  @retval EFI_SUCCESS            Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVgaBlt (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL       *This,\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION  BltOperation,\r
-  IN  UINTN                              SourceX,\r
-  IN  UINTN                              SourceY,\r
-  IN  UINTN                              DestinationX,\r
-  IN  UINTN                              DestinationY,\r
-  IN  UINTN                              Width,\r
-  IN  UINTN                              Height,\r
-  IN  UINTN                              Delta\r
-  );\r
-\r
-//\r
-// BIOS VGA Mini Port Protocol functions\r
-//\r
-\r
-/**\r
-  VgaMiniPort protocol interface to set mode.\r
-\r
-  @param  This                   Pointer to VgaMiniPort protocol instance\r
-  @param  ModeNumber             The index of the mode\r
-\r
-  @retval EFI_UNSUPPORTED        The requested mode is not supported\r
-  @retval EFI_SUCCESS            The requested mode is set successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoVgaMiniPortSetMode (\r
-  IN  EFI_VGA_MINI_PORT_PROTOCOL  *This,\r
-  IN  UINTN                       ModeNumber\r
-  );\r
-\r
-/**\r
-  Event handler for Exit Boot Service.\r
-\r
-  @param  Event       The event that be siganlled when exiting boot service.\r
-  @param  Context     Pointer to instance of BIOS_VIDEO_DEV.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BiosVideoNotifyExitBootServices (\r
-  IN  EFI_EVENT Event,\r
-  IN  VOID      *Context\r
-  );\r
-\r
-//\r
-// Standard VGA Definitions\r
-//\r
-#define VGA_HORIZONTAL_RESOLUTION                         640\r
-#define VGA_VERTICAL_RESOLUTION                           480\r
-#define VGA_NUMBER_OF_BIT_PLANES                          4\r
-#define VGA_PIXELS_PER_BYTE                               8\r
-#define VGA_BYTES_PER_SCAN_LINE                           (VGA_HORIZONTAL_RESOLUTION / VGA_PIXELS_PER_BYTE)\r
-#define VGA_BYTES_PER_BIT_PLANE                           (VGA_VERTICAL_RESOLUTION * VGA_BYTES_PER_SCAN_LINE)\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER          0x3ce\r
-#define VGA_GRAPHICS_CONTROLLER_DATA_REGISTER             0x3cf\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_SET_RESET_REGISTER        0x00\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_ENABLE_SET_RESET_REGISTER 0x01\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_COLOR_COMPARE_REGISTER    0x02\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER      0x03\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE          0x00\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_AND              0x08\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_OR               0x10\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_XOR              0x18\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER  0x04\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_MODE_REGISTER             0x05\r
-#define VGA_GRAPHICS_CONTROLLER_READ_MODE_0               0x00\r
-#define VGA_GRAPHICS_CONTROLLER_READ_MODE_1               0x08\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_0              0x00\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_1              0x01\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2              0x02\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_3              0x03\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_MISCELLANEOUS_REGISTER    0x06\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_COLOR_DONT_CARE_REGISTER  0x07\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER         0x08\r
-\r
-/**\r
-  Install child handles if the Handle supports MBR format.\r
-\r
-  @param  This                   Calling context.\r
-  @param  ParentHandle           Parent Handle\r
-  @param  ParentPciIo            Parent PciIo interface\r
-  @param  ParentLegacyBios       Parent LegacyBios interface\r
-  @param  ParentDevicePath       Parent Device Path\r
-  @param  RemainingDevicePath    Remaining Device Path\r
-\r
-  @retval EFI_SUCCESS            If a child handle was added\r
-  @retval other                  A child handle was not added\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoChildHandleInstall (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ParentHandle,\r
-  IN  EFI_PCI_IO_PROTOCOL          *ParentPciIo,\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL     *ParentLegacyBios,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *ParentDevicePath,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  );\r
-\r
-/**\r
-  Deregister an video child handle and free resources.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  Controller             Video controller handle\r
-  @param  Handle                 Video child handle\r
-\r
-  @return EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoChildHandleUninstall (\r
-  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  EFI_HANDLE                     Controller,\r
-  EFI_HANDLE                     Handle\r
-  );\r
-\r
-/**\r
-  Release resource for biso video instance.\r
-\r
-  @param  BiosVideoPrivate       Video child device private data structure\r
-\r
-**/\r
-VOID\r
-BiosVideoDeviceReleaseResource (\r
-  BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  );\r
-\r
-/**\r
-  Check if all video child handles have been uninstalled.\r
-\r
-  @param  Controller             Video controller handle\r
-\r
-  @return TRUE                   Child handles exist.\r
-  @return FALSE                  All video child handles have been uninstalled.\r
-\r
-**/\r
-BOOLEAN\r
-HasChildHandle (\r
-  IN EFI_HANDLE  Controller\r
-  );\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideoDxe.uni b/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideoDxe.uni
deleted file mode 100644 (file)
index 326d9de..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// /** @file\r
-// Video driver based on legacy bios.\r
-//\r
-// This driver by using Legacy Bios protocol service to support csm Video\r
-// and produce Graphics Output Protocol.\r
-//\r
-// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Video driver based on legacy bios"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This driver uses the Legacy Bios protocol service to utilize the CSM Video Support and produce the Graphics Output Protocol."\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideoDxeExtra.uni b/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/BiosVideoDxeExtra.uni
deleted file mode 100644 (file)
index 23fb8fe..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// BiosVideoDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Legacy Video DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/ComponentName.c b/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/ComponentName.c
deleted file mode 100644 (file)
index dc914aa..0000000
+++ /dev/null
@@ -1,306 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BiosVideo.h"\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gBiosVideoComponentName = {\r
-  BiosVideoComponentNameGetDriverName,\r
-  BiosVideoComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) BiosVideoComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) BiosVideoComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosVideoDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"BIOS[INT10] Video Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mBiosVideoDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gBiosVideoComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VesaBiosExtensions.h b/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VesaBiosExtensions.h
deleted file mode 100644 (file)
index dbf7061..0000000
+++ /dev/null
@@ -1,459 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _VESA_BIOS_EXTENSIONS_H_\r
-#define _VESA_BIOS_EXTENSIONS_H_\r
-\r
-//\r
-// Turn on byte packing of data structures\r
-//\r
-#pragma pack(1)\r
-//\r
-// VESA BIOS Extensions status codes\r
-//\r
-#define VESA_BIOS_EXTENSIONS_STATUS_SUCCESS 0x004f\r
-\r
-//\r
-// VESA BIOS Extensions Services\r
-//\r
-#define VESA_BIOS_EXTENSIONS_RETURN_CONTROLLER_INFORMATION  0x4f00\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 00 : Return Controller Information\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f00\r
-      ES:DI = Pointer to buffer to place VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK structure\r
-    Outputs:\r
-      AX    = Return Status\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION  0x4f01\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 01 : Return Mode Information\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f01\r
-      CX    = Mode Number\r
-      ES:DI = Pointer to buffer to place VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK structure\r
-    Outputs:\r
-      AX    = Return Status\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_SET_MODE 0x4f02\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 02 : Set Mode\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f02\r
-      BX    = Desired mode to set\r
-        D0-D8   = Mode Number\r
-        D9-D10  = Reserved (must be 0)\r
-        D11     = 0 - Use current default refresh rate\r
-                = 1 - Use user specfieid CRTC values for refresh rate\r
-        D12-D13 = Reserved (must be 0)\r
-        D14     = 0 - Use windowed frame buffer model\r
-                = 1 - Use linear/flat frame buffer model\r
-        D15     = 0 - Clear display memory\r
-                = 1 - Don't clear display memory\r
-      ES:DI = Pointer to buffer to the VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK structure\r
-    Outputs:\r
-      AX    = Return Status\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_RETURN_CURRENT_MODE  0x4f03\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 03 : Return Current Mode\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f03\r
-    Outputs:\r
-      AX    = Return Status\r
-      BX    = Current mode\r
-        D0-D13  = Mode Number\r
-        D14     = 0 - Windowed frame buffer model\r
-                = 1 - Linear/flat frame buffer model\r
-        D15     = 0 - Memory cleared at last mode set\r
-                = 1 - Memory not cleared at last mode set\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_SAVE_RESTORE_STATE 0x4f04\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 04 : Save/Restore State\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f03\r
-      DL    = 0x00 - Return Save/Restore State buffer size\r
-            = 0x01 - Save State\r
-            = 0x02 - Restore State\r
-      CX    = Requested Status\r
-        D0  = Save/Restore controller hardware state\r
-        D1  = Save/Restore BIOS data state\r
-        D2  = Save/Restore DAC state\r
-        D3  = Save/Restore Regsiter state\r
-      ES:BX = Pointer to buffer if DL=1 or DL=2\r
-    Outputs:\r
-      AX    = Return Status\r
-      BX    = Number of 64 byte blocks to hold the state buffer if DL=0\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_EDID  0x4f15\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 15 : implement VBE/DDC service\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f15\r
-      BL    = 0x00 - Report VBE/DDC Capabilities\r
-      CX    = 0x00 - Controller unit number (00 = primary controller)\r
-      ES:DI = Null pointer, must be 0:0 in version 1.0\r
-    Outputs:\r
-      AX    = Return Status\r
-      BH    = Approx. time in seconds, rounded up, to transfer one EDID block(128 bytes)\r
-      BL    = DDC level supported\r
-        D0  = 0 DDC1 not supported\r
-            = 1 DDC1 supported\r
-        D1  = 0 DDC2 not supported\r
-            = 1 DDC2 supported\r
-        D2  = 0 Screen not blanked during data transfer\r
-            = 1 Screen blanked during data transfer\r
-\r
-    Inputs:\r
-      AX    = 0x4f15\r
-      BL    = 0x01 - Read EDID\r
-      CX    = 0x00 - Controller unit number (00 = primary controller)\r
-      DX    = 0x00 - EDID block number\r
-      ES:DI = Pointer to buffer in which the EDID block is returned\r
-    Outputs:\r
-      AX    = Return Status\r
---*/\r
-\r
-//\r
-// Timing data from EDID data block\r
-//\r
-#define VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE                    128\r
-#define VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER 17\r
-\r
-//\r
-// Established Timings: 24 possible resolutions\r
-// Standard Timings: 8 possible resolutions\r
-// Detailed Timings: 4 possible resolutions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_EDID_TIMING_MAX_NUMBER             36\r
-\r
-//\r
-// Timing data size for Established Timings, Standard Timings and Detailed Timings\r
-//\r
-#define VESA_BIOS_EXTENSIONS_ESTABLISHED_TIMING_SIZE                  3\r
-#define VESA_BIOS_EXTENSIONS_STANDARD_TIMING_SIZE                     16\r
-#define VESA_BIOS_EXTENSIONS_DETAILED_TIMING_EACH_DESCRIPTOR_SIZE     18\r
-#define VESA_BIOS_EXTENSIONS_DETAILED_TIMING_DESCRIPTOR_MAX_SIZE      72\r
-\r
-typedef struct {\r
-  UINT16  HorizontalResolution;\r
-  UINT16  VerticalResolution;\r
-  UINT16  RefreshRate;\r
-} VESA_BIOS_EXTENSIONS_EDID_TIMING;\r
-\r
-typedef struct {\r
-  UINT32  ValidNumber;\r
-  UINT32  Key[VESA_BIOS_EXTENSIONS_EDID_TIMING_MAX_NUMBER];\r
-} VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING;\r
-\r
-typedef struct {\r
-  UINT8   Header[8];                        //EDID header "00 FF FF FF FF FF FF 00"\r
-  UINT16  ManufactureName;                  //EISA 3-character ID\r
-  UINT16  ProductCode;                      //Vendor assigned code\r
-  UINT32  SerialNumber;                     //32-bit serial number\r
-  UINT8   WeekOfManufacture;                //Week number\r
-  UINT8   YearOfManufacture;                //Year\r
-  UINT8   EdidVersion;                      //EDID Structure Version\r
-  UINT8   EdidRevision;                     //EDID Structure Revision\r
-  UINT8   VideoInputDefinition;\r
-  UINT8   MaxHorizontalImageSize;           //cm\r
-  UINT8   MaxVerticalImageSize;             //cm\r
-  UINT8   DisplayTransferCharacteristic;\r
-  UINT8   FeatureSupport;\r
-  UINT8   RedGreenLowBits;                  //Rx1 Rx0 Ry1 Ry0 Gx1 Gx0 Gy1Gy0\r
-  UINT8   BlueWhiteLowBits;                 //Bx1 Bx0 By1 By0 Wx1 Wx0 Wy1 Wy0\r
-  UINT8   RedX;                             //Red-x Bits 9 - 2\r
-  UINT8   RedY;                             //Red-y Bits 9 - 2\r
-  UINT8   GreenX;                           //Green-x Bits 9 - 2\r
-  UINT8   GreenY;                           //Green-y Bits 9 - 2\r
-  UINT8   BlueX;                            //Blue-x Bits 9 - 2\r
-  UINT8   BlueY;                            //Blue-y Bits 9 - 2\r
-  UINT8   WhiteX;                           //White-x Bits 9 - 2\r
-  UINT8   WhiteY;                           //White-x Bits 9 - 2\r
-  UINT8   EstablishedTimings[VESA_BIOS_EXTENSIONS_ESTABLISHED_TIMING_SIZE];\r
-  UINT8   StandardTimingIdentification[VESA_BIOS_EXTENSIONS_STANDARD_TIMING_SIZE];\r
-  UINT8   DetailedTimingDescriptions[VESA_BIOS_EXTENSIONS_DETAILED_TIMING_DESCRIPTOR_MAX_SIZE];\r
-  UINT8   ExtensionFlag;                    //Number of (optional) 128-byte EDID extension blocks to follow\r
-  UINT8   Checksum;\r
-} VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK;\r
-\r
-//\r
-// Super VGA Information Block\r
-//\r
-typedef struct {\r
-  UINT32  VESASignature;      // 'VESA' 4 byte signature\r
-  UINT16  VESAVersion;        // VBE version number\r
-  UINT32  OEMStringPtr;      // Pointer to OEM string\r
-  UINT32  Capabilities;       // Capabilities of video card\r
-  UINT32  VideoModePtr;      // Pointer to an array of 16-bit supported modes values terminated by 0xFFFF\r
-  UINT16  TotalMemory;        // Number of 64kb memory blocks\r
-  UINT16  OemSoftwareRev;     // VBE implementation Software revision\r
-  UINT32  OemVendorNamePtr;  // VbeFarPtr to Vendor Name String\r
-  UINT32  OemProductNamePtr; // VbeFarPtr to Product Name String\r
-  UINT32  OemProductRevPtr;  // VbeFarPtr to Product Revision String\r
-  UINT8   Reserved[222];      // Reserved for VBE implementation scratch area\r
-  UINT8   OemData[256];       // Data area for OEM strings.  Pad to 512 byte block size\r
-} VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK;\r
-\r
-//\r
-// Super VGA Information Block VESASignature values\r
-//\r
-#define VESA_BIOS_EXTENSIONS_VESA_SIGNATURE SIGNATURE_32 ('V', 'E', 'S', 'A')\r
-#define VESA_BIOS_EXTENSIONS_VBE2_SIGNATURE SIGNATURE_32 ('V', 'B', 'E', '2')\r
-\r
-//\r
-// Super VGA Information Block VESAVersion values\r
-//\r
-#define VESA_BIOS_EXTENSIONS_VERSION_1_2  0x0102\r
-#define VESA_BIOS_EXTENSIONS_VERSION_2_0  0x0200\r
-#define VESA_BIOS_EXTENSIONS_VERSION_3_0  0x0300\r
-\r
-//\r
-// Super VGA Information Block Capabilities field bit defintions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_8_BIT_DAC 0x01  // 0: DAC width is fixed at 6 bits/color\r
-// 1: DAC width switchable to 8 bits/color\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_NOT_VGA 0x02  // 0: Controller is VGA compatible\r
-// 1: Controller is not VGA compatible\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_NOT_NORMAL_RAMDAC 0x04  // 0: Normal RAMDAC operation\r
-// 1: Use blank bit in function 9 to program RAMDAC\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_STEREOSCOPIC  0x08  // 0: No hardware stereoscopic signal support\r
-// 1: Hardware stereoscopic signal support\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_VESA_EVC  0x10  // 0: Stero signaling supported via external VESA stereo connector\r
-// 1: Stero signaling supported via VESA EVC connector\r
-//\r
-// Super VGA mode number bite field definitions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA 0x0100  // 0: Not a VESA defined VBE mode\r
-// 1: A VESA defined VBE mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_REFRESH_CONTROL_USER 0x0800  // 0: Use current BIOS default referesh rate\r
-// 1: Use the user specified CRTC values for refresh rate\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_LINEAR_FRAME_BUFFER  0x4000  // 0: Use a banked/windowed frame buffer\r
-// 1: Use a linear/flat frame buffer\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_PRESERVE_MEMORY  0x8000  // 0: Clear display memory\r
-// 1: Preseve display memory\r
-//\r
-// Super VGA Information Block mode list terminator value\r
-//\r
-#define VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST 0xffff\r
-\r
-//\r
-// Window Function\r
-//\r
-typedef\r
-VOID\r
-(*VESA_BIOS_EXTENSIONS_WINDOW_FUNCTION) (\r
-  VOID\r
-  );\r
-\r
-//\r
-// Super VGA Mode Information Block\r
-//\r
-typedef struct {\r
-  //\r
-  // Manadory fields for all VESA Bios Extensions revisions\r
-  //\r
-  UINT16                                ModeAttributes;   // Mode attributes\r
-  UINT8                                 WinAAttributes;   // Window A attributes\r
-  UINT8                                 WinBAttributes;   // Window B attributes\r
-  UINT16                                WinGranularity;   // Window granularity in k\r
-  UINT16                                WinSize;          // Window size in k\r
-  UINT16                                WinASegment;      // Window A segment\r
-  UINT16                                WinBSegment;      // Window B segment\r
-  UINT32                                WindowFunction;   // Pointer to window function\r
-  UINT16                                BytesPerScanLine; // Bytes per scanline\r
-  //\r
-  // Manadory fields for VESA Bios Extensions 1.2 and above\r
-  //\r
-  UINT16                                XResolution;          // Horizontal resolution\r
-  UINT16                                YResolution;          // Vertical resolution\r
-  UINT8                                 XCharSize;            // Character cell width\r
-  UINT8                                 YCharSize;            // Character cell height\r
-  UINT8                                 NumberOfPlanes;       // Number of memory planes\r
-  UINT8                                 BitsPerPixel;         // Bits per pixel\r
-  UINT8                                 NumberOfBanks;        // Number of CGA style banks\r
-  UINT8                                 MemoryModel;          // Memory model type\r
-  UINT8                                 BankSize;             // Size of CGA style banks\r
-  UINT8                                 NumberOfImagePages;   // Number of images pages\r
-  UINT8                                 Reserved1;            // Reserved\r
-  UINT8                                 RedMaskSize;          // Size of direct color red mask\r
-  UINT8                                 RedFieldPosition;     // Bit posn of lsb of red mask\r
-  UINT8                                 GreenMaskSize;        // Size of direct color green mask\r
-  UINT8                                 GreenFieldPosition;   // Bit posn of lsb of green mask\r
-  UINT8                                 BlueMaskSize;         // Size of direct color blue mask\r
-  UINT8                                 BlueFieldPosition;    // Bit posn of lsb of blue mask\r
-  UINT8                                 RsvdMaskSize;         // Size of direct color res mask\r
-  UINT8                                 RsvdFieldPosition;    // Bit posn of lsb of res mask\r
-  UINT8                                 DirectColorModeInfo;  // Direct color mode attributes\r
-  //\r
-  // Manadory fields for VESA Bios Extensions 2.0 and above\r
-  //\r
-  UINT32                                PhysBasePtr;  // Physical Address for flat memory frame buffer\r
-  UINT32                                Reserved2;    // Reserved\r
-  UINT16                                Reserved3;    // Reserved\r
-  //\r
-  // Manadory fields for VESA Bios Extensions 3.0 and above\r
-  //\r
-  UINT16                                LinBytesPerScanLine;    // Bytes/scan line for linear modes\r
-  UINT8                                 BnkNumberOfImagePages;  // Number of images for banked modes\r
-  UINT8                                 LinNumberOfImagePages;  // Number of images for linear modes\r
-  UINT8                                 LinRedMaskSize;         // Size of direct color red mask (linear mode)\r
-  UINT8                                 LinRedFieldPosition;    // Bit posiiton of lsb of red mask (linear modes)\r
-  UINT8                                 LinGreenMaskSize;       // Size of direct color green mask (linear mode)\r
-  UINT8                                 LinGreenFieldPosition;  // Bit posiiton of lsb of green mask (linear modes)\r
-  UINT8                                 LinBlueMaskSize;        // Size of direct color blue mask (linear mode)\r
-  UINT8                                 LinBlueFieldPosition;   // Bit posiiton of lsb of blue mask (linear modes)\r
-  UINT8                                 LinRsvdMaskSize;        // Size of direct color reserved mask (linear mode)\r
-  UINT8                                 LinRsvdFieldPosition;   // Bit posiiton of lsb of reserved mask (linear modes)\r
-  UINT32                                MaxPixelClock;          // Maximum pixel clock (in Hz) for graphics mode\r
-  UINT8                                 Pad[190];               // Pad to 256 byte block size\r
-} VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK;\r
-\r
-//\r
-// Super VGA Mode Information Block ModeAttributes field bit defintions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_HARDWARE  0x0001  // 0: Mode not supported in handware\r
-// 1: Mode supported in handware\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_TTY 0x0004  // 0: TTY Output functions not supported by BIOS\r
-// 1: TTY Output functions supported by BIOS\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_COLOR 0x0008  // 0: Monochrome mode\r
-// 1: Color mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_GRAPHICS  0x0010  // 0: Text mode\r
-// 1: Graphics mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NOT_VGA 0x0020  // 0: VGA compatible mode\r
-// 1: Not a VGA compatible mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NOT_WINDOWED  0x0040  // 0: VGA compatible windowed memory mode\r
-// 1: Not a VGA compatible windowed memory mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER 0x0080  // 0: No linear fram buffer mode available\r
-// 1: Linear frame buffer mode available\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_DOUBLE_SCAN 0x0100  // 0: No double scan mode available\r
-// 1: Double scan mode available\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_INTERLACED  0x0200  // 0: No interlaced mode is available\r
-// 1: Interlaced mode is available\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NO_TRIPPLE_BUFFER 0x0400  // 0: No hardware triple buffer mode support available\r
-// 1: Hardware triple buffer mode support available\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_STEREOSCOPIC  0x0800  // 0: No hardware steroscopic display support\r
-// 1: Hardware steroscopic display support\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_DUAL_DISPLAY  0x1000  // 0: No dual display start address support\r
-// 1: Dual display start address support\r
-//\r
-// Super VGA Mode Information Block WinAAttribite/WinBAttributes field bit defintions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_RELOCATABLE 0x01  // 0: Single non-relocatable window only\r
-// 1: Relocatable window(s) are supported\r
-//\r
-#define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_READABLE  0x02  // 0: Window is not readable\r
-// 1: Window is readable\r
-//\r
-#define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_WRITABLE  0x04  // 0: Window is not writable\r
-// 1: Window is writable\r
-//\r
-// Super VGA Mode Information Block DirectColorMode field bit defintions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_DIRECT_COLOR_MODE_PROG_COLOR_RAMP  0x01  // 0: Color ram is fixed\r
-// 1: Color ramp is programmable\r
-//\r
-#define VESA_BIOS_EXTENSIONS_DIRECT_COLOR_MODE_RSVD_USABLE  0x02  // 0: Bits in Rsvd field are reserved\r
-// 1: Bits in Rsdv field are usable\r
-//\r
-// Super VGA Memory Models\r
-//\r
-typedef enum {\r
-  MemPL = 3,  // Planar memory model\r
-  MemPK = 4,  // Packed pixel memory model\r
-  MemRGB= 6,  // Direct color RGB memory model\r
-  MemYUV= 7   // Direct color YUV memory model\r
-} VESA_BIOS_EXTENSIONS_MEMORY_MODELS;\r
-\r
-//\r
-// Super VGA CRTC Information Block\r
-//\r
-typedef struct {\r
-  UINT16  HorizontalTotal;      // Horizontal total in pixels\r
-  UINT16  HorizontalSyncStart;  // Horizontal sync start in pixels\r
-  UINT16  HorizontalSyncEnd;    // Horizontal sync end in pixels\r
-  UINT16  VericalTotal;         // Vertical total in pixels\r
-  UINT16  VericalSyncStart;     // Vertical sync start in pixels\r
-  UINT16  VericalSyncEnd;       // Vertical sync end in pixels\r
-  UINT8   Flags;                // Flags (Interlaced/DoubleScan/etc).\r
-  UINT32  PixelClock;           // Pixel clock in units of Hz\r
-  UINT16  RefreshRate;          // Refresh rate in units of 0.01 Hz\r
-  UINT8   Reserved[40];         // Pad\r
-} VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK;\r
-\r
-#define VESA_BIOS_EXTENSIONS_CRTC_FLAGS_DOUBLE_SCAN 0x01  // 0: Graphics mode is not souble scanned\r
-// 1: Graphics mode is double scanned\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CRTC_FLAGSINTERLACED 0x02  // 0: Graphics mode is not interlaced\r
-// 1: Graphics mode is interlaced\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CRTC_HORIZONTAL_SYNC_NEGATIVE  0x04  // 0: Horizontal sync polarity is positive(+)\r
-// 0: Horizontal sync polarity is negative(-)\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CRTC_VERITICAL_SYNC_NEGATIVE 0x08  // 0: Verical sync polarity is positive(+)\r
-// 0: Verical sync polarity is negative(-)\r
-//\r
-// Turn off byte packing of data structures\r
-//\r
-#pragma pack()\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf b/IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf
deleted file mode 100644 (file)
index 1526bc4..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-## @file\r
-# Video driver based on legacy bios.\r
-#\r
-# This driver by using Legacy Bios protocol service to support csm Video\r
-# and produce Graphics Output Protocol.\r
-#\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = BiosVideoDxe\r
-  MODULE_UNI_FILE                = BiosVideoDxe.uni\r
-  FILE_GUID                      = 0B04B2ED-861C-42cd-A22F-C3AAFACCB896\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = BiosVideoEntryPoint\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-#  DRIVER_BINDING                =  gBiosVideoDriverBinding\r
-#  COMPONENT_NAME                =  gBiosVideoComponentName\r
-#\r
-\r
-[Sources]\r
-  BiosVideo.c\r
-  BiosVideo.h\r
-  ComponentName.c\r
-  VesaBiosExtensions.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  MemoryAllocationLib\r
-  DevicePathLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  BaseMemoryLib\r
-  ReportStatusCodeLib\r
-  DebugLib\r
-  PcdLib\r
-\r
-\r
-[Guids]\r
-  gEfiLegacyBiosGuid                            ## PRODUCES  ##GUID # Install Legacy BIOS GUID to mark this driver as a BIOS Thunk Driver\r
-  gEfiEventExitBootServicesGuid                 ## CONSUMES  ##Event\r
-\r
-[Protocols]\r
-  gEfiVgaMiniPortProtocolGuid                   ## BY_START\r
-  gEfiEdidDiscoveredProtocolGuid                ## BY_START\r
-  gEfiGraphicsOutputProtocolGuid                ## BY_START\r
-  gEfiEdidActiveProtocolGuid                    ## BY_START\r
-  gEfiLegacyBiosProtocolGuid                    ## CONSUMES\r
-  gEfiPciIoProtocolGuid                         ## TO_START\r
-  gEfiDevicePathProtocolGuid                    ## TO_START\r
-  gEfiDevicePathProtocolGuid                    ## BY_START\r
-  gEfiEdidOverrideProtocolGuid                  ## SOMETIMES_CONSUMES\r
-\r
-[Pcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBiosVideoSetTextVgaModeEnable  ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBiosVideoCheckVbeEnable        ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBiosVideoCheckVgaEnable        ## SOMETIMES_CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution                 ## SOMETIMES_CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution                   ## SOMETIMES_CONSUMES\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  BiosVideoDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.nasm b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/IA32/InterruptTable.nasm
deleted file mode 100644 (file)
index 90bfdff..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-;; @file\r
-;  Interrupt Redirection Template\r
-;\r
-; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
-;\r
-; SPDX-License-Identifier: BSD-2-Clause-Patent\r
-;\r
-;;\r
-\r
-SECTION .text\r
-\r
-;----------------------------------------------------------------------------\r
-; Procedure:    InterruptRedirectionTemplate: Redirects interrupts 0x68-0x6F\r
-;\r
-; Input:        None\r
-;\r
-; Output:       None\r
-;\r
-; Prototype:    VOID\r
-;               InterruptRedirectionTemplate (\r
-;                                VOID\r
-;                                );\r
-;\r
-; Saves:        None\r
-;\r
-; Modified:     None\r
-;\r
-; Description:  Contains the code that is copied into low memory (below 640K).\r
-;               This code reflects interrupts 0x68-0x6f to interrupts 0x08-0x0f.\r
-;               This template must be copied into low memory, and the IDT entries\r
-;               0x68-0x6F must be point to the low memory copy of this code.  Each\r
-;               entry is 4 bytes long, so IDT entries 0x68-0x6F can be easily\r
-;               computed.\r
-;\r
-;----------------------------------------------------------------------------\r
-\r
-global ASM_PFX(InterruptRedirectionTemplate)\r
-ASM_PFX(InterruptRedirectionTemplate):\r
-  int     0x8\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0x9\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xa\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xb\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xc\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xd\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xe\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xf\r
-  DB      0xcf          ; IRET\r
-  nop\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c
deleted file mode 100644 (file)
index 6b1dd34..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-#include <IndustryStandard/Pci.h>\r
-\r
-// Give floppy 3 states\r
-// FLOPPY_PRESENT_WITH_MEDIA  = Floppy controller present and media is inserted\r
-// FLOPPY_NOT_PRESENT = No floppy controller present\r
-// FLOPPY_PRESENT_NO_MEDIA = Floppy controller present but no media inserted\r
-//\r
-#define FLOPPY_NOT_PRESENT           0\r
-#define FLOPPY_PRESENT_WITH_MEDIA    1\r
-#define FLOPPY_PRESENT_NO_MEDIA      2\r
-\r
-BBS_TABLE           *mBbsTable;\r
-BOOLEAN             mBbsTableDoneFlag   = FALSE;\r
-BOOLEAN             IsHaveMediaInFloppy = TRUE;\r
-\r
-/**\r
-  Checks the state of the floppy and if media is inserted.\r
-\r
-  This routine checks the state of the floppy and if media is inserted.\r
-  There are 3 cases:\r
-  No floppy present         - Set BBS entry to ignore\r
-  Floppy present & no media - Set BBS entry to lowest priority. We cannot\r
-  set it to ignore since 16-bit CSM will\r
-  indicate no floppy and thus drive A: is\r
-  unusable. CSM-16 will not try floppy since\r
-  lowest priority and thus not incur boot\r
-  time penality.\r
-  Floppy present & media    - Set BBS entry to some priority.\r
-\r
-  @return  State of floppy media\r
-\r
-**/\r
-UINT8\r
-HasMediaInFloppy (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  UINTN                                 HandleCount;\r
-  EFI_HANDLE                            *HandleBuffer;\r
-  UINTN                                 Index;\r
-  EFI_ISA_IO_PROTOCOL                   *IsaIo;\r
-  EFI_BLOCK_IO_PROTOCOL                 *BlkIo;\r
-\r
-  HandleBuffer  = NULL;\r
-  HandleCount   = 0;\r
-\r
-  gBS->LocateHandleBuffer (\r
-        ByProtocol,\r
-        &gEfiIsaIoProtocolGuid,\r
-        NULL,\r
-        &HandleCount,\r
-        &HandleBuffer\r
-        );\r
-\r
-  //\r
-  // If don't find any ISA/IO protocol assume no floppy. Need for floppy\r
-  // free system\r
-  //\r
-  if (HandleCount == 0) {\r
-    return FLOPPY_NOT_PRESENT;\r
-  }\r
-\r
-  ASSERT (HandleBuffer != NULL);\r
-\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiIsaIoProtocolGuid,\r
-                    (VOID **) &IsaIo\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {\r
-      continue;\r
-    }\r
-    //\r
-    // Update blockio in case the floppy is inserted in during BdsTimeout\r
-    //\r
-    Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiBlockIoProtocolGuid,\r
-                    (VOID **) &BlkIo\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    if (BlkIo->Media->MediaPresent) {\r
-      FreePool (HandleBuffer);\r
-      return FLOPPY_PRESENT_WITH_MEDIA;\r
-    } else {\r
-      FreePool (HandleBuffer);\r
-      return FLOPPY_PRESENT_NO_MEDIA;\r
-    }\r
-  }\r
-\r
-  FreePool (HandleBuffer);\r
-\r
-  return FLOPPY_NOT_PRESENT;\r
-\r
-}\r
-\r
-\r
-/**\r
-  Complete build of BBS TABLE.\r
-\r
-  @param  Private                 Legacy BIOS Instance data\r
-  @param  BbsTable                BBS Table passed to 16-bit code\r
-\r
-  @retval EFI_SUCCESS             Removable media not present\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildBbs (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private,\r
-  IN  BBS_TABLE                 *BbsTable\r
-  )\r
-{\r
-  UINTN     BbsIndex;\r
-  HDD_INFO  *HddInfo;\r
-  UINTN     HddIndex;\r
-  UINTN     Index;\r
-\r
-  //\r
-  // First entry is floppy.\r
-  // Next 2*MAX_IDE_CONTROLLER entries are for onboard IDE.\r
-  // Next n entries are filled in after each ROM is dispatched.\r
-  //   Entry filled in if follow BBS spec. See LegacyPci.c\r
-  // Next entries are for non-BBS compliant ROMS. They are filled in by\r
-  //   16-bit code during Legacy16UpdateBbs invocation. Final BootPriority\r
-  //   occurs after that invocation.\r
-  //\r
-  // Floppy\r
-  // Set default state.\r
-  //\r
-  IsHaveMediaInFloppy = HasMediaInFloppy ();\r
-  if (IsHaveMediaInFloppy == FLOPPY_PRESENT_WITH_MEDIA) {\r
-    BbsTable[0].BootPriority = BBS_UNPRIORITIZED_ENTRY;\r
-  } else {\r
-    if (IsHaveMediaInFloppy == FLOPPY_PRESENT_NO_MEDIA) {\r
-      BbsTable[0].BootPriority = BBS_LOWEST_PRIORITY;\r
-    } else {\r
-      BbsTable[0].BootPriority = BBS_IGNORE_ENTRY;\r
-    }\r
-  }\r
-\r
-  BbsTable[0].Bus                       = 0xff;\r
-  BbsTable[0].Device                    = 0xff;\r
-  BbsTable[0].Function                  = 0xff;\r
-  BbsTable[0].DeviceType                = BBS_FLOPPY;\r
-  BbsTable[0].Class                     = 01;\r
-  BbsTable[0].SubClass                  = 02;\r
-  BbsTable[0].StatusFlags.OldPosition   = 0;\r
-  BbsTable[0].StatusFlags.Reserved1     = 0;\r
-  BbsTable[0].StatusFlags.Enabled       = 0;\r
-  BbsTable[0].StatusFlags.Failed        = 0;\r
-  BbsTable[0].StatusFlags.MediaPresent  = 0;\r
-  BbsTable[0].StatusFlags.Reserved2     = 0;\r
-\r
-  //\r
-  // Onboard HDD - Note Each HDD controller controls 2 drives\r
-  //               Master & Slave\r
-  //\r
-  HddInfo = &Private->IntThunk->EfiToLegacy16BootTable.HddInfo[0];\r
-  //\r
-  // Get IDE Drive Info\r
-  //\r
-  LegacyBiosBuildIdeData (Private, &HddInfo, 0);\r
-\r
-  for (HddIndex = 0; HddIndex < MAX_IDE_CONTROLLER; HddIndex++) {\r
-\r
-    BbsIndex = HddIndex * 2 + 1;\r
-    for (Index = 0; Index < 2; ++Index) {\r
-\r
-      BbsTable[BbsIndex + Index].Bus                      = HddInfo[HddIndex].Bus;\r
-      BbsTable[BbsIndex + Index].Device                   = HddInfo[HddIndex].Device;\r
-      BbsTable[BbsIndex + Index].Function                 = HddInfo[HddIndex].Function;\r
-      BbsTable[BbsIndex + Index].Class                    = 01;\r
-      BbsTable[BbsIndex + Index].SubClass                 = 01;\r
-      BbsTable[BbsIndex + Index].StatusFlags.OldPosition  = 0;\r
-      BbsTable[BbsIndex + Index].StatusFlags.Reserved1    = 0;\r
-      BbsTable[BbsIndex + Index].StatusFlags.Enabled      = 0;\r
-      BbsTable[BbsIndex + Index].StatusFlags.Failed       = 0;\r
-      BbsTable[BbsIndex + Index].StatusFlags.MediaPresent = 0;\r
-      BbsTable[BbsIndex + Index].StatusFlags.Reserved2    = 0;\r
-\r
-      //\r
-      // If no controller found or no device found set to ignore\r
-      // else set to unprioritized and set device type\r
-      //\r
-      if (HddInfo[HddIndex].CommandBaseAddress == 0) {\r
-        BbsTable[BbsIndex + Index].BootPriority = BBS_IGNORE_ENTRY;\r
-      } else {\r
-        if (Index == 0) {\r
-          if ((HddInfo[HddIndex].Status & (HDD_MASTER_IDE | HDD_MASTER_ATAPI_CDROM | HDD_MASTER_ATAPI_ZIPDISK)) != 0) {\r
-            BbsTable[BbsIndex + Index].BootPriority = BBS_UNPRIORITIZED_ENTRY;\r
-            if ((HddInfo[HddIndex].Status & HDD_MASTER_IDE) != 0) {\r
-              BbsTable[BbsIndex + Index].DeviceType = BBS_HARDDISK;\r
-            } else if ((HddInfo[HddIndex].Status & HDD_MASTER_ATAPI_CDROM) != 0) {\r
-              BbsTable[BbsIndex + Index].DeviceType = BBS_CDROM;\r
-            } else {\r
-              //\r
-              // for ZIPDISK\r
-              //\r
-              BbsTable[BbsIndex + Index].DeviceType = BBS_HARDDISK;\r
-            }\r
-          } else {\r
-            BbsTable[BbsIndex + Index].BootPriority = BBS_IGNORE_ENTRY;\r
-          }\r
-        } else {\r
-          if ((HddInfo[HddIndex].Status & (HDD_SLAVE_IDE | HDD_SLAVE_ATAPI_CDROM | HDD_SLAVE_ATAPI_ZIPDISK)) != 0) {\r
-            BbsTable[BbsIndex + Index].BootPriority = BBS_UNPRIORITIZED_ENTRY;\r
-            if ((HddInfo[HddIndex].Status & HDD_SLAVE_IDE) != 0) {\r
-              BbsTable[BbsIndex + Index].DeviceType = BBS_HARDDISK;\r
-            } else if ((HddInfo[HddIndex].Status & HDD_SLAVE_ATAPI_CDROM) != 0) {\r
-              BbsTable[BbsIndex + Index].DeviceType = BBS_CDROM;\r
-            } else {\r
-              //\r
-              // for ZIPDISK\r
-              //\r
-              BbsTable[BbsIndex + Index].DeviceType = BBS_HARDDISK;\r
-            }\r
-          } else {\r
-            BbsTable[BbsIndex + Index].BootPriority = BBS_IGNORE_ENTRY;\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-\r
-/**\r
-  Get all BBS info\r
-\r
-  @param  This                    Protocol instance pointer.\r
-  @param  HddCount                Number of HDD_INFO structures\r
-  @param  HddInfo                 Onboard IDE controller information\r
-  @param  BbsCount                Number of BBS_TABLE structures\r
-  @param  BbsTable                List BBS entries\r
-\r
-  @retval EFI_SUCCESS             Tables returned\r
-  @retval EFI_NOT_FOUND           resource not found\r
-  @retval EFI_DEVICE_ERROR        can not get BBS table\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosGetBbsInfo (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL         *This,\r
-  OUT UINT16                          *HddCount,\r
-  OUT HDD_INFO                        **HddInfo,\r
-  OUT UINT16                          *BbsCount,\r
-  OUT BBS_TABLE                       **BbsTable\r
-  )\r
-{\r
-  LEGACY_BIOS_INSTANCE              *Private;\r
-  EFI_IA32_REGISTER_SET             Regs;\r
-  EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;\r
-//  HDD_INFO                          *LocalHddInfo;\r
-//  IN BBS_TABLE                      *LocalBbsTable;\r
-  UINTN                             NumHandles;\r
-  EFI_HANDLE                        *HandleBuffer;\r
-  UINTN                             Index;\r
-  UINTN                             TempData;\r
-  UINT32                            Granularity;\r
-\r
-  HandleBuffer            = NULL;\r
-\r
-  Private                 = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-  EfiToLegacy16BootTable  = &Private->IntThunk->EfiToLegacy16BootTable;\r
-//  LocalHddInfo            = EfiToLegacy16BootTable->HddInfo;\r
-//  LocalBbsTable           = (BBS_TABLE*)(UINTN)EfiToLegacy16BootTable->BbsTable;\r
-\r
-  if (!mBbsTableDoneFlag) {\r
-    mBbsTable = Private->BbsTablePtr;\r
-\r
-    //\r
-    // Always enable disk controllers so 16-bit CSM code has valid information for all\r
-    // drives.\r
-    //\r
-    //\r
-    // Get PciRootBridgeIO protocol\r
-    //\r
-    gBS->LocateHandleBuffer (\r
-          ByProtocol,\r
-          &gEfiPciRootBridgeIoProtocolGuid,\r
-          NULL,\r
-          &NumHandles,\r
-          &HandleBuffer\r
-          );\r
-\r
-    if (NumHandles == 0) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    mBbsTableDoneFlag = TRUE;\r
-    for (Index = 0; Index < NumHandles; Index++) {\r
-      //\r
-      // Connect PciRootBridgeIO protocol handle with FALSE parameter to let\r
-      // PCI bus driver enumerate all subsequent handles\r
-      //\r
-      gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE);\r
-\r
-    }\r
-\r
-    LegacyBiosBuildBbs (Private, mBbsTable);\r
-\r
-    Private->LegacyRegion->UnLock (Private->LegacyRegion, 0xe0000, 0x20000, &Granularity);\r
-\r
-    //\r
-    // Call into Legacy16 code to add to BBS table for non BBS compliant OPROMs.\r
-    //\r
-    ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-    Regs.X.AX = Legacy16UpdateBbs;\r
-\r
-    //\r
-    // Pass in handoff data\r
-    //\r
-    TempData  = (UINTN) EfiToLegacy16BootTable;\r
-    Regs.X.ES = NORMALIZE_EFI_SEGMENT ((UINT32) TempData);\r
-    Regs.X.BX = NORMALIZE_EFI_OFFSET ((UINT32) TempData);\r
-\r
-    Private->LegacyBios.FarCall86 (\r
-      This,\r
-      Private->Legacy16CallSegment,\r
-      Private->Legacy16CallOffset,\r
-      &Regs,\r
-      NULL,\r
-      0\r
-      );\r
-\r
-    Private->Cpu->FlushDataCache (Private->Cpu, 0xE0000, 0x20000, EfiCpuFlushTypeWriteBackInvalidate);\r
-    Private->LegacyRegion->Lock (Private->LegacyRegion, 0xe0000, 0x20000, &Granularity);\r
-\r
-    if (Regs.X.AX != 0) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool (HandleBuffer);\r
-  }\r
-\r
-  *HddCount = MAX_IDE_CONTROLLER;\r
-  *HddInfo  = EfiToLegacy16BootTable->HddInfo;\r
-  *BbsTable = (BBS_TABLE*)(UINTN)EfiToLegacy16BootTable->BbsTable;\r
-  *BbsCount = (UINT16) (sizeof (Private->IntThunk->BbsTable) / sizeof (BBS_TABLE));\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBda.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBda.c
deleted file mode 100644 (file)
index aa6e07a..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/** @file\r
-  This code fills in BDA (0x400) and EBDA (pointed to by 0x4xx)\r
-  information. There is support for doing initializeation before\r
-  Legacy16 is loaded and before a legacy boot is attempted.\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-\r
-/**\r
-  Fill in the standard BDA and EBDA stuff before Legacy16 load\r
-\r
-  @param  Private     Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosInitBda (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  )\r
-{\r
-  BDA_STRUC *Bda;\r
-  UINT8     *Ebda;\r
-\r
-  Bda   = (BDA_STRUC *) ((UINTN) 0x400);\r
-  Ebda  = (UINT8 *) ((UINTN) 0x9fc00);\r
-\r
-  ACCESS_PAGE0_CODE (\r
-    ZeroMem (Bda, 0x100);\r
-    //\r
-    // 640k-1k for EBDA\r
-    //\r
-    Bda->MemSize        = 0x27f;\r
-    Bda->KeyHead        = 0x1e;\r
-    Bda->KeyTail        = 0x1e;\r
-    Bda->FloppyData     = 0x00;\r
-    Bda->FloppyTimeout  = 0xff;\r
-\r
-    Bda->KeyStart       = 0x001E;\r
-    Bda->KeyEnd         = 0x003E;\r
-    Bda->KeyboardStatus = 0x10;\r
-    Bda->Ebda           = 0x9fc0;\r
-\r
-    //\r
-    // Move LPT time out here and zero out LPT4 since some SCSI OPROMS\r
-    // use this as scratch pad (LPT4 is Reserved)\r
-    //\r
-    Bda->Lpt1_2Timeout  = 0x1414;\r
-    Bda->Lpt3_4Timeout  = 0x1400;\r
-\r
-  );\r
-\r
-  ZeroMem (Ebda, 0x400);\r
-  *Ebda = 0x01;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
deleted file mode 100644 (file)
index 05e3ffd..0000000
+++ /dev/null
@@ -1,1214 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-\r
-#define PHYSICAL_ADDRESS_TO_POINTER(Address)  ((VOID *) ((UINTN) Address))\r
-\r
-//\r
-// define maximum number of HDD system supports\r
-//\r
-#define MAX_HDD_ENTRIES 0x30\r
-\r
-//\r
-// Module Global:\r
-//  Since this driver will only ever produce one instance of the Private Data\r
-//  protocol you are not required to dynamically allocate the PrivateData.\r
-//\r
-LEGACY_BIOS_INSTANCE  mPrivateData;\r
-\r
-//\r
-// The SMBIOS table in EfiRuntimeServicesData memory\r
-//\r
-VOID                  *mRuntimeSmbiosEntryPoint = NULL;\r
-\r
-//\r
-// The SMBIOS table in EfiReservedMemoryType memory\r
-//\r
-EFI_PHYSICAL_ADDRESS  mReserveSmbiosEntryPoint = 0;\r
-EFI_PHYSICAL_ADDRESS  mStructureTableAddress   = 0;\r
-UINTN                 mStructureTablePages     = 0;\r
-BOOLEAN               mEndOfDxe                = FALSE;\r
-\r
-/**\r
-  Allocate memory for legacy usage. The memory is executable.\r
-\r
-  @param  AllocateType               The type of allocation to perform.\r
-  @param  MemoryType                 The type of memory to allocate.\r
-  @param  StartPageAddress           Start address of range\r
-  @param  Pages                      Number of pages to allocate\r
-  @param  Result                     Result of allocation\r
-\r
-  @retval EFI_SUCCESS                Legacy memory is allocated successfully.\r
-  @retval Other                      Legacy memory is not allocated.\r
-\r
-**/\r
-EFI_STATUS\r
-AllocateLegacyMemory (\r
-  IN  EFI_ALLOCATE_TYPE         AllocateType,\r
-  IN  EFI_MEMORY_TYPE           MemoryType,\r
-  IN  EFI_PHYSICAL_ADDRESS      StartPageAddress,\r
-  IN  UINTN                     Pages,\r
-  OUT EFI_PHYSICAL_ADDRESS      *Result\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_PHYSICAL_ADDRESS            MemPage;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc;\r
-\r
-  //\r
-  // Allocate Pages of memory less <= StartPageAddress\r
-  //\r
-  MemPage = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPageAddress;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateType,\r
-                  MemoryType,\r
-                  Pages,\r
-                  &MemPage\r
-                  );\r
-  //\r
-  // Do not ASSERT on Status error but let caller decide since some cases\r
-  // memory is already taken but that is ok.\r
-  //\r
-  if (!EFI_ERROR (Status)) {\r
-    if (MemoryType != EfiBootServicesCode) {\r
-      //\r
-      // Make sure that the buffer can be used to store code.\r
-      //\r
-      Status = gDS->GetMemorySpaceDescriptor (MemPage, &MemDesc);\r
-      if (!EFI_ERROR (Status) && (MemDesc.Attributes & EFI_MEMORY_XP) != 0) {\r
-        Status = gDS->SetMemorySpaceAttributes (\r
-                        MemPage,\r
-                        EFI_PAGES_TO_SIZE (Pages),\r
-                        MemDesc.Attributes & (~EFI_MEMORY_XP)\r
-                        );\r
-      }\r
-      if (EFI_ERROR (Status)) {\r
-        gBS->FreePages (MemPage, Pages);\r
-      }\r
-    }\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    *Result = (EFI_PHYSICAL_ADDRESS) (UINTN) MemPage;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  This function is called when EFI needs to reserve an area in the 0xE0000 or 0xF0000\r
-  64 KB blocks.\r
-\r
-  Note: inconsistency with the Framework CSM spec. Per the spec, this function may be\r
-  invoked only once. This limitation is relaxed to allow multiple calls in this implemenation.\r
-\r
-  @param  This                       Protocol instance pointer.\r
-  @param  LegacyMemorySize           Size of required region\r
-  @param  Region                     Region to use. 00 = Either 0xE0000 or 0xF0000\r
-                                     block Bit0 = 1 0xF0000 block Bit1 = 1 0xE0000\r
-                                     block\r
-  @param  Alignment                  Address alignment. Bit mapped. First non-zero\r
-                                     bit from right is alignment.\r
-  @param  LegacyMemoryAddress        Region Assigned\r
-\r
-  @retval EFI_SUCCESS                Region assigned\r
-  @retval EFI_ACCESS_DENIED          Procedure previously invoked\r
-  @retval Other                      Region not assigned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosGetLegacyRegion (\r
-  IN    EFI_LEGACY_BIOS_PROTOCOL *This,\r
-  IN    UINTN                    LegacyMemorySize,\r
-  IN    UINTN                    Region,\r
-  IN    UINTN                    Alignment,\r
-  OUT   VOID                     **LegacyMemoryAddress\r
-  )\r
-{\r
-\r
-  LEGACY_BIOS_INSTANCE  *Private;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-  EFI_STATUS            Status;\r
-  UINT32                Granularity;\r
-\r
-  Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-  Private->LegacyRegion->UnLock (Private->LegacyRegion, 0xE0000, 0x20000, &Granularity);\r
-\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-  Regs.X.AX = Legacy16GetTableAddress;\r
-  Regs.X.BX = (UINT16) Region;\r
-  Regs.X.CX = (UINT16) LegacyMemorySize;\r
-  Regs.X.DX = (UINT16) Alignment;\r
-  Private->LegacyBios.FarCall86 (\r
-     &Private->LegacyBios,\r
-     Private->Legacy16CallSegment,\r
-     Private->Legacy16CallOffset,\r
-     &Regs,\r
-     NULL,\r
-     0\r
-     );\r
-\r
-  if (Regs.X.AX == 0) {\r
-    *LegacyMemoryAddress  = (VOID *) (((UINTN) Regs.X.DS << 4) + Regs.X.BX);\r
-    Status = EFI_SUCCESS;\r
-  } else {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Private->Cpu->FlushDataCache (Private->Cpu, 0xE0000, 0x20000, EfiCpuFlushTypeWriteBackInvalidate);\r
-  Private->LegacyRegion->Lock (Private->LegacyRegion, 0xE0000, 0x20000, &Granularity);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  This function is called when copying data to the region assigned by\r
-  EFI_LEGACY_BIOS_PROTOCOL.GetLegacyRegion().\r
-\r
-  @param  This                       Protocol instance pointer.\r
-  @param  LegacyMemorySize           Size of data to copy\r
-  @param  LegacyMemoryAddress        Legacy Region destination address Note: must\r
-                                     be in region assigned by\r
-                                     LegacyBiosGetLegacyRegion\r
-  @param  LegacyMemorySourceAddress  Source of data\r
-\r
-  @retval EFI_SUCCESS                The data was copied successfully.\r
-  @retval EFI_ACCESS_DENIED          Either the starting or ending address is out of bounds.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosCopyLegacyRegion (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
-  IN    UINTN                 LegacyMemorySize,\r
-  IN    VOID                  *LegacyMemoryAddress,\r
-  IN    VOID                  *LegacyMemorySourceAddress\r
-  )\r
-{\r
-\r
-  LEGACY_BIOS_INSTANCE  *Private;\r
-  UINT32                Granularity;\r
-\r
-  if ((LegacyMemoryAddress < (VOID *)(UINTN)0xE0000 ) ||\r
-      ((UINTN) LegacyMemoryAddress + LegacyMemorySize > (UINTN) 0x100000)\r
-        ) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-  //\r
-  // There is no protection from writes over lapping if this function is\r
-  // called multiple times.\r
-  //\r
-  Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-  Private->LegacyRegion->UnLock (Private->LegacyRegion, 0xE0000, 0x20000, &Granularity);\r
-  CopyMem (LegacyMemoryAddress, LegacyMemorySourceAddress, LegacyMemorySize);\r
-\r
-  Private->Cpu->FlushDataCache (Private->Cpu, 0xE0000, 0x20000, EfiCpuFlushTypeWriteBackInvalidate);\r
-  Private->LegacyRegion->Lock (Private->LegacyRegion, 0xE0000, 0x20000, &Granularity);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Find Legacy16 BIOS image in the FLASH device and shadow it into memory. Find\r
-  the $EFI table in the shadow area. Thunk into the Legacy16 code after it had\r
-  been shadowed.\r
-\r
-  @param  Private                    Legacy BIOS context data\r
-\r
-  @retval EFI_SUCCESS                Legacy16 code loaded\r
-  @retval Other                      No protocol installed, unload driver.\r
-\r
-**/\r
-EFI_STATUS\r
-ShadowAndStartLegacy16 (\r
-  IN  LEGACY_BIOS_INSTANCE  *Private\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  UINT8                             *Ptr;\r
-  UINT8                             *PtrEnd;\r
-  BOOLEAN                           Done;\r
-  EFI_COMPATIBILITY16_TABLE         *Table;\r
-  UINT8                             CheckSum;\r
-  EFI_IA32_REGISTER_SET             Regs;\r
-  EFI_TO_COMPATIBILITY16_INIT_TABLE *EfiToLegacy16InitTable;\r
-  EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;\r
-  VOID                              *LegacyBiosImage;\r
-  UINTN                             LegacyBiosImageSize;\r
-  UINTN                             E820Size;\r
-  UINT32                            *ClearPtr;\r
-  BBS_TABLE                         *BbsTable;\r
-  LEGACY_EFI_HDD_TABLE              *LegacyEfiHddTable;\r
-  UINTN                             Index;\r
-  UINT32                            TpmPointer;\r
-  VOID                              *TpmBinaryImage;\r
-  UINTN                             TpmBinaryImageSize;\r
-  UINTN                             Location;\r
-  UINTN                             Alignment;\r
-  UINTN                             TempData;\r
-  EFI_PHYSICAL_ADDRESS              Address;\r
-  UINT16                            OldMask;\r
-  UINT16                            NewMask;\r
-  UINT32                            Granularity;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR   Descriptor;\r
-\r
-  Location  = 0;\r
-  Alignment = 0;\r
-\r
-  //\r
-  // we allocate the C/D/E/F segment as RT code so no one will use it any more.\r
-  //\r
-  Address = 0xC0000;\r
-  gDS->GetMemorySpaceDescriptor (Address, &Descriptor);\r
-  if (Descriptor.GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {\r
-    //\r
-    // If it is already reserved, we should be safe, or else we allocate it.\r
-    //\r
-    Status = gBS->AllocatePages (\r
-                    AllocateAddress,\r
-                    EfiRuntimeServicesCode,\r
-                    0x40000/EFI_PAGE_SIZE,\r
-                    &Address\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Bugbug: need to figure out whether C/D/E/F segment should be marked as reserved memory.\r
-      //\r
-      DEBUG ((DEBUG_ERROR, "Failed to allocate the C/D/E/F segment Status = %r", Status));\r
-    }\r
-  }\r
-\r
-  //\r
-  // start testtest\r
-  //    GetTimerValue (&Ticker);\r
-  //\r
-  //  gRT->SetVariable (L"StartLegacy",\r
-  //                    &gEfiGlobalVariableGuid,\r
-  //                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-  //                    sizeof (UINT64),\r
-  //                    (VOID *)&Ticker\r
-  //                    );\r
-  // end testtest\r
-  //\r
-  EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;\r
-  Status = Private->LegacyBiosPlatform->GetPlatformInfo (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiGetPlatformBinarySystemRom,\r
-                                          &LegacyBiosImage,\r
-                                          &LegacyBiosImageSize,\r
-                                          &Location,\r
-                                          &Alignment,\r
-                                          0,\r
-                                          0\r
-                                          );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Private->BiosStart            = (UINT32) (0x100000 - LegacyBiosImageSize);\r
-  Private->OptionRom            = 0xc0000;\r
-  Private->LegacyBiosImageSize  = (UINT32) LegacyBiosImageSize;\r
-\r
-  //\r
-  // Can only shadow into memory allocated for legacy useage.\r
-  //\r
-  ASSERT (Private->BiosStart > Private->OptionRom);\r
-\r
-  //\r
-  // Shadow Legacy BIOS. Turn on memory and copy image\r
-  //\r
-  Private->LegacyRegion->UnLock (Private->LegacyRegion, 0xc0000, 0x40000, &Granularity);\r
-\r
-  ClearPtr = (VOID *) ((UINTN) 0xc0000);\r
-\r
-  //\r
-  // Initialize region from 0xc0000 to start of BIOS to all ffs. This allows unused\r
-  // regions to be used by EMM386 etc.\r
-  //\r
-  SetMem ((VOID *) ClearPtr, (UINTN) (0x40000 - LegacyBiosImageSize), 0xff);\r
-\r
-  TempData = Private->BiosStart;\r
-\r
-  CopyMem (\r
-    (VOID *) TempData,\r
-    LegacyBiosImage,\r
-    (UINTN) LegacyBiosImageSize\r
-    );\r
-\r
-  Private->Cpu->FlushDataCache (Private->Cpu, 0xc0000, 0x40000, EfiCpuFlushTypeWriteBackInvalidate);\r
-\r
-  //\r
-  // Search for Legacy16 table in Shadowed ROM\r
-  //\r
-  Done  = FALSE;\r
-  Table = NULL;\r
-  for (Ptr = (UINT8 *) TempData; Ptr < (UINT8 *) ((UINTN) 0x100000) && !Done; Ptr += 0x10) {\r
-    if (*(UINT32 *) Ptr == SIGNATURE_32 ('I', 'F', 'E', '$')) {\r
-      Table   = (EFI_COMPATIBILITY16_TABLE *) Ptr;\r
-      PtrEnd  = Ptr + Table->TableLength;\r
-      for (CheckSum = 0; Ptr < PtrEnd; Ptr++) {\r
-        CheckSum = (UINT8) (CheckSum +*Ptr);\r
-      }\r
-\r
-      Done = TRUE;\r
-    }\r
-  }\r
-\r
-  if (Table == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "No Legacy16 table found\n"));\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if (!Done) {\r
-    //\r
-    // Legacy16 table header checksum error.\r
-    //\r
-    DEBUG ((EFI_D_ERROR, "Legacy16 table found with bad talbe header checksum\n"));\r
-  }\r
-\r
-  //\r
-  // Remember location of the Legacy16 table\r
-  //\r
-  Private->Legacy16Table            = Table;\r
-  Private->Legacy16CallSegment      = Table->Compatibility16CallSegment;\r
-  Private->Legacy16CallOffset       = Table->Compatibility16CallOffset;\r
-  EfiToLegacy16InitTable            = &Private->IntThunk->EfiToLegacy16InitTable;\r
-  Private->Legacy16InitPtr          = EfiToLegacy16InitTable;\r
-  Private->Legacy16BootPtr          = &Private->IntThunk->EfiToLegacy16BootTable;\r
-  Private->InternalIrqRoutingTable  = NULL;\r
-  Private->NumberIrqRoutingEntries  = 0;\r
-  Private->BbsTablePtr              = NULL;\r
-  Private->LegacyEfiHddTable        = NULL;\r
-  Private->DiskEnd                  = 0;\r
-  Private->Disk4075                 = 0;\r
-  Private->HddTablePtr              = &Private->IntThunk->EfiToLegacy16BootTable.HddInfo;\r
-  Private->NumberHddControllers     = MAX_IDE_CONTROLLER;\r
-  Private->Dump[0]                  = 'D';\r
-  Private->Dump[1]                  = 'U';\r
-  Private->Dump[2]                  = 'M';\r
-  Private->Dump[3]                  = 'P';\r
-\r
-  ZeroMem (\r
-    Private->Legacy16BootPtr,\r
-    sizeof (EFI_TO_COMPATIBILITY16_BOOT_TABLE)\r
-    );\r
-\r
-  //\r
-  // Store away a copy of the EFI System Table\r
-  //\r
-  Table->EfiSystemTable = (UINT32) (UINTN) gST;\r
-\r
-  //\r
-  // IPF CSM integration -Bug\r
-  //\r
-  // Construct the Legacy16 boot memory map. This sets up number of\r
-  // E820 entries.\r
-  //\r
-  LegacyBiosBuildE820 (Private, &E820Size);\r
-  //\r
-  // Initialize BDA and EBDA standard values needed to load Legacy16 code\r
-  //\r
-  LegacyBiosInitBda (Private);\r
-  LegacyBiosInitCmos (Private);\r
-\r
-  //\r
-  // All legacy interrupt should be masked when do initialization work from legacy 16 code.\r
-  //\r
-  Private->Legacy8259->GetMask(Private->Legacy8259, &OldMask, NULL, NULL, NULL);\r
-  NewMask = 0xFFFF;\r
-  Private->Legacy8259->SetMask(Private->Legacy8259, &NewMask, NULL, NULL, NULL);\r
-\r
-  //\r
-  // Call into Legacy16 code to do an INIT\r
-  //\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-  Regs.X.AX = Legacy16InitializeYourself;\r
-  Regs.X.ES = EFI_SEGMENT (*((UINT32 *) &EfiToLegacy16InitTable));\r
-  Regs.X.BX = EFI_OFFSET (*((UINT32 *) &EfiToLegacy16InitTable));\r
-\r
-  Private->LegacyBios.FarCall86 (\r
-    &Private->LegacyBios,\r
-    Table->Compatibility16CallSegment,\r
-    Table->Compatibility16CallOffset,\r
-    &Regs,\r
-    NULL,\r
-    0\r
-    );\r
-\r
-  //\r
-  // Restore original legacy interrupt mask value\r
-  //\r
-  Private->Legacy8259->SetMask(Private->Legacy8259, &OldMask, NULL, NULL, NULL);\r
-\r
-  if (Regs.X.AX != 0) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // start testtest\r
-  //  GetTimerValue (&Ticker);\r
-  //\r
-  //  gRT->SetVariable (L"BackFromInitYourself",\r
-  //                    &gEfiGlobalVariableGuid,\r
-  //                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-  //                    sizeof (UINT64),\r
-  //                    (VOID *)&Ticker\r
-  //                    );\r
-  // end testtest\r
-  //\r
-  // Copy E820 table after InitializeYourself is completed\r
-  //\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-  Regs.X.AX = Legacy16GetTableAddress;\r
-  Regs.X.CX = (UINT16) E820Size;\r
-  Regs.X.DX = 1;\r
-  Private->LegacyBios.FarCall86 (\r
-    &Private->LegacyBios,\r
-    Table->Compatibility16CallSegment,\r
-    Table->Compatibility16CallOffset,\r
-    &Regs,\r
-    NULL,\r
-    0\r
-    );\r
-\r
-  Table->E820Pointer  = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);\r
-  Table->E820Length   = (UINT32) E820Size;\r
-  if (Regs.X.AX != 0) {\r
-    DEBUG ((EFI_D_ERROR, "Legacy16 E820 length insufficient\n"));\r
-  } else {\r
-    TempData = Table->E820Pointer;\r
-    CopyMem ((VOID *) TempData, Private->E820Table, E820Size);\r
-  }\r
-  //\r
-  // Get PnPInstallationCheck Info.\r
-  //\r
-  Private->PnPInstallationCheckSegment  = Table->PnPInstallationCheckSegment;\r
-  Private->PnPInstallationCheckOffset   = Table->PnPInstallationCheckOffset;\r
-\r
-  //\r
-  // Check if PCI Express is supported. If yes, Save base address.\r
-  //\r
-  Status = Private->LegacyBiosPlatform->GetPlatformInfo (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiGetPlatformPciExpressBase,\r
-                                          NULL,\r
-                                          NULL,\r
-                                          &Location,\r
-                                          &Alignment,\r
-                                          0,\r
-                                          0\r
-                                          );\r
-  if (!EFI_ERROR (Status)) {\r
-    Private->Legacy16Table->PciExpressBase  = (UINT32)Location;\r
-    Location = 0;\r
-  }\r
-  //\r
-  // Check if TPM is supported. If yes get a region in E0000,F0000 to copy it\r
-  // into, copy it and update pointer to binary image. This needs to be\r
-  // done prior to any OPROM for security purposes.\r
-  //\r
-  Status = Private->LegacyBiosPlatform->GetPlatformInfo (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiGetPlatformBinaryTpmBinary,\r
-                                          &TpmBinaryImage,\r
-                                          &TpmBinaryImageSize,\r
-                                          &Location,\r
-                                          &Alignment,\r
-                                          0,\r
-                                          0\r
-                                          );\r
-  if (!EFI_ERROR (Status)) {\r
-\r
-    ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-    Regs.X.AX = Legacy16GetTableAddress;\r
-    Regs.X.CX = (UINT16) TpmBinaryImageSize;\r
-    Regs.X.DX = 1;\r
-    Private->LegacyBios.FarCall86 (\r
-      &Private->LegacyBios,\r
-      Table->Compatibility16CallSegment,\r
-      Table->Compatibility16CallOffset,\r
-      &Regs,\r
-      NULL,\r
-      0\r
-      );\r
-\r
-    TpmPointer = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);\r
-    if (Regs.X.AX != 0) {\r
-      DEBUG ((EFI_D_ERROR, "TPM cannot be loaded\n"));\r
-    } else {\r
-      CopyMem ((VOID *) (UINTN)TpmPointer, TpmBinaryImage, TpmBinaryImageSize);\r
-      Table->TpmSegment = Regs.X.DS;\r
-      Table->TpmOffset  = Regs.X.BX;\r
-\r
-    }\r
-  }\r
-  //\r
-  // Lock the Legacy BIOS region\r
-  //\r
-  Private->Cpu->FlushDataCache (Private->Cpu, Private->BiosStart, (UINT32) LegacyBiosImageSize, EfiCpuFlushTypeWriteBackInvalidate);\r
-  Private->LegacyRegion->Lock (Private->LegacyRegion, Private->BiosStart, (UINT32) LegacyBiosImageSize, &Granularity);\r
-\r
-  //\r
-  // Get the BbsTable from LOW_MEMORY_THUNK\r
-  //\r
-  BbsTable = (BBS_TABLE *)(UINTN)Private->IntThunk->BbsTable;\r
-  ZeroMem ((VOID *)BbsTable, sizeof (Private->IntThunk->BbsTable));\r
-\r
-  EfiToLegacy16BootTable->BbsTable  = (UINT32)(UINTN)BbsTable;\r
-  Private->BbsTablePtr              = (VOID *) BbsTable;\r
-  //\r
-  // Skip Floppy and possible onboard IDE drives\r
-  //\r
-  EfiToLegacy16BootTable->NumberBbsEntries = 1 + 2 * MAX_IDE_CONTROLLER;\r
-\r
-  for (Index = 0; Index < (sizeof (Private->IntThunk->BbsTable) / sizeof (BBS_TABLE)); Index++) {\r
-    BbsTable[Index].BootPriority = BBS_IGNORE_ENTRY;\r
-  }\r
-  //\r
-  // Allocate space for Legacy HDD table\r
-  //\r
-  LegacyEfiHddTable = (LEGACY_EFI_HDD_TABLE *) AllocateZeroPool ((UINTN) MAX_HDD_ENTRIES * sizeof (LEGACY_EFI_HDD_TABLE));\r
-  ASSERT (LegacyEfiHddTable);\r
-\r
-  Private->LegacyEfiHddTable      = LegacyEfiHddTable;\r
-  Private->LegacyEfiHddTableIndex = 0x00;\r
-\r
-  //\r
-  // start testtest\r
-  //  GetTimerValue (&Ticker);\r
-  //\r
-  //  gRT->SetVariable (L"EndOfLoadFv",\r
-  //                    &gEfiGlobalVariableGuid,\r
-  //                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-  //                    sizeof (UINT64),\r
-  //                    (VOID *)&Ticker\r
-  //                    );\r
-  // end testtest\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Shadow all legacy16 OPROMs that haven't been shadowed.\r
-  Warning: Use this with caution. This routine disconnects all EFI\r
-  drivers. If used externally then caller must re-connect EFI\r
-  drivers.\r
-\r
-  @param  This                    Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS             OPROMs shadowed\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosShadowAllLegacyOproms (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL *This\r
-  )\r
-{\r
-  LEGACY_BIOS_INSTANCE  *Private;\r
-\r
-  //\r
-  //  EFI_LEGACY_BIOS_PLATFORM_PROTOCOL    *LegacyBiosPlatform;\r
-  //  EFI_LEGACY16_TABLE                   *Legacy16Table;\r
-  //\r
-  Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-\r
-  //\r
-  //  LegacyBiosPlatform       = Private->LegacyBiosPlatform;\r
-  //  Legacy16Table            = Private->Legacy16Table;\r
-  //\r
-  // Shadow PCI ROMs. We must do this near the end since this will kick\r
-  // of Native EFI drivers that may be needed to collect info for Legacy16\r
-  //\r
-  //  WARNING: PciIo is gone after this call.\r
-  //\r
-  PciProgramAllInterruptLineRegisters (Private);\r
-\r
-  PciShadowRoms (Private);\r
-\r
-  //\r
-  // Shadow PXE base code, BIS etc.\r
-  //\r
-  //  LegacyBiosPlatform->ShadowServiceRoms (LegacyBiosPlatform,\r
-  //                       &Private->OptionRom,\r
-  //                       Legacy16Table);\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Get the PCI BIOS interface version.\r
-\r
-  @param  Private  Driver private data.\r
-\r
-  @return The PCI interface version number in Binary Coded Decimal (BCD) format.\r
-          E.g.: 0x0210 indicates 2.10, 0x0300 indicates 3.00\r
-\r
-**/\r
-UINT16\r
-GetPciInterfaceVersion (\r
-  IN LEGACY_BIOS_INSTANCE *Private\r
-  )\r
-{\r
-  EFI_IA32_REGISTER_SET Reg;\r
-  BOOLEAN               ThunkFailed;\r
-  UINT16                PciInterfaceVersion;\r
-\r
-  PciInterfaceVersion = 0;\r
-\r
-  Reg.X.AX = 0xB101;\r
-  Reg.E.EDI = 0;\r
-\r
-  ThunkFailed = Private->LegacyBios.Int86 (&Private->LegacyBios, 0x1A, &Reg);\r
-  if (!ThunkFailed) {\r
-    //\r
-    // From PCI Firmware 3.0 Specification:\r
-    //   If the CARRY FLAG [CF] is cleared and AH is set to 00h, it is still necessary to examine the\r
-    //   contents of [EDX] for the presence of the string "PCI" + (trailing space) to fully validate the\r
-    //   presence of the PCI function set. [BX] will further indicate the version level, with enough\r
-    //   granularity to allow for incremental changes in the code that don't affect the function interface.\r
-    //   Version numbers are stored as Binary Coded Decimal (BCD) values. For example, Version 2.10\r
-    //   would be returned as a 02h in the [BH] registers and 10h in the [BL] registers.\r
-    //\r
-    if ((Reg.X.Flags.CF == 0) && (Reg.H.AH == 0) && (Reg.E.EDX == SIGNATURE_32 ('P', 'C', 'I', ' '))) {\r
-      PciInterfaceVersion = Reg.X.BX;\r
-    }\r
-  }\r
-  return PciInterfaceVersion;\r
-}\r
-\r
-/**\r
-  Callback function to calculate SMBIOS table size, and allocate memory for SMBIOS table.\r
-  SMBIOS table will be copied into EfiReservedMemoryType memory in legacy boot path.\r
-\r
-  @param  Event                 Event whose notification function is being invoked.\r
-  @param  Context               The pointer to the notification function's context,\r
-                                which is implementation-dependent.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-InstallSmbiosEventCallback (\r
-  IN EFI_EVENT                Event,\r
-  IN VOID                     *Context\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  SMBIOS_TABLE_ENTRY_POINT    *EntryPointStructure;\r
-\r
-  //\r
-  // Get SMBIOS table from EFI configuration table\r
-  //\r
-  Status = EfiGetSystemConfigurationTable (\r
-            &gEfiSmbiosTableGuid,\r
-            &mRuntimeSmbiosEntryPoint\r
-            );\r
-  if ((EFI_ERROR (Status)) || (mRuntimeSmbiosEntryPoint == NULL)) {\r
-    return;\r
-  }\r
-\r
-  EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) mRuntimeSmbiosEntryPoint;\r
-\r
-  //\r
-  // Allocate memory for SMBIOS Entry Point Structure.\r
-  // CSM framework spec requires SMBIOS table below 4GB in EFI_TO_COMPATIBILITY16_BOOT_TABLE.\r
-  //\r
-  if (mReserveSmbiosEntryPoint == 0) {\r
-    //\r
-    // Entrypoint structure with fixed size is allocated only once.\r
-    //\r
-    mReserveSmbiosEntryPoint = SIZE_4GB - 1;\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiReservedMemoryType,\r
-                    EFI_SIZE_TO_PAGES ((UINTN) (EntryPointStructure->EntryPointLength)),\r
-                    &mReserveSmbiosEntryPoint\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      mReserveSmbiosEntryPoint = 0;\r
-      return;\r
-    }\r
-    DEBUG ((EFI_D_INFO, "Allocate memory for Smbios Entry Point Structure\n"));\r
-  }\r
-\r
-  if ((mStructureTableAddress != 0) &&\r
-      (mStructureTablePages < EFI_SIZE_TO_PAGES ((UINT32)EntryPointStructure->TableLength))) {\r
-    //\r
-    // If original buffer is not enough for the new SMBIOS table, free original buffer and re-allocate\r
-    //\r
-    gBS->FreePages (mStructureTableAddress, mStructureTablePages);\r
-    mStructureTableAddress = 0;\r
-    mStructureTablePages   = 0;\r
-    DEBUG ((EFI_D_INFO, "Original size is not enough. Re-allocate the memory.\n"));\r
-  }\r
-\r
-  if (mStructureTableAddress == 0) {\r
-    //\r
-    // Allocate reserved memory below 4GB.\r
-    // Smbios spec requires the structure table is below 4GB.\r
-    //\r
-    mStructureTableAddress = SIZE_4GB - 1;\r
-    mStructureTablePages   = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength);\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiReservedMemoryType,\r
-                    mStructureTablePages,\r
-                    &mStructureTableAddress\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      gBS->FreePages (\r
-        mReserveSmbiosEntryPoint,\r
-        EFI_SIZE_TO_PAGES ((UINTN) (EntryPointStructure->EntryPointLength))\r
-        );\r
-      mReserveSmbiosEntryPoint = 0;\r
-      mStructureTableAddress   = 0;\r
-      mStructureTablePages     = 0;\r
-      return;\r
-    }\r
-    DEBUG ((EFI_D_INFO, "Allocate memory for Smbios Structure Table\n"));\r
-  }\r
-}\r
-\r
-/**\r
-  Callback function to toggle EndOfDxe status. NULL pointer detection needs\r
-  this status to decide if it's necessary to change attributes of page 0.\r
-\r
-  @param  Event            Event whose notification function is being invoked.\r
-  @param  Context          The pointer to the notification function's context,\r
-                           which is implementation-dependent.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-ToggleEndOfDxeStatus (\r
-  IN EFI_EVENT                Event,\r
-  IN VOID                     *Context\r
-  )\r
-{\r
-  mEndOfDxe = TRUE;\r
-  return;\r
-}\r
-\r
-/**\r
-  Install Driver to produce Legacy BIOS protocol.\r
-\r
-  @param  ImageHandle  Handle of driver image.\r
-  @param  SystemTable  Pointer to system table.\r
-\r
-  @retval EFI_SUCCESS  Legacy BIOS protocol installed\r
-  @retval No protocol installed, unload driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosInstall (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS                         Status;\r
-  LEGACY_BIOS_INSTANCE               *Private;\r
-  EFI_TO_COMPATIBILITY16_INIT_TABLE  *EfiToLegacy16InitTable;\r
-  EFI_PHYSICAL_ADDRESS               MemoryAddress;\r
-  EFI_PHYSICAL_ADDRESS               EbdaReservedBaseAddress;\r
-  VOID                               *MemoryPtr;\r
-  EFI_PHYSICAL_ADDRESS               MemoryAddressUnder1MB;\r
-  UINTN                              Index;\r
-  UINT32                             *BaseVectorMaster;\r
-  EFI_PHYSICAL_ADDRESS               StartAddress;\r
-  UINT32                             *ClearPtr;\r
-  EFI_PHYSICAL_ADDRESS               MemStart;\r
-  UINT32                             IntRedirCode;\r
-  UINT32                             Granularity;\r
-  BOOLEAN                            DecodeOn;\r
-  UINT32                             MemorySize;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR    Descriptor;\r
-  UINT64                             Length;\r
-  UINT8                              *SecureBoot;\r
-  EFI_EVENT                          InstallSmbiosEvent;\r
-  EFI_EVENT                          EndOfDxeEvent;\r
-\r
-  //\r
-  // Load this driver's image to memory\r
-  //\r
-  Status = RelocateImageUnder4GIfNeeded (ImageHandle, SystemTable);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // When UEFI Secure Boot is enabled, CSM module will not start any more.\r
-  //\r
-  SecureBoot = NULL;\r
-  GetEfiGlobalVariable2 (EFI_SECURE_BOOT_MODE_NAME, (VOID**)&SecureBoot, NULL);\r
-  if ((SecureBoot != NULL) && (*SecureBoot == SECURE_BOOT_MODE_ENABLE)) {\r
-    FreePool (SecureBoot);\r
-    return EFI_SECURITY_VIOLATION;\r
-  }\r
-\r
-  if (SecureBoot != NULL) {\r
-    FreePool (SecureBoot);\r
-  }\r
-\r
-  Private = &mPrivateData;\r
-  ZeroMem (Private, sizeof (LEGACY_BIOS_INSTANCE));\r
-\r
-  //\r
-  // Grab a copy of all the protocols we depend on. Any error would\r
-  // be a dispatcher bug!.\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **) &Private->Cpu);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **) &Private->Timer);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->LocateProtocol (&gEfiLegacyRegion2ProtocolGuid, NULL, (VOID **) &Private->LegacyRegion);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosPlatformProtocolGuid, NULL, (VOID **) &Private->LegacyBiosPlatform);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->LocateProtocol (&gEfiLegacy8259ProtocolGuid, NULL, (VOID **) &Private->Legacy8259);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->LocateProtocol (&gEfiLegacyInterruptProtocolGuid, NULL, (VOID **) &Private->LegacyInterrupt);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Locate Memory Test Protocol if exists\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiGenericMemTestProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &Private->GenericMemoryTest\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Make sure all memory from 0-640K is tested\r
-  //\r
-  for (StartAddress = 0; StartAddress < 0xa0000; ) {\r
-    gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor);\r
-    if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved) {\r
-      StartAddress = Descriptor.BaseAddress + Descriptor.Length;\r
-      continue;\r
-    }\r
-    Length = MIN (Descriptor.Length, 0xa0000 - StartAddress);\r
-    Private->GenericMemoryTest->CompatibleRangeTest (\r
-                                  Private->GenericMemoryTest,\r
-                                  StartAddress,\r
-                                  Length\r
-                                  );\r
-    StartAddress = StartAddress + Length;\r
-  }\r
-  //\r
-  // Make sure all memory from 1MB to 16MB is tested and added to memory map\r
-  //\r
-  for (StartAddress = BASE_1MB; StartAddress < BASE_16MB; ) {\r
-    gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor);\r
-    if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved) {\r
-      StartAddress = Descriptor.BaseAddress + Descriptor.Length;\r
-      continue;\r
-    }\r
-    Length = MIN (Descriptor.Length, BASE_16MB - StartAddress);\r
-    Private->GenericMemoryTest->CompatibleRangeTest (\r
-                                  Private->GenericMemoryTest,\r
-                                  StartAddress,\r
-                                  Length\r
-                                  );\r
-    StartAddress = StartAddress + Length;\r
-  }\r
-\r
-  Private->Signature = LEGACY_BIOS_INSTANCE_SIGNATURE;\r
-\r
-  Private->LegacyBios.Int86 = LegacyBiosInt86;\r
-  Private->LegacyBios.FarCall86 = LegacyBiosFarCall86;\r
-  Private->LegacyBios.CheckPciRom = LegacyBiosCheckPciRom;\r
-  Private->LegacyBios.InstallPciRom = LegacyBiosInstallPciRom;\r
-  Private->LegacyBios.LegacyBoot = LegacyBiosLegacyBoot;\r
-  Private->LegacyBios.UpdateKeyboardLedStatus = LegacyBiosUpdateKeyboardLedStatus;\r
-  Private->LegacyBios.GetBbsInfo = LegacyBiosGetBbsInfo;\r
-  Private->LegacyBios.ShadowAllLegacyOproms = LegacyBiosShadowAllLegacyOproms;\r
-  Private->LegacyBios.PrepareToBootEfi = LegacyBiosPrepareToBootEfi;\r
-  Private->LegacyBios.GetLegacyRegion = LegacyBiosGetLegacyRegion;\r
-  Private->LegacyBios.CopyLegacyRegion = LegacyBiosCopyLegacyRegion;\r
-  Private->LegacyBios.BootUnconventionalDevice = LegacyBiosBootUnconventionalDevice;\r
-\r
-  Private->ImageHandle = ImageHandle;\r
-\r
-  //\r
-  // Enable read attribute of legacy region.\r
-  //\r
-  DecodeOn = TRUE;\r
-  Private->LegacyRegion->Decode (\r
-                           Private->LegacyRegion,\r
-                           0xc0000,\r
-                           0x40000,\r
-                           &Granularity,\r
-                           &DecodeOn\r
-                           );\r
-  //\r
-  // Set Cachebility for legacy region\r
-  // BUGBUG: Comments about this legacy region cacheability setting\r
-  //         This setting will make D865GCHProduction CSM Unhappy\r
-  //\r
-  if (PcdGetBool (PcdLegacyBiosCacheLegacyRegion)) {\r
-    gDS->SetMemorySpaceAttributes (\r
-           0x0,\r
-           0xA0000,\r
-           EFI_MEMORY_WB\r
-           );\r
-    gDS->SetMemorySpaceAttributes (\r
-           0xc0000,\r
-           0x40000,\r
-           EFI_MEMORY_WB\r
-           );\r
-  }\r
-\r
-  gDS->SetMemorySpaceAttributes (\r
-         0xA0000,\r
-         0x20000,\r
-         EFI_MEMORY_UC\r
-         );\r
-\r
-  //\r
-  // Allocate 0 - 4K for real mode interupt vectors and BDA.\r
-  //\r
-  AllocateLegacyMemory (\r
-    AllocateAddress,\r
-    EfiReservedMemoryType,\r
-    0,\r
-    1,\r
-    &MemoryAddress\r
-    );\r
-  ASSERT (MemoryAddress == 0x000000000);\r
-\r
-  ClearPtr = (VOID *) ((UINTN) 0x0000);\r
-\r
-  //\r
-  // Initialize region from 0x0000 to 4k. This initializes interrupt vector\r
-  // range.\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    gBS->SetMem ((VOID *) ClearPtr, 0x400, INITIAL_VALUE_BELOW_1K);\r
-    ZeroMem ((VOID *) ((UINTN)ClearPtr + 0x400), 0xC00);\r
-  );\r
-\r
-  //\r
-  // Allocate pages for OPROM usage\r
-  //\r
-  MemorySize = PcdGet32 (PcdEbdaReservedMemorySize);\r
-  ASSERT ((MemorySize & 0xFFF) == 0);\r
-\r
-  Status = AllocateLegacyMemory (\r
-             AllocateAddress,\r
-             EfiReservedMemoryType,\r
-             CONVENTIONAL_MEMORY_TOP - MemorySize,\r
-             EFI_SIZE_TO_PAGES (MemorySize),\r
-             &MemoryAddress\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  ZeroMem ((VOID *) ((UINTN) MemoryAddress), MemorySize);\r
-\r
-  //\r
-  // Allocate all 32k chunks from 0x60000 ~ 0x88000 for Legacy OPROMs that\r
-  // don't use PMM but look for zeroed memory. Note that various non-BBS\r
-  // OpROMs expect different areas to be free\r
-  //\r
-  EbdaReservedBaseAddress = MemoryAddress;\r
-  MemoryAddress = PcdGet32 (PcdOpromReservedMemoryBase);\r
-  MemorySize    = PcdGet32 (PcdOpromReservedMemorySize);\r
-  //\r
-  // Check if base address and size for reserved memory are 4KB aligned.\r
-  //\r
-  ASSERT ((MemoryAddress & 0xFFF) == 0);\r
-  ASSERT ((MemorySize & 0xFFF) == 0);\r
-  //\r
-  // Check if the reserved memory is below EBDA reserved range.\r
-  //\r
-  ASSERT ((MemoryAddress < EbdaReservedBaseAddress) && ((MemoryAddress + MemorySize - 1) < EbdaReservedBaseAddress));\r
-  for (MemStart = MemoryAddress; MemStart < MemoryAddress + MemorySize; MemStart += 0x1000) {\r
-    Status = AllocateLegacyMemory (\r
-               AllocateAddress,\r
-               EfiBootServicesCode,\r
-               MemStart,\r
-               1,\r
-               &StartAddress\r
-               );\r
-    if (!EFI_ERROR (Status)) {\r
-      MemoryPtr = (VOID *) ((UINTN) StartAddress);\r
-      ZeroMem (MemoryPtr, 0x1000);\r
-    } else {\r
-      DEBUG ((EFI_D_ERROR, "WARNING: Allocate legacy memory fail for SCSI card - %x\n", MemStart));\r
-    }\r
-  }\r
-\r
-  //\r
-  // Allocate low PMM memory and zero it out\r
-  //\r
-  MemorySize = PcdGet32 (PcdLowPmmMemorySize);\r
-  ASSERT ((MemorySize & 0xFFF) == 0);\r
-  Status = AllocateLegacyMemory (\r
-             AllocateMaxAddress,\r
-             EfiBootServicesCode,\r
-             CONVENTIONAL_MEMORY_TOP,\r
-             EFI_SIZE_TO_PAGES (MemorySize),\r
-             &MemoryAddressUnder1MB\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  ZeroMem ((VOID *) ((UINTN) MemoryAddressUnder1MB), MemorySize);\r
-\r
-  //\r
-  // Allocate space for thunker and Init Thunker\r
-  //\r
-  Status = AllocateLegacyMemory (\r
-             AllocateMaxAddress,\r
-             EfiReservedMemoryType,\r
-             CONVENTIONAL_MEMORY_TOP,\r
-             (sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 2,\r
-             &MemoryAddress\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-  Private->IntThunk                   = (LOW_MEMORY_THUNK *) (UINTN) MemoryAddress;\r
-  EfiToLegacy16InitTable                   = &Private->IntThunk->EfiToLegacy16InitTable;\r
-  EfiToLegacy16InitTable->ThunkStart       = (UINT32) (EFI_PHYSICAL_ADDRESS) (UINTN) MemoryAddress;\r
-  EfiToLegacy16InitTable->ThunkSizeInBytes = (UINT32) (sizeof (LOW_MEMORY_THUNK));\r
-\r
-  Status = LegacyBiosInitializeThunk (Private);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Init the legacy memory map in memory < 1 MB.\r
-  //\r
-  EfiToLegacy16InitTable->BiosLessThan1MB         = (UINT32) MemoryAddressUnder1MB;\r
-  EfiToLegacy16InitTable->LowPmmMemory            = (UINT32) MemoryAddressUnder1MB;\r
-  EfiToLegacy16InitTable->LowPmmMemorySizeInBytes = MemorySize;\r
-\r
-  MemorySize = PcdGet32 (PcdHighPmmMemorySize);\r
-  ASSERT ((MemorySize & 0xFFF) == 0);\r
-  //\r
-  // Allocate high PMM Memory under 16 MB\r
-  //\r
-  Status = AllocateLegacyMemory (\r
-             AllocateMaxAddress,\r
-             EfiBootServicesCode,\r
-             0x1000000,\r
-             EFI_SIZE_TO_PAGES (MemorySize),\r
-             &MemoryAddress\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // If it fails, allocate high PMM Memory under 4GB\r
-    //\r
-    Status = AllocateLegacyMemory (\r
-               AllocateMaxAddress,\r
-               EfiBootServicesCode,\r
-               0xFFFFFFFF,\r
-               EFI_SIZE_TO_PAGES (MemorySize),\r
-               &MemoryAddress\r
-               );\r
-  }\r
-  if (!EFI_ERROR (Status)) {\r
-    EfiToLegacy16InitTable->HiPmmMemory            = (UINT32) (EFI_PHYSICAL_ADDRESS) (UINTN) MemoryAddress;\r
-    EfiToLegacy16InitTable->HiPmmMemorySizeInBytes = MemorySize;\r
-  }\r
-\r
-  //\r
-  //  ShutdownAPs();\r
-  //\r
-  // Start the Legacy BIOS;\r
-  //\r
-  Status = ShadowAndStartLegacy16 (Private);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Initialize interrupt redirection code and entries;\r
-  // IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.\r
-  //\r
-  CopyMem (\r
-         Private->IntThunk->InterruptRedirectionCode,\r
-         (VOID *) (UINTN) InterruptRedirectionTemplate,\r
-         sizeof (Private->IntThunk->InterruptRedirectionCode)\r
-         );\r
-\r
-  //\r
-  // Save Unexpected interrupt vector so can restore it just prior to boot\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);\r
-    Private->BiosUnexpectedInt = BaseVectorMaster[0];\r
-    IntRedirCode = (UINT32) (UINTN) Private->IntThunk->InterruptRedirectionCode;\r
-    for (Index = 0; Index < 8; Index++) {\r
-      BaseVectorMaster[Index] = (EFI_SEGMENT (IntRedirCode + Index * 4) << 16) | EFI_OFFSET (IntRedirCode + Index * 4);\r
-    }\r
-  );\r
-\r
-  //\r
-  // Save EFI value\r
-  //\r
-  Private->ThunkSeg = (UINT16) (EFI_SEGMENT (IntRedirCode));\r
-\r
-  //\r
-  // Allocate reserved memory for SMBIOS table used in legacy boot if SMBIOS table exists\r
-  //\r
-  InstallSmbiosEventCallback (NULL, NULL);\r
-\r
-  //\r
-  // Create callback function to update the size of reserved memory after LegacyBiosDxe starts\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  InstallSmbiosEventCallback,\r
-                  NULL,\r
-                  &gEfiSmbiosTableGuid,\r
-                  &InstallSmbiosEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Create callback to update status of EndOfDxe, which is needed by NULL\r
-  // pointer detection\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  ToggleEndOfDxeStatus,\r
-                  NULL,\r
-                  &gEfiEndOfDxeEventGroupGuid,\r
-                  &EndOfDxeEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Make a new handle and install the protocol\r
-  //\r
-  Private->Handle = NULL;\r
-  Status = gBS->InstallProtocolInterface (\r
-                  &Private->Handle,\r
-                  &gEfiLegacyBiosProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &Private->LegacyBios\r
-                  );\r
-  Private->Csm16PciInterfaceVersion = GetPciInterfaceVersion (Private);\r
-\r
-  DEBUG ((EFI_D_INFO, "CSM16 PCI BIOS Interface Version: %02x.%02x\n",\r
-          (UINT8) (Private->Csm16PciInterfaceVersion >> 8),\r
-          (UINT8) Private->Csm16PciInterfaceVersion\r
-        ));\r
-  ASSERT (Private->Csm16PciInterfaceVersion != 0);\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf
deleted file mode 100644 (file)
index 471d373..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-## @file\r
-# Legacy Bios Module to support CSM.\r
-#\r
-# This driver installs Legacy Bios Protocol to support CSM module work in EFI system.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = LegacyBiosDxe\r
-  MODULE_UNI_FILE                = LegacyBiosDxe.uni\r
-  FILE_GUID                      = F122A15C-C10B-4d54-8F48-60F4F06DD1AD\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = LegacyBiosInstall\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64\r
-#\r
-\r
-[Sources]\r
-  LegacyCmos.c\r
-  LegacyIde.c\r
-  LegacyBios.c\r
-  LegacyBda.c\r
-  LegacyBiosInterface.h\r
-  LegacyPci.c\r
-\r
-[Sources.Ia32]\r
-  IA32/InterruptTable.nasm\r
-  Thunk.c\r
-  LegacyBootSupport.c\r
-  LegacyBbs.c\r
-  LegacySio.c\r
-\r
-[Sources.X64]\r
-  X64/InterruptTable.nasm\r
-  Thunk.c\r
-  LegacyBootSupport.c\r
-  LegacyBbs.c\r
-  LegacySio.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  DevicePathLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  UefiDriverEntryPoint\r
-  BaseMemoryLib\r
-  UefiLib\r
-  DebugLib\r
-  DxeServicesTableLib\r
-  PcdLib\r
-  ReportStatusCodeLib\r
-  DebugAgentLib\r
-\r
-[LibraryClasses.IA32]\r
-  IoLib\r
-  HobLib\r
-  UefiRuntimeServicesTableLib\r
-  BaseLib\r
-\r
-[LibraryClasses.X64]\r
-  IoLib\r
-  HobLib\r
-  UefiRuntimeServicesTableLib\r
-  BaseLib\r
-\r
-[Guids]\r
-  gEfiDiskInfoIdeInterfaceGuid                  ## SOMETIMES_CONSUMES ##GUID #Used in LegacyBiosBuildIdeData() to assure device is a disk\r
-  gEfiSmbiosTableGuid                           ## SOMETIMES_CONSUMES ##SystemTable\r
-  gEfiLegacyBiosGuid                            ## SOMETIMES_CONSUMES ##GUID #Used in LegacyBiosInstallVgaRom() to locate handle buffer\r
-  gEfiEndOfDxeEventGroupGuid                    ## CONSUMES\r
-\r
-[Guids.IA32]\r
-  gEfiAcpi20TableGuid                           ## SOMETIMES_CONSUMES ##SystemTable\r
-  gEfiAcpi10TableGuid                           ## SOMETIMES_CONSUMES ##SystemTable\r
-\r
-[Guids.X64]\r
-  gEfiAcpi20TableGuid                           ## SOMETIMES_CONSUMES ##SystemTable\r
-  gEfiAcpi10TableGuid                           ## SOMETIMES_CONSUMES ##SystemTable\r
-\r
-\r
-[Protocols]\r
-  gEfiLoadedImageProtocolGuid                   ## SOMETIMES_CONSUMES\r
-  gEfiDevicePathProtocolGuid                    ## SOMETIMES_CONSUMES\r
-  gEfiPciRootBridgeIoProtocolGuid               ## SOMETIMES_CONSUMES\r
-  gEfiCpuArchProtocolGuid                       ## CONSUMES\r
-  gEfiTimerArchProtocolGuid                     ## CONSUMES\r
-  gEfiIsaIoProtocolGuid                         ## SOMETIMES_CONSUMES\r
-  gEfiBlockIoProtocolGuid                       ## SOMETIMES_CONSUMES\r
-  gEfiPciIoProtocolGuid                         ## SOMETIMES_CONSUMES\r
-  gEfiGenericMemTestProtocolGuid                ## CONSUMES\r
-  gEfiDiskInfoProtocolGuid                      ## SOMETIMES_CONSUMES\r
-  gEfiSimpleTextInProtocolGuid                  ## SOMETIMES_CONSUMES\r
-  gEfiLegacy8259ProtocolGuid                    ## CONSUMES\r
-  gEfiLegacyBiosPlatformProtocolGuid            ## CONSUMES\r
-  gEfiLegacyInterruptProtocolGuid               ## CONSUMES\r
-  gEfiLegacyRegion2ProtocolGuid                 ## CONSUMES\r
-  gEfiLegacyBiosProtocolGuid                    ## PRODUCES\r
-  gEfiSerialIoProtocolGuid                      ## CONSUMES\r
-  gEfiSioProtocolGuid                           ## CONSUMES\r
-  gEdkiiIoMmuProtocolGuid                       ## CONSUMES\r
-\r
-[Pcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLegacyBiosCacheLegacyRegion  ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEbdaReservedMemorySize       ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEndOpromShadowAddress        ## SOMETIMES_CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLowPmmMemorySize             ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdHighPmmMemorySize            ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdOpromReservedMemoryBase      ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdOpromReservedMemorySize      ## CONSUMES\r
-\r
-[Depex]\r
-  gEfiLegacyRegion2ProtocolGuid AND gEfiLegacyInterruptProtocolGuid AND gEfiLegacyBiosPlatformProtocolGuid AND gEfiLegacy8259ProtocolGuid AND gEfiGenericMemTestProtocolGuid AND gEfiCpuArchProtocolGuid AND gEfiTimerArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  LegacyBiosDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.uni b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.uni
deleted file mode 100644 (file)
index 1a41d6d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// Legacy Bios Module to support CSM.\r
-//\r
-// This driver installs Legacy Bios Protocol to support CSM module work in EFI system.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Legacy Bios Module to support CSM"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This driver installs Legacy Bios Protocol to support CSM module work in a EFI system."\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxeExtra.uni b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxeExtra.uni
deleted file mode 100644 (file)
index a02e783..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// LegacyBiosDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Legacy BIOS Support DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
deleted file mode 100644 (file)
index a72c847..0000000
+++ /dev/null
@@ -1,1460 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _LEGACY_BIOS_INTERFACE_\r
-#define _LEGACY_BIOS_INTERFACE_\r
-\r
-\r
-#include <FrameworkDxe.h>\r
-#include <IndustryStandard/Pci.h>\r
-#include <IndustryStandard/SmBios.h>\r
-#include <IndustryStandard/Acpi10.h>\r
-\r
-#include <Guid/SmBios.h>\r
-#include <Guid/Acpi.h>\r
-#include <Guid/DxeServices.h>\r
-#include <Guid/LegacyBios.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/ImageAuthentication.h>\r
-\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/LoadedImage.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/Cpu.h>\r
-#include <Protocol/Timer.h>\r
-#include <Protocol/IsaIo.h>\r
-#include <Protocol/LegacyRegion2.h>\r
-#include <Protocol/SimpleTextIn.h>\r
-#include <Protocol/LegacyInterrupt.h>\r
-#include <Protocol/LegacyBios.h>\r
-#include <Protocol/DiskInfo.h>\r
-#include <Protocol/GenericMemoryTest.h>\r
-#include <Protocol/LegacyBiosPlatform.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/Legacy8259.h>\r
-#include <Protocol/PciRootBridgeIo.h>\r
-#include <Protocol/SerialIo.h>\r
-#include <Protocol/SuperIo.h>\r
-#include <Protocol/IoMmu.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/DebugAgentLib.h>\r
-\r
-//\r
-// BUGBUG: This entry maybe changed to PCD in future and wait for\r
-//         redesign of BDS library\r
-//\r
-#define MAX_BBS_ENTRIES 0x100\r
-\r
-//\r
-// Thunk Status Codes\r
-//   (These apply only to errors with the thunk and not to the code that was\r
-//   thunked to.)\r
-//\r
-#define THUNK_OK              0x00\r
-#define THUNK_ERR_A20_UNSUP   0x01\r
-#define THUNK_ERR_A20_FAILED  0x02\r
-\r
-//\r
-// Vector base definitions\r
-//\r
-//\r
-// 8259 Hardware definitions\r
-//\r
-#define LEGACY_MODE_BASE_VECTOR_MASTER     0x08\r
-#define LEGACY_MODE_BASE_VECTOR_SLAVE      0x70\r
-\r
-//\r
-// The original PC used INT8-F for master PIC. Since these mapped over\r
-// processor exceptions TIANO moved the master PIC to INT68-6F.\r
-//\r
-// The vector base for slave PIC is set as 0x70 for PC-AT compatibility.\r
-//\r
-#define PROTECTED_MODE_BASE_VECTOR_MASTER  0x68\r
-#define PROTECTED_MODE_BASE_VECTOR_SLAVE   0x70\r
-\r
-//\r
-// When we call CSM16 functions, some CSM16 use es:[offset + 0xabcd] to get data passed from CSM32,\r
-// offset + 0xabcd could overflow which exceeds 0xFFFF which is invalid in real mode.\r
-// So this will keep offset as small as possible to avoid offset overflow in real mode.\r
-//\r
-#define NORMALIZE_EFI_SEGMENT(_Adr)      (UINT16) (((UINTN) (_Adr)) >> 4)\r
-#define NORMALIZE_EFI_OFFSET(_Adr)       (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xf)\r
-\r
-//\r
-// Trace defines\r
-//\r
-//\r
-#define LEGACY_BDA_TRACE    0x000\r
-#define LEGACY_BIOS_TRACE   0x040\r
-#define LEGACY_BOOT_TRACE   0x080\r
-#define LEGACY_CMOS_TRACE   0x0C0\r
-#define LEGACY_IDE_TRACE    0x100\r
-#define LEGACY_MP_TRACE     0x140\r
-#define LEGACY_PCI_TRACE    0x180\r
-#define LEGACY_SIO_TRACE    0x1C0\r
-\r
-#define LEGACY_PCI_TRACE_000 LEGACY_PCI_TRACE + 0x00\r
-#define LEGACY_PCI_TRACE_001 LEGACY_PCI_TRACE + 0x01\r
-#define LEGACY_PCI_TRACE_002 LEGACY_PCI_TRACE + 0x02\r
-#define LEGACY_PCI_TRACE_003 LEGACY_PCI_TRACE + 0x03\r
-#define LEGACY_PCI_TRACE_004 LEGACY_PCI_TRACE + 0x04\r
-#define LEGACY_PCI_TRACE_005 LEGACY_PCI_TRACE + 0x05\r
-#define LEGACY_PCI_TRACE_006 LEGACY_PCI_TRACE + 0x06\r
-#define LEGACY_PCI_TRACE_007 LEGACY_PCI_TRACE + 0x07\r
-#define LEGACY_PCI_TRACE_008 LEGACY_PCI_TRACE + 0x08\r
-#define LEGACY_PCI_TRACE_009 LEGACY_PCI_TRACE + 0x09\r
-#define LEGACY_PCI_TRACE_00A LEGACY_PCI_TRACE + 0x0A\r
-#define LEGACY_PCI_TRACE_00B LEGACY_PCI_TRACE + 0x0B\r
-#define LEGACY_PCI_TRACE_00C LEGACY_PCI_TRACE + 0x0C\r
-#define LEGACY_PCI_TRACE_00D LEGACY_PCI_TRACE + 0x0D\r
-#define LEGACY_PCI_TRACE_00E LEGACY_PCI_TRACE + 0x0E\r
-#define LEGACY_PCI_TRACE_00F LEGACY_PCI_TRACE + 0x0F\r
-\r
-#define BDA_VIDEO_MODE      0x49\r
-\r
-#define IDE_PI_REGISTER_PNE     BIT0\r
-#define IDE_PI_REGISTER_SNE     BIT2\r
-\r
-typedef struct {\r
-  UINTN   PciSegment;\r
-  UINTN   PciBus;\r
-  UINTN   PciDevice;\r
-  UINTN   PciFunction;\r
-  UINT32  ShadowAddress;\r
-  UINT32  ShadowedSize;\r
-  UINT8   DiskStart;\r
-  UINT8   DiskEnd;\r
-} ROM_INSTANCE_ENTRY;\r
-\r
-//\r
-// Values for RealModeGdt\r
-//\r
-#if defined (MDE_CPU_IA32)\r
-\r
-#define NUM_REAL_GDT_ENTRIES  3\r
-#define CONVENTIONAL_MEMORY_TOP 0xA0000   // 640 KB\r
-#define INITIAL_VALUE_BELOW_1K  0x0\r
-\r
-#elif defined (MDE_CPU_X64)\r
-\r
-#define NUM_REAL_GDT_ENTRIES  8\r
-#define CONVENTIONAL_MEMORY_TOP 0xA0000   // 640 KB\r
-#define INITIAL_VALUE_BELOW_1K  0x0\r
-\r
-#endif\r
-\r
-#pragma pack(1)\r
-\r
-//\r
-// Define what a processor GDT looks like\r
-//\r
-typedef struct {\r
-  UINT32  LimitLo : 16;\r
-  UINT32  BaseLo : 16;\r
-  UINT32  BaseMid : 8;\r
-  UINT32  Type : 4;\r
-  UINT32  System : 1;\r
-  UINT32  Dpl : 2;\r
-  UINT32  Present : 1;\r
-  UINT32  LimitHi : 4;\r
-  UINT32  Software : 1;\r
-  UINT32  Reserved : 1;\r
-  UINT32  DefaultSize : 1;\r
-  UINT32  Granularity : 1;\r
-  UINT32  BaseHi : 8;\r
-} GDT32;\r
-\r
-typedef struct {\r
-  UINT16  LimitLow;\r
-  UINT16  BaseLow;\r
-  UINT8   BaseMid;\r
-  UINT8   Attribute;\r
-  UINT8   LimitHi;\r
-  UINT8   BaseHi;\r
-} GDT64;\r
-\r
-//\r
-// Define what a processor descriptor looks like\r
-// This data structure must be kept in sync with ASM STRUCT in Thunk.inc\r
-//\r
-typedef struct {\r
-  UINT16  Limit;\r
-  UINT64  Base;\r
-} DESCRIPTOR64;\r
-\r
-typedef struct {\r
-  UINT16  Limit;\r
-  UINT32  Base;\r
-} DESCRIPTOR32;\r
-\r
-//\r
-// Low stub lay out\r
-//\r
-#define LOW_STACK_SIZE      (8 * 1024)  // 8k?\r
-#define EFI_MAX_E820_ENTRY  100\r
-#define FIRST_INSTANCE      1\r
-#define NOT_FIRST_INSTANCE  0\r
-\r
-#if defined (MDE_CPU_IA32)\r
-typedef struct {\r
-  //\r
-  // Space for the code\r
-  //  The address of Code is also the beginning of the relocated Thunk code\r
-  //\r
-  CHAR8                             Code[4096]; // ?\r
-  //\r
-  // The address of the Reverse Thunk code\r
-  //  Note that this member CONTAINS the address of the relocated reverse thunk\r
-  //  code unlike the member variable 'Code', which IS the address of the Thunk\r
-  //  code.\r
-  //\r
-  UINT32                            LowReverseThunkStart;\r
-\r
-  //\r
-  // Data for the code (cs releative)\r
-  //\r
-  DESCRIPTOR32                      GdtDesc;          // Protected mode GDT\r
-  DESCRIPTOR32                      IdtDesc;          // Protected mode IDT\r
-  UINT32                            FlatSs;\r
-  UINT32                            FlatEsp;\r
-\r
-  UINT32                            LowCodeSelector;  // Low code selector in GDT\r
-  UINT32                            LowDataSelector;  // Low data selector in GDT\r
-  UINT32                            LowStack;\r
-  DESCRIPTOR32                      RealModeIdtDesc;\r
-\r
-  //\r
-  // real-mode GDT (temporary GDT with two real mode segment descriptors)\r
-  //\r
-  GDT32                             RealModeGdt[NUM_REAL_GDT_ENTRIES];\r
-  DESCRIPTOR32                      RealModeGdtDesc;\r
-\r
-  //\r
-  // Members specifically for the reverse thunk\r
-  //  The RevReal* members are used to store the current state of real mode\r
-  //  before performing the reverse thunk.  The RevFlat* members must be set\r
-  //  before calling the reverse thunk assembly code.\r
-  //\r
-  UINT16                            RevRealDs;\r
-  UINT16                            RevRealSs;\r
-  UINT32                            RevRealEsp;\r
-  DESCRIPTOR32                      RevRealIdtDesc;\r
-  UINT16                            RevFlatDataSelector;  // Flat data selector in GDT\r
-  UINT32                            RevFlatStack;\r
-\r
-  //\r
-  // A low memory stack\r
-  //\r
-  CHAR8                             Stack[LOW_STACK_SIZE];\r
-\r
-  //\r
-  // Stack for flat mode after reverse thunk\r
-  // @bug    - This may no longer be necessary if the reverse thunk interface\r
-  //           is changed to have the flat stack in a different location.\r
-  //\r
-  CHAR8                             RevThunkStack[LOW_STACK_SIZE];\r
-\r
-  //\r
-  // Legacy16 Init memory map info\r
-  //\r
-  EFI_TO_COMPATIBILITY16_INIT_TABLE EfiToLegacy16InitTable;\r
-\r
-  EFI_TO_COMPATIBILITY16_BOOT_TABLE EfiToLegacy16BootTable;\r
-\r
-  CHAR8                             InterruptRedirectionCode[32];\r
-  EFI_LEGACY_INSTALL_PCI_HANDLER    PciHandler;\r
-  EFI_DISPATCH_OPROM_TABLE          DispatchOpromTable;\r
-  BBS_TABLE                         BbsTable[MAX_BBS_ENTRIES];\r
-} LOW_MEMORY_THUNK;\r
-\r
-#elif defined (MDE_CPU_X64)\r
-\r
-typedef struct {\r
-  //\r
-  // Space for the code\r
-  //  The address of Code is also the beginning of the relocated Thunk code\r
-  //\r
-  CHAR8                             Code[4096]; // ?\r
-\r
-  //\r
-  // Data for the code (cs releative)\r
-  //\r
-  DESCRIPTOR64                      X64GdtDesc;          // Protected mode GDT\r
-  DESCRIPTOR64                      X64IdtDesc;          // Protected mode IDT\r
-  UINTN                             X64Ss;\r
-  UINTN                             X64Esp;\r
-\r
-  UINTN                             RealStack;\r
-  DESCRIPTOR32                      RealModeIdtDesc;\r
-  DESCRIPTOR32                      RealModeGdtDesc;\r
-\r
-  //\r
-  // real-mode GDT (temporary GDT with two real mode segment descriptors)\r
-  //\r
-  GDT64                             RealModeGdt[NUM_REAL_GDT_ENTRIES];\r
-  UINT64                            PageMapLevel4;\r
-\r
-  //\r
-  // A low memory stack\r
-  //\r
-  CHAR8                             Stack[LOW_STACK_SIZE];\r
-\r
-  //\r
-  // Legacy16 Init memory map info\r
-  //\r
-  EFI_TO_COMPATIBILITY16_INIT_TABLE EfiToLegacy16InitTable;\r
-\r
-  EFI_TO_COMPATIBILITY16_BOOT_TABLE EfiToLegacy16BootTable;\r
-\r
-  CHAR8                             InterruptRedirectionCode[32];\r
-  EFI_LEGACY_INSTALL_PCI_HANDLER    PciHandler;\r
-  EFI_DISPATCH_OPROM_TABLE          DispatchOpromTable;\r
-  BBS_TABLE                         BbsTable[MAX_BBS_ENTRIES];\r
-} LOW_MEMORY_THUNK;\r
-\r
-#endif\r
-\r
-//\r
-// PnP Expansion Header\r
-//\r
-typedef struct {\r
-  UINT32  PnpSignature;\r
-  UINT8   Revision;\r
-  UINT8   Length;\r
-  UINT16  NextHeader;\r
-  UINT8   Reserved1;\r
-  UINT8   Checksum;\r
-  UINT32  DeviceId;\r
-  UINT16  MfgPointer;\r
-  UINT16  ProductNamePointer;\r
-  UINT8   Class;\r
-  UINT8   SubClass;\r
-  UINT8   Interface;\r
-  UINT8   DeviceIndicators;\r
-  UINT16  Bcv;\r
-  UINT16  DisconnectVector;\r
-  UINT16  Bev;\r
-  UINT16  Reserved2;\r
-  UINT16  StaticResourceVector;\r
-} LEGACY_PNP_EXPANSION_HEADER;\r
-\r
-typedef struct {\r
-  UINT8   PciSegment;\r
-  UINT8   PciBus;\r
-  UINT8   PciDevice;\r
-  UINT8   PciFunction;\r
-  UINT16  Vid;\r
-  UINT16  Did;\r
-  UINT16  SysSid;\r
-  UINT16  SVid;\r
-  UINT8   Class;\r
-  UINT8   SubClass;\r
-  UINT8   Interface;\r
-  UINT8   Reserved;\r
-  UINTN   RomStart;\r
-  UINTN   ManufacturerString;\r
-  UINTN   ProductNameString;\r
-} LEGACY_ROM_AND_BBS_TABLE;\r
-\r
-//\r
-// Structure how EFI has mapped a devices HDD drive numbers.\r
-// Boot to EFI aware OS or shell requires this mapping when\r
-// 16-bit CSM assigns drive numbers.\r
-// This mapping is ignored booting to a legacy OS.\r
-//\r
-typedef struct {\r
-  UINT8 PciSegment;\r
-  UINT8 PciBus;\r
-  UINT8 PciDevice;\r
-  UINT8 PciFunction;\r
-  UINT8 StartDriveNumber;\r
-  UINT8 EndDriveNumber;\r
-} LEGACY_EFI_HDD_TABLE;\r
-\r
-//\r
-// This data is passed to Leacy16Boot\r
-//\r
-typedef enum {\r
-  EfiAcpiAddressRangeMemory   = 1,\r
-  EfiAcpiAddressRangeReserved = 2,\r
-  EfiAcpiAddressRangeACPI     = 3,\r
-  EfiAcpiAddressRangeNVS      = 4,\r
-  EfiAddressRangePersistentMemory = 7\r
-} EFI_ACPI_MEMORY_TYPE;\r
-\r
-typedef struct {\r
-  UINT64                BaseAddr;\r
-  UINT64                Length;\r
-  EFI_ACPI_MEMORY_TYPE  Type;\r
-} EFI_E820_ENTRY64;\r
-\r
-typedef struct {\r
-  UINT32                BassAddrLow;\r
-  UINT32                BaseAddrHigh;\r
-  UINT32                LengthLow;\r
-  UINT32                LengthHigh;\r
-  EFI_ACPI_MEMORY_TYPE  Type;\r
-} EFI_E820_ENTRY;\r
-\r
-#pragma pack()\r
-\r
-extern BBS_TABLE           *mBbsTable;\r
-\r
-extern EFI_GENERIC_MEMORY_TEST_PROTOCOL *gGenMemoryTest;\r
-\r
-extern BOOLEAN mEndOfDxe;\r
-\r
-#define PORT_70 0x70\r
-#define PORT_71 0x71\r
-\r
-#define CMOS_0A     0x0a  ///< Status register A\r
-#define CMOS_0D     0x0d  ///< Status register D\r
-#define CMOS_0E     0x0e  ///< Diagnostic Status\r
-#define CMOS_0F     0x0f  ///< Shutdown status\r
-#define CMOS_10     0x10  ///< Floppy type\r
-#define CMOS_12     0x12  ///< IDE type\r
-#define CMOS_14     0x14  ///< Same as BDA 40:10\r
-#define CMOS_15     0x15  ///< Low byte of base memory in 1k increments\r
-#define CMOS_16     0x16  ///< High byte of base memory in 1k increments\r
-#define CMOS_17     0x17  ///< Low byte of 1MB+ memory in 1k increments - max 15 MB\r
-#define CMOS_18     0x18  ///< High byte of 1MB+ memory in 1k increments - max 15 MB\r
-#define CMOS_19     0x19  ///< C: extended drive type\r
-#define CMOS_1A     0x1a  ///< D: extended drive type\r
-#define CMOS_2E     0x2e  ///< Most significient byte of standard checksum\r
-#define CMOS_2F     0x2f  ///< Least significient byte of standard checksum\r
-#define CMOS_30     0x30  ///< CMOS 0x17\r
-#define CMOS_31     0x31  ///< CMOS 0x18\r
-#define CMOS_32     0x32  ///< Century byte\r
-\r
-//\r
-// 8254 Timer registers\r
-//\r
-#define TIMER0_COUNT_PORT                         0x40\r
-#define TIMER1_COUNT_PORT                         0x41\r
-#define TIMER2_COUNT_PORT                         0x42\r
-#define TIMER_CONTROL_PORT                        0x43\r
-\r
-//\r
-// Timer 0, Read/Write LSB then MSB, Square wave output, binary count use.\r
-//\r
-#define TIMER0_CONTROL_WORD         0x36\r
-\r
-#define LEGACY_BIOS_INSTANCE_SIGNATURE  SIGNATURE_32 ('L', 'B', 'I', 'T')\r
-typedef struct {\r
-  UINTN                             Signature;\r
-\r
-  EFI_HANDLE                        Handle;\r
-  EFI_LEGACY_BIOS_PROTOCOL          LegacyBios;\r
-\r
-  EFI_HANDLE                        ImageHandle;\r
-\r
-  //\r
-  // CPU Architectural Protocol\r
-  //\r
-  EFI_CPU_ARCH_PROTOCOL             *Cpu;\r
-\r
-  //\r
-  // Timer Architectural Protocol\r
-  //\r
-  EFI_TIMER_ARCH_PROTOCOL           *Timer;\r
-  BOOLEAN                           TimerUses8254;\r
-\r
-  //\r
-  // Protocol to Lock and Unlock 0xc0000 - 0xfffff\r
-  //\r
-  EFI_LEGACY_REGION2_PROTOCOL       *LegacyRegion;\r
-\r
-  EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;\r
-\r
-  //\r
-  // Interrupt control for thunk and PCI IRQ\r
-  //\r
-  EFI_LEGACY_8259_PROTOCOL          *Legacy8259;\r
-\r
-  //\r
-  // PCI Interrupt PIRQ control\r
-  //\r
-  EFI_LEGACY_INTERRUPT_PROTOCOL     *LegacyInterrupt;\r
-\r
-  //\r
-  // Generic Memory Test\r
-  //\r
-  EFI_GENERIC_MEMORY_TEST_PROTOCOL  *GenericMemoryTest;\r
-\r
-  //\r
-  // TRUE if PCI Interupt Line registers have been programmed.\r
-  //\r
-  BOOLEAN                           PciInterruptLine;\r
-\r
-  //\r
-  // Code space below 1MB needed by thunker to transition to real mode.\r
-  // Contains stack and real mode code fragments\r
-  //\r
-  LOW_MEMORY_THUNK                  *IntThunk;\r
-\r
-  //\r
-  // Starting shadow address of the Legacy BIOS\r
-  //\r
-  UINT32                            BiosStart;\r
-  UINT32                            LegacyBiosImageSize;\r
-\r
-  //\r
-  // Start of variables used by CsmItp.mac ITP macro file and/os LegacyBios\r
-  //\r
-  UINT8                             Dump[4];\r
-\r
-  //\r
-  // $EFI Legacy16 code entry info in memory < 1 MB;\r
-  //\r
-  EFI_COMPATIBILITY16_TABLE         *Legacy16Table;\r
-  VOID                              *Legacy16InitPtr;\r
-  VOID                              *Legacy16BootPtr;\r
-  VOID                              *InternalIrqRoutingTable;\r
-  UINT32                            NumberIrqRoutingEntries;\r
-  VOID                              *BbsTablePtr;\r
-  VOID                              *HddTablePtr;\r
-  UINT32                            NumberHddControllers;\r
-\r
-  //\r
-  // Cached copy of Legacy16 entry point\r
-  //\r
-  UINT16                            Legacy16CallSegment;\r
-  UINT16                            Legacy16CallOffset;\r
-\r
-  //\r
-  // Returned from $EFI and passed in to OPROMS\r
-  //\r
-  UINT16                            PnPInstallationCheckSegment;\r
-  UINT16                            PnPInstallationCheckOffset;\r
-\r
-  //\r
-  // E820 table\r
-  //\r
-  EFI_E820_ENTRY                    E820Table[EFI_MAX_E820_ENTRY];\r
-  UINT32                            NumberE820Entries;\r
-\r
-  //\r
-  // True if legacy VGA INT 10h handler installed\r
-  //\r
-  BOOLEAN                           VgaInstalled;\r
-\r
-  //\r
-  // Number of IDE drives\r
-  //\r
-  UINT8                             IdeDriveCount;\r
-\r
-  //\r
-  // Current Free Option ROM space. An option ROM must NOT go past\r
-  // BiosStart.\r
-  //\r
-  UINT32                            OptionRom;\r
-\r
-  //\r
-  // Save Legacy16 unexpected interrupt vector. Reprogram INT 68-6F from\r
-  // EFI values to legacy value just before boot.\r
-  //\r
-  UINT32                            BiosUnexpectedInt;\r
-  UINT32                            ThunkSavedInt[8];\r
-  UINT16                            ThunkSeg;\r
-  LEGACY_EFI_HDD_TABLE              *LegacyEfiHddTable;\r
-  UINT16                            LegacyEfiHddTableIndex;\r
-  UINT8                             DiskEnd;\r
-  UINT8                             Disk4075;\r
-  UINT16                            TraceIndex;\r
-  UINT16                            Trace[0x200];\r
-\r
-  //\r
-  // Indicate that whether GenericLegacyBoot is entered or not\r
-  //\r
-  BOOLEAN                           LegacyBootEntered;\r
-\r
-  //\r
-  // CSM16 PCI Interface Version\r
-  //\r
-  UINT16                            Csm16PciInterfaceVersion;\r
-\r
-} LEGACY_BIOS_INSTANCE;\r
-\r
-\r
-#pragma pack(1)\r
-\r
-/*\r
-  40:00-01 Com1\r
-  40:02-03 Com2\r
-  40:04-05 Com3\r
-  40:06-07 Com4\r
-  40:08-09 Lpt1\r
-  40:0A-0B Lpt2\r
-  40:0C-0D Lpt3\r
-  40:0E-0E Ebda segment\r
-  40:10-11 MachineConfig\r
-  40:12    Bda12 - skip\r
-  40:13-14 MemSize below 1MB\r
-  40:15-16 Bda15_16 - skip\r
-  40:17    Keyboard Shift status\r
-  40:18-19 Bda18_19 - skip\r
-  40:1A-1B Key buffer head\r
-  40:1C-1D Key buffer tail\r
-  40:1E-3D Bda1E_3D- key buffer -skip\r
-  40:3E-3F FloppyData 3E = Calibration status 3F = Motor status\r
-  40:40    FloppyTimeout\r
-  40:41-74 Bda41_74 - skip\r
-  40:75    Number of HDD drives\r
-  40:76-77 Bda76_77 - skip\r
-  40:78-79 78 = Lpt1 timeout, 79 = Lpt2 timeout\r
-  40:7A-7B 7A = Lpt3 timeout, 7B = Lpt4 timeout\r
-  40:7C-7D 7C = Com1 timeout, 7D = Com2 timeout\r
-  40:7E-7F 7E = Com3 timeout, 7F = Com4 timeout\r
-  40:80-81 Pointer to start of key buffer\r
-  40:82-83 Pointer to end of key buffer\r
-  40:84-87 Bda84_87 - skip\r
-  40:88    HDD Data Xmit rate\r
-  40:89-8f skip\r
-  40:90    Floppy data rate\r
-  40:91-95 skip\r
-  40:96    Keyboard Status\r
-  40:97    LED Status\r
-  40:98-101 skip\r
-*/\r
-typedef struct {\r
-  UINT16  Com1;\r
-  UINT16  Com2;\r
-  UINT16  Com3;\r
-  UINT16  Com4;\r
-  UINT16  Lpt1;\r
-  UINT16  Lpt2;\r
-  UINT16  Lpt3;\r
-  UINT16  Ebda;\r
-  UINT16  MachineConfig;\r
-  UINT8   Bda12;\r
-  UINT16  MemSize;\r
-  UINT8   Bda15_16[0x02];\r
-  UINT8   ShiftStatus;\r
-  UINT8   Bda18_19[0x02];\r
-  UINT16  KeyHead;\r
-  UINT16  KeyTail;\r
-  UINT16  Bda1E_3D[0x10];\r
-  UINT16  FloppyData;\r
-  UINT8   FloppyTimeout;\r
-  UINT8   Bda41_74[0x34];\r
-  UINT8   NumberOfDrives;\r
-  UINT8   Bda76_77[0x02];\r
-  UINT16  Lpt1_2Timeout;\r
-  UINT16  Lpt3_4Timeout;\r
-  UINT16  Com1_2Timeout;\r
-  UINT16  Com3_4Timeout;\r
-  UINT16  KeyStart;\r
-  UINT16  KeyEnd;\r
-  UINT8   Bda84_87[0x4];\r
-  UINT8   DataXmit;\r
-  UINT8   Bda89_8F[0x07];\r
-  UINT8   FloppyXRate;\r
-  UINT8   Bda91_95[0x05];\r
-  UINT8   KeyboardStatus;\r
-  UINT8   LedStatus;\r
-} BDA_STRUC;\r
-#pragma pack()\r
-\r
-#define LEGACY_BIOS_INSTANCE_FROM_THIS(this)  CR (this, LEGACY_BIOS_INSTANCE, LegacyBios, LEGACY_BIOS_INSTANCE_SIGNATURE)\r
-\r
-/**\r
-  Thunk to 16-bit real mode and execute a software interrupt with a vector\r
-  of BiosInt. Regs will contain the 16-bit register context on entry and\r
-  exit.\r
-\r
-  @param  This    Protocol instance pointer.\r
-  @param  BiosInt Processor interrupt vector to invoke\r
-  @param  Regs    Register contexted passed into (and returned) from thunk to\r
-                  16-bit mode\r
-\r
-  @retval FALSE   Thunk completed, and there were no BIOS errors in the target code.\r
-                  See Regs for status.\r
-  @retval TRUE     There was a BIOS erro in the target code.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-LegacyBiosInt86 (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL          *This,\r
-  IN  UINT8                             BiosInt,\r
-  IN  EFI_IA32_REGISTER_SET             *Regs\r
-  );\r
-\r
-\r
-/**\r
-  Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the\r
-  16-bit register context on entry and exit. Arguments can be passed on\r
-  the Stack argument\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  Segment                Segemnt of 16-bit mode call\r
-  @param  Offset                 Offset of 16-bit mdoe call\r
-  @param  Regs                   Register contexted passed into (and returned) from\r
-                                 thunk to  16-bit mode\r
-  @param  Stack                  Caller allocated stack used to pass arguments\r
-  @param  StackSize              Size of Stack in bytes\r
-\r
-  @retval FALSE                  Thunk completed, and there were no BIOS errors in\r
-                                 the target code. See Regs for status.\r
-  @retval TRUE                   There was a BIOS erro in the target code.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-LegacyBiosFarCall86 (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL          *This,\r
-  IN  UINT16                            Segment,\r
-  IN  UINT16                            Offset,\r
-  IN  EFI_IA32_REGISTER_SET             *Regs,\r
-  IN  VOID                              *Stack,\r
-  IN  UINTN                             StackSize\r
-  );\r
-\r
-\r
-/**\r
-  Test to see if a legacy PCI ROM exists for this device. Optionally return\r
-  the Legacy ROM instance for this PCI device.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  PciHandle              The PCI PC-AT OPROM from this devices ROM BAR will\r
-                                 be loaded\r
-  @param  RomImage               Return the legacy PCI ROM for this device\r
-  @param  RomSize                Size of ROM Image\r
-  @param  Flags                  Indicates if ROM found and if PC-AT.\r
-\r
-  @retval EFI_SUCCESS            Legacy Option ROM available for this device\r
-  @retval EFI_UNSUPPORTED        Legacy Option ROM not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosCheckPciRom (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL          *This,\r
-  IN  EFI_HANDLE                        PciHandle,\r
-  OUT VOID                              **RomImage, OPTIONAL\r
-  OUT UINTN                             *RomSize, OPTIONAL\r
-  OUT UINTN                             *Flags\r
-  );\r
-\r
-\r
-/**\r
-  Assign drive number to legacy HDD drives prior to booting an EFI\r
-  aware OS so the OS can access drives without an EFI driver.\r
-  Note: BBS compliant drives ARE NOT available until this call by\r
-  either shell or EFI.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  BbsCount               Number of BBS_TABLE structures\r
-  @param  BbsTable               List BBS entries\r
-\r
-  @retval EFI_SUCCESS            Drive numbers assigned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosPrepareToBootEfi (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL         *This,\r
-  OUT UINT16                          *BbsCount,\r
-  OUT BBS_TABLE                       **BbsTable\r
-  );\r
-\r
-\r
-/**\r
-  To boot from an unconventional device like parties and/or execute\r
-  HDD diagnostics.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  Attributes             How to interpret the other input parameters\r
-  @param  BbsEntry               The 0-based index into the BbsTable for the parent\r
-                                  device.\r
-  @param  BeerData               Pointer to the 128 bytes of ram BEER data.\r
-  @param  ServiceAreaData        Pointer to the 64 bytes of raw Service Area data.\r
-                                 The caller must provide a pointer to the specific\r
-                                 Service Area and not the start all Service Areas.\r
- EFI_INVALID_PARAMETER if error. Does NOT return if no error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosBootUnconventionalDevice (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL         *This,\r
-  IN UDC_ATTRIBUTES                   Attributes,\r
-  IN UINTN                            BbsEntry,\r
-  IN VOID                             *BeerData,\r
-  IN VOID                             *ServiceAreaData\r
-  );\r
-\r
-\r
-/**\r
-  Load a legacy PC-AT OPROM on the PciHandle device. Return information\r
-  about how many disks were added by the OPROM and the shadow address and\r
-  size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  PciHandle              The PCI PC-AT OPROM from this devices ROM BAR will\r
-                                 be loaded. This value is NULL if RomImage is\r
-                                 non-NULL. This is the normal case.\r
-  @param  RomImage               A PCI PC-AT ROM image. This argument is non-NULL\r
-                                 if there is no hardware associated with the ROM\r
-                                 and thus no PciHandle, otherwise is must be NULL.\r
-                                 Example is PXE base code.\r
-  @param  Flags                  Indicates if ROM found and if PC-AT.\r
-  @param  DiskStart              Disk number of first device hooked by the ROM. If\r
-                                 DiskStart is the same as DiskEnd no disked were\r
-                                 hooked.\r
-  @param  DiskEnd                Disk number of the last device hooked by the ROM.\r
-  @param  RomShadowAddress       Shadow address of PC-AT ROM\r
-  @param  RomShadowedSize        Size of RomShadowAddress in bytes\r
-\r
-  @retval EFI_SUCCESS            Legacy ROM loaded for this device\r
-  @retval EFI_INVALID_PARAMETER  PciHandle not found\r
-  @retval EFI_UNSUPPORTED        There is no PCI ROM in the ROM BAR or no onboard\r
-                                 ROM\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosInstallPciRom (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL          * This,\r
-  IN  EFI_HANDLE                        PciHandle,\r
-  IN  VOID                              **RomImage,\r
-  OUT UINTN                             *Flags,\r
-  OUT UINT8                             *DiskStart, OPTIONAL\r
-  OUT UINT8                             *DiskEnd, OPTIONAL\r
-  OUT VOID                              **RomShadowAddress, OPTIONAL\r
-  OUT UINT32                            *RomShadowedSize OPTIONAL\r
-  );\r
-\r
-\r
-/**\r
-  Fill in the standard BDA for Keyboard LEDs\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  Leds                   Current LED status\r
-\r
-  @retval EFI_SUCCESS            It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosUpdateKeyboardLedStatus (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL           *This,\r
-  IN UINT8                              Leds\r
-  );\r
-\r
-\r
-/**\r
-  Get all BBS info\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  HddCount               Number of HDD_INFO structures\r
-  @param  HddInfo                Onboard IDE controller information\r
-  @param  BbsCount               Number of BBS_TABLE structures\r
-  @param  BbsTable               List BBS entries\r
-\r
-  @retval EFI_SUCCESS            Tables returned\r
-  @retval EFI_NOT_FOUND          resource not found\r
-  @retval EFI_DEVICE_ERROR       can not get BBS table\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosGetBbsInfo (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL          *This,\r
-  OUT UINT16                            *HddCount,\r
-  OUT HDD_INFO                          **HddInfo,\r
-  OUT UINT16                            *BbsCount,\r
-  OUT BBS_TABLE                         **BbsTable\r
-  );\r
-\r
-\r
-/**\r
-  Shadow all legacy16 OPROMs that haven't been shadowed.\r
-  Warning: Use this with caution. This routine disconnects all EFI\r
-  drivers. If used externally then caller must re-connect EFI\r
-  drivers.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS            OPROMs shadowed\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosShadowAllLegacyOproms (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL   *This\r
-  );\r
-\r
-\r
-/**\r
-  Attempt to legacy boot the BootOption. If the EFI contexted has been\r
-  compromised this function will not return.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  BbsDevicePath          EFI Device Path from BootXXXX variable.\r
-  @param  LoadOptionsSize        Size of LoadOption in size.\r
-  @param  LoadOptions            LoadOption from BootXXXX variable\r
-\r
-  @retval EFI_SUCCESS            Removable media not present\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosLegacyBoot (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL          *This,\r
-  IN  BBS_BBS_DEVICE_PATH               *BbsDevicePath,\r
-  IN  UINT32                            LoadOptionsSize,\r
-  IN  VOID                              *LoadOptions\r
-  );\r
-\r
-\r
-/**\r
-  Allocate memory < 1 MB and copy the thunker code into low memory. Se up\r
-  all the descriptors.\r
-\r
-  @param  Private                Private context for Legacy BIOS\r
-\r
-  @retval EFI_SUCCESS            Should only pass.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosInitializeThunk (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  );\r
-\r
-\r
-/**\r
-  Fill in the standard BDA and EBDA stuff before Legacy16 load\r
-\r
-  @param  Private                Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS            It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosInitBda (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  );\r
-\r
-\r
-/**\r
-  Collect IDE Inquiry data from the IDE disks\r
-\r
-  @param  Private                Legacy BIOS Instance data\r
-  @param  HddInfo                Hdd Information\r
-  @param  Flag                   Reconnect IdeController or not\r
-\r
-  @retval EFI_SUCCESS            It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildIdeData (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private,\r
-  IN  HDD_INFO                  **HddInfo,\r
-  IN  UINT16                    Flag\r
-  );\r
-\r
-\r
-/**\r
-  Enable ide controller.  This gets disabled when LegacyBoot.c is about\r
-  to run the Option ROMs.\r
-\r
-  @param  Private                Legacy BIOS Instance data\r
-\r
-\r
-**/\r
-VOID\r
-EnableIdeController (\r
-  IN LEGACY_BIOS_INSTANCE       *Private\r
-  );\r
-\r
-\r
-/**\r
-  If the IDE channel is in compatibility (legacy) mode, remove all\r
-  PCI I/O BAR addresses from the controller.\r
-\r
-  @param  IdeController          The handle of target IDE controller\r
-\r
-\r
-**/\r
-VOID\r
-InitLegacyIdeController (\r
-  IN EFI_HANDLE                 IdeController\r
-  );\r
-\r
-\r
-/**\r
-  Program the interrupt routing register in all the PCI devices. On a PC AT system\r
-  this register contains the 8259 IRQ vector that matches it's PCI interrupt.\r
-\r
-  @param  Private                Legacy  BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS            Succeed.\r
-  @retval EFI_ALREADY_STARTED    All PCI devices have been processed.\r
-\r
-**/\r
-EFI_STATUS\r
-PciProgramAllInterruptLineRegisters (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private\r
-  );\r
-\r
-\r
-/**\r
-  Collect EFI Info about legacy devices.\r
-\r
-  @param  Private                Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS            It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildSioData (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private\r
-  );\r
-\r
-\r
-/**\r
-  Shadow all the PCI legacy ROMs. Use data from the Legacy BIOS Protocol\r
-  to chose the order. Skip any devices that have already have legacy\r
-  BIOS run.\r
-\r
-  @param  Private                Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS            Succeed.\r
-  @retval EFI_UNSUPPORTED        Cannot get VGA device handle.\r
-\r
-**/\r
-EFI_STATUS\r
-PciShadowRoms (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private\r
-  );\r
-\r
-\r
-/**\r
-  Fill in the standard BDA and EBDA stuff prior to legacy Boot\r
-\r
-  @param  Private                Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS            It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosCompleteBdaBeforeBoot (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  );\r
-\r
-\r
-/**\r
-  Fill in the standard CMOS stuff before Legacy16 load\r
-\r
-  @param  Private                Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS            It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosInitCmos (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  );\r
-\r
-\r
-/**\r
-  Fill in the standard CMOS stuff prior to legacy Boot\r
-\r
-  @param  Private                Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS            It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosCompleteStandardCmosBeforeBoot (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  );\r
-\r
-\r
-/**\r
-  Contains the code that is copied into low memory (below 640K).\r
-  This code reflects interrupts 0x68-0x6f to interrupts 0x08-0x0f.\r
-  This template must be copied into low memory, and the IDT entries\r
-  0x68-0x6F must be point to the low memory copy of this code.  Each\r
-  entry is 4 bytes long, so IDT entries 0x68-0x6F can be easily\r
-  computed.\r
-\r
-**/\r
-VOID\r
-InterruptRedirectionTemplate (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Build the E820 table.\r
-\r
-  @param  Private                Legacy BIOS Instance data\r
-  @param  Size                   Size of E820 Table\r
-\r
-  @retval EFI_SUCCESS            It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildE820 (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private,\r
-  OUT UINTN                   *Size\r
-  );\r
-\r
-/**\r
-  This function is to put all AP in halt state.\r
-\r
-  @param  Private                Legacy BIOS Instance data\r
-\r
-**/\r
-VOID\r
-ShutdownAPs (\r
-  IN LEGACY_BIOS_INSTANCE              *Private\r
-  );\r
-\r
-/**\r
-  Worker function for LegacyBiosGetFlatDescs, retrieving content of\r
-  specific registers.\r
-\r
-  @param  IntThunk  Pointer to IntThunk of Legacy BIOS context.\r
-\r
-**/\r
-VOID\r
-GetRegisters (\r
-  LOW_MEMORY_THUNK    *IntThunk\r
-  );\r
-\r
-/**\r
-  Routine for calling real thunk code.\r
-\r
-  @param  RealCode    The address of thunk code.\r
-  @param  BiosInt     The Bios interrupt vector number.\r
-  @param  CallAddress The address of 16-bit mode call.\r
-\r
-  @return  Status returned by real thunk code\r
-\r
-**/\r
-UINTN\r
-CallRealThunkCode (\r
-  UINT8               *RealCode,\r
-  UINT8               BiosInt,\r
-  UINT32              CallAddress\r
-  );\r
-\r
-/**\r
-  Routine for generating soft interrupt.\r
-\r
-  @param Vector  The interrupt vector number.\r
-\r
-**/\r
-VOID\r
-GenerateSoftInit (\r
-  UINT8               Vector\r
-  );\r
-\r
-/**\r
-  Allocate memory for legacy usage.\r
-\r
-  @param  AllocateType               The type of allocation to perform.\r
-  @param  MemoryType                 The type of memory to allocate.\r
-  @param  StartPageAddress           Start address of range\r
-  @param  Pages                      Number of pages to allocate\r
-  @param  Result                     Result of allocation\r
-\r
-  @retval EFI_SUCCESS                Legacy16 code loaded\r
-  @retval Other                      No protocol installed, unload driver.\r
-\r
-**/\r
-EFI_STATUS\r
-AllocateLegacyMemory (\r
-  IN  EFI_ALLOCATE_TYPE         AllocateType,\r
-  IN  EFI_MEMORY_TYPE           MemoryType,\r
-  IN  EFI_PHYSICAL_ADDRESS      StartPageAddress,\r
-  IN  UINTN                     Pages,\r
-  OUT EFI_PHYSICAL_ADDRESS      *Result\r
-  );\r
-\r
-/**\r
-  Get a region from the LegacyBios for Tiano usage. Can only be invoked once.\r
-\r
-  @param  This                       Protocol instance pointer.\r
-  @param  LegacyMemorySize           Size of required region\r
-  @param  Region                     Region to use. 00 = Either 0xE0000 or 0xF0000\r
-                                     block Bit0 = 1 0xF0000 block Bit1 = 1 0xE0000\r
-                                     block\r
-  @param  Alignment                  Address alignment. Bit mapped. First non-zero\r
-                                     bit from right is alignment.\r
-  @param  LegacyMemoryAddress        Region Assigned\r
-\r
-  @retval EFI_SUCCESS                Region assigned\r
-  @retval EFI_ACCESS_DENIED          Procedure previously invoked\r
-  @retval Other                      Region not assigned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosGetLegacyRegion (\r
-  IN    EFI_LEGACY_BIOS_PROTOCOL *This,\r
-  IN    UINTN                    LegacyMemorySize,\r
-  IN    UINTN                    Region,\r
-  IN    UINTN                    Alignment,\r
-  OUT   VOID                     **LegacyMemoryAddress\r
-  );\r
-\r
-/**\r
-  Get a region from the LegacyBios for Tiano usage. Can only be invoked once.\r
-\r
-  @param  This                       Protocol instance pointer.\r
-  @param  LegacyMemorySize           Size of data to copy\r
-  @param  LegacyMemoryAddress        Legacy Region destination address Note: must\r
-                                     be in region assigned by\r
-                                     LegacyBiosGetLegacyRegion\r
-  @param  LegacyMemorySourceAddress  Source of data\r
-\r
-  @retval EFI_SUCCESS                Region assigned\r
-  @retval EFI_ACCESS_DENIED          Destination outside assigned region\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosCopyLegacyRegion (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
-  IN    UINTN                 LegacyMemorySize,\r
-  IN    VOID                  *LegacyMemoryAddress,\r
-  IN    VOID                  *LegacyMemorySourceAddress\r
-  );\r
-\r
-/**\r
-  Find Legacy16 BIOS image in the FLASH device and shadow it into memory. Find\r
-  the $EFI table in the shadow area. Thunk into the Legacy16 code after it had\r
-  been shadowed.\r
-\r
-  @param  Private                    Legacy BIOS context data\r
-\r
-  @retval EFI_SUCCESS                Legacy16 code loaded\r
-  @retval Other                      No protocol installed, unload driver.\r
-\r
-**/\r
-EFI_STATUS\r
-ShadowAndStartLegacy16 (\r
-  IN  LEGACY_BIOS_INSTANCE  *Private\r
-  );\r
-\r
-/**\r
-  Checks the state of the floppy and if media is inserted.\r
-\r
-  This routine checks the state of the floppy and if media is inserted.\r
-  There are 3 cases:\r
-  No floppy present         - Set BBS entry to ignore\r
-  Floppy present & no media - Set BBS entry to lowest priority. We cannot\r
-  set it to ignore since 16-bit CSM will\r
-  indicate no floppy and thus drive A: is\r
-  unusable. CSM-16 will not try floppy since\r
-  lowest priority and thus not incur boot\r
-  time penality.\r
-  Floppy present & media    - Set BBS entry to some priority.\r
-\r
-  @return  State of floppy media\r
-\r
-**/\r
-UINT8\r
-HasMediaInFloppy (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Identify drive data must be updated to actual parameters before boot.\r
-  This requires updating the checksum, if it exists.\r
-\r
-  @param  IdentifyDriveData       ATA Identify Data\r
-  @param  Checksum                checksum of the ATA Identify Data\r
-\r
-  @retval EFI_SUCCESS             checksum calculated\r
-  @retval EFI_SECURITY_VIOLATION  IdentifyData invalid\r
-\r
-**/\r
-EFI_STATUS\r
-CalculateIdentifyDriveChecksum (\r
-  IN  UINT8     *IdentifyDriveData,\r
-  OUT UINT8     *Checksum\r
-  );\r
-\r
-/**\r
-  Identify drive data must be updated to actual parameters before boot.\r
-\r
-  @param  IdentifyDriveData       ATA Identify Data\r
-\r
-**/\r
-VOID\r
-UpdateIdentifyDriveData (\r
-  IN  UINT8     *IdentifyDriveData\r
-  );\r
-\r
-/**\r
-  Complete build of BBS TABLE.\r
-\r
-  @param  Private                 Legacy BIOS Instance data\r
-  @param  BbsTable                BBS Table passed to 16-bit code\r
-\r
-  @retval EFI_SUCCESS             Removable media not present\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildBbs (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private,\r
-  IN  BBS_TABLE                 *BbsTable\r
-  );\r
-\r
-/**\r
-  Read CMOS register through index/data port.\r
-\r
-  @param[in]  Index   The index of the CMOS register to read.\r
-\r
-  @return  The data value from the CMOS register specified by Index.\r
-\r
-**/\r
-UINT8\r
-LegacyReadStandardCmos (\r
-  IN UINT8  Index\r
-  );\r
-\r
-/**\r
-  Write CMOS register through index/data port.\r
-\r
-  @param[in]  Index  The index of the CMOS register to write.\r
-  @param[in]  Value  The value of CMOS register to write.\r
-\r
-  @return  The value written to the CMOS register specified by Index.\r
-\r
-**/\r
-UINT8\r
-LegacyWriteStandardCmos (\r
-  IN UINT8  Index,\r
-  IN UINT8  Value\r
-  );\r
-\r
-/**\r
-  Calculate the new standard CMOS checksum and write it.\r
-\r
-  @param  Private      Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS  Calculate 16-bit checksum successfully\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyCalculateWriteStandardCmosChecksum (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Test to see if a legacy PCI ROM exists for this device. Optionally return\r
-  the Legacy ROM instance for this PCI device.\r
-\r
-  @param[in]  This                   Protocol instance pointer.\r
-  @param[in]  PciHandle              The PCI PC-AT OPROM from this devices ROM BAR will be loaded\r
-  @param[out] RomImage               Return the legacy PCI ROM for this device\r
-  @param[out] RomSize                Size of ROM Image\r
-  @param[out] RuntimeImageLength     Runtime size of ROM Image\r
-  @param[out] Flags                  Indicates if ROM found and if PC-AT.\r
-  @param[out] OpromRevision          Revision of the PCI Rom\r
-  @param[out] ConfigUtilityCodeHeaderPointer of Configuration Utility Code Header\r
-\r
-  @return EFI_SUCCESS            Legacy Option ROM available for this device\r
-  @return EFI_ALREADY_STARTED    This device is already managed by its Oprom\r
-  @return EFI_UNSUPPORTED        Legacy Option ROM not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosCheckPciRomEx (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL           *This,\r
-  IN  EFI_HANDLE                        PciHandle,\r
-  OUT VOID                              **RomImage, OPTIONAL\r
-  OUT UINTN                             *RomSize, OPTIONAL\r
-  OUT UINTN                             *RuntimeImageLength, OPTIONAL\r
-  OUT UINTN                             *Flags, OPTIONAL\r
-  OUT UINT8                             *OpromRevision, OPTIONAL\r
-  OUT VOID                              **ConfigUtilityCodeHeader OPTIONAL\r
-  );\r
-\r
-/**\r
-  Relocate this image under 4G memory for IPF.\r
-\r
-  @param  ImageHandle  Handle of driver image.\r
-  @param  SystemTable  Pointer to system table.\r
-\r
-  @retval EFI_SUCCESS  Image successfully relocated.\r
-  @retval EFI_ABORTED  Failed to relocate image.\r
-\r
-**/\r
-EFI_STATUS\r
-RelocateImageUnder4GIfNeeded (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  );\r
-\r
-/**\r
-  Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the\r
-  16-bit register context on entry and exit. Arguments can be passed on\r
-  the Stack argument\r
-\r
-  @param  This       Protocol instance pointer.\r
-  @param  Segment    Segemnt of 16-bit mode call\r
-  @param  Offset     Offset of 16-bit mdoe call\r
-  @param  Regs       Register contexted passed into (and returned) from thunk to\r
-                     16-bit mode\r
-  @param  Stack      Caller allocated stack used to pass arguments\r
-  @param  StackSize  Size of Stack in bytes\r
-\r
-  @retval FALSE      Thunk completed, and there were no BIOS errors in the target code.\r
-                     See Regs for status.\r
-  @retval TRUE       There was a BIOS erro in the target code.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-InternalLegacyBiosFarCall (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL        *This,\r
-  IN  UINT16                          Segment,\r
-  IN  UINT16                          Offset,\r
-  IN  EFI_IA32_REGISTER_SET           *Regs,\r
-  IN  VOID                            *Stack,\r
-  IN  UINTN                           StackSize\r
-  );\r
-\r
-/**\r
-  Load a legacy PC-AT OpROM for VGA controller.\r
-\r
-  @param  Private                Driver private data.\r
-\r
-  @retval EFI_SUCCESS            Legacy ROM successfully installed for this device.\r
-  @retval EFI_DEVICE_ERROR       No VGA device handle found, or native EFI video\r
-                                 driver cannot be successfully disconnected, or VGA\r
-                                 thunk driver cannot be successfully connected.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosInstallVgaRom (\r
-  IN  LEGACY_BIOS_INSTANCE            *Private\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBootSupport.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBootSupport.c
deleted file mode 100644 (file)
index 211750c..0000000
+++ /dev/null
@@ -1,2173 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-#include <IndustryStandard/Pci.h>\r
-\r
-#define BOOT_LEGACY_OS              0\r
-#define BOOT_EFI_OS                 1\r
-#define BOOT_UNCONVENTIONAL_DEVICE  2\r
-\r
-UINT32              mLoadOptionsSize    = 0;\r
-UINTN               mBootMode           = BOOT_LEGACY_OS;\r
-VOID                *mLoadOptions       = NULL;\r
-BBS_BBS_DEVICE_PATH *mBbsDevicePathPtr  = NULL;\r
-BBS_BBS_DEVICE_PATH mBbsDevicePathNode;\r
-UDC_ATTRIBUTES      mAttributes         = { 0, 0, 0, 0 };\r
-UINTN               mBbsEntry           = 0;\r
-VOID                *mBeerData          = NULL;\r
-VOID                *mServiceAreaData   = NULL;\r
-UINT64              mLowWater           = 0xffffffffffffffffULL;\r
-\r
-extern BBS_TABLE           *mBbsTable;\r
-\r
-extern VOID                  *mRuntimeSmbiosEntryPoint;\r
-extern EFI_PHYSICAL_ADDRESS  mReserveSmbiosEntryPoint;\r
-extern EFI_PHYSICAL_ADDRESS  mStructureTableAddress;\r
-\r
-/**\r
-  Print the BBS Table.\r
-\r
-  @param BbsTable   The BBS table.\r
-\r
-\r
-**/\r
-VOID\r
-PrintBbsTable (\r
-  IN BBS_TABLE *BbsTable\r
-  )\r
-{\r
-  UINT16 Index;\r
-  UINT16 SubIndex;\r
-  CHAR8  *String;\r
-\r
-  DEBUG ((EFI_D_INFO, "\n"));\r
-  DEBUG ((EFI_D_INFO, " NO  Prio bb/dd/ff cl/sc Type Stat segm:offs mfgs:mfgo dess:deso\n"));\r
-  DEBUG ((EFI_D_INFO, "=================================================================\n"));\r
-  for (Index = 0; Index < MAX_BBS_ENTRIES; Index++) {\r
-    //\r
-    // Filter\r
-    //\r
-    if (BbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) {\r
-      continue;\r
-    }\r
-\r
-    DEBUG ((\r
-      EFI_D_INFO,\r
-      " %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x",\r
-      (UINTN) Index,\r
-      (UINTN) BbsTable[Index].BootPriority,\r
-      (UINTN) BbsTable[Index].Bus,\r
-      (UINTN) BbsTable[Index].Device,\r
-      (UINTN) BbsTable[Index].Function,\r
-      (UINTN) BbsTable[Index].Class,\r
-      (UINTN) BbsTable[Index].SubClass,\r
-      (UINTN) BbsTable[Index].DeviceType,\r
-      (UINTN) * (UINT16 *) &BbsTable[Index].StatusFlags\r
-      ));\r
-    DEBUG ((\r
-      EFI_D_INFO,\r
-      " %04x:%04x %04x:%04x %04x:%04x",\r
-      (UINTN) BbsTable[Index].BootHandlerSegment,\r
-      (UINTN) BbsTable[Index].BootHandlerOffset,\r
-      (UINTN) BbsTable[Index].MfgStringSegment,\r
-      (UINTN) BbsTable[Index].MfgStringOffset,\r
-      (UINTN) BbsTable[Index].DescStringSegment,\r
-      (UINTN) BbsTable[Index].DescStringOffset\r
-      ));\r
-\r
-    //\r
-    // Print DescString\r
-    //\r
-    String = (CHAR8 *)(((UINTN)BbsTable[Index].DescStringSegment << 4) + BbsTable[Index].DescStringOffset);\r
-    if (String != NULL) {\r
-      DEBUG ((EFI_D_INFO," ("));\r
-      for (SubIndex = 0; String[SubIndex] != 0; SubIndex++) {\r
-        DEBUG ((EFI_D_INFO, "%c", String[SubIndex]));\r
-      }\r
-      DEBUG ((EFI_D_INFO,")"));\r
-    }\r
-    DEBUG ((EFI_D_INFO,"\n"));\r
-  }\r
-\r
-  DEBUG ((EFI_D_INFO, "\n"));\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Print the BBS Table.\r
-\r
-  @param HddInfo   The HddInfo table.\r
-\r
-\r
-**/\r
-VOID\r
-PrintHddInfo (\r
-  IN HDD_INFO *HddInfo\r
-  )\r
-{\r
-  UINTN Index;\r
-\r
-  DEBUG ((EFI_D_INFO, "\n"));\r
-  for (Index = 0; Index < MAX_IDE_CONTROLLER; Index++) {\r
-    DEBUG ((EFI_D_INFO, "Index - %04x\n", Index));\r
-    DEBUG ((EFI_D_INFO, "  Status    - %04x\n", (UINTN)HddInfo[Index].Status));\r
-    DEBUG ((EFI_D_INFO, "  B/D/F     - %02x/%02x/%02x\n", (UINTN)HddInfo[Index].Bus, (UINTN)HddInfo[Index].Device, (UINTN)HddInfo[Index].Function));\r
-    DEBUG ((EFI_D_INFO, "  Command   - %04x\n", HddInfo[Index].CommandBaseAddress));\r
-    DEBUG ((EFI_D_INFO, "  Control   - %04x\n", HddInfo[Index].ControlBaseAddress));\r
-    DEBUG ((EFI_D_INFO, "  BusMaster - %04x\n", HddInfo[Index].BusMasterAddress));\r
-    DEBUG ((EFI_D_INFO, "  HddIrq    - %02x\n", HddInfo[Index].HddIrq));\r
-    DEBUG ((EFI_D_INFO, "  IdentifyDrive[0].Raw[0] - %x\n", HddInfo[Index].IdentifyDrive[0].Raw[0]));\r
-    DEBUG ((EFI_D_INFO, "  IdentifyDrive[1].Raw[0] - %x\n", HddInfo[Index].IdentifyDrive[1].Raw[0]));\r
-  }\r
-\r
-  DEBUG ((EFI_D_INFO, "\n"));\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Print the PCI Interrupt Line and Interrupt Pin registers.\r
-**/\r
-VOID\r
-PrintPciInterruptRegister (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  UINTN                       Index;\r
-  EFI_HANDLE                  *Handles;\r
-  UINTN                       HandleNum;\r
-  EFI_PCI_IO_PROTOCOL         *PciIo;\r
-  UINT8                       Interrupt[2];\r
-  UINTN                       Segment;\r
-  UINTN                       Bus;\r
-  UINTN                       Device;\r
-  UINTN                       Function;\r
-\r
-  gBS->LocateHandleBuffer (\r
-         ByProtocol,\r
-         &gEfiPciIoProtocolGuid,\r
-         NULL,\r
-         &HandleNum,\r
-         &Handles\r
-         );\r
-\r
-  Bus      = 0;\r
-  Device   = 0;\r
-  Function = 0;\r
-\r
-  DEBUG ((EFI_D_INFO, "\n"));\r
-  DEBUG ((EFI_D_INFO, " bb/dd/ff interrupt line interrupt pin\n"));\r
-  DEBUG ((EFI_D_INFO, "======================================\n"));\r
-  for (Index = 0; Index < HandleNum; Index++) {\r
-    Status = gBS->HandleProtocol (Handles[Index], &gEfiPciIoProtocolGuid, (VOID **) &PciIo);\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = PciIo->Pci.Read (\r
-                            PciIo,\r
-                            EfiPciIoWidthUint8,\r
-                            PCI_INT_LINE_OFFSET,\r
-                            2,\r
-                            Interrupt\r
-                            );\r
-    }\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = PciIo->GetLocation (\r
-                        PciIo,\r
-                        &Segment,\r
-                        &Bus,\r
-                        &Device,\r
-                        &Function\r
-                        );\r
-    }\r
-    if (!EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_INFO, " %02x/%02x/%02x 0x%02x           0x%02x\n",\r
-              Bus, Device, Function, Interrupt[0], Interrupt[1]));\r
-    }\r
-  }\r
-  DEBUG ((EFI_D_INFO, "\n"));\r
-\r
-  if (Handles != NULL) {\r
-    FreePool (Handles);\r
-  }\r
-}\r
-\r
-/**\r
-  Identify drive data must be updated to actual parameters before boot.\r
-\r
-  @param  IdentifyDriveData       ATA Identify Data\r
-\r
-**/\r
-VOID\r
-UpdateIdentifyDriveData (\r
-  IN  UINT8     *IdentifyDriveData\r
-  );\r
-\r
-/**\r
-  Update SIO data.\r
-\r
-  @param  Private                 Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS             Removable media not present\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateSioData (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  UINTN                               Index;\r
-  UINTN                               Index1;\r
-  UINT8                               LegacyInterrupts[16];\r
-  EFI_LEGACY_IRQ_ROUTING_ENTRY        *RoutingTable;\r
-  UINTN                               RoutingTableEntries;\r
-  EFI_LEGACY_IRQ_PRIORITY_TABLE_ENTRY *IrqPriorityTable;\r
-  UINTN                               NumberPriorityEntries;\r
-  EFI_TO_COMPATIBILITY16_BOOT_TABLE   *EfiToLegacy16BootTable;\r
-  UINT8                               HddIrq;\r
-  UINT16                              LegacyInt;\r
-  UINT16                              LegMask;\r
-  UINT32                              Register;\r
-  UINTN                               HandleCount;\r
-  EFI_HANDLE                          *HandleBuffer;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-\r
-  LegacyInt               = 0;\r
-  HandleBuffer            = NULL;\r
-\r
-  EfiToLegacy16BootTable  = &Private->IntThunk->EfiToLegacy16BootTable;\r
-  LegacyBiosBuildSioData (Private);\r
-  SetMem (LegacyInterrupts, sizeof (LegacyInterrupts), 0);\r
-\r
-  //\r
-  // Create list of legacy interrupts.\r
-  //\r
-  for (Index = 0; Index < 4; Index++) {\r
-    LegacyInterrupts[Index] = EfiToLegacy16BootTable->SioData.Serial[Index].Irq;\r
-  }\r
-\r
-  for (Index = 4; Index < 7; Index++) {\r
-    LegacyInterrupts[Index] = EfiToLegacy16BootTable->SioData.Parallel[Index - 4].Irq;\r
-  }\r
-\r
-  LegacyInterrupts[7] = EfiToLegacy16BootTable->SioData.Floppy.Irq;\r
-\r
-  //\r
-  // Get Legacy Hdd IRQs. If native mode treat as PCI\r
-  //\r
-  for (Index = 0; Index < 2; Index++) {\r
-    HddIrq = EfiToLegacy16BootTable->HddInfo[Index].HddIrq;\r
-    if ((HddIrq != 0) && ((HddIrq == 15) || (HddIrq == 14))) {\r
-      LegacyInterrupts[Index + 8] = HddIrq;\r
-    }\r
-  }\r
-\r
-  Private->LegacyBiosPlatform->GetRoutingTable (\r
-                                Private->LegacyBiosPlatform,\r
-                                (VOID *) &RoutingTable,\r
-                                &RoutingTableEntries,\r
-                                NULL,\r
-                                NULL,\r
-                                (VOID **) &IrqPriorityTable,\r
-                                &NumberPriorityEntries\r
-                                );\r
-  //\r
-  // Remove legacy interrupts from the list of PCI interrupts available.\r
-  //\r
-  for (Index = 0; Index <= 0x0b; Index++) {\r
-    for (Index1 = 0; Index1 <= NumberPriorityEntries; Index1++) {\r
-      if (LegacyInterrupts[Index] != 0) {\r
-        LegacyInt = (UINT16) (LegacyInt | (1 << LegacyInterrupts[Index]));\r
-        if (LegacyInterrupts[Index] == IrqPriorityTable[Index1].Irq) {\r
-          IrqPriorityTable[Index1].Used = LEGACY_USED;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  Private->Legacy8259->GetMask (\r
-                        Private->Legacy8259,\r
-                        &LegMask,\r
-                        NULL,\r
-                        NULL,\r
-                        NULL\r
-                        );\r
-\r
-  //\r
-  // Set SIO interrupts and disable mouse. Let mouse driver\r
-  // re-enable it.\r
-  //\r
-  LegMask = (UINT16) ((LegMask &~LegacyInt) | 0x1000);\r
-  Private->Legacy8259->SetMask (\r
-                        Private->Legacy8259,\r
-                        &LegMask,\r
-                        NULL,\r
-                        NULL,\r
-                        NULL\r
-                        );\r
-\r
-  //\r
-  // Disable mouse in keyboard controller\r
-  //\r
-  Register = 0xA7;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiIsaIoProtocolGuid,\r
-                    (VOID **) &IsaIo\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-    IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, 0x64, 1, &Register);\r
-\r
-  }\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool (HandleBuffer);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-/**\r
-  Identify drive data must be updated to actual parameters before boot.\r
-  This requires updating the checksum, if it exists.\r
-\r
-  @param  IdentifyDriveData       ATA Identify Data\r
-  @param  Checksum                checksum of the ATA Identify Data\r
-\r
-  @retval EFI_SUCCESS             checksum calculated\r
-  @retval EFI_SECURITY_VIOLATION  IdentifyData invalid\r
-\r
-**/\r
-EFI_STATUS\r
-CalculateIdentifyDriveChecksum (\r
-  IN  UINT8     *IdentifyDriveData,\r
-  OUT UINT8     *Checksum\r
-  )\r
-{\r
-  UINTN Index;\r
-  UINT8 LocalChecksum;\r
-  LocalChecksum = 0;\r
-  *Checksum     = 0;\r
-  if (IdentifyDriveData[510] != 0xA5) {\r
-    return EFI_SECURITY_VIOLATION;\r
-  }\r
-\r
-  for (Index = 0; Index < 512; Index++) {\r
-    LocalChecksum = (UINT8) (LocalChecksum + IdentifyDriveData[Index]);\r
-  }\r
-\r
-  *Checksum = LocalChecksum;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Identify drive data must be updated to actual parameters before boot.\r
-\r
-  @param  IdentifyDriveData       ATA Identify Data\r
-\r
-\r
-**/\r
-VOID\r
-UpdateIdentifyDriveData (\r
-  IN  UINT8     *IdentifyDriveData\r
-  )\r
-{\r
-  UINT16          NumberCylinders;\r
-  UINT16          NumberHeads;\r
-  UINT16          NumberSectorsTrack;\r
-  UINT32          CapacityInSectors;\r
-  UINT8           OriginalChecksum;\r
-  UINT8           FinalChecksum;\r
-  EFI_STATUS      Status;\r
-  ATAPI_IDENTIFY  *ReadInfo;\r
-\r
-  //\r
-  // Status indicates if Integrity byte is correct. Checksum should be\r
-  // 0 if valid.\r
-  //\r
-  ReadInfo  = (ATAPI_IDENTIFY *) IdentifyDriveData;\r
-  Status    = CalculateIdentifyDriveChecksum (IdentifyDriveData, &OriginalChecksum);\r
-  if (OriginalChecksum != 0) {\r
-    Status = EFI_SECURITY_VIOLATION;\r
-  }\r
-  //\r
-  // If NumberCylinders = 0 then do data(Controller present but don drive attached).\r
-  //\r
-  NumberCylinders = ReadInfo->Raw[1];\r
-  if (NumberCylinders != 0) {\r
-    ReadInfo->Raw[54]   = NumberCylinders;\r
-\r
-    NumberHeads         = ReadInfo->Raw[3];\r
-    ReadInfo->Raw[55]   = NumberHeads;\r
-\r
-    NumberSectorsTrack  = ReadInfo->Raw[6];\r
-    ReadInfo->Raw[56]   = NumberSectorsTrack;\r
-\r
-    //\r
-    // Copy Multisector info and set valid bit.\r
-    //\r
-    ReadInfo->Raw[59] = (UINT16) (ReadInfo->Raw[47] + 0x100);\r
-    CapacityInSectors = (UINT32) ((UINT32) (NumberCylinders) * (UINT32) (NumberHeads) * (UINT32) (NumberSectorsTrack));\r
-    ReadInfo->Raw[57] = (UINT16) (CapacityInSectors >> 16);\r
-    ReadInfo->Raw[58] = (UINT16) (CapacityInSectors & 0xffff);\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Forece checksum byte to 0 and get new checksum.\r
-      //\r
-      ReadInfo->Raw[255] &= 0xff;\r
-      CalculateIdentifyDriveChecksum (IdentifyDriveData, &FinalChecksum);\r
-\r
-      //\r
-      // Force new checksum such that sum is 0.\r
-      //\r
-      FinalChecksum = (UINT8) ((UINT8)0 - FinalChecksum);\r
-      ReadInfo->Raw[255] = (UINT16) (ReadInfo->Raw[255] | (FinalChecksum << 8));\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Identify drive data must be updated to actual parameters before boot.\r
-  Do for all drives.\r
-\r
-  @param  Private                 Legacy BIOS Instance data\r
-\r
-\r
-**/\r
-VOID\r
-UpdateAllIdentifyDriveData (\r
-  IN LEGACY_BIOS_INSTANCE                 *Private\r
-  )\r
-{\r
-  UINTN     Index;\r
-  HDD_INFO  *HddInfo;\r
-\r
-  HddInfo = &Private->IntThunk->EfiToLegacy16BootTable.HddInfo[0];\r
-\r
-  for (Index = 0; Index < MAX_IDE_CONTROLLER; Index++) {\r
-    //\r
-    // Each controller can have 2 devices. Update for each device\r
-    //\r
-    if ((HddInfo[Index].Status & HDD_MASTER_IDE) != 0) {\r
-      UpdateIdentifyDriveData ((UINT8 *) (&HddInfo[Index].IdentifyDrive[0].Raw[0]));\r
-    }\r
-\r
-    if ((HddInfo[Index].Status & HDD_SLAVE_IDE) != 0) {\r
-      UpdateIdentifyDriveData ((UINT8 *) (&HddInfo[Index].IdentifyDrive[1].Raw[0]));\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Enable ide controller.  This gets disabled when LegacyBoot.c is about\r
-  to run the Option ROMs.\r
-\r
-  @param  Private        Legacy BIOS Instance data\r
-\r
-\r
-**/\r
-VOID\r
-EnableIdeController (\r
-  IN LEGACY_BIOS_INSTANCE              *Private\r
-  )\r
-{\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-  EFI_STATUS          Status;\r
-  EFI_HANDLE          IdeController;\r
-  UINT8               ByteBuffer;\r
-  UINTN               HandleCount;\r
-  EFI_HANDLE          *HandleBuffer;\r
-\r
-  Status = Private->LegacyBiosPlatform->GetPlatformHandle (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiGetPlatformIdeHandle,\r
-                                          0,\r
-                                          &HandleBuffer,\r
-                                          &HandleCount,\r
-                                          NULL\r
-                                          );\r
-  if (!EFI_ERROR (Status)) {\r
-    IdeController = HandleBuffer[0];\r
-    Status = gBS->HandleProtocol (\r
-                    IdeController,\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo\r
-                    );\r
-    ByteBuffer = 0x1f;\r
-    if (!EFI_ERROR (Status)) {\r
-      PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x04, 1, &ByteBuffer);\r
-    }\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Enable ide controller.  This gets disabled when LegacyBoot.c is about\r
-  to run the Option ROMs.\r
-\r
-  @param  Private                 Legacy BIOS Instance data\r
-\r
-\r
-**/\r
-VOID\r
-EnableAllControllers (\r
-  IN LEGACY_BIOS_INSTANCE              *Private\r
-  )\r
-{\r
-  UINTN               HandleCount;\r
-  EFI_HANDLE          *HandleBuffer;\r
-  UINTN               Index;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-  PCI_TYPE01          PciConfigHeader;\r
-  EFI_STATUS          Status;\r
-\r
-  //\r
-  //\r
-  //\r
-  EnableIdeController (Private);\r
-\r
-  //\r
-  // Assumption is table is built from low bus to high bus numbers.\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    PciIo->Pci.Read (\r
-                PciIo,\r
-                EfiPciIoWidthUint32,\r
-                0,\r
-                sizeof (PciConfigHeader) / sizeof (UINT32),\r
-                &PciConfigHeader\r
-                );\r
-\r
-    //\r
-    // We do not enable PPB here. This is for HotPlug Consideration.\r
-    // The Platform HotPlug Driver is responsible for Padding enough hot plug\r
-    // resources. It is also responsible for enable this bridge. If it\r
-    // does not pad it. It will cause some early Windows fail to installation.\r
-    // If the platform driver does not pad resource for PPB, PPB should be in\r
-    // un-enabled state to let Windows know that this PPB is not configured by\r
-    // BIOS. So Windows will allocate default resource for PPB.\r
-    //\r
-    // The reason for why we enable the command register is:\r
-    // The CSM will use the IO bar to detect some IRQ status, if the command\r
-    // is disabled, the IO resource will be out of scope.\r
-    // For example:\r
-    // We installed a legacy IRQ handle for a PCI IDE controller. When IRQ\r
-    // comes up, the handle will check the IO space to identify is the\r
-    // controller generated the IRQ source.\r
-    // If the IO command is not enabled, the IRQ handler will has wrong\r
-    // information. It will cause IRQ storm when the correctly IRQ handler fails\r
-    // to run.\r
-    //\r
-    if (!(IS_PCI_VGA (&PciConfigHeader)     ||\r
-          IS_PCI_OLD_VGA (&PciConfigHeader) ||\r
-          IS_PCI_IDE (&PciConfigHeader)     ||\r
-          IS_PCI_P2P (&PciConfigHeader)     ||\r
-          IS_PCI_P2P_SUB (&PciConfigHeader) ||\r
-          IS_PCI_LPC (&PciConfigHeader)     )) {\r
-\r
-      PciConfigHeader.Hdr.Command |= 0x1f;\r
-\r
-      PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 4, 1, &PciConfigHeader.Hdr.Command);\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  The following routines are identical in operation, so combine\r
-  for code compaction:\r
-  EfiGetPlatformBinaryGetMpTable\r
-  EfiGetPlatformBinaryGetOemIntData\r
-  EfiGetPlatformBinaryGetOem32Data\r
-  EfiGetPlatformBinaryGetOem16Data\r
-\r
-  @param  This                    Protocol instance pointer.\r
-  @param  Id                      Table/Data identifier\r
-\r
-  @retval EFI_SUCCESS             Success\r
-  @retval EFI_INVALID_PARAMETER   Invalid ID\r
-  @retval EFI_OUT_OF_RESOURCES    no resource to get data or table\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyGetDataOrTable (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL         *This,\r
-  IN EFI_GET_PLATFORM_INFO_MODE       Id\r
-  )\r
-{\r
-  VOID                              *Table;\r
-  UINT32                            TablePtr;\r
-  UINTN                             TableSize;\r
-  UINTN                             Alignment;\r
-  UINTN                             Location;\r
-  EFI_STATUS                        Status;\r
-  EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;\r
-  EFI_COMPATIBILITY16_TABLE         *Legacy16Table;\r
-  EFI_IA32_REGISTER_SET             Regs;\r
-  LEGACY_BIOS_INSTANCE              *Private;\r
-\r
-  Private             = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-\r
-  LegacyBiosPlatform  = Private->LegacyBiosPlatform;\r
-  Legacy16Table       = Private->Legacy16Table;\r
-\r
-  //\r
-  // Phase 1 - get an address allocated in 16-bit code\r
-  //\r
-  while (TRUE) {\r
-    switch (Id) {\r
-    case EfiGetPlatformBinaryMpTable:\r
-    case EfiGetPlatformBinaryOemIntData:\r
-    case EfiGetPlatformBinaryOem32Data:\r
-    case EfiGetPlatformBinaryOem16Data:\r
-      {\r
-        Status = LegacyBiosPlatform->GetPlatformInfo (\r
-                                      LegacyBiosPlatform,\r
-                                      Id,\r
-                                      (VOID *) &Table,\r
-                                      &TableSize,\r
-                                      &Location,\r
-                                      &Alignment,\r
-                                      0,\r
-                                      0\r
-                                      );\r
-        DEBUG ((EFI_D_INFO, "LegacyGetDataOrTable - ID: %x, %r\n", (UINTN)Id, Status));\r
-        DEBUG ((EFI_D_INFO, "  Table - %x, Size - %x, Location - %x, Alignment - %x\n", (UINTN)Table, (UINTN)TableSize, (UINTN)Location, (UINTN)Alignment));\r
-        break;\r
-      }\r
-\r
-    default:\r
-      {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-    Regs.X.AX = Legacy16GetTableAddress;\r
-    Regs.X.CX = (UINT16) TableSize;\r
-    Regs.X.BX = (UINT16) Location;\r
-    Regs.X.DX = (UINT16) Alignment;\r
-    Private->LegacyBios.FarCall86 (\r
-      This,\r
-      Private->Legacy16CallSegment,\r
-      Private->Legacy16CallOffset,\r
-      &Regs,\r
-      NULL,\r
-      0\r
-      );\r
-\r
-    if (Regs.X.AX != 0) {\r
-      DEBUG ((EFI_D_ERROR, "Table ID %x length insufficient\n", Id));\r
-      return EFI_OUT_OF_RESOURCES;\r
-    } else {\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Phase 2 Call routine second time with address to allow address adjustment\r
-  //\r
-  Status = LegacyBiosPlatform->GetPlatformInfo (\r
-                                LegacyBiosPlatform,\r
-                                Id,\r
-                                (VOID *) &Table,\r
-                                &TableSize,\r
-                                &Location,\r
-                                &Alignment,\r
-                                Regs.X.DS,\r
-                                Regs.X.BX\r
-                                );\r
-  switch (Id) {\r
-  case EfiGetPlatformBinaryMpTable:\r
-    {\r
-      Legacy16Table->MpTablePtr     = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);\r
-      Legacy16Table->MpTableLength  = (UINT32)TableSize;\r
-      DEBUG ((EFI_D_INFO, "MP table in legacy region - %x\n", (UINTN)Legacy16Table->MpTablePtr));\r
-      break;\r
-    }\r
-\r
-  case EfiGetPlatformBinaryOemIntData:\r
-    {\r
-\r
-      Legacy16Table->OemIntSegment  = Regs.X.DS;\r
-      Legacy16Table->OemIntOffset   = Regs.X.BX;\r
-      DEBUG ((EFI_D_INFO, "OemInt table in legacy region - %04x:%04x\n", (UINTN)Legacy16Table->OemIntSegment, (UINTN)Legacy16Table->OemIntOffset));\r
-      break;\r
-    }\r
-\r
-  case EfiGetPlatformBinaryOem32Data:\r
-    {\r
-      Legacy16Table->Oem32Segment = Regs.X.DS;\r
-      Legacy16Table->Oem32Offset  = Regs.X.BX;\r
-      DEBUG ((EFI_D_INFO, "Oem32 table in legacy region - %04x:%04x\n", (UINTN)Legacy16Table->Oem32Segment, (UINTN)Legacy16Table->Oem32Offset));\r
-      break;\r
-    }\r
-\r
-  case EfiGetPlatformBinaryOem16Data:\r
-    {\r
-      //\r
-      //          Legacy16Table->Oem16Segment = Regs.X.DS;\r
-      //          Legacy16Table->Oem16Offset  = Regs.X.BX;\r
-      DEBUG ((EFI_D_INFO, "Oem16 table in legacy region - %04x:%04x\n", (UINTN)Legacy16Table->Oem16Segment, (UINTN)Legacy16Table->Oem16Offset));\r
-      break;\r
-    }\r
-\r
-  default:\r
-    {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Phase 3 Copy table to final location\r
-  //\r
-  TablePtr = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);\r
-\r
-  CopyMem (\r
-    (VOID *) (UINTN)TablePtr,\r
-    Table,\r
-    TableSize\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Copy SMBIOS table to EfiReservedMemoryType of memory for legacy boot.\r
-\r
-**/\r
-VOID\r
-CreateSmbiosTableInReservedMemory (\r
-  VOID\r
-  )\r
-{\r
-  SMBIOS_TABLE_ENTRY_POINT    *EntryPointStructure;\r
-\r
-  if ((mRuntimeSmbiosEntryPoint == NULL) ||\r
-      (mReserveSmbiosEntryPoint == 0) ||\r
-      (mStructureTableAddress == 0)) {\r
-    return;\r
-  }\r
-\r
-  EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) mRuntimeSmbiosEntryPoint;\r
-\r
-  //\r
-  // Copy SMBIOS Entry Point Structure\r
-  //\r
-  CopyMem (\r
-    (VOID *)(UINTN) mReserveSmbiosEntryPoint,\r
-    EntryPointStructure,\r
-    EntryPointStructure->EntryPointLength\r
-  );\r
-\r
-  //\r
-  // Copy SMBIOS Structure Table into EfiReservedMemoryType memory\r
-  //\r
-  CopyMem (\r
-    (VOID *)(UINTN) mStructureTableAddress,\r
-    (VOID *)(UINTN) EntryPointStructure->TableAddress,\r
-    EntryPointStructure->TableLength\r
-  );\r
-\r
-  //\r
-  // Update TableAddress in Entry Point Structure\r
-  //\r
-  EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)(UINTN) mReserveSmbiosEntryPoint;\r
-  EntryPointStructure->TableAddress = (UINT32)(UINTN) mStructureTableAddress;\r
-\r
-  //\r
-  // Fixup checksums in the Entry Point Structure\r
-  //\r
-  EntryPointStructure->IntermediateChecksum = 0;\r
-  EntryPointStructure->EntryPointStructureChecksum = 0;\r
-\r
-  EntryPointStructure->IntermediateChecksum =\r
-    CalculateCheckSum8 (\r
-      (UINT8 *) EntryPointStructure + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),\r
-      EntryPointStructure->EntryPointLength - OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString)\r
-      );\r
-  EntryPointStructure->EntryPointStructureChecksum =\r
-    CalculateCheckSum8 ((UINT8 *) EntryPointStructure, EntryPointStructure->EntryPointLength);\r
-}\r
-\r
-/**\r
-  Assign drive number to legacy HDD drives prior to booting an EFI\r
-  aware OS so the OS can access drives without an EFI driver.\r
-  Note: BBS compliant drives ARE NOT available until this call by\r
-  either shell or EFI.\r
-\r
-  @param  This                    Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS             Drive numbers assigned\r
-\r
-**/\r
-EFI_STATUS\r
-GenericLegacyBoot (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL           *This\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  LEGACY_BIOS_INSTANCE              *Private;\r
-  EFI_IA32_REGISTER_SET             Regs;\r
-  EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;\r
-  EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;\r
-  UINTN                             CopySize;\r
-  VOID                              *AcpiPtr;\r
-  HDD_INFO                          *HddInfo;\r
-  HDD_INFO                          *LocalHddInfo;\r
-  UINTN                             Index;\r
-  EFI_COMPATIBILITY16_TABLE         *Legacy16Table;\r
-  UINT32                            *BdaPtr;\r
-  UINT16                            HddCount;\r
-  UINT16                            BbsCount;\r
-  BBS_TABLE                         *LocalBbsTable;\r
-  UINT32                            *BaseVectorMaster;\r
-  EFI_TIME                          BootTime;\r
-  UINT32                            LocalTime;\r
-  EFI_HANDLE                        IdeController;\r
-  UINTN                             HandleCount;\r
-  EFI_HANDLE                        *HandleBuffer;\r
-  VOID                              *AcpiTable;\r
-  UINTN                             ShadowAddress;\r
-  UINT32                            Granularity;\r
-\r
-  LocalHddInfo  = NULL;\r
-  HddCount      = 0;\r
-  BbsCount      = 0;\r
-  LocalBbsTable = NULL;\r
-\r
-  Private       = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-  DEBUG_CODE (\r
-    DEBUG ((EFI_D_ERROR, "Start of legacy boot\n"));\r
-  );\r
-\r
-  Legacy16Table                         = Private->Legacy16Table;\r
-  EfiToLegacy16BootTable                = &Private->IntThunk->EfiToLegacy16BootTable;\r
-  HddInfo = &EfiToLegacy16BootTable->HddInfo[0];\r
-\r
-  LegacyBiosPlatform = Private->LegacyBiosPlatform;\r
-\r
-  EfiToLegacy16BootTable->MajorVersion = EFI_TO_LEGACY_MAJOR_VERSION;\r
-  EfiToLegacy16BootTable->MinorVersion = EFI_TO_LEGACY_MINOR_VERSION;\r
-\r
-  //\r
-  // If booting to a legacy OS then force HDD drives to the appropriate\r
-  // boot mode by calling GetIdeHandle.\r
-  // A reconnect -r can force all HDDs back to native mode.\r
-  //\r
-  IdeController = NULL;\r
-  if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {\r
-    Status = LegacyBiosPlatform->GetPlatformHandle (\r
-                                  Private->LegacyBiosPlatform,\r
-                                  EfiGetPlatformIdeHandle,\r
-                                  0,\r
-                                  &HandleBuffer,\r
-                                  &HandleCount,\r
-                                  NULL\r
-                                  );\r
-    if (!EFI_ERROR (Status)) {\r
-      IdeController = HandleBuffer[0];\r
-    }\r
-  }\r
-  //\r
-  // Unlock the Legacy BIOS region\r
-  //\r
-  Private->LegacyRegion->UnLock (\r
-                           Private->LegacyRegion,\r
-                           0xE0000,\r
-                           0x20000,\r
-                           &Granularity\r
-                           );\r
-\r
-  //\r
-  // Reconstruct the Legacy16 boot memory map\r
-  //\r
-  LegacyBiosBuildE820 (Private, &CopySize);\r
-  if (CopySize > Private->Legacy16Table->E820Length) {\r
-    ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-    Regs.X.AX = Legacy16GetTableAddress;\r
-    Regs.X.CX = (UINT16) CopySize;\r
-    Private->LegacyBios.FarCall86 (\r
-      &Private->LegacyBios,\r
-      Private->Legacy16Table->Compatibility16CallSegment,\r
-      Private->Legacy16Table->Compatibility16CallOffset,\r
-      &Regs,\r
-      NULL,\r
-      0\r
-      );\r
-\r
-    Private->Legacy16Table->E820Pointer = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);\r
-    Private->Legacy16Table->E820Length  = (UINT32) CopySize;\r
-    if (Regs.X.AX != 0) {\r
-      DEBUG ((EFI_D_ERROR, "Legacy16 E820 length insufficient\n"));\r
-    } else {\r
-      CopyMem (\r
-        (VOID *)(UINTN) Private->Legacy16Table->E820Pointer,\r
-        Private->E820Table,\r
-        CopySize\r
-        );\r
-    }\r
-  } else {\r
-    CopyMem (\r
-      (VOID *)(UINTN) Private->Legacy16Table->E820Pointer,\r
-      Private->E820Table,\r
-      CopySize\r
-      );\r
-    Private->Legacy16Table->E820Length = (UINT32) CopySize;\r
-  }\r
-\r
-  //\r
-  // We do not ASSERT if SmbiosTable not found. It is possbile that a platform does not produce SmbiosTable.\r
-  //\r
-  if (mReserveSmbiosEntryPoint == 0) {\r
-    DEBUG ((EFI_D_INFO, "Smbios table is not found!\n"));\r
-  }\r
-  CreateSmbiosTableInReservedMemory ();\r
-  EfiToLegacy16BootTable->SmbiosTable = (UINT32)(UINTN)mReserveSmbiosEntryPoint;\r
-\r
-  AcpiTable = NULL;\r
-  Status = EfiGetSystemConfigurationTable (\r
-             &gEfiAcpi20TableGuid,\r
-             &AcpiTable\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EfiGetSystemConfigurationTable (\r
-               &gEfiAcpi10TableGuid,\r
-               &AcpiTable\r
-               );\r
-  }\r
-  //\r
-  // We do not ASSERT if AcpiTable not found. It is possbile that a platform does not produce AcpiTable.\r
-  //\r
-  if (AcpiTable == NULL) {\r
-    DEBUG ((EFI_D_INFO, "ACPI table is not found!\n"));\r
-  }\r
-  EfiToLegacy16BootTable->AcpiTable = (UINT32)(UINTN)AcpiTable;\r
-\r
-  //\r
-  // Get RSD Ptr table rev at offset 15 decimal\r
-  // Rev = 0 Length is 20 decimal\r
-  // Rev != 0 Length is UINT32 at offset 20 decimal\r
-  //\r
-  if (AcpiTable != NULL) {\r
-\r
-    AcpiPtr = AcpiTable;\r
-    if (*((UINT8 *) AcpiPtr + 15) == 0) {\r
-      CopySize = 20;\r
-    } else {\r
-      AcpiPtr   = ((UINT8 *) AcpiPtr + 20);\r
-      CopySize  = (*(UINT32 *) AcpiPtr);\r
-    }\r
-\r
-    CopyMem (\r
-      (VOID *)(UINTN) Private->Legacy16Table->AcpiRsdPtrPointer,\r
-      AcpiTable,\r
-      CopySize\r
-      );\r
-  }\r
-  //\r
-  // Make sure all PCI Interrupt Line register are programmed to match 8259\r
-  //\r
-  PciProgramAllInterruptLineRegisters (Private);\r
-\r
-  //\r
-  // Unlock the Legacy BIOS region as PciProgramAllInterruptLineRegisters\r
-  // can lock it.\r
-  //\r
-  Private->LegacyRegion->UnLock (\r
-                           Private->LegacyRegion,\r
-                           Private->BiosStart,\r
-                           Private->LegacyBiosImageSize,\r
-                           &Granularity\r
-                           );\r
-\r
-  //\r
-  // Configure Legacy Device Magic\r
-  //\r
-  // Only do this code if booting legacy OS\r
-  //\r
-  if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {\r
-    UpdateSioData (Private);\r
-  }\r
-  //\r
-  // Setup BDA and EBDA standard areas before Legacy Boot\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    LegacyBiosCompleteBdaBeforeBoot (Private);\r
-  );\r
-  LegacyBiosCompleteStandardCmosBeforeBoot (Private);\r
-\r
-  //\r
-  // We must build IDE data, if it hasn't been done, before PciShadowRoms\r
-  // to insure EFI drivers are connected.\r
-  //\r
-  LegacyBiosBuildIdeData (Private, &HddInfo, 1);\r
-  UpdateAllIdentifyDriveData (Private);\r
-\r
-  //\r
-  // Clear IO BAR, if IDE controller in legacy mode.\r
-  //\r
-  InitLegacyIdeController (IdeController);\r
-\r
-  //\r
-  // Generate number of ticks since midnight for BDA. DOS requires this\r
-  // for its time. We have to make assumptions as to how long following\r
-  // code takes since after PciShadowRoms PciIo is gone. Place result in\r
-  // 40:6C-6F\r
-  //\r
-  // Adjust value by 1 second.\r
-  //\r
-  gRT->GetTime (&BootTime, NULL);\r
-  LocalTime = BootTime.Hour * 3600 + BootTime.Minute * 60 + BootTime.Second;\r
-  LocalTime += 1;\r
-\r
-  //\r
-  // Multiply result by 18.2 for number of ticks since midnight.\r
-  // Use 182/10 to avoid floating point math.\r
-  //\r
-  LocalTime = (LocalTime * 182) / 10;\r
-  ACCESS_PAGE0_CODE (\r
-    BdaPtr    = (UINT32 *) (UINTN)0x46C;\r
-    *BdaPtr   = LocalTime;\r
-  );\r
-\r
-  //\r
-  // Shadow PCI ROMs. We must do this near the end since this will kick\r
-  // of Native EFI drivers that may be needed to collect info for Legacy16\r
-  //\r
-  //  WARNING: PciIo is gone after this call.\r
-  //\r
-  PciShadowRoms (Private);\r
-\r
-  //\r
-  // Shadow PXE base code, BIS etc.\r
-  //\r
-  Private->LegacyRegion->UnLock (Private->LegacyRegion, 0xc0000, 0x40000, &Granularity);\r
-  ShadowAddress = Private->OptionRom;\r
-  Private->LegacyBiosPlatform->PlatformHooks (\r
-                                 Private->LegacyBiosPlatform,\r
-                                 EfiPlatformHookShadowServiceRoms,\r
-                                 0,\r
-                                 0,\r
-                                 &ShadowAddress,\r
-                                 Legacy16Table,\r
-                                 NULL\r
-                                 );\r
-  Private->OptionRom = (UINT32)ShadowAddress;\r
-  //\r
-  // Register Legacy SMI Handler\r
-  //\r
-  LegacyBiosPlatform->SmmInit (\r
-                        LegacyBiosPlatform,\r
-                        EfiToLegacy16BootTable\r
-                        );\r
-\r
-  //\r
-  // Let platform code know the boot options\r
-  //\r
-  LegacyBiosGetBbsInfo (\r
-    This,\r
-    &HddCount,\r
-    &LocalHddInfo,\r
-    &BbsCount,\r
-    &LocalBbsTable\r
-    );\r
-\r
-  DEBUG_CODE (\r
-    PrintPciInterruptRegister ();\r
-    PrintBbsTable (LocalBbsTable);\r
-    PrintHddInfo (LocalHddInfo);\r
-    );\r
-  //\r
-  // If drive wasn't spun up then BuildIdeData may have found new drives.\r
-  // Need to update BBS boot priority.\r
-  //\r
-  for (Index = 0; Index < MAX_IDE_CONTROLLER; Index++) {\r
-    if ((LocalHddInfo[Index].IdentifyDrive[0].Raw[0] != 0) &&\r
-        (LocalBbsTable[2 * Index + 1].BootPriority == BBS_IGNORE_ENTRY)\r
-        ) {\r
-      LocalBbsTable[2 * Index + 1].BootPriority = BBS_UNPRIORITIZED_ENTRY;\r
-    }\r
-\r
-    if ((LocalHddInfo[Index].IdentifyDrive[1].Raw[0] != 0) &&\r
-        (LocalBbsTable[2 * Index + 2].BootPriority == BBS_IGNORE_ENTRY)\r
-        ) {\r
-      LocalBbsTable[2 * Index + 2].BootPriority = BBS_UNPRIORITIZED_ENTRY;\r
-    }\r
-  }\r
-\r
-  Private->LegacyRegion->UnLock (\r
-                           Private->LegacyRegion,\r
-                           0xc0000,\r
-                           0x40000,\r
-                           &Granularity\r
-                           );\r
-\r
-  LegacyBiosPlatform->PrepareToBoot (\r
-                        LegacyBiosPlatform,\r
-                        mBbsDevicePathPtr,\r
-                        mBbsTable,\r
-                        mLoadOptionsSize,\r
-                        mLoadOptions,\r
-                        (VOID *) &Private->IntThunk->EfiToLegacy16BootTable\r
-                        );\r
-\r
-  //\r
-  // If no boot device return to BDS\r
-  //\r
-  if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {\r
-    for (Index = 0; Index < BbsCount; Index++){\r
-      if ((LocalBbsTable[Index].BootPriority != BBS_DO_NOT_BOOT_FROM) &&\r
-          (LocalBbsTable[Index].BootPriority != BBS_UNPRIORITIZED_ENTRY) &&\r
-          (LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY)) {\r
-        break;\r
-      }\r
-    }\r
-    if (Index == BbsCount) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // Let the Legacy16 code know the device path type for legacy boot\r
-  //\r
-  EfiToLegacy16BootTable->DevicePathType = mBbsDevicePathPtr->DeviceType;\r
-\r
-  //\r
-  // Copy MP table, if it exists.\r
-  //\r
-  LegacyGetDataOrTable (This, EfiGetPlatformBinaryMpTable);\r
-\r
-  if (!Private->LegacyBootEntered) {\r
-    //\r
-    // Copy OEM INT Data, if it exists. Note: This code treats any data\r
-    // as a bag of bits and knows nothing of the contents nor cares.\r
-    // Contents are IBV specific.\r
-    //\r
-    LegacyGetDataOrTable (This, EfiGetPlatformBinaryOemIntData);\r
-\r
-    //\r
-    // Copy OEM16 Data, if it exists.Note: This code treats any data\r
-    // as a bag of bits and knows nothing of the contents nor cares.\r
-    // Contents are IBV specific.\r
-    //\r
-    LegacyGetDataOrTable (This, EfiGetPlatformBinaryOem16Data);\r
-\r
-    //\r
-    // Copy OEM32 Data, if it exists.Note: This code treats any data\r
-    // as a bag of bits and knows nothing of the contents nor cares.\r
-    // Contents are IBV specific.\r
-    //\r
-    LegacyGetDataOrTable (This, EfiGetPlatformBinaryOem32Data);\r
-  }\r
-\r
-  //\r
-  // Call into Legacy16 code to prepare for INT 19h\r
-  //\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-  Regs.X.AX = Legacy16PrepareToBoot;\r
-\r
-  //\r
-  // Pass in handoff data\r
-  //\r
-  Regs.X.ES = NORMALIZE_EFI_SEGMENT ((UINTN)EfiToLegacy16BootTable);\r
-  Regs.X.BX = NORMALIZE_EFI_OFFSET ((UINTN)EfiToLegacy16BootTable);\r
-\r
-  Private->LegacyBios.FarCall86 (\r
-    This,\r
-    Private->Legacy16CallSegment,\r
-    Private->Legacy16CallOffset,\r
-    &Regs,\r
-    NULL,\r
-    0\r
-    );\r
-\r
-  if (Regs.X.AX != 0) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Lock the Legacy BIOS region\r
-  //\r
-  Private->LegacyRegion->Lock (\r
-                           Private->LegacyRegion,\r
-                           0xc0000,\r
-                           0x40000,\r
-                           &Granularity\r
-                           );\r
-\r
-  if ((Private->Legacy16Table->TableLength >= OFFSET_OF (EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) &&\r
-      ((Private->Legacy16Table->UmaAddress != 0) && (Private->Legacy16Table->UmaSize != 0))) {\r
-    //\r
-    // Here we could reduce UmaAddress down as far as Private->OptionRom, taking into\r
-    // account the granularity of the access control.\r
-    //\r
-    DEBUG((EFI_D_INFO, "Unlocking UMB RAM region 0x%x-0x%x\n", Private->Legacy16Table->UmaAddress,\r
-                        Private->Legacy16Table->UmaAddress + Private->Legacy16Table->UmaSize));\r
-\r
-    Private->LegacyRegion->UnLock (\r
-                             Private->LegacyRegion,\r
-                             Private->Legacy16Table->UmaAddress,\r
-                             Private->Legacy16Table->UmaSize,\r
-                             &Granularity\r
-                             );\r
-  }\r
-\r
-  //\r
-  // Lock attributes of the Legacy Region if chipset supports\r
-  //\r
-  Private->LegacyRegion->BootLock (\r
-                           Private->LegacyRegion,\r
-                           0xc0000,\r
-                           0x40000,\r
-                           &Granularity\r
-                           );\r
-\r
-  //\r
-  // Call into Legacy16 code to do the INT 19h\r
-  //\r
-  EnableAllControllers (Private);\r
-  if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {\r
-\r
-    //\r
-    // Signal all the events that are waiting on EVT_SIGNAL_LEGACY_BOOT\r
-    //\r
-    EfiSignalEventLegacyBoot ();\r
-\r
-    //\r
-    // Report Status Code to indicate legacy boot event was signalled\r
-    //\r
-    REPORT_STATUS_CODE (\r
-      EFI_PROGRESS_CODE,\r
-      (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT)\r
-      );\r
-\r
-    DEBUG ((EFI_D_INFO, "Legacy INT19 Boot...\n"));\r
-\r
-    //\r
-    // Disable DXE Timer while executing in real mode\r
-    //\r
-    Private->Timer->SetTimerPeriod (Private->Timer, 0);\r
-\r
-    //\r
-    // Save and disable interrupt of debug timer\r
-    //\r
-    SaveAndSetDebugTimerInterrupt (FALSE);\r
-\r
-\r
-    //\r
-    // Put the 8259 into its legacy mode by reprogramming the vector bases\r
-    //\r
-    Private->Legacy8259->SetVectorBase (Private->Legacy8259, LEGACY_MODE_BASE_VECTOR_MASTER, LEGACY_MODE_BASE_VECTOR_SLAVE);\r
-    //\r
-    // PC History\r
-    //   The original PC used INT8-F for master PIC. Since these mapped over\r
-    //   processor exceptions TIANO moved the master PIC to INT68-6F.\r
-    // We need to set these back to the Legacy16 unexpected interrupt(saved\r
-    // in LegacyBios.c) since some OS see that these have values different from\r
-    // what is expected and invoke them. Since the legacy OS corrupts EFI\r
-    // memory, there is no handler for these interrupts and OS blows up.\r
-    //\r
-    // We need to save the TIANO values for the rare case that the Legacy16\r
-    // code cannot boot but knows memory hasn't been destroyed.\r
-    //\r
-    // To compound the problem, video takes over one of these INTS and must be\r
-    // be left.\r
-    // @bug - determine if video hooks INT(in which case we must find new\r
-    //          set of TIANO vectors) or takes it over.\r
-    //\r
-    //\r
-    ACCESS_PAGE0_CODE (\r
-      BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);\r
-      for (Index = 0; Index < 8; Index++) {\r
-        Private->ThunkSavedInt[Index] = BaseVectorMaster[Index];\r
-        if (Private->ThunkSeg == (UINT16) (BaseVectorMaster[Index] >> 16)) {\r
-          BaseVectorMaster[Index] = (UINT32) (Private->BiosUnexpectedInt);\r
-        }\r
-      }\r
-    );\r
-\r
-    ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-    Regs.X.AX = Legacy16Boot;\r
-\r
-    Private->LegacyBios.FarCall86 (\r
-      This,\r
-      Private->Legacy16CallSegment,\r
-      Private->Legacy16CallOffset,\r
-      &Regs,\r
-      NULL,\r
-      0\r
-      );\r
-\r
-    ACCESS_PAGE0_CODE (\r
-      BaseVectorMaster = (UINT32 *) (sizeof (UINT32) * PROTECTED_MODE_BASE_VECTOR_MASTER);\r
-      for (Index = 0; Index < 8; Index++) {\r
-        BaseVectorMaster[Index] = Private->ThunkSavedInt[Index];\r
-      }\r
-    );\r
-  }\r
-  Private->LegacyBootEntered = TRUE;\r
-  if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {\r
-    //\r
-    // Should never return unless never passed control to 0:7c00(first stage\r
-    // OS loader) and only then if no bootable device found.\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
-  } else {\r
-    //\r
-    // If boot to EFI then expect to return to caller\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Assign drive number to legacy HDD drives prior to booting an EFI\r
-  aware OS so the OS can access drives without an EFI driver.\r
-  Note: BBS compliant drives ARE NOT available until this call by\r
-  either shell or EFI.\r
-\r
-  @param  This                    Protocol instance pointer.\r
-  @param  BbsCount                Number of BBS_TABLE structures\r
-  @param  BbsTable                List BBS entries\r
-\r
-  @retval EFI_SUCCESS             Drive numbers assigned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosPrepareToBootEfi (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL         *This,\r
-  OUT UINT16                          *BbsCount,\r
-  OUT BBS_TABLE                       **BbsTable\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;\r
-  LEGACY_BIOS_INSTANCE              *Private;\r
-\r
-  Private                 = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-  EfiToLegacy16BootTable  = &Private->IntThunk->EfiToLegacy16BootTable;\r
-  mBootMode               = BOOT_EFI_OS;\r
-  mBbsDevicePathPtr       = NULL;\r
-  Status                  = GenericLegacyBoot (This);\r
-  *BbsTable               = (BBS_TABLE*)(UINTN)EfiToLegacy16BootTable->BbsTable;\r
-  *BbsCount               = (UINT16) (sizeof (Private->IntThunk->BbsTable) / sizeof (BBS_TABLE));\r
-  return Status;\r
-}\r
-\r
-/**\r
-  To boot from an unconventional device like parties and/or execute HDD diagnostics.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  Attributes      How to interpret the other input parameters\r
-  @param  BbsEntry        The 0-based index into the BbsTable for the parent\r
-                          device.\r
-  @param  BeerData        Pointer to the 128 bytes of ram BEER data.\r
-  @param  ServiceAreaData Pointer to the 64 bytes of raw Service Area data. The\r
-                          caller must provide a pointer to the specific Service\r
-                          Area and not the start all Service Areas.\r
-\r
-  @retval EFI_INVALID_PARAMETER if error. Does NOT return if no error.\r
-\r
-***/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosBootUnconventionalDevice (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL         *This,\r
-  IN UDC_ATTRIBUTES                   Attributes,\r
-  IN UINTN                            BbsEntry,\r
-  IN VOID                             *BeerData,\r
-  IN VOID                             *ServiceAreaData\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_TO_COMPATIBILITY16_BOOT_TABLE *EfiToLegacy16BootTable;\r
-  LEGACY_BIOS_INSTANCE              *Private;\r
-  UD_TABLE                          *UcdTable;\r
-  UINTN                             Index;\r
-  UINT16                            BootPriority;\r
-  BBS_TABLE                         *BbsTable;\r
-\r
-  BootPriority = 0;\r
-  Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-  mBootMode = BOOT_UNCONVENTIONAL_DEVICE;\r
-  mBbsDevicePathPtr = &mBbsDevicePathNode;\r
-  mAttributes = Attributes;\r
-  mBbsEntry = BbsEntry;\r
-  mBeerData = BeerData, mServiceAreaData = ServiceAreaData;\r
-\r
-  EfiToLegacy16BootTable = &Private->IntThunk->EfiToLegacy16BootTable;\r
-\r
-  //\r
-  // Do input parameter checking\r
-  //\r
-  if ((Attributes.DirectoryServiceValidity == 0) &&\r
-      (Attributes.RabcaUsedFlag == 0) &&\r
-      (Attributes.ExecuteHddDiagnosticsFlag == 0)\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (((Attributes.DirectoryServiceValidity != 0) && (ServiceAreaData == NULL)) ||\r
-      (((Attributes.DirectoryServiceValidity | Attributes.RabcaUsedFlag) != 0) && (BeerData == NULL))\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  UcdTable = (UD_TABLE *) AllocatePool (\r
-                            sizeof (UD_TABLE)\r
-                            );\r
-  if (NULL == UcdTable) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  EfiToLegacy16BootTable->UnconventionalDeviceTable = (UINT32)(UINTN)UcdTable;\r
-  UcdTable->Attributes = Attributes;\r
-  UcdTable->BbsTableEntryNumberForParentDevice = (UINT8) BbsEntry;\r
-  //\r
-  // Force all existing BBS entries to DoNotBoot. This allows 16-bit CSM\r
-  // to assign drive numbers but bot boot from. Only newly created entries\r
-  // will be valid.\r
-  //\r
-  BbsTable = (BBS_TABLE*)(UINTN)EfiToLegacy16BootTable->BbsTable;\r
-  for (Index = 0; Index < EfiToLegacy16BootTable->NumberBbsEntries; Index++) {\r
-    BbsTable[Index].BootPriority = BBS_DO_NOT_BOOT_FROM;\r
-  }\r
-  //\r
-  // If parent is onboard IDE then assign controller & device number\r
-  // else they are 0.\r
-  //\r
-  if (BbsEntry < MAX_IDE_CONTROLLER * 2) {\r
-    UcdTable->DeviceNumber = (UINT8) ((BbsEntry - 1) % 2);\r
-  }\r
-\r
-  if (BeerData != NULL) {\r
-    CopyMem (\r
-      (VOID *) UcdTable->BeerData,\r
-      BeerData,\r
-      (UINTN) 128\r
-      );\r
-  }\r
-\r
-  if (ServiceAreaData != NULL) {\r
-    CopyMem (\r
-      (VOID *) UcdTable->ServiceAreaData,\r
-      ServiceAreaData,\r
-      (UINTN) 64\r
-      );\r
-  }\r
-  //\r
-  // For each new entry do the following:\r
-  //   1. Increment current number of BBS entries\r
-  //   2. Copy parent entry to new entry.\r
-  //   3. Zero out BootHandler Offset & segment\r
-  //   4. Set appropriate device type. BEV(0x80) for HDD diagnostics\r
-  //      and Floppy(0x01) for PARTIES boot.\r
-  //   5. Assign new priority.\r
-  //\r
-  if ((Attributes.ExecuteHddDiagnosticsFlag) != 0) {\r
-    EfiToLegacy16BootTable->NumberBbsEntries += 1;\r
-\r
-    CopyMem (\r
-      (VOID *) &BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority,\r
-      (VOID *) &BbsTable[BbsEntry].BootPriority,\r
-      sizeof (BBS_TABLE)\r
-      );\r
-\r
-    BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootHandlerOffset  = 0;\r
-    BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootHandlerSegment = 0;\r
-    BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].DeviceType         = 0x80;\r
-\r
-    UcdTable->BbsTableEntryNumberForHddDiag = (UINT8) (EfiToLegacy16BootTable->NumberBbsEntries - 1);\r
-\r
-    BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority = BootPriority;\r
-    BootPriority += 1;\r
-\r
-    //\r
-    // Set device type as BBS_TYPE_DEV for PARTIES diagnostic\r
-    //\r
-    mBbsDevicePathNode.DeviceType = BBS_TYPE_BEV;\r
-  }\r
-\r
-  if (((Attributes.DirectoryServiceValidity | Attributes.RabcaUsedFlag)) != 0) {\r
-    EfiToLegacy16BootTable->NumberBbsEntries += 1;\r
-    CopyMem (\r
-      (VOID *) &BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority,\r
-      (VOID *) &BbsTable[BbsEntry].BootPriority,\r
-      sizeof (BBS_TABLE)\r
-      );\r
-\r
-    BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootHandlerOffset  = 0;\r
-    BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootHandlerSegment = 0;\r
-    BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].DeviceType         = 0x01;\r
-    UcdTable->BbsTableEntryNumberForBoot = (UINT8) (EfiToLegacy16BootTable->NumberBbsEntries - 1);\r
-    BbsTable[EfiToLegacy16BootTable->NumberBbsEntries].BootPriority = BootPriority;\r
-\r
-    //\r
-    // Set device type as BBS_TYPE_FLOPPY for PARTIES boot as floppy\r
-    //\r
-    mBbsDevicePathNode.DeviceType = BBS_TYPE_FLOPPY;\r
-  }\r
-  //\r
-  // Build the BBS Device Path for this boot selection\r
-  //\r
-  mBbsDevicePathNode.Header.Type    = BBS_DEVICE_PATH;\r
-  mBbsDevicePathNode.Header.SubType = BBS_BBS_DP;\r
-  SetDevicePathNodeLength (&mBbsDevicePathNode.Header, sizeof (BBS_BBS_DEVICE_PATH));\r
-  mBbsDevicePathNode.StatusFlag = 0;\r
-  mBbsDevicePathNode.String[0]  = 0;\r
-\r
-  Status                        = GenericLegacyBoot (This);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Attempt to legacy boot the BootOption. If the EFI contexted has been\r
-  compromised this function will not return.\r
-\r
-  @param  This             Protocol instance pointer.\r
-  @param  BbsDevicePath    EFI Device Path from BootXXXX variable.\r
-  @param  LoadOptionsSize  Size of LoadOption in size.\r
-  @param  LoadOptions      LoadOption from BootXXXX variable\r
-\r
-  @retval EFI_SUCCESS      Removable media not present\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosLegacyBoot (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL           *This,\r
-  IN  BBS_BBS_DEVICE_PATH               *BbsDevicePath,\r
-  IN  UINT32                            LoadOptionsSize,\r
-  IN  VOID                              *LoadOptions\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  mBbsDevicePathPtr = BbsDevicePath;\r
-  mLoadOptionsSize  = LoadOptionsSize;\r
-  mLoadOptions      = LoadOptions;\r
-  mBootMode         = BOOT_LEGACY_OS;\r
-  Status            = GenericLegacyBoot (This);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Convert EFI Memory Type to E820 Memory Type.\r
-\r
-  @param  Type  EFI Memory Type\r
-\r
-  @return ACPI Memory Type for EFI Memory Type\r
-\r
-**/\r
-EFI_ACPI_MEMORY_TYPE\r
-EfiMemoryTypeToE820Type (\r
-  IN  UINT32    Type\r
-  )\r
-{\r
-  switch (Type) {\r
-  case EfiLoaderCode:\r
-  case EfiLoaderData:\r
-  case EfiBootServicesCode:\r
-  case EfiBootServicesData:\r
-  case EfiConventionalMemory:\r
-  //\r
-  // The memory of EfiRuntimeServicesCode and EfiRuntimeServicesData are\r
-  // usable memory for legacy OS, because legacy OS is not aware of EFI runtime concept.\r
-  // In ACPI specification, EfiRuntimeServiceCode and EfiRuntimeServiceData\r
-  // should be mapped to AddressRangeReserved. This statement is for UEFI OS, not for legacy OS.\r
-  //\r
-  case EfiRuntimeServicesCode:\r
-  case EfiRuntimeServicesData:\r
-    return EfiAcpiAddressRangeMemory;\r
-\r
-  case EfiPersistentMemory:\r
-    return EfiAddressRangePersistentMemory;\r
-\r
-  case EfiACPIReclaimMemory:\r
-    return EfiAcpiAddressRangeACPI;\r
-\r
-  case EfiACPIMemoryNVS:\r
-    return EfiAcpiAddressRangeNVS;\r
-\r
-  //\r
-  // All other types map to reserved.\r
-  // Adding the code just waists FLASH space.\r
-  //\r
-  //  case  EfiReservedMemoryType:\r
-  //  case  EfiUnusableMemory:\r
-  //  case  EfiMemoryMappedIO:\r
-  //  case  EfiMemoryMappedIOPortSpace:\r
-  //  case  EfiPalCode:\r
-  //\r
-  default:\r
-    return EfiAcpiAddressRangeReserved;\r
-  }\r
-}\r
-\r
-/**\r
-  Build the E820 table.\r
-\r
-  @param  Private  Legacy BIOS Instance data\r
-  @param  Size     Size of E820 Table\r
-\r
-  @retval EFI_SUCCESS  It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildE820 (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private,\r
-  OUT UINTN                   *Size\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_E820_ENTRY64            *E820Table;\r
-  EFI_MEMORY_DESCRIPTOR       *EfiMemoryMap;\r
-  EFI_MEMORY_DESCRIPTOR       *EfiMemoryMapEnd;\r
-  EFI_MEMORY_DESCRIPTOR       *EfiEntry;\r
-  EFI_MEMORY_DESCRIPTOR       *NextEfiEntry;\r
-  EFI_MEMORY_DESCRIPTOR       TempEfiEntry;\r
-  UINTN                       EfiMemoryMapSize;\r
-  UINTN                       EfiMapKey;\r
-  UINTN                       EfiDescriptorSize;\r
-  UINT32                      EfiDescriptorVersion;\r
-  UINTN                       Index;\r
-  EFI_PEI_HOB_POINTERS        Hob;\r
-  EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;\r
-  UINTN                       TempIndex;\r
-  UINTN                       IndexSort;\r
-  UINTN                       TempNextIndex;\r
-  EFI_E820_ENTRY64            TempE820;\r
-  EFI_ACPI_MEMORY_TYPE        TempType;\r
-  BOOLEAN                     ChangedFlag;\r
-  UINTN                       Above1MIndex;\r
-  UINT64                      MemoryBlockLength;\r
-\r
-  E820Table = (EFI_E820_ENTRY64 *) Private->E820Table;\r
-\r
-  //\r
-  // Get the EFI memory map.\r
-  //\r
-  EfiMemoryMapSize  = 0;\r
-  EfiMemoryMap      = NULL;\r
-  Status = gBS->GetMemoryMap (\r
-                  &EfiMemoryMapSize,\r
-                  EfiMemoryMap,\r
-                  &EfiMapKey,\r
-                  &EfiDescriptorSize,\r
-                  &EfiDescriptorVersion\r
-                  );\r
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
-\r
-  do {\r
-    //\r
-    // Use size returned for the AllocatePool.\r
-    // We don't just multiply by 2 since the "for" loop below terminates on\r
-    // EfiMemoryMapEnd which is dependent upon EfiMemoryMapSize. Otherwise\r
-    // we process bogus entries and create bogus E820 entries.\r
-    //\r
-    EfiMemoryMap = (EFI_MEMORY_DESCRIPTOR *) AllocatePool (EfiMemoryMapSize);\r
-    ASSERT (EfiMemoryMap != NULL);\r
-    Status = gBS->GetMemoryMap (\r
-                    &EfiMemoryMapSize,\r
-                    EfiMemoryMap,\r
-                    &EfiMapKey,\r
-                    &EfiDescriptorSize,\r
-                    &EfiDescriptorVersion\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (EfiMemoryMap);\r
-    }\r
-  } while (Status == EFI_BUFFER_TOO_SMALL);\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Punch in the E820 table for memory less than 1 MB.\r
-  // Assume ZeroMem () has been done on data structure.\r
-  //\r
-  //\r
-  // First entry is 0 to (640k - EBDA)\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    E820Table[0].BaseAddr  = 0;\r
-    E820Table[0].Length    = (UINT64) ((*(UINT16 *) (UINTN)0x40E) << 4);\r
-    E820Table[0].Type      = EfiAcpiAddressRangeMemory;\r
-  );\r
-\r
-  //\r
-  // Second entry is (640k - EBDA) to 640k\r
-  //\r
-  E820Table[1].BaseAddr  = E820Table[0].Length;\r
-  E820Table[1].Length    = (UINT64) ((640 * 1024) - E820Table[0].Length);\r
-  E820Table[1].Type      = EfiAcpiAddressRangeReserved;\r
-\r
-  //\r
-  // Third Entry is legacy BIOS\r
-  // DO NOT CLAIM region from 0xA0000-0xDFFFF. OS can use free areas\r
-  // to page in memory under 1MB.\r
-  // Omit region from 0xE0000 to start of BIOS, if any. This can be\r
-  // used for a multiple reasons including OPROMS.\r
-  //\r
-\r
-  //\r
-  // The CSM binary image size is not the actually size that CSM binary used,\r
-  // to avoid memory corrupt, we declare the 0E0000 - 0FFFFF is used by CSM binary.\r
-  //\r
-  E820Table[2].BaseAddr  = 0xE0000;\r
-  E820Table[2].Length    = 0x20000;\r
-  E820Table[2].Type      = EfiAcpiAddressRangeReserved;\r
-\r
-  Above1MIndex = 2;\r
-\r
-  //\r
-  // Process the EFI map to produce E820 map;\r
-  //\r
-\r
-  //\r
-  // Sort memory map from low to high\r
-  //\r
-  EfiEntry        = EfiMemoryMap;\r
-  NextEfiEntry    = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);\r
-  EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) EfiMemoryMap + EfiMemoryMapSize);\r
-  while (EfiEntry < EfiMemoryMapEnd) {\r
-    while (NextEfiEntry < EfiMemoryMapEnd) {\r
-      if (EfiEntry->PhysicalStart > NextEfiEntry->PhysicalStart) {\r
-        CopyMem (&TempEfiEntry, EfiEntry, sizeof (EFI_MEMORY_DESCRIPTOR));\r
-        CopyMem (EfiEntry, NextEfiEntry, sizeof (EFI_MEMORY_DESCRIPTOR));\r
-        CopyMem (NextEfiEntry, &TempEfiEntry, sizeof (EFI_MEMORY_DESCRIPTOR));\r
-      }\r
-\r
-      NextEfiEntry = NEXT_MEMORY_DESCRIPTOR (NextEfiEntry, EfiDescriptorSize);\r
-    }\r
-\r
-    EfiEntry      = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);\r
-    NextEfiEntry  = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);\r
-  }\r
-\r
-  EfiEntry        = EfiMemoryMap;\r
-  EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) EfiMemoryMap + EfiMemoryMapSize);\r
-  for (Index = Above1MIndex; (EfiEntry < EfiMemoryMapEnd) && (Index < EFI_MAX_E820_ENTRY - 1); ) {\r
-    MemoryBlockLength = (UINT64) (LShiftU64 (EfiEntry->NumberOfPages, 12));\r
-    if ((EfiEntry->PhysicalStart + MemoryBlockLength) < 0x100000) {\r
-      //\r
-      // Skip the memory block if under 1MB\r
-      //\r
-    } else {\r
-      if (EfiEntry->PhysicalStart < 0x100000) {\r
-        //\r
-        // When the memory block spans below 1MB, ensure the memory block start address is at least 1MB\r
-        //\r
-        MemoryBlockLength       -= 0x100000 - EfiEntry->PhysicalStart;\r
-        EfiEntry->PhysicalStart =  0x100000;\r
-      }\r
-\r
-      //\r
-      // Convert memory type to E820 type\r
-      //\r
-      TempType = EfiMemoryTypeToE820Type (EfiEntry->Type);\r
-\r
-      if ((E820Table[Index].Type == TempType) && (EfiEntry->PhysicalStart == (E820Table[Index].BaseAddr + E820Table[Index].Length))) {\r
-        //\r
-        // Grow an existing entry\r
-        //\r
-        E820Table[Index].Length += MemoryBlockLength;\r
-      } else {\r
-        //\r
-        // Make a new entry\r
-        //\r
-        ++Index;\r
-        E820Table[Index].BaseAddr  = EfiEntry->PhysicalStart;\r
-        E820Table[Index].Length    = MemoryBlockLength;\r
-        E820Table[Index].Type      = TempType;\r
-      }\r
-    }\r
-    EfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);\r
-  }\r
-\r
-  FreePool (EfiMemoryMap);\r
-\r
-  //\r
-  // Process the reserved memory map to produce E820 map ;\r
-  //\r
-  for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {\r
-    if (Hob.Raw != NULL && GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
-      ResourceHob = Hob.ResourceDescriptor;\r
-      if (((ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_MAPPED_IO) ||\r
-          (ResourceHob->ResourceType == EFI_RESOURCE_FIRMWARE_DEVICE)  ||\r
-          (ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_RESERVED)    ) &&\r
-          (ResourceHob->PhysicalStart > 0x100000) &&\r
-          (Index < EFI_MAX_E820_ENTRY - 1)) {\r
-        ++Index;\r
-        E820Table[Index].BaseAddr  = ResourceHob->PhysicalStart;\r
-        E820Table[Index].Length    = ResourceHob->ResourceLength;\r
-        E820Table[Index].Type      = EfiAcpiAddressRangeReserved;\r
-      }\r
-    }\r
-  }\r
-\r
-  Index ++;\r
-  Private->IntThunk->EfiToLegacy16InitTable.NumberE820Entries = (UINT32)Index;\r
-  Private->IntThunk->EfiToLegacy16BootTable.NumberE820Entries = (UINT32)Index;\r
-  Private->NumberE820Entries = (UINT32)Index;\r
-  *Size = (UINTN) (Index * sizeof (EFI_E820_ENTRY64));\r
-\r
-  //\r
-  // Sort E820Table from low to high\r
-  //\r
-  for (TempIndex = 0; TempIndex < Index; TempIndex++) {\r
-    ChangedFlag = FALSE;\r
-    for (TempNextIndex = 1; TempNextIndex < Index - TempIndex; TempNextIndex++) {\r
-      if (E820Table[TempNextIndex - 1].BaseAddr > E820Table[TempNextIndex].BaseAddr) {\r
-        ChangedFlag                       = TRUE;\r
-        TempE820.BaseAddr                 = E820Table[TempNextIndex - 1].BaseAddr;\r
-        TempE820.Length                   = E820Table[TempNextIndex - 1].Length;\r
-        TempE820.Type                     = E820Table[TempNextIndex - 1].Type;\r
-\r
-        E820Table[TempNextIndex - 1].BaseAddr  = E820Table[TempNextIndex].BaseAddr;\r
-        E820Table[TempNextIndex - 1].Length    = E820Table[TempNextIndex].Length;\r
-        E820Table[TempNextIndex - 1].Type      = E820Table[TempNextIndex].Type;\r
-\r
-        E820Table[TempNextIndex].BaseAddr      = TempE820.BaseAddr;\r
-        E820Table[TempNextIndex].Length        = TempE820.Length;\r
-        E820Table[TempNextIndex].Type          = TempE820.Type;\r
-      }\r
-    }\r
-\r
-    if (!ChangedFlag) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Remove the overlap range\r
-  //\r
-  for (TempIndex = 1; TempIndex < Index; TempIndex++) {\r
-    if (E820Table[TempIndex - 1].BaseAddr <= E820Table[TempIndex].BaseAddr &&\r
-        ((E820Table[TempIndex - 1].BaseAddr + E820Table[TempIndex - 1].Length) >=\r
-         (E820Table[TempIndex].BaseAddr +E820Table[TempIndex].Length))) {\r
-        //\r
-        //Overlap range is found\r
-        //\r
-        ASSERT (E820Table[TempIndex - 1].Type == E820Table[TempIndex].Type);\r
-\r
-        if (TempIndex == Index - 1) {\r
-          E820Table[TempIndex].BaseAddr = 0;\r
-          E820Table[TempIndex].Length   = 0;\r
-          E820Table[TempIndex].Type     = (EFI_ACPI_MEMORY_TYPE) 0;\r
-          Index--;\r
-          break;\r
-        } else {\r
-          for (IndexSort = TempIndex; IndexSort < Index - 1; IndexSort ++) {\r
-            E820Table[IndexSort].BaseAddr = E820Table[IndexSort + 1].BaseAddr;\r
-            E820Table[IndexSort].Length   = E820Table[IndexSort + 1].Length;\r
-            E820Table[IndexSort].Type     = E820Table[IndexSort + 1].Type;\r
-          }\r
-          Index--;\r
-       }\r
-    }\r
-  }\r
-\r
-\r
-\r
-  Private->IntThunk->EfiToLegacy16InitTable.NumberE820Entries = (UINT32)Index;\r
-  Private->IntThunk->EfiToLegacy16BootTable.NumberE820Entries = (UINT32)Index;\r
-  Private->NumberE820Entries = (UINT32)Index;\r
-  *Size = (UINTN) (Index * sizeof (EFI_E820_ENTRY64));\r
-\r
-  //\r
-  // Determine OS usable memory above 1MB\r
-  //\r
-  Private->IntThunk->EfiToLegacy16BootTable.OsMemoryAbove1Mb = 0x0000;\r
-  for (TempIndex = Above1MIndex; TempIndex < Index; TempIndex++) {\r
-    if (E820Table[TempIndex].BaseAddr >= 0x100000 && E820Table[TempIndex].BaseAddr < 0x100000000ULL) { // not include above 4G memory\r
-      //\r
-      // ACPIReclaimMemory is also usable memory for ACPI OS, after OS dumps all ACPI tables.\r
-      //\r
-      if ((E820Table[TempIndex].Type == EfiAcpiAddressRangeMemory) || (E820Table[TempIndex].Type == EfiAcpiAddressRangeACPI)) {\r
-        Private->IntThunk->EfiToLegacy16BootTable.OsMemoryAbove1Mb += (UINT32) (E820Table[TempIndex].Length);\r
-      } else {\r
-        break; // break at first not normal memory, because SMM may use reserved memory.\r
-      }\r
-    }\r
-  }\r
-\r
-  Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb = Private->IntThunk->EfiToLegacy16BootTable.OsMemoryAbove1Mb;\r
-\r
-  //\r
-  // Print DEBUG information\r
-  //\r
-  for (TempIndex = 0; TempIndex < Index; TempIndex++) {\r
-    DEBUG((EFI_D_INFO, "E820[%2d]: 0x%016lx - 0x%016lx, Type = %d\n",\r
-      TempIndex,\r
-      E820Table[TempIndex].BaseAddr,\r
-      (E820Table[TempIndex].BaseAddr + E820Table[TempIndex].Length),\r
-      E820Table[TempIndex].Type\r
-      ));\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Fill in the standard BDA and EBDA stuff prior to legacy Boot\r
-\r
-  @param  Private      Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS  It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosCompleteBdaBeforeBoot (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  )\r
-{\r
-  BDA_STRUC                   *Bda;\r
-  UINT16                      MachineConfig;\r
-  DEVICE_PRODUCER_DATA_HEADER *SioPtr;\r
-\r
-  Bda           = (BDA_STRUC *) ((UINTN) 0x400);\r
-  MachineConfig = 0;\r
-\r
-  SioPtr        = &(Private->IntThunk->EfiToLegacy16BootTable.SioData);\r
-  Bda->Com1     = SioPtr->Serial[0].Address;\r
-  Bda->Com2     = SioPtr->Serial[1].Address;\r
-  Bda->Com3     = SioPtr->Serial[2].Address;\r
-  Bda->Com4     = SioPtr->Serial[3].Address;\r
-\r
-  if (SioPtr->Serial[0].Address != 0x00) {\r
-    MachineConfig += 0x200;\r
-  }\r
-\r
-  if (SioPtr->Serial[1].Address != 0x00) {\r
-    MachineConfig += 0x200;\r
-  }\r
-\r
-  if (SioPtr->Serial[2].Address != 0x00) {\r
-    MachineConfig += 0x200;\r
-  }\r
-\r
-  if (SioPtr->Serial[3].Address != 0x00) {\r
-    MachineConfig += 0x200;\r
-  }\r
-\r
-  Bda->Lpt1 = SioPtr->Parallel[0].Address;\r
-  Bda->Lpt2 = SioPtr->Parallel[1].Address;\r
-  Bda->Lpt3 = SioPtr->Parallel[2].Address;\r
-\r
-  if (SioPtr->Parallel[0].Address != 0x00) {\r
-    MachineConfig += 0x4000;\r
-  }\r
-\r
-  if (SioPtr->Parallel[1].Address != 0x00) {\r
-    MachineConfig += 0x4000;\r
-  }\r
-\r
-  if (SioPtr->Parallel[2].Address != 0x00) {\r
-    MachineConfig += 0x4000;\r
-  }\r
-\r
-  Bda->NumberOfDrives = (UINT8) (Bda->NumberOfDrives + Private->IdeDriveCount);\r
-  if (SioPtr->Floppy.NumberOfFloppy != 0x00) {\r
-    MachineConfig     = (UINT16) (MachineConfig + 0x01 + (SioPtr->Floppy.NumberOfFloppy - 1) * 0x40);\r
-    Bda->FloppyXRate  = 0x07;\r
-  }\r
-\r
-  Bda->Lpt1_2Timeout  = 0x1414;\r
-  Bda->Lpt3_4Timeout  = 0x1414;\r
-  Bda->Com1_2Timeout  = 0x0101;\r
-  Bda->Com3_4Timeout  = 0x0101;\r
-\r
-  //\r
-  // Force VGA and Coprocessor, indicate 101/102 keyboard\r
-  //\r
-  MachineConfig       = (UINT16) (MachineConfig + 0x00 + 0x02 + (SioPtr->MousePresent * 0x04));\r
-  Bda->MachineConfig  = MachineConfig;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Fill in the standard BDA for Keyboard LEDs\r
-\r
-  @param  This         Protocol instance pointer.\r
-  @param  Leds         Current LED status\r
-\r
-  @retval EFI_SUCCESS  It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosUpdateKeyboardLedStatus (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL           *This,\r
-  IN  UINT8                             Leds\r
-  )\r
-{\r
-  LEGACY_BIOS_INSTANCE  *Private;\r
-  BDA_STRUC             *Bda;\r
-  UINT8                 LocalLeds;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-\r
-  Private             = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-\r
-  ACCESS_PAGE0_CODE (\r
-    Bda                 = (BDA_STRUC *) ((UINTN) 0x400);\r
-    LocalLeds           = Leds;\r
-    Bda->LedStatus      = (UINT8) ((Bda->LedStatus &~0x07) | LocalLeds);\r
-    LocalLeds           = (UINT8) (LocalLeds << 4);\r
-    Bda->ShiftStatus    = (UINT8) ((Bda->ShiftStatus &~0x70) | LocalLeds);\r
-    LocalLeds           = (UINT8) (Leds & 0x20);\r
-    Bda->KeyboardStatus = (UINT8) ((Bda->KeyboardStatus &~0x20) | LocalLeds);\r
-  );\r
-\r
-  //\r
-  // Call into Legacy16 code to allow it to do any processing\r
-  //\r
-  ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-  Regs.X.AX = Legacy16SetKeyboardLeds;\r
-  Regs.H.CL = Leds;\r
-\r
-  Private->LegacyBios.FarCall86 (\r
-    &Private->LegacyBios,\r
-    Private->Legacy16Table->Compatibility16CallSegment,\r
-    Private->Legacy16Table->Compatibility16CallOffset,\r
-    &Regs,\r
-    NULL,\r
-    0\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Fill in the standard CMOS stuff prior to legacy Boot\r
-\r
-  @param  Private      Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS  It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosCompleteStandardCmosBeforeBoot (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  )\r
-{\r
-  UINT8   Bda;\r
-  UINT8   Floppy;\r
-  UINT32  Size;\r
-\r
-  //\r
-  // Update CMOS locations\r
-  // 10 floppy\r
-  // 12,19,1A - ignore as OS don't use them and there is no standard due\r
-  //            to large capacity drives\r
-  // CMOS 14 = BDA 40:10 plus bit 3(display enabled)\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    Bda = (UINT8)(*((UINT8 *)((UINTN)0x410)) | BIT3);\r
-  );\r
-\r
-  //\r
-  // Force display enabled\r
-  //\r
-  Floppy = 0x00;\r
-  if ((Bda & BIT0) != 0) {\r
-    Floppy = BIT6;\r
-  }\r
-\r
-  //\r
-  // Check if 2.88MB floppy set\r
-  //\r
-  if ((Bda & (BIT7 | BIT6)) != 0) {\r
-    Floppy = (UINT8)(Floppy | BIT1);\r
-  }\r
-\r
-  LegacyWriteStandardCmos (CMOS_10, Floppy);\r
-  LegacyWriteStandardCmos (CMOS_14, Bda);\r
-\r
-  //\r
-  // Force Status Register A to set rate selection bits and divider\r
-  //\r
-  LegacyWriteStandardCmos (CMOS_0A, 0x26);\r
-\r
-  //\r
-  // redo memory size since it can change\r
-  //\r
-  Size = (15 * SIZE_1MB) >> 10;\r
-  if (Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb < (15 * SIZE_1MB)) {\r
-    Size  = Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb >> 10;\r
-  }\r
-\r
-  LegacyWriteStandardCmos (CMOS_17, (UINT8)(Size & 0xFF));\r
-  LegacyWriteStandardCmos (CMOS_30, (UINT8)(Size & 0xFF));\r
-  LegacyWriteStandardCmos (CMOS_18, (UINT8)(Size >> 8));\r
-  LegacyWriteStandardCmos (CMOS_31, (UINT8)(Size >> 8));\r
-\r
-  LegacyCalculateWriteStandardCmosChecksum ();\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Relocate this image under 4G memory for IPF.\r
-\r
-  @param  ImageHandle  Handle of driver image.\r
-  @param  SystemTable  Pointer to system table.\r
-\r
-  @retval EFI_SUCCESS  Image successfully relocated.\r
-  @retval EFI_ABORTED  Failed to relocate image.\r
-\r
-**/\r
-EFI_STATUS\r
-RelocateImageUnder4GIfNeeded (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyCmos.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyCmos.c
deleted file mode 100644 (file)
index de25e06..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/** @file\r
-  This code fills in standard CMOS values and updates the standard CMOS\r
-  checksum. The Legacy16 code or LegacyBiosPlatform.c is responsible for\r
-  non-standard CMOS locations and non-standard checksums.\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-\r
-/**\r
-  Read CMOS register through index/data port.\r
-\r
-  @param[in]  Index   The index of the CMOS register to read.\r
-\r
-  @return  The data value from the CMOS register specified by Index.\r
-\r
-**/\r
-UINT8\r
-LegacyReadStandardCmos (\r
-  IN UINT8  Index\r
-  )\r
-{\r
-  IoWrite8 (PORT_70, Index);\r
-  return IoRead8 (PORT_71);\r
-}\r
-\r
-/**\r
-  Write CMOS register through index/data port.\r
-\r
-  @param[in]  Index  The index of the CMOS register to write.\r
-  @param[in]  Value  The value of CMOS register to write.\r
-\r
-  @return  The value written to the CMOS register specified by Index.\r
-\r
-**/\r
-UINT8\r
-LegacyWriteStandardCmos (\r
-  IN UINT8  Index,\r
-  IN UINT8  Value\r
-  )\r
-{\r
-  IoWrite8 (PORT_70, Index);\r
-  return IoWrite8 (PORT_71, Value);\r
-}\r
-\r
-/**\r
-  Calculate the new standard CMOS checksum and write it.\r
-\r
-  @param  Private      Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS  Calculate 16-bit checksum successfully\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyCalculateWriteStandardCmosChecksum (\r
-  VOID\r
-  )\r
-{\r
-  UINT8   Register;\r
-  UINT16  Checksum;\r
-\r
-  for (Checksum = 0, Register = 0x10; Register < 0x2e; Register++) {\r
-    Checksum = (UINT16)(Checksum + LegacyReadStandardCmos (Register));\r
-  }\r
-  LegacyWriteStandardCmos (CMOS_2E, (UINT8)(Checksum >> 8));\r
-  LegacyWriteStandardCmos (CMOS_2F, (UINT8)(Checksum & 0xff));\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Fill in the standard CMOS stuff before Legacy16 load\r
-\r
-  @param  Private      Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS  It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosInitCmos (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  )\r
-{\r
-  UINT32  Size;\r
-\r
-  //\r
-  //  Clear all errors except RTC lost power\r
-  //\r
-  LegacyWriteStandardCmos (CMOS_0E, (UINT8)(LegacyReadStandardCmos (CMOS_0E) & BIT7));\r
-\r
-  //\r
-  // Update CMOS locations 15,16,17,18,30,31 and 32\r
-  // CMOS 16,15 = 640Kb = 0x280\r
-  // CMOS 18,17 = 31,30 = 15Mb max in 1Kb increments =0x3C00 max\r
-  // CMOS 32 = 0x20\r
-  //\r
-  LegacyWriteStandardCmos (CMOS_15, 0x80);\r
-  LegacyWriteStandardCmos (CMOS_16, 0x02);\r
-\r
-  Size = 15 * SIZE_1MB;\r
-  if (Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb < (15 * SIZE_1MB)) {\r
-    Size  = Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb >> 10;\r
-  }\r
-\r
-  LegacyWriteStandardCmos (CMOS_17, (UINT8)(Size & 0xFF));\r
-  LegacyWriteStandardCmos (CMOS_30, (UINT8)(Size & 0xFF));\r
-  LegacyWriteStandardCmos (CMOS_18, (UINT8)(Size >> 8));\r
-  LegacyWriteStandardCmos (CMOS_31, (UINT8)(Size >> 8));\r
-\r
-  LegacyCalculateWriteStandardCmosChecksum ();\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyIde.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyIde.c
deleted file mode 100644 (file)
index 789f483..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-/** @file\r
-  Collect IDE information from Native EFI Driver\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-\r
-BOOLEAN mIdeDataBuiltFlag = FALSE;\r
-\r
-/**\r
-  Collect IDE Inquiry data from the IDE disks\r
-\r
-  @param  Private        Legacy BIOS Instance data\r
-  @param  HddInfo        Hdd Information\r
-  @param  Flag           Reconnect IdeController or not\r
-\r
-  @retval EFI_SUCCESS    It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildIdeData (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private,\r
-  IN  HDD_INFO                  **HddInfo,\r
-  IN  UINT16                    Flag\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_HANDLE                IdeController;\r
-  UINTN                     HandleCount;\r
-  EFI_HANDLE                *HandleBuffer;\r
-  UINTN                     Index;\r
-  EFI_DISK_INFO_PROTOCOL    *DiskInfo;\r
-  UINT32                    IdeChannel;\r
-  UINT32                    IdeDevice;\r
-  UINT32                    Size;\r
-  UINT8                     *InquiryData;\r
-  UINT32                    InquiryDataSize;\r
-  HDD_INFO                  *LocalHddInfo;\r
-  UINT32                    PciIndex;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePathNode;\r
-  PCI_DEVICE_PATH           *PciDevicePath;\r
-\r
-  //\r
-  // Only build data once\r
-  // We have a problem with GetBbsInfo in that it can be invoked two\r
-  // places. Once in BDS, when all EFI drivers are connected and once in\r
-  // LegacyBoot after all EFI drivers are disconnected causing this routine\r
-  // to hang. In LegacyBoot this function is also called before EFI drivers\r
-  // are disconnected.\r
-  // Cases covered\r
-  //    GetBbsInfo invoked in BDS. Both invocations in LegacyBoot ignored.\r
-  //    GetBbsInfo not invoked in BDS. First invocation of this function\r
-  //       proceeds normally and second via GetBbsInfo ignored.\r
-  //\r
-  PciDevicePath = NULL;\r
-  LocalHddInfo  = *HddInfo;\r
-  Status = Private->LegacyBiosPlatform->GetPlatformHandle (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiGetPlatformIdeHandle,\r
-                                          0,\r
-                                          &HandleBuffer,\r
-                                          &HandleCount,\r
-                                          (VOID *) &LocalHddInfo\r
-                                          );\r
-  if (!EFI_ERROR (Status)) {\r
-    IdeController = HandleBuffer[0];\r
-    //\r
-    // Force IDE drive spin up!\r
-    //\r
-    if (Flag != 0) {\r
-      gBS->DisconnectController (\r
-            IdeController,\r
-            NULL,\r
-            NULL\r
-            );\r
-    }\r
-\r
-    gBS->ConnectController (IdeController, NULL, NULL, FALSE);\r
-\r
-    //\r
-    // Do GetIdeHandle twice since disconnect/reconnect will switch to native mode\r
-    // And GetIdeHandle will switch to Legacy mode, if required.\r
-    //\r
-    Private->LegacyBiosPlatform->GetPlatformHandle (\r
-                                  Private->LegacyBiosPlatform,\r
-                                  EfiGetPlatformIdeHandle,\r
-                                  0,\r
-                                  &HandleBuffer,\r
-                                  &HandleCount,\r
-                                  (VOID *) &LocalHddInfo\r
-                                  );\r
-  }\r
-\r
-  mIdeDataBuiltFlag = TRUE;\r
-\r
-  //\r
-  // Get Identity command from all drives\r
-  //\r
-  gBS->LocateHandleBuffer (\r
-        ByProtocol,\r
-        &gEfiDiskInfoProtocolGuid,\r
-        NULL,\r
-        &HandleCount,\r
-        &HandleBuffer\r
-        );\r
-\r
-  Private->IdeDriveCount = (UINT8) HandleCount;\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiDiskInfoProtocolGuid,\r
-                    (VOID **) &DiskInfo\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoIdeInterfaceGuid)) {\r
-      //\r
-      //  Locate which PCI device\r
-      //\r
-      Status = gBS->HandleProtocol (\r
-                      HandleBuffer[Index],\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      (VOID *) &DevicePath\r
-                      );\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-      DevicePathNode = DevicePath;\r
-      while (!IsDevicePathEnd (DevicePathNode)) {\r
-        TempDevicePathNode = NextDevicePathNode (DevicePathNode);\r
-        if ((DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH) &&\r
-              ( DevicePathSubType (DevicePathNode) == HW_PCI_DP) &&\r
-              ( DevicePathType(TempDevicePathNode) == MESSAGING_DEVICE_PATH) &&\r
-              ( DevicePathSubType(TempDevicePathNode) == MSG_ATAPI_DP) ) {\r
-          PciDevicePath = (PCI_DEVICE_PATH *) DevicePathNode;\r
-          break;\r
-        }\r
-        DevicePathNode = NextDevicePathNode (DevicePathNode);\r
-      }\r
-\r
-      if (PciDevicePath == NULL) {\r
-        continue;\r
-      }\r
-\r
-      //\r
-      // Find start of PCI device in HddInfo. The assumption of the data\r
-      // structure is 2 controllers(channels) per PCI device and each\r
-      // controller can have 2 drives(devices).\r
-      // HddInfo[PciIndex+0].[0] = Channel[0].Device[0] Primary Master\r
-      // HddInfo[PciIndex+0].[1] = Channel[0].Device[1] Primary Slave\r
-      // HddInfo[PciIndex+1].[0] = Channel[1].Device[0] Secondary Master\r
-      // HddInfo[PciIndex+1].[1] = Channel[1].Device[1] Secondary Slave\r
-      // @bug eventually need to pass in max number of entries\r
-      // for end of for loop\r
-      //\r
-      for (PciIndex = 0; PciIndex < 8; PciIndex++) {\r
-        if ((PciDevicePath->Device == LocalHddInfo[PciIndex].Device) &&\r
-            (PciDevicePath->Function == LocalHddInfo[PciIndex].Function)\r
-            ) {\r
-          break;\r
-        }\r
-      }\r
-\r
-      if (PciIndex == 8) {\r
-        continue;\r
-      }\r
-\r
-      Status = DiskInfo->WhichIde (DiskInfo, &IdeChannel, &IdeDevice);\r
-      if (!EFI_ERROR (Status)) {\r
-        Size = sizeof (ATAPI_IDENTIFY);\r
-        DiskInfo->Identify (\r
-                    DiskInfo,\r
-                    &LocalHddInfo[PciIndex + IdeChannel].IdentifyDrive[IdeDevice],\r
-                    &Size\r
-                    );\r
-        if (IdeChannel == 0) {\r
-          LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_PRIMARY;\r
-        } else if (IdeChannel == 1) {\r
-          LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_SECONDARY;\r
-        }\r
-\r
-        InquiryData     = NULL;\r
-        InquiryDataSize = 0;\r
-        Status = DiskInfo->Inquiry (\r
-                             DiskInfo,\r
-                             NULL,\r
-                             &InquiryDataSize\r
-                             );\r
-        if (Status == EFI_BUFFER_TOO_SMALL) {\r
-          InquiryData = (UINT8 *) AllocatePool (\r
-                                  InquiryDataSize\r
-                                  );\r
-          if (InquiryData != NULL) {\r
-            Status = DiskInfo->Inquiry (\r
-                                 DiskInfo,\r
-                                 InquiryData,\r
-                                 &InquiryDataSize\r
-                                 );\r
-          }\r
-        } else {\r
-          Status = EFI_DEVICE_ERROR;\r
-        }\r
-\r
-        //\r
-        // If ATAPI device then Inquiry will pass and ATA fail.\r
-        //\r
-        if (!EFI_ERROR (Status)) {\r
-          ASSERT (InquiryData != NULL);\r
-          //\r
-          // If IdeDevice = 0 then set master bit, else slave bit\r
-          //\r
-          if (IdeDevice == 0) {\r
-            if ((InquiryData[0] & 0x1f) == 0x05) {\r
-              LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_MASTER_ATAPI_CDROM;\r
-            } else if ((InquiryData[0] & 0x1f) == 0x00) {\r
-              LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_MASTER_ATAPI_ZIPDISK;\r
-            }\r
-          } else {\r
-            if ((InquiryData[0] & 0x1f) == 0x05) {\r
-              LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_SLAVE_ATAPI_CDROM;\r
-            } else if ((InquiryData[0] & 0x1f) == 0x00) {\r
-              LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_SLAVE_ATAPI_ZIPDISK;\r
-            }\r
-          }\r
-          FreePool (InquiryData);\r
-        } else {\r
-          if (IdeDevice == 0) {\r
-            LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_MASTER_IDE;\r
-          } else {\r
-            LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_SLAVE_IDE;\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool (HandleBuffer);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  If the IDE channel is in compatibility (legacy) mode, remove all\r
-  PCI I/O BAR addresses from the controller.\r
-\r
-  @param  IdeController  The handle of target IDE controller\r
-\r
-\r
-**/\r
-VOID\r
-InitLegacyIdeController (\r
-  IN EFI_HANDLE                        IdeController\r
-  )\r
-{\r
-  EFI_PCI_IO_PROTOCOL               *PciIo;\r
-  UINT32                            IOBarClear;\r
-  EFI_STATUS                        Status;\r
-  PCI_TYPE00                        PciData;\r
-\r
-  //\r
-  // If the IDE channel is in compatibility (legacy) mode, remove all\r
-  // PCI I/O BAR addresses from the controller.  Some software gets\r
-  // confused if an IDE controller is in compatibility (legacy) mode\r
-  // and has PCI I/O resources allocated\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  IdeController,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **)&PciIo\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return ;\r
-  }\r
-\r
-  Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0, sizeof (PciData), &PciData);\r
-  if (EFI_ERROR (Status)) {\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Check whether this is IDE\r
-  //\r
-  if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) ||\r
-      (PciData.Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE)) {\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Clear bar for legacy IDE\r
-  //\r
-  IOBarClear = 0x00;\r
-  if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_PNE) == 0) {\r
-    PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x10, 1, &IOBarClear);\r
-    PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x14, 1, &IOBarClear);\r
-  }\r
-  if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_SNE) == 0) {\r
-    PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x18, 1, &IOBarClear);\r
-    PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1C, 1, &IOBarClear);\r
-  }\r
-\r
-  return ;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyPci.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyPci.c
deleted file mode 100644 (file)
index dc1f760..0000000
+++ /dev/null
@@ -1,3083 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-#include <IndustryStandard/Pci30.h>\r
-\r
-#define PCI_START_ADDRESS(x)   (((x) + 0x7ff) & ~0x7ff)\r
-\r
-#define MAX_BRIDGE_INDEX  0x20\r
-typedef struct {\r
-  UINTN PciSegment;\r
-  UINTN PciBus;\r
-  UINTN PciDevice;\r
-  UINTN PciFunction;\r
-  UINT8 PrimaryBus;\r
-  UINT8 SecondaryBus;\r
-  UINT8 SubordinateBus;\r
-} BRIDGE_TABLE;\r
-\r
-#define ROM_MAX_ENTRIES 24\r
-BRIDGE_TABLE                        Bridges[MAX_BRIDGE_INDEX];\r
-UINTN                               SortedBridgeIndex[MAX_BRIDGE_INDEX];\r
-UINTN                               NumberOfBridges;\r
-LEGACY_PNP_EXPANSION_HEADER  *mBasePnpPtr;\r
-UINT16                              mBbsRomSegment;\r
-UINTN                               mHandleCount;\r
-EFI_HANDLE                          mVgaHandle;\r
-BOOLEAN                             mIgnoreBbsUpdateFlag;\r
-BOOLEAN                             mVgaInstallationInProgress  = FALSE;\r
-UINT32                              mRomCount                   = 0x00;\r
-ROM_INSTANCE_ENTRY                  mRomEntry[ROM_MAX_ENTRIES];\r
-EDKII_IOMMU_PROTOCOL                *mIoMmu;\r
-\r
-/**\r
-  Query shadowed legacy ROM parameters registered by RomShadow() previously.\r
-\r
-  @param  PciHandle        PCI device whos ROM has been shadowed\r
-  @param  DiskStart        DiskStart value from EFI_LEGACY_BIOS_PROTOCOL.InstallPciRom\r
-  @param  DiskEnd          DiskEnd value from EFI_LEGACY_BIOS_PROTOCOL.InstallPciRom\r
-  @param  RomShadowAddress Address where ROM was shadowed\r
-  @param  ShadowedSize     Runtime size of ROM\r
-\r
-  @retval EFI_SUCCESS      Query Logging successful.\r
-  @retval EFI_NOT_FOUND    No logged data found about PciHandle.\r
-\r
-**/\r
-EFI_STATUS\r
-GetShadowedRomParameters (\r
-  IN EFI_HANDLE                         PciHandle,\r
-  OUT UINT8                             *DiskStart,         OPTIONAL\r
-  OUT UINT8                             *DiskEnd,           OPTIONAL\r
-  OUT VOID                              **RomShadowAddress, OPTIONAL\r
-  OUT UINTN                             *ShadowedSize       OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-  UINTN               Index;\r
-  UINTN               PciSegment;\r
-  UINTN               PciBus;\r
-  UINTN               PciDevice;\r
-  UINTN               PciFunction;\r
-\r
-  //\r
-  // Get the PCI I/O Protocol on PciHandle\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  PciHandle,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get the location of the PCI device\r
-  //\r
-  PciIo->GetLocation (\r
-           PciIo,\r
-           &PciSegment,\r
-           &PciBus,\r
-           &PciDevice,\r
-           &PciFunction\r
-           );\r
-\r
-  for(Index = 0; Index < mRomCount; Index++) {\r
-    if ((mRomEntry[Index].PciSegment == PciSegment) &&\r
-        (mRomEntry[Index].PciBus == PciBus)         &&\r
-        (mRomEntry[Index].PciDevice == PciDevice)   &&\r
-        (mRomEntry[Index].PciFunction == PciFunction)) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (Index == mRomCount) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if (DiskStart != NULL) {\r
-    *DiskStart = mRomEntry[Index].DiskStart;\r
-  }\r
-\r
-  if (DiskEnd != NULL) {\r
-    *DiskEnd = mRomEntry[Index].DiskEnd;\r
-  }\r
-\r
-  if (RomShadowAddress != NULL) {\r
-    *RomShadowAddress = (VOID *)(UINTN)mRomEntry[Index].ShadowAddress;\r
-  }\r
-\r
-  if (ShadowedSize != NULL) {\r
-    *ShadowedSize = mRomEntry[Index].ShadowedSize;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Every legacy ROM that is shadowed by the Legacy BIOS driver will be\r
-  registered into this API so that the policy code can know what has\r
-  happend\r
-\r
-  @param  PciHandle              PCI device whos ROM is being shadowed\r
-  @param  ShadowAddress          Address that ROM was shadowed\r
-  @param  ShadowedSize           Runtime size of ROM\r
-  @param  DiskStart              DiskStart value from\r
-                                 EFI_LEGACY_BIOS_PROTOCOL.InstallPciRom\r
-  @param  DiskEnd                DiskEnd value from\r
-                                 EFI_LEGACY_BIOS_PROTOCOL.InstallPciRom\r
-\r
-  @retval EFI_SUCCESS            Logging successful.\r
-  @retval EFI_OUT_OF_RESOURCES   No remaining room for registering another option\r
-                                 ROM.\r
-\r
-**/\r
-EFI_STATUS\r
-RomShadow (\r
-  IN  EFI_HANDLE                                  PciHandle,\r
-  IN  UINT32                                      ShadowAddress,\r
-  IN  UINT32                                      ShadowedSize,\r
-  IN  UINT8                                       DiskStart,\r
-  IN  UINT8                                       DiskEnd\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-\r
-  //\r
-  // See if there is room to register another option ROM\r
-  //\r
-  if (mRomCount >= ROM_MAX_ENTRIES) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Get the PCI I/O Protocol on PciHandle\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  PciHandle,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Get the location of the PCI device\r
-  //\r
-  PciIo->GetLocation (\r
-           PciIo,\r
-           &mRomEntry[mRomCount].PciSegment,\r
-           &mRomEntry[mRomCount].PciBus,\r
-           &mRomEntry[mRomCount].PciDevice,\r
-           &mRomEntry[mRomCount].PciFunction\r
-           );\r
-  mRomEntry[mRomCount].ShadowAddress = ShadowAddress;\r
-  mRomEntry[mRomCount].ShadowedSize  = ShadowedSize;\r
-  mRomEntry[mRomCount].DiskStart     = DiskStart;\r
-  mRomEntry[mRomCount].DiskEnd       = DiskEnd;\r
-\r
-  mRomCount++;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Return EFI_SUCCESS if PciHandle has had a legacy BIOS ROM shadowed. This\r
-  information represents every call to RomShadow ()\r
-\r
-  @param  PciHandle              PCI device to get status for\r
-\r
-  @retval EFI_SUCCESS            Legacy ROM loaded for this device\r
-  @retval EFI_NOT_FOUND          No Legacy ROM loaded for this device\r
-\r
-**/\r
-EFI_STATUS\r
-IsLegacyRom (\r
-  IN  EFI_HANDLE                PciHandle\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-  UINTN               Index;\r
-  UINTN               Segment;\r
-  UINTN               Bus;\r
-  UINTN               Device;\r
-  UINTN               Function;\r
-\r
-  //\r
-  // Get the PCI I/O Protocol on PciHandle\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  PciHandle,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Get the location of the PCI device\r
-  //\r
-  PciIo->GetLocation (\r
-           PciIo,\r
-           &Segment,\r
-           &Bus,\r
-           &Device,\r
-           &Function\r
-           );\r
-\r
-  //\r
-  // See if the option ROM from PciHandle has been previously posted\r
-  //\r
-  for (Index = 0; Index < mRomCount; Index++) {\r
-    if (mRomEntry[Index].PciSegment == Segment &&\r
-        mRomEntry[Index].PciBus == Bus &&\r
-        mRomEntry[Index].PciDevice == Device &&\r
-        mRomEntry[Index].PciFunction == Function\r
-        ) {\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Find the PC-AT ROM Image in the raw PCI Option ROM. Also return the\r
-  related information from the header.\r
-\r
-  @param  Csm16Revision           The PCI interface version of underlying CSM16\r
-  @param  VendorId                Vendor ID of the PCI device\r
-  @param  DeviceId                Device ID of the PCI device\r
-  @param  Rom                     On input pointing to beginning of the raw PCI OpROM\r
-                                  On output pointing to the first legacy PCI OpROM\r
-  @param  ImageSize               On input is the size of Raw PCI Rom\r
-                                  On output is the size of the first legacy PCI ROM\r
-  @param  MaxRuntimeImageLength   The max runtime image length only valid if OpRomRevision >= 3\r
-  @param  OpRomRevision           Revision of the PCI Rom\r
-  @param  ConfigUtilityCodeHeader Pointer to Configuration Utility Code Header\r
-\r
-  @retval EFI_SUCCESS             Successfully find the legacy PCI ROM\r
-  @retval EFI_NOT_FOUND           Failed to find the legacy PCI ROM\r
-\r
-**/\r
-EFI_STATUS\r
-GetPciLegacyRom (\r
-  IN     UINT16 Csm16Revision,\r
-  IN     UINT16 VendorId,\r
-  IN     UINT16 DeviceId,\r
-  IN OUT VOID   **Rom,\r
-  IN OUT UINTN  *ImageSize,\r
-  OUT    UINTN  *MaxRuntimeImageLength,   OPTIONAL\r
-  OUT    UINT8  *OpRomRevision,           OPTIONAL\r
-  OUT    VOID   **ConfigUtilityCodeHeader OPTIONAL\r
-  )\r
-{\r
-  BOOLEAN                 Match;\r
-  UINT16                  *DeviceIdList;\r
-  EFI_PCI_ROM_HEADER      RomHeader;\r
-  PCI_3_0_DATA_STRUCTURE  *Pcir;\r
-  VOID                    *BackupImage;\r
-  VOID                    *BestImage;\r
-\r
-\r
-  if (*ImageSize < sizeof (EFI_PCI_ROM_HEADER)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  BestImage     = NULL;\r
-  BackupImage   = NULL;\r
-  RomHeader.Raw = *Rom;\r
-  while (RomHeader.Generic->Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r
-    if (RomHeader.Generic->PcirOffset == 0 ||\r
-        (RomHeader.Generic->PcirOffset & 3) !=0 ||\r
-        *ImageSize < RomHeader.Raw - (UINT8 *) *Rom + RomHeader.Generic->PcirOffset + sizeof (PCI_DATA_STRUCTURE)) {\r
-      break;\r
-    }\r
-\r
-    Pcir = (PCI_3_0_DATA_STRUCTURE *) (RomHeader.Raw + RomHeader.Generic->PcirOffset);\r
-    //\r
-    // Check signature in the PCI Data Structure.\r
-    //\r
-    if (Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
-      break;\r
-    }\r
-\r
-    if (((UINTN)RomHeader.Raw - (UINTN)*Rom) + Pcir->ImageLength * 512 > *ImageSize) {\r
-      break;\r
-    }\r
-\r
-    if (Pcir->CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {\r
-      Match = FALSE;\r
-      if (Pcir->VendorId == VendorId) {\r
-        if (Pcir->DeviceId == DeviceId) {\r
-          Match = TRUE;\r
-        } else if ((Pcir->Revision >= 3) && (Pcir->DeviceListOffset != 0)) {\r
-          DeviceIdList = (UINT16 *)(((UINT8 *) Pcir) + Pcir->DeviceListOffset);\r
-          //\r
-          // Checking the device list\r
-          //\r
-          while (*DeviceIdList != 0) {\r
-            if (*DeviceIdList == DeviceId) {\r
-              Match = TRUE;\r
-              break;\r
-            }\r
-            DeviceIdList ++;\r
-          }\r
-        }\r
-      }\r
-\r
-      if (Match) {\r
-        if (Csm16Revision >= 0x0300) {\r
-          //\r
-          // Case 1: CSM16 3.0\r
-          //\r
-          if (Pcir->Revision >= 3) {\r
-            //\r
-            // case 1.1: meets OpRom 3.0\r
-            //           Perfect!!!\r
-            //\r
-            BestImage  = RomHeader.Raw;\r
-            break;\r
-          } else {\r
-            //\r
-            // case 1.2: meets OpRom 2.x\r
-            //           Store it and try to find the OpRom 3.0\r
-            //\r
-            BackupImage = RomHeader.Raw;\r
-          }\r
-        } else {\r
-          //\r
-          // Case 2: CSM16 2.x\r
-          //\r
-          if (Pcir->Revision >= 3) {\r
-            //\r
-            // case 2.1: meets OpRom 3.0\r
-            //           Store it and try to find the OpRom 2.x\r
-            //\r
-            BackupImage = RomHeader.Raw;\r
-          } else {\r
-            //\r
-            // case 2.2: meets OpRom 2.x\r
-            //           Perfect!!!\r
-            //\r
-            BestImage   = RomHeader.Raw;\r
-            break;\r
-          }\r
-        }\r
-      } else {\r
-        DEBUG ((EFI_D_ERROR, "GetPciLegacyRom - OpRom not match (%04x-%04x)\n", (UINTN)VendorId, (UINTN)DeviceId));\r
-      }\r
-    }\r
-\r
-    if ((Pcir->Indicator & 0x80) == 0x80) {\r
-      break;\r
-    } else {\r
-      RomHeader.Raw += 512 * Pcir->ImageLength;\r
-    }\r
-  }\r
-\r
-  if (BestImage == NULL) {\r
-    if (BackupImage == NULL) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-    //\r
-    // The versions of CSM16 and OpRom don't match exactly\r
-    //\r
-    BestImage = BackupImage;\r
-  }\r
-  RomHeader.Raw = BestImage;\r
-  Pcir = (PCI_3_0_DATA_STRUCTURE *) (RomHeader.Raw + RomHeader.Generic->PcirOffset);\r
-  *Rom       = BestImage;\r
-  *ImageSize = Pcir->ImageLength * 512;\r
-\r
-  if (MaxRuntimeImageLength != NULL) {\r
-    if (Pcir->Revision < 3) {\r
-      *MaxRuntimeImageLength = 0;\r
-    } else {\r
-      *MaxRuntimeImageLength = Pcir->MaxRuntimeImageLength * 512;\r
-    }\r
-  }\r
-\r
-  if (OpRomRevision != NULL) {\r
-    //\r
-    // Optional return PCI Data Structure revision\r
-    //\r
-    if (Pcir->Length >= 0x1C) {\r
-      *OpRomRevision = Pcir->Revision;\r
-    } else {\r
-      *OpRomRevision = 0;\r
-    }\r
-  }\r
-\r
-  if (ConfigUtilityCodeHeader != NULL) {\r
-    //\r
-    // Optional return ConfigUtilityCodeHeaderOffset supported by the PC-AT ROM\r
-    //\r
-    if ((Pcir->Revision < 3) || (Pcir->ConfigUtilityCodeHeaderOffset == 0)) {\r
-      *ConfigUtilityCodeHeader = NULL;\r
-    } else {\r
-      *ConfigUtilityCodeHeader = RomHeader.Raw + Pcir->ConfigUtilityCodeHeaderOffset;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Build a table of bridge info for PIRQ translation.\r
-\r
-  @param  RoutingTable         RoutingTable obtained from Platform.\r
-  @param  RoutingTableEntries  Number of RoutingTable entries.\r
-\r
-  @retval EFI_SUCCESS          New Subordinate bus.\r
-  @retval EFI_NOT_FOUND        No more Subordinate busses.\r
-\r
-**/\r
-EFI_STATUS\r
-CreateBridgeTable (\r
-  IN EFI_LEGACY_IRQ_ROUTING_ENTRY         *RoutingTable,\r
-  IN UINTN                                RoutingTableEntries\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-  UINTN               HandleCount;\r
-  EFI_HANDLE          *HandleBuffer;\r
-  UINTN               BridgeIndex;\r
-  UINTN               Index;\r
-  UINTN               Index1;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-  PCI_TYPE01          PciConfigHeader;\r
-  BRIDGE_TABLE        SlotBridges[MAX_BRIDGE_INDEX];\r
-  UINTN               SlotBridgeIndex;\r
-\r
-  BridgeIndex = 0x00;\r
-  SlotBridgeIndex = 0x00;\r
-\r
-  //\r
-  // Assumption is table is built from low bus to high bus numbers.\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    PciIo->Pci.Read (\r
-                 PciIo,\r
-                 EfiPciIoWidthUint32,\r
-                 0,\r
-                 sizeof (PciConfigHeader) / sizeof (UINT32),\r
-                 &PciConfigHeader\r
-                 );\r
-\r
-    if (IS_PCI_P2P (&PciConfigHeader) && (BridgeIndex < MAX_BRIDGE_INDEX)) {\r
-      PciIo->GetLocation (\r
-               PciIo,\r
-               &Bridges[BridgeIndex].PciSegment,\r
-               &Bridges[BridgeIndex].PciBus,\r
-               &Bridges[BridgeIndex].PciDevice,\r
-               &Bridges[BridgeIndex].PciFunction\r
-               );\r
-\r
-      Bridges[BridgeIndex].PrimaryBus     = PciConfigHeader.Bridge.PrimaryBus;\r
-\r
-      Bridges[BridgeIndex].SecondaryBus   = PciConfigHeader.Bridge.SecondaryBus;\r
-\r
-      Bridges[BridgeIndex].SubordinateBus = PciConfigHeader.Bridge.SubordinateBus;\r
-\r
-      for (Index1 = 0; Index1 < RoutingTableEntries; Index1++){\r
-        //\r
-        // Test whether we have found the Bridge in the slot, must be the one that directly interfaced to the board\r
-        // Once we find one, store it in the SlotBridges[]\r
-        //\r
-        if ((RoutingTable[Index1].Slot != 0) && (Bridges[BridgeIndex].PrimaryBus == RoutingTable[Index1].Bus)\r
-           && ((Bridges[BridgeIndex].PciDevice << 3) == RoutingTable[Index1].Device)) {\r
-          CopyMem (&SlotBridges[SlotBridgeIndex], &Bridges[BridgeIndex], sizeof (BRIDGE_TABLE));\r
-          SlotBridgeIndex++;\r
-\r
-          break;\r
-        }\r
-      }\r
-\r
-      ++BridgeIndex;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Pack up Bridges by removing those useless ones\r
-  //\r
-  for (Index = 0; Index < BridgeIndex;){\r
-    for (Index1 = 0; Index1 < SlotBridgeIndex; Index1++) {\r
-      if (((Bridges[Index].PciBus == SlotBridges[Index1].PrimaryBus) && (Bridges[Index].PciDevice == SlotBridges[Index1].PciDevice)) ||\r
-        ((Bridges[Index].PciBus >= SlotBridges[Index1].SecondaryBus) && (Bridges[Index].PciBus <= SlotBridges[Index1].SubordinateBus))) {\r
-        //\r
-        // We have found one that meets our criteria\r
-        //\r
-        Index++;\r
-        break;\r
-      }\r
-    }\r
-\r
-    //\r
-    // This one doesn't meet criteria, pack it\r
-    //\r
-    if (Index1 >= SlotBridgeIndex) {\r
-      for (Index1 = Index; BridgeIndex > 1 && Index1 < BridgeIndex - 1 ; Index1++) {\r
-        CopyMem (&Bridges[Index1], &Bridges[Index1 + 1], sizeof (BRIDGE_TABLE));\r
-      }\r
-\r
-      BridgeIndex--;\r
-    }\r
-  }\r
-\r
-  NumberOfBridges = BridgeIndex;\r
-\r
-  //\r
-  // Sort bridges low to high by Secondary bus followed by subordinate bus\r
-  //\r
-  if (NumberOfBridges > 1) {\r
-    Index = 0;\r
-    do {\r
-      SortedBridgeIndex[Index] = Index;\r
-      ++Index;\r
-    } while (Index < NumberOfBridges);\r
-\r
-    for (Index = 0; Index < NumberOfBridges - 1; Index++) {\r
-      for (Index1 = Index + 1; Index1 < NumberOfBridges; Index1++) {\r
-        if (Bridges[Index].SecondaryBus > Bridges[Index1].SecondaryBus) {\r
-          SortedBridgeIndex[Index]  = Index1;\r
-          SortedBridgeIndex[Index1] = Index;\r
-        }\r
-\r
-        if ((Bridges[Index].SecondaryBus == Bridges[Index1].SecondaryBus) &&\r
-            (Bridges[Index].SubordinateBus > Bridges[Index1].SubordinateBus)\r
-            ) {\r
-          SortedBridgeIndex[Index]  = Index1;\r
-          SortedBridgeIndex[Index1] = Index;\r
-        }\r
-      }\r
-    }\r
-  }\r
-  FreePool (HandleBuffer);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Find base Bridge for device.\r
-\r
-  @param  Private                Legacy  BIOS Instance data\r
-  @param  PciBus                 Input = Bus of device.\r
-  @param  PciDevice              Input = Device.\r
-  @param  RoutingTable           The platform specific routing table\r
-  @param  RoutingTableEntries    Number of entries in table\r
-\r
-  @retval EFI_SUCCESS            At base bus.\r
-  @retval EFI_NOT_FOUND          Behind a bridge.\r
-\r
-**/\r
-EFI_STATUS\r
-GetBaseBus (\r
-  IN  LEGACY_BIOS_INSTANCE        *Private,\r
-  IN UINTN                        PciBus,\r
-  IN UINTN                        PciDevice,\r
-  IN EFI_LEGACY_IRQ_ROUTING_ENTRY *RoutingTable,\r
-  IN UINTN                        RoutingTableEntries\r
-  )\r
-{\r
-  UINTN Index;\r
-  for (Index = 0; Index < RoutingTableEntries; Index++) {\r
-    if ((RoutingTable[Index].Bus == PciBus) && (RoutingTable[Index].Device == (PciDevice << 3))) {\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Translate PIRQ through busses\r
-\r
-  @param  Private              Legacy  BIOS Instance data\r
-  @param  PciBus               Input = Bus of device. Output = Translated Bus\r
-  @param  PciDevice            Input = Device. Output = Translated Device\r
-  @param  PciFunction          Input = Function. Output = Translated Function\r
-  @param  PirqIndex            Input = Original PIRQ index. If single function\r
-                                  device then 0, otherwise 0-3.\r
-                               Output = Translated Index\r
-\r
-  @retval EFI_SUCCESS          Pirq successfully translated.\r
-  @retval EFI_NOT_FOUND        The device is not behind any known bridge.\r
-\r
-**/\r
-EFI_STATUS\r
-TranslateBusPirq (\r
-  IN  LEGACY_BIOS_INSTANCE            *Private,\r
-  IN OUT UINTN                        *PciBus,\r
-  IN OUT UINTN                        *PciDevice,\r
-  IN OUT UINTN                        *PciFunction,\r
-  IN OUT UINT8                        *PirqIndex\r
-  )\r
-{\r
-  /*\r
-  This routine traverses the PCI busses from base slot\r
-  and translates the PIRQ register to the appropriate one.\r
-\r
-  Example:\r
-\r
-  Bus 0, Device 1 is PCI-PCI bridge that all PCI slots reside on.\r
-    Primary bus# = 0\r
-    Secondary bus # = 1\r
-    Subordinate bus # is highest bus # behind this bus\r
-       Bus 1, Device 0 is Slot 0 and is not a bridge.\r
-       Bus 1, Device 1 is Slot 1 and is a bridge.\r
-         Slot PIRQ routing is A,B,C,D.\r
-         Primary bus # = 1\r
-         Secondary bus # = 2\r
-         Subordinate bus # = 5\r
-            Bus 2, Device 6 is a bridge. It has no bridges behind it.\r
-              Primary bus # = 2\r
-              Secondary bus # = 3\r
-              Subordinate bus # = 3\r
-              Bridge PIRQ routing is C,D,A,B\r
-            Bus 2, Device 7 is a bridge. It has 1 bridge behind it.\r
-              Primary bus # = 2\r
-              Secondary bus = 4   Device 6 takes bus 2.\r
-              Subordinate bus = 5.\r
-              Bridge PIRQ routing is D,A,B,C\r
-                 Bus 4, Device 2 is a bridge. It has no bridges behind it.\r
-                   Primary bus # = 4\r
-                   Secondary bus # = 5\r
-                   Subordinate bus = 5\r
-                   Bridge PIRQ routing is B,C,D,A\r
-                      Bus 5, Device 1 is to be programmed.\r
-                         Device PIRQ routing is C,D,A,B\r
-\r
-\r
-Search busses starting from slot bus for final bus >= Secondary bus and\r
-final bus <= Suborninate bus. Assumption is bus entries increase in bus\r
-number.\r
-Starting PIRQ is A,B,C,D.\r
-Bus 2, Device 7 satisfies search criteria. Rotate (A,B,C,D) left by device\r
-  7 modulo 4 giving (D,A,B,C).\r
-Bus 4, Device 2 satisfies search criteria. Rotate (D,A,B,C) left by 2 giving\r
-  (B,C,D,A).\r
-No other busses match criteria. Device to be programmed is Bus 5, Device 1.\r
-Rotate (B,C,D,A) by 1 giving C,D,A,B. Translated PIRQ is C.\r
-\r
-*/\r
-  UINTN LocalBus;\r
-  UINTN LocalDevice;\r
-  UINTN BaseBus;\r
-  UINTN BaseDevice;\r
-  UINTN BaseFunction;\r
-  UINT8 LocalPirqIndex;\r
-  BOOLEAN BaseIndexFlag;\r
-  UINTN BridgeIndex;\r
-  UINTN SBridgeIndex;\r
-  BaseIndexFlag   = FALSE;\r
-  BridgeIndex     = 0x00;\r
-\r
-  LocalPirqIndex  = *PirqIndex;\r
-  LocalBus        = *PciBus;\r
-  LocalDevice     = *PciDevice;\r
-  BaseBus         = *PciBus;\r
-  BaseDevice      = *PciDevice;\r
-  BaseFunction    = *PciFunction;\r
-\r
-  //\r
-  // LocalPirqIndex list PIRQs in rotated fashion\r
-  // = 0  A,B,C,D\r
-  // = 1  B,C,D,A\r
-  // = 2  C,D,A,B\r
-  // = 3  D,A,B,C\r
-  //\r
-\r
-  for (BridgeIndex = 0; BridgeIndex < NumberOfBridges; BridgeIndex++) {\r
-    SBridgeIndex = SortedBridgeIndex[BridgeIndex];\r
-    //\r
-    // Check if device behind this bridge\r
-    //\r
-    if ((LocalBus >= Bridges[SBridgeIndex].SecondaryBus) && (LocalBus <= Bridges[SBridgeIndex].SubordinateBus)) {\r
-      //\r
-      // If BaseIndexFlag = FALSE then have found base bridge, i.e\r
-      // bridge in slot. Save info for use by IRQ routing table.\r
-      //\r
-      if (!BaseIndexFlag) {\r
-        BaseBus       = Bridges[SBridgeIndex].PciBus;\r
-        BaseDevice    = Bridges[SBridgeIndex].PciDevice;\r
-        BaseFunction  = Bridges[SBridgeIndex].PciFunction;\r
-        BaseIndexFlag = TRUE;\r
-      } else {\r
-        LocalPirqIndex = (UINT8) ((LocalPirqIndex + (UINT8)Bridges[SBridgeIndex].PciDevice)%4);\r
-      }\r
-\r
-      //\r
-      // Check if at device. If not get new PCI location & PIRQ\r
-      //\r
-      if (Bridges[SBridgeIndex].SecondaryBus == (UINT8) LocalBus) {\r
-        //\r
-        // Translate PIRQ\r
-        //\r
-        LocalPirqIndex = (UINT8) ((LocalPirqIndex + (UINT8) (LocalDevice)) % 4);\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // In case we fail to find the Bridge just above us, this is some potential error and we want to warn the user\r
-  //\r
-  if(BridgeIndex >= NumberOfBridges){\r
-    DEBUG ((EFI_D_ERROR, "Cannot Find IRQ Routing for Bus %d, Device %d, Function %d\n", *PciBus, *PciDevice, *PciFunction));\r
-  }\r
-\r
-  *PirqIndex    = LocalPirqIndex;\r
-  *PciBus       = BaseBus;\r
-  *PciDevice    = BaseDevice;\r
-  *PciFunction  = BaseFunction;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Copy the $PIR table as required.\r
-\r
-  @param  Private                Legacy  BIOS Instance data\r
-  @param  RoutingTable           Pointer to IRQ routing table\r
-  @param  RoutingTableEntries    IRQ routing table entries\r
-  @param  PirqTable              Pointer to $PIR table\r
-  @param  PirqTableSize          Length of table\r
-\r
-**/\r
-VOID\r
-CopyPirqTable (\r
-  IN  LEGACY_BIOS_INSTANCE                *Private,\r
-  IN EFI_LEGACY_IRQ_ROUTING_ENTRY         *RoutingTable,\r
-  IN UINTN                                RoutingTableEntries,\r
-  IN EFI_LEGACY_PIRQ_TABLE_HEADER         *PirqTable,\r
-  IN UINTN                                PirqTableSize\r
-  )\r
-{\r
-  EFI_IA32_REGISTER_SET Regs;\r
-  UINT32                Granularity;\r
-\r
-  //\r
-  // Copy $PIR table, if it exists.\r
-  //\r
-  if (PirqTable != NULL) {\r
-    Private->LegacyRegion->UnLock (\r
-                            Private->LegacyRegion,\r
-                            0xE0000,\r
-                            0x20000,\r
-                            &Granularity\r
-                            );\r
-\r
-    Private->InternalIrqRoutingTable  = RoutingTable;\r
-    Private->NumberIrqRoutingEntries  = (UINT16) (RoutingTableEntries);\r
-    ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));\r
-\r
-    Regs.X.AX = Legacy16GetTableAddress;\r
-    Regs.X.CX = (UINT16) PirqTableSize;\r
-    //\r
-    // Allocate at F segment according to PCI IRQ Routing Table Specification\r
-    //\r
-    Regs.X.BX = (UINT16) 0x1;\r
-    //\r
-    // 16-byte boundary alignment requirement according to\r
-    // PCI IRQ Routing Table Specification\r
-    //\r
-    Regs.X.DX = 0x10;\r
-    Private->LegacyBios.FarCall86 (\r
-      &Private->LegacyBios,\r
-      Private->Legacy16CallSegment,\r
-      Private->Legacy16CallOffset,\r
-      &Regs,\r
-      NULL,\r
-      0\r
-      );\r
-\r
-    Private->Legacy16Table->IrqRoutingTablePointer = (UINT32) (Regs.X.DS * 16 + Regs.X.BX);\r
-    if (Regs.X.AX != 0) {\r
-      DEBUG ((EFI_D_ERROR, "PIRQ table length insufficient - %x\n", PirqTableSize));\r
-    } else {\r
-      DEBUG ((EFI_D_INFO, "PIRQ table in legacy region - %x\n", Private->Legacy16Table->IrqRoutingTablePointer));\r
-      Private->Legacy16Table->IrqRoutingTableLength = (UINT32)PirqTableSize;\r
-      CopyMem (\r
-        (VOID *) (UINTN)Private->Legacy16Table->IrqRoutingTablePointer,\r
-        PirqTable,\r
-        PirqTableSize\r
-        );\r
-    }\r
-\r
-    Private->Cpu->FlushDataCache (Private->Cpu, 0xE0000, 0x20000, EfiCpuFlushTypeWriteBackInvalidate);\r
-    Private->LegacyRegion->Lock (\r
-                             Private->LegacyRegion,\r
-                             0xE0000,\r
-                             0x20000,\r
-                             &Granularity\r
-                             );\r
-  }\r
-\r
-  Private->PciInterruptLine = TRUE;\r
-  mHandleCount              = 0;\r
-}\r
-\r
-/**\r
-  Dump EFI_LEGACY_INSTALL_PCI_HANDLER structure information.\r
-\r
-  @param  PciHandle               The pointer to EFI_LEGACY_INSTALL_PCI_HANDLER structure\r
-\r
-**/\r
-VOID\r
-DumpPciHandle (\r
-  IN EFI_LEGACY_INSTALL_PCI_HANDLER  *PciHandle\r
-  )\r
-{\r
-  DEBUG ((EFI_D_INFO, "PciBus             - %02x\n", (UINTN)PciHandle->PciBus));\r
-  DEBUG ((EFI_D_INFO, "PciDeviceFun       - %02x\n", (UINTN)PciHandle->PciDeviceFun));\r
-  DEBUG ((EFI_D_INFO, "PciSegment         - %02x\n", (UINTN)PciHandle->PciSegment));\r
-  DEBUG ((EFI_D_INFO, "PciClass           - %02x\n", (UINTN)PciHandle->PciClass));\r
-  DEBUG ((EFI_D_INFO, "PciSubclass        - %02x\n", (UINTN)PciHandle->PciSubclass));\r
-  DEBUG ((EFI_D_INFO, "PciInterface       - %02x\n", (UINTN)PciHandle->PciInterface));\r
-\r
-  DEBUG ((EFI_D_INFO, "PrimaryIrq         - %02x\n", (UINTN)PciHandle->PrimaryIrq));\r
-  DEBUG ((EFI_D_INFO, "PrimaryReserved    - %02x\n", (UINTN)PciHandle->PrimaryReserved));\r
-  DEBUG ((EFI_D_INFO, "PrimaryControl     - %04x\n", (UINTN)PciHandle->PrimaryControl));\r
-  DEBUG ((EFI_D_INFO, "PrimaryBase        - %04x\n", (UINTN)PciHandle->PrimaryBase));\r
-  DEBUG ((EFI_D_INFO, "PrimaryBusMaster   - %04x\n", (UINTN)PciHandle->PrimaryBusMaster));\r
-\r
-  DEBUG ((EFI_D_INFO, "SecondaryIrq       - %02x\n", (UINTN)PciHandle->SecondaryIrq));\r
-  DEBUG ((EFI_D_INFO, "SecondaryReserved  - %02x\n", (UINTN)PciHandle->SecondaryReserved));\r
-  DEBUG ((EFI_D_INFO, "SecondaryControl   - %04x\n", (UINTN)PciHandle->SecondaryControl));\r
-  DEBUG ((EFI_D_INFO, "SecondaryBase      - %04x\n", (UINTN)PciHandle->SecondaryBase));\r
-  DEBUG ((EFI_D_INFO, "SecondaryBusMaster - %04x\n", (UINTN)PciHandle->SecondaryBusMaster));\r
-  return;\r
-}\r
-\r
-/**\r
-  Copy the $PIR table as required.\r
-\r
-  @param  Private                Legacy  BIOS Instance data\r
-  @param  PciIo                  Pointer to PCI_IO protocol\r
-  @param  PciIrq                 Pci IRQ number\r
-  @param  PciConfigHeader        Type00 Pci configuration header\r
-\r
-**/\r
-VOID\r
-InstallLegacyIrqHandler (\r
-  IN LEGACY_BIOS_INSTANCE       *Private,\r
-  IN EFI_PCI_IO_PROTOCOL        *PciIo,\r
-  IN UINT8                      PciIrq,\r
-  IN PCI_TYPE00                 *PciConfigHeader\r
-  )\r
-{\r
-  EFI_IA32_REGISTER_SET     Regs;\r
-  UINT16                    LegMask;\r
-  UINTN                     PciSegment;\r
-  UINTN                     PciBus;\r
-  UINTN                     PciDevice;\r
-  UINTN                     PciFunction;\r
-  EFI_LEGACY_8259_PROTOCOL  *Legacy8259;\r
-  UINT16                    PrimaryMaster;\r
-  UINT16                    SecondaryMaster;\r
-  UINTN                     TempData;\r
-  UINTN                     RegisterAddress;\r
-  UINT32                    Granularity;\r
-\r
-  PrimaryMaster   = 0;\r
-  SecondaryMaster = 0;\r
-  Legacy8259      = Private->Legacy8259;\r
-  //\r
-  // Disable interrupt in PIC, in case shared, to prevent an\r
-  // interrupt from occuring.\r
-  //\r
-  Legacy8259->GetMask (\r
-                Legacy8259,\r
-                &LegMask,\r
-                NULL,\r
-                NULL,\r
-                NULL\r
-                );\r
-\r
-  LegMask = (UINT16) (LegMask | (UINT16) (1 << PciIrq));\r
-\r
-  Legacy8259->SetMask (\r
-                Legacy8259,\r
-                &LegMask,\r
-                NULL,\r
-                NULL,\r
-                NULL\r
-                );\r
-\r
-  PciIo->GetLocation (\r
-          PciIo,\r
-          &PciSegment,\r
-          &PciBus,\r
-          &PciDevice,\r
-          &PciFunction\r
-          );\r
-  Private->IntThunk->PciHandler.PciBus              = (UINT8) PciBus;\r
-  Private->IntThunk->PciHandler.PciDeviceFun        = (UINT8) ((PciDevice << 3) + PciFunction);\r
-  Private->IntThunk->PciHandler.PciSegment          = (UINT8) PciSegment;\r
-  Private->IntThunk->PciHandler.PciClass            = PciConfigHeader->Hdr.ClassCode[2];\r
-  Private->IntThunk->PciHandler.PciSubclass         = PciConfigHeader->Hdr.ClassCode[1];\r
-  Private->IntThunk->PciHandler.PciInterface        = PciConfigHeader->Hdr.ClassCode[0];\r
-\r
-  //\r
-  // Use native mode base address registers in two cases:\r
-  // 1. Programming Interface (PI) register indicates Primary Controller is\r
-  // in native mode OR\r
-  // 2. PCI device Sub Class Code is not IDE\r
-  //\r
-  Private->IntThunk->PciHandler.PrimaryBusMaster  = (UINT16)(PciConfigHeader->Device.Bar[4] & 0xfffc);\r
-  if (((PciConfigHeader->Hdr.ClassCode[0] & 0x01) != 0) || (PciConfigHeader->Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE)) {\r
-    Private->IntThunk->PciHandler.PrimaryIrq      = PciIrq;\r
-    Private->IntThunk->PciHandler.PrimaryBase     = (UINT16) (PciConfigHeader->Device.Bar[0] & 0xfffc);\r
-    Private->IntThunk->PciHandler.PrimaryControl  = (UINT16) ((PciConfigHeader->Device.Bar[1] & 0xfffc) + 2);\r
-  } else {\r
-    Private->IntThunk->PciHandler.PrimaryIrq      = 14;\r
-    Private->IntThunk->PciHandler.PrimaryBase     = 0x1f0;\r
-    Private->IntThunk->PciHandler.PrimaryControl  = 0x3f6;\r
-  }\r
-  //\r
-  // Secondary controller data\r
-  //\r
-  if (Private->IntThunk->PciHandler.PrimaryBusMaster != 0) {\r
-    Private->IntThunk->PciHandler.SecondaryBusMaster  = (UINT16) ((PciConfigHeader->Device.Bar[4] & 0xfffc) + 8);\r
-    PrimaryMaster = (UINT16) (Private->IntThunk->PciHandler.PrimaryBusMaster + 2);\r
-    SecondaryMaster = (UINT16) (Private->IntThunk->PciHandler.SecondaryBusMaster + 2);\r
-\r
-    //\r
-    // Clear pending interrupts in Bus Master registers\r
-    //\r
-    IoWrite16 (PrimaryMaster, 0x04);\r
-    IoWrite16 (SecondaryMaster, 0x04);\r
-\r
-  }\r
-\r
-  //\r
-  // Use native mode base address registers in two cases:\r
-  // 1. Programming Interface (PI) register indicates Secondary Controller is\r
-  // in native mode OR\r
-  // 2. PCI device Sub Class Code is not IDE\r
-  //\r
-  if (((PciConfigHeader->Hdr.ClassCode[0] & 0x04) != 0) || (PciConfigHeader->Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE)) {\r
-    Private->IntThunk->PciHandler.SecondaryIrq      = PciIrq;\r
-    Private->IntThunk->PciHandler.SecondaryBase     = (UINT16) (PciConfigHeader->Device.Bar[2] & 0xfffc);\r
-    Private->IntThunk->PciHandler.SecondaryControl  = (UINT16) ((PciConfigHeader->Device.Bar[3] & 0xfffc) + 2);\r
-  } else {\r
-\r
-    Private->IntThunk->PciHandler.SecondaryIrq      = 15;\r
-    Private->IntThunk->PciHandler.SecondaryBase     = 0x170;\r
-    Private->IntThunk->PciHandler.SecondaryControl  = 0x376;\r
-  }\r
-\r
-  //\r
-  // Clear pending interrupts in IDE Command Block Status reg before we\r
-  // Thunk to CSM16 below.  Don't want a pending Interrupt before we\r
-  // install the handlers as wierd corruption would occur and hang system.\r
-  //\r
-  //\r
-  // Read IDE CMD blk status reg to clear out any pending interrupts.\r
-  // Do here for Primary and Secondary IDE channels\r
-  //\r
-  RegisterAddress = (UINT16)Private->IntThunk->PciHandler.PrimaryBase + 0x07;\r
-  IoRead8 (RegisterAddress);\r
-  RegisterAddress = (UINT16)Private->IntThunk->PciHandler.SecondaryBase + 0x07;\r
-  IoRead8 (RegisterAddress);\r
-\r
-  Private->IntThunk->PciHandler.PrimaryReserved   = 0;\r
-  Private->IntThunk->PciHandler.SecondaryReserved = 0;\r
-  Private->LegacyRegion->UnLock (\r
-                           Private->LegacyRegion,\r
-                           0xE0000,\r
-                           0x20000,\r
-                           &Granularity\r
-                           );\r
-\r
-  Regs.X.AX = Legacy16InstallPciHandler;\r
-  TempData  = (UINTN) &Private->IntThunk->PciHandler;\r
-  Regs.X.ES = EFI_SEGMENT ((UINT32) TempData);\r
-  Regs.X.BX = EFI_OFFSET ((UINT32) TempData);\r
-\r
-  DumpPciHandle (&Private->IntThunk->PciHandler);\r
-\r
-  Private->LegacyBios.FarCall86 (\r
-    &Private->LegacyBios,\r
-    Private->Legacy16CallSegment,\r
-    Private->Legacy16CallOffset,\r
-    &Regs,\r
-    NULL,\r
-    0\r
-    );\r
-\r
-  Private->Cpu->FlushDataCache (Private->Cpu, 0xE0000, 0x20000, EfiCpuFlushTypeWriteBackInvalidate);\r
-  Private->LegacyRegion->Lock (\r
-                           Private->LegacyRegion,\r
-                           0xE0000,\r
-                           0x20000,\r
-                           &Granularity\r
-                           );\r
-\r
-}\r
-\r
-\r
-/**\r
-  Program the interrupt routing register in all the PCI devices. On a PC AT system\r
-  this register contains the 8259 IRQ vector that matches it's PCI interrupt.\r
-\r
-  @param  Private                Legacy  BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS            Succeed.\r
-  @retval EFI_ALREADY_STARTED    All PCI devices have been processed.\r
-\r
-**/\r
-EFI_STATUS\r
-PciProgramAllInterruptLineRegisters (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_PCI_IO_PROTOCOL               *PciIo;\r
-  EFI_LEGACY_8259_PROTOCOL          *Legacy8259;\r
-  EFI_LEGACY_INTERRUPT_PROTOCOL     *LegacyInterrupt;\r
-  EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;\r
-  UINT8                             InterruptPin;\r
-  UINTN                             Index;\r
-  UINTN                             HandleCount;\r
-  EFI_HANDLE                        *HandleBuffer;\r
-  UINTN                             MassStorageHandleCount;\r
-  EFI_HANDLE                        *MassStorageHandleBuffer;\r
-  UINTN                             MassStorageHandleIndex;\r
-  UINT8                             PciIrq;\r
-  UINT16                            Command;\r
-  UINTN                             PciSegment;\r
-  UINTN                             PciBus;\r
-  UINTN                             PciDevice;\r
-  UINTN                             PciFunction;\r
-  EFI_LEGACY_IRQ_ROUTING_ENTRY      *RoutingTable;\r
-  UINTN                             RoutingTableEntries;\r
-  UINT16                            LegMask;\r
-  UINT16                            LegEdgeLevel;\r
-  PCI_TYPE00                        PciConfigHeader;\r
-  EFI_LEGACY_PIRQ_TABLE_HEADER      *PirqTable;\r
-  UINTN                             PirqTableSize;\r
-  UINTN                             Flags;\r
-  HDD_INFO                          *HddInfo;\r
-  UINT64                            Supports;\r
-\r
-  //\r
-  // Note - This routine use to return immediately if Private->PciInterruptLine\r
-  //        was true. Routine changed since resets etc can cause not all\r
-  //        PciIo protocols to be registered the first time through.\r
-  // New algorithm is to do the copy $PIR table on first pass and save\r
-  // HandleCount on first pass. If subsequent passes LocateHandleBuffer gives\r
-  // a larger handle count then proceed with body of function else return\r
-  // EFI_ALREADY_STARTED. In addition check if PCI device InterruptLine != 0.\r
-  // If zero then function unprogrammed else skip function.\r
-  //\r
-  Legacy8259          = Private->Legacy8259;\r
-  LegacyInterrupt     = Private->LegacyInterrupt;\r
-  LegacyBiosPlatform  = Private->LegacyBiosPlatform;\r
-\r
-  LegacyBiosPlatform->GetRoutingTable (\r
-                        Private->LegacyBiosPlatform,\r
-                        (VOID *) &RoutingTable,\r
-                        &RoutingTableEntries,\r
-                        (VOID *) &PirqTable,\r
-                        &PirqTableSize,\r
-                        NULL,\r
-                        NULL\r
-                        );\r
-  CreateBridgeTable (RoutingTable, RoutingTableEntries);\r
-\r
-  if (!Private->PciInterruptLine) {\r
-    CopyPirqTable (\r
-      Private,\r
-      RoutingTable,\r
-      RoutingTableEntries,\r
-      PirqTable,\r
-      PirqTableSize\r
-      );\r
-  }\r
-\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  if (HandleCount == mHandleCount) {\r
-    FreePool (HandleBuffer);\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-\r
-  if (mHandleCount == 0x00) {\r
-    mHandleCount = HandleCount;\r
-  }\r
-\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    //\r
-    // If VGA then only do VGA to allow drives fore time to spin up\r
-    // otherwise assign PCI IRQs to all potential devices.\r
-    //\r
-    if ((mVgaInstallationInProgress) && (HandleBuffer[Index] != mVgaHandle)) {\r
-      continue;\r
-    } else {\r
-      //\r
-      // Force code to go through all handles next time called if video.\r
-      // This will catch case where HandleCount doesn't change but want\r
-      //  to get drive info etc.\r
-      //\r
-      mHandleCount = 0x00;\r
-    }\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Test whether the device can be enabled or not.\r
-    // If it can't be enabled, then just skip it to avoid further operation.\r
-    //\r
-    PciIo->Pci.Read (\r
-                 PciIo,\r
-                 EfiPciIoWidthUint32,\r
-                 0,\r
-                 sizeof (PciConfigHeader) / sizeof (UINT32),\r
-                 &PciConfigHeader\r
-                 );\r
-    Command = PciConfigHeader.Hdr.Command;\r
-\r
-    //\r
-    // Note PciIo->Attributes does not program the PCI command register\r
-    //\r
-    Status = PciIo->Attributes (\r
-                      PciIo,\r
-                      EfiPciIoAttributeOperationSupported,\r
-                      0,\r
-                      &Supports\r
-                      );\r
-    if (!EFI_ERROR (Status)) {\r
-      Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
-      Status = PciIo->Attributes (\r
-                        PciIo,\r
-                        EfiPciIoAttributeOperationEnable,\r
-                        Supports,\r
-                        NULL\r
-                        );\r
-    }\r
-    PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x04, 1, &Command);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    InterruptPin = PciConfigHeader.Device.InterruptPin;\r
-\r
-    if ((InterruptPin != 0) && (PciConfigHeader.Device.InterruptLine == PCI_INT_LINE_UNKNOWN)) {\r
-      PciIo->GetLocation (\r
-               PciIo,\r
-               &PciSegment,\r
-               &PciBus,\r
-               &PciDevice,\r
-               &PciFunction\r
-               );\r
-      //\r
-      // Translate PIRQ index back thru busses to slot bus with InterruptPin\r
-      // zero based\r
-      //\r
-      InterruptPin -= 1;\r
-\r
-      Status = GetBaseBus (\r
-                 Private,\r
-                 PciBus,\r
-                 PciDevice,\r
-                 RoutingTable,\r
-                 RoutingTableEntries\r
-                 );\r
-\r
-      if (Status == EFI_NOT_FOUND) {\r
-        TranslateBusPirq (\r
-          Private,\r
-          &PciBus,\r
-          &PciDevice,\r
-          &PciFunction,\r
-          &InterruptPin\r
-          );\r
-      }\r
-      //\r
-      // Translate InterruptPin(0-3) into PIRQ\r
-      //\r
-      Status = LegacyBiosPlatform->TranslatePirq (\r
-                                     LegacyBiosPlatform,\r
-                                     PciBus,\r
-                                     (PciDevice << 3),\r
-                                     PciFunction,\r
-                                     &InterruptPin,\r
-                                     &PciIrq\r
-                                     );\r
-      //\r
-      // TranslatePirq() should never fail or we are in trouble\r
-      // If it does return failure status, check your PIRQ routing table to see if some item is missing or incorrect\r
-      //\r
-      if (EFI_ERROR (Status)) {\r
-        DEBUG ((EFI_D_ERROR, "Translate Pirq Failed - Status = %r\n ", Status));\r
-        continue;\r
-      }\r
-\r
-      LegacyInterrupt->WritePirq (\r
-                         LegacyInterrupt,\r
-                         InterruptPin,\r
-                         PciIrq\r
-                         );\r
-\r
-      //\r
-      // Check if device has an OPROM associated with it.\r
-      // If not invoke special 16-bit function, to allow 16-bit\r
-      // code to install an interrupt handler.\r
-      //\r
-      Status = LegacyBiosCheckPciRom (\r
-                 &Private->LegacyBios,\r
-                 HandleBuffer[Index],\r
-                 NULL,\r
-                 NULL,\r
-                 &Flags\r
-                 );\r
-      if ((EFI_ERROR (Status)) && (PciConfigHeader.Hdr.ClassCode[2] == PCI_CLASS_MASS_STORAGE)) {\r
-        //\r
-        // Device has no OPROM associated with it and is a mass storage\r
-        // device. It needs to have an PCI IRQ handler installed. To\r
-        // correctly install the handler we need to insure device is\r
-        // connected. The device may just have register itself but not\r
-        // been connected. Re-read PCI config space after as it can\r
-        // change\r
-        //\r
-        //\r
-        // Get IDE Handle. If matches handle then skip ConnectController\r
-        // since ConnectController may force native mode and we don't\r
-        // want that for primary IDE controller\r
-        //\r
-        MassStorageHandleCount = 0;\r
-        MassStorageHandleBuffer = NULL;\r
-        LegacyBiosPlatform->GetPlatformHandle (\r
-                              Private->LegacyBiosPlatform,\r
-                              EfiGetPlatformIdeHandle,\r
-                              0,\r
-                              &MassStorageHandleBuffer,\r
-                              &MassStorageHandleCount,\r
-                              NULL\r
-                              );\r
-\r
-        HddInfo = &Private->IntThunk->EfiToLegacy16BootTable.HddInfo[0];\r
-\r
-        LegacyBiosBuildIdeData (Private, &HddInfo, 0);\r
-        PciIo->Pci.Read (\r
-                     PciIo,\r
-                     EfiPciIoWidthUint32,\r
-                     0,\r
-                     sizeof (PciConfigHeader) / sizeof (UINT32),\r
-                     &PciConfigHeader\r
-                     );\r
-\r
-        for (MassStorageHandleIndex = 0; MassStorageHandleIndex < MassStorageHandleCount; MassStorageHandleIndex++) {\r
-          if (MassStorageHandleBuffer[MassStorageHandleIndex] == HandleBuffer[Index]) {\r
-            //\r
-            // InstallLegacyIrqHandler according to Platform requirement\r
-            //\r
-            InstallLegacyIrqHandler (\r
-              Private,\r
-              PciIo,\r
-              PciIrq,\r
-              &PciConfigHeader\r
-              );\r
-            break;\r
-          }\r
-        }\r
-      }\r
-      //\r
-      // Write InterruptPin and enable 8259.\r
-      //\r
-      PciIo->Pci.Write (\r
-                   PciIo,\r
-                   EfiPciIoWidthUint8,\r
-                   0x3c,\r
-                   1,\r
-                   &PciIrq\r
-                   );\r
-      Private->IntThunk->EfiToLegacy16BootTable.PciIrqMask = (UINT16) (Private->IntThunk->EfiToLegacy16BootTable.PciIrqMask | (UINT16) (1 << PciIrq));\r
-\r
-      Legacy8259->GetMask (\r
-                    Legacy8259,\r
-                    &LegMask,\r
-                    &LegEdgeLevel,\r
-                    NULL,\r
-                    NULL\r
-                    );\r
-\r
-      LegMask       = (UINT16) (LegMask & (UINT16)~(1 << PciIrq));\r
-      LegEdgeLevel  = (UINT16) (LegEdgeLevel | (UINT16) (1 << PciIrq));\r
-      Legacy8259->SetMask (\r
-                    Legacy8259,\r
-                    &LegMask,\r
-                    &LegEdgeLevel,\r
-                    NULL,\r
-                    NULL\r
-                    );\r
-    }\r
-  }\r
-  FreePool (HandleBuffer);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Find & verify PnP Expansion header in ROM image\r
-\r
-  @param  Private                Protocol instance pointer.\r
-  @param  FirstHeader            1 = Find first header, 0 = Find successive headers\r
-  @param  PnpPtr                 Input Rom start if FirstHeader =1, Current Header\r
-                                 otherwise Output Next header, if it exists\r
-\r
-  @retval EFI_SUCCESS            Next Header found at BasePnpPtr\r
-  @retval EFI_NOT_FOUND          No more headers\r
-\r
-**/\r
-EFI_STATUS\r
-FindNextPnpExpansionHeader (\r
-  IN  LEGACY_BIOS_INSTANCE             *Private,\r
-  IN BOOLEAN                           FirstHeader,\r
-  IN OUT LEGACY_PNP_EXPANSION_HEADER   **PnpPtr\r
-\r
-  )\r
-{\r
-  UINTN                       TempData;\r
-  LEGACY_PNP_EXPANSION_HEADER *LocalPnpPtr;\r
-  LocalPnpPtr = *PnpPtr;\r
-  if (FirstHeader == FIRST_INSTANCE) {\r
-    mBasePnpPtr     = LocalPnpPtr;\r
-    mBbsRomSegment  = (UINT16) ((UINTN) mBasePnpPtr >> 4);\r
-    //\r
-    // Offset 0x1a gives offset to PnP expansion header for the first\r
-    // instance, there after the structure gives the offset to the next\r
-    // structure\r
-    //\r
-    LocalPnpPtr = (LEGACY_PNP_EXPANSION_HEADER *) ((UINT8 *) LocalPnpPtr + 0x1a);\r
-    TempData    = (*((UINT16 *) LocalPnpPtr));\r
-  } else {\r
-    TempData = (UINT16) LocalPnpPtr->NextHeader;\r
-  }\r
-\r
-  LocalPnpPtr = (LEGACY_PNP_EXPANSION_HEADER *) (((UINT8 *) mBasePnpPtr + TempData));\r
-\r
-  //\r
-  // Search for PnP table in Shadowed ROM\r
-  //\r
-  *PnpPtr = LocalPnpPtr;\r
-  if (*(UINT32 *) LocalPnpPtr == SIGNATURE_32 ('$', 'P', 'n', 'P')) {\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Update list of Bev or BCV table entries.\r
-\r
-  @param  Private                Protocol instance pointer.\r
-  @param  RomStart               Table of ROM start address in RAM/ROM. PciIo  _\r
-                                 Handle to PCI IO for this device\r
-  @param  PciIo                  Instance of PCI I/O Protocol\r
-\r
-  @retval EFI_SUCCESS            Always should succeed.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateBevBcvTable (\r
-  IN  LEGACY_BIOS_INSTANCE             *Private,\r
-  IN  EFI_LEGACY_EXPANSION_ROM_HEADER  *RomStart,\r
-  IN  EFI_PCI_IO_PROTOCOL              *PciIo\r
-  )\r
-{\r
-  VOID                            *RomEnd;\r
-  BBS_TABLE                       *BbsTable;\r
-  UINTN                           BbsIndex;\r
-  EFI_LEGACY_EXPANSION_ROM_HEADER *PciPtr;\r
-  LEGACY_PNP_EXPANSION_HEADER     *PnpPtr;\r
-  BOOLEAN                         Instance;\r
-  EFI_STATUS                      Status;\r
-  UINTN                           Segment;\r
-  UINTN                           Bus;\r
-  UINTN                           Device;\r
-  UINTN                           Function;\r
-  UINT8                           Class;\r
-  UINT16                          DeviceType;\r
-  Segment     = 0;\r
-  Bus         = 0;\r
-  Device      = 0;\r
-  Function    = 0;\r
-  Class       = 0;\r
-  DeviceType  = BBS_UNKNOWN;\r
-\r
-  //\r
-  // Skip floppy and 2*onboard IDE controller entries(Master/Slave per\r
-  // controller).\r
-  //\r
-  BbsIndex  = Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;\r
-\r
-  BbsTable  = (BBS_TABLE*)(UINTN) Private->IntThunk->EfiToLegacy16BootTable.BbsTable;\r
-  PnpPtr    = (LEGACY_PNP_EXPANSION_HEADER *) RomStart;\r
-  PciPtr    = (EFI_LEGACY_EXPANSION_ROM_HEADER *) RomStart;\r
-\r
-  RomEnd    = (VOID *) (PciPtr->Size512 * 512 + (UINTN) PciPtr);\r
-  Instance  = FIRST_INSTANCE;\r
-  //\r
-  // OPROMs like PXE may not be tied to a piece of hardware and thus\r
-  // don't have a PciIo associated with them\r
-  //\r
-  if (PciIo != NULL) {\r
-    PciIo->GetLocation (\r
-             PciIo,\r
-             &Segment,\r
-             &Bus,\r
-             &Device,\r
-             &Function\r
-             );\r
-    PciIo->Pci.Read (\r
-                 PciIo,\r
-                 EfiPciIoWidthUint8,\r
-                 0x0b,\r
-                 1,\r
-                 &Class\r
-                 );\r
-\r
-    if (Class == PCI_CLASS_MASS_STORAGE) {\r
-      DeviceType = BBS_HARDDISK;\r
-    } else {\r
-      if (Class == PCI_CLASS_NETWORK) {\r
-        DeviceType = BBS_EMBED_NETWORK;\r
-      }\r
-    }\r
-  }\r
-\r
-  while (TRUE) {\r
-    Status    = FindNextPnpExpansionHeader (Private, Instance, &PnpPtr);\r
-    Instance  = NOT_FIRST_INSTANCE;\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    //\r
-    // There can be additional $PnP headers within the OPROM.\r
-    // Example: SCSI can have one per drive.\r
-    //\r
-    BbsTable[BbsIndex].BootPriority             = BBS_UNPRIORITIZED_ENTRY;\r
-    BbsTable[BbsIndex].DeviceType               = DeviceType;\r
-    BbsTable[BbsIndex].Bus                      = (UINT32) Bus;\r
-    BbsTable[BbsIndex].Device                   = (UINT32) Device;\r
-    BbsTable[BbsIndex].Function                 = (UINT32) Function;\r
-    BbsTable[BbsIndex].StatusFlags.OldPosition  = 0;\r
-    BbsTable[BbsIndex].StatusFlags.Reserved1    = 0;\r
-    BbsTable[BbsIndex].StatusFlags.Enabled      = 0;\r
-    BbsTable[BbsIndex].StatusFlags.Failed       = 0;\r
-    BbsTable[BbsIndex].StatusFlags.MediaPresent = 0;\r
-    BbsTable[BbsIndex].StatusFlags.Reserved2    = 0;\r
-    BbsTable[BbsIndex].Class                    = PnpPtr->Class;\r
-    BbsTable[BbsIndex].SubClass                 = PnpPtr->SubClass;\r
-    BbsTable[BbsIndex].DescStringOffset         = PnpPtr->ProductNamePointer;\r
-    BbsTable[BbsIndex].DescStringSegment        = mBbsRomSegment;\r
-    BbsTable[BbsIndex].MfgStringOffset          = PnpPtr->MfgPointer;\r
-    BbsTable[BbsIndex].MfgStringSegment         = mBbsRomSegment;\r
-    BbsTable[BbsIndex].BootHandlerSegment       = mBbsRomSegment;\r
-\r
-    //\r
-    // Have seen case where PXE base code have PnP expansion ROM\r
-    // header but no Bcv or Bev vectors.\r
-    //\r
-    if (PnpPtr->Bcv != 0) {\r
-      BbsTable[BbsIndex].BootHandlerOffset = PnpPtr->Bcv;\r
-      ++BbsIndex;\r
-    }\r
-\r
-    if (PnpPtr->Bev != 0) {\r
-      BbsTable[BbsIndex].BootHandlerOffset  = PnpPtr->Bev;\r
-      BbsTable[BbsIndex].DeviceType         = BBS_BEV_DEVICE;\r
-      ++BbsIndex;\r
-    }\r
-\r
-    if ((PnpPtr == (LEGACY_PNP_EXPANSION_HEADER *) PciPtr) || (PnpPtr > (LEGACY_PNP_EXPANSION_HEADER *) RomEnd)) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  BbsTable[BbsIndex].BootPriority = BBS_IGNORE_ENTRY;\r
-  Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries = (UINT32) BbsIndex;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Shadow all the PCI legacy ROMs. Use data from the Legacy BIOS Protocol\r
-  to chose the order. Skip any devices that have already have legacy\r
-  BIOS run.\r
-\r
-  @param  Private                Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS            Succeed.\r
-  @retval EFI_UNSUPPORTED        Cannot get VGA device handle.\r
-\r
-**/\r
-EFI_STATUS\r
-PciShadowRoms (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_PCI_IO_PROTOCOL               *PciIo;\r
-  PCI_TYPE00                        Pci;\r
-  UINTN                             Index;\r
-  UINTN                             HandleCount;\r
-  EFI_HANDLE                        *HandleBuffer;\r
-  EFI_HANDLE                        VgaHandle;\r
-  EFI_HANDLE                        FirstHandle;\r
-  VOID                              **RomStart;\r
-  UINTN                             Flags;\r
-  PCI_TYPE00                        PciConfigHeader;\r
-  UINT16                            *Command;\r
-  UINT64                            Supports;\r
-\r
-  //\r
-  // Make the VGA device first\r
-  //\r
-  Status = Private->LegacyBiosPlatform->GetPlatformHandle (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiGetPlatformVgaHandle,\r
-                                          0,\r
-                                          &HandleBuffer,\r
-                                          &HandleCount,\r
-                                          NULL\r
-                                          );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  VgaHandle = HandleBuffer[0];\r
-\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Place the VGA handle as first.\r
-  //\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    if (HandleBuffer[Index] == VgaHandle) {\r
-      FirstHandle         = HandleBuffer[0];\r
-      HandleBuffer[0]     = HandleBuffer[Index];\r
-      HandleBuffer[Index] = FirstHandle;\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Allocate memory to save Command WORD from each device. We do this\r
-  // to restore devices to same state as EFI after switching to legacy.\r
-  //\r
-  Command = (UINT16 *) AllocatePool (\r
-                         sizeof (UINT16) * (HandleCount + 1)\r
-                         );\r
-  if (NULL == Command) {\r
-    FreePool (HandleBuffer);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Disconnect all EFI devices first. This covers cases where alegacy BIOS\r
-  // may control multiple PCI devices.\r
-  //\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Save command register for "connect" loop\r
-    //\r
-    PciIo->Pci.Read (\r
-                 PciIo,\r
-                 EfiPciIoWidthUint32,\r
-                 0,\r
-                 sizeof (PciConfigHeader) / sizeof (UINT32),\r
-                 &PciConfigHeader\r
-                 );\r
-    Command[Index] = PciConfigHeader.Hdr.Command;\r
-    //\r
-    // Skip any device that already has a legacy ROM run\r
-    //\r
-    Status = IsLegacyRom (HandleBuffer[Index]);\r
-    if (!EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-    //\r
-    // Stop EFI Drivers with oprom.\r
-    //\r
-    gBS->DisconnectController (\r
-           HandleBuffer[Index],\r
-           NULL,\r
-           NULL\r
-           );\r
-  }\r
-  //\r
-  // For every device that has not had a legacy ROM started. Start a legacy ROM.\r
-  //\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo\r
-                    );\r
-\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Here make sure if one VGA have been shadowed,\r
-    // then wil not shadowed another one.\r
-    //\r
-    PciIo->Pci.Read (\r
-                 PciIo,\r
-                 EfiPciIoWidthUint32,\r
-                 0,\r
-                 sizeof (Pci) / sizeof (UINT32),\r
-                 &Pci\r
-                 );\r
-\r
-    //\r
-    // Only one Video OPROM can be given control in BIOS phase. If there are multiple Video devices,\r
-    // one will work in legacy mode (OPROM will be given control) and\r
-    // other Video devices will work in native mode (OS driver will handle these devices).\r
-    //\r
-    if (IS_PCI_DISPLAY (&Pci) && Index != 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // Skip any device that already has a legacy ROM run\r
-    //\r
-    Status = IsLegacyRom (HandleBuffer[Index]);\r
-    if (!EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // If legacy VBIOS Oprom has not been dispatched before, install legacy VBIOS here.\r
-    //\r
-    if (IS_PCI_DISPLAY (&Pci) && Index == 0) {\r
-      Status = LegacyBiosInstallVgaRom (Private);\r
-      //\r
-      // A return status of EFI_NOT_FOUND is considered valid (No EFI\r
-      // driver is controlling video).\r
-      //\r
-      ASSERT ((Status == EFI_SUCCESS) || (Status == EFI_NOT_FOUND));\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Install legacy ROM\r
-    //\r
-    Status = LegacyBiosInstallPciRom (\r
-               &Private->LegacyBios,\r
-               HandleBuffer[Index],\r
-               NULL,\r
-               &Flags,\r
-               NULL,\r
-               NULL,\r
-               (VOID **) &RomStart,\r
-               NULL\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      if (!((Status == EFI_UNSUPPORTED) && (Flags == NO_ROM))) {\r
-        continue;\r
-      }\r
-    }\r
-    //\r
-    // Restore Command register so legacy has same devices enabled or disabled\r
-    // as EFI.\r
-    // If Flags = NO_ROM use command register as is. This covers the\r
-    //            following cases:\r
-    //              Device has no ROMs associated with it.\r
-    //              Device has ROM associated with it but was already\r
-    //              installed.\r
-    //          = ROM_FOUND but not VALID_LEGACY_ROM, disable it.\r
-    //          = ROM_FOUND and VALID_LEGACY_ROM, enable it.\r
-    //\r
-    if ((Flags & ROM_FOUND) == ROM_FOUND) {\r
-      if ((Flags & VALID_LEGACY_ROM) == 0) {\r
-        Command[Index] = 0;\r
-      } else {\r
-        //\r
-        // For several VGAs, only one of them can be enabled.\r
-        //\r
-        Status = PciIo->Attributes (\r
-                          PciIo,\r
-                          EfiPciIoAttributeOperationSupported,\r
-                          0,\r
-                          &Supports\r
-                          );\r
-        if (!EFI_ERROR (Status)) {\r
-          Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
-          Status = PciIo->Attributes (\r
-                            PciIo,\r
-                            EfiPciIoAttributeOperationEnable,\r
-                            Supports,\r
-                            NULL\r
-                            );\r
-        }\r
-        if (!EFI_ERROR (Status)) {\r
-          Command[Index] = 0x1f;\r
-        }\r
-      }\r
-    }\r
-\r
-    PciIo->Pci.Write (\r
-                 PciIo,\r
-                 EfiPciIoWidthUint16,\r
-                 0x04,\r
-                 1,\r
-                 &Command[Index]\r
-                 );\r
-  }\r
-\r
-  FreePool (Command);\r
-  FreePool (HandleBuffer);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Test to see if a legacy PCI ROM exists for this device. Optionally return\r
-  the Legacy ROM instance for this PCI device.\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  PciHandle              The PCI PC-AT OPROM from this devices ROM BAR will\r
-                                 be loaded\r
-  @param  RomImage               Return the legacy PCI ROM for this device\r
-  @param  RomSize                Size of ROM Image\r
-  @param  Flags                  Indicates if ROM found and if PC-AT.\r
-\r
-  @retval EFI_SUCCESS            Legacy Option ROM available for this device\r
-  @retval EFI_UNSUPPORTED        Legacy Option ROM not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosCheckPciRom (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL           *This,\r
-  IN  EFI_HANDLE                        PciHandle,\r
-  OUT VOID                              **RomImage, OPTIONAL\r
-  OUT UINTN                             *RomSize, OPTIONAL\r
-  OUT UINTN                             *Flags\r
-  )\r
-{\r
-  return LegacyBiosCheckPciRomEx (\r
-           This,\r
-           PciHandle,\r
-           RomImage,\r
-           RomSize,\r
-           NULL,\r
-           Flags,\r
-           NULL,\r
-           NULL\r
-           );\r
-\r
-}\r
-\r
-/**\r
-\r
-  Routine Description:\r
-    Test to see if a legacy PCI ROM exists for this device. Optionally return\r
-    the Legacy ROM instance for this PCI device.\r
-\r
-    @param[in] This          Protocol instance pointer.\r
-    @param[in] PciHandle               The PCI PC-AT OPROM from this devices ROM BAR will be loaded\r
-    @param[out] RomImage               Return the legacy PCI ROM for this device\r
-    @param[out] RomSize                Size of ROM Image\r
-    @param[out] RuntimeImageLength     Runtime size of ROM Image\r
-    @param[out] Flags                  Indicates if ROM found and if PC-AT.\r
-    @param[out] OpromRevision          Revision of the PCI Rom\r
-    @param[out] ConfigUtilityCodeHeaderPointer of Configuration Utility Code Header\r
-\r
-    @return EFI_SUCCESS            Legacy Option ROM available for this device\r
-    @return EFI_ALREADY_STARTED    This device is already managed by its Oprom\r
-    @return EFI_UNSUPPORTED        Legacy Option ROM not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosCheckPciRomEx (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL           *This,\r
-  IN  EFI_HANDLE                        PciHandle,\r
-  OUT VOID                              **RomImage, OPTIONAL\r
-  OUT UINTN                             *RomSize, OPTIONAL\r
-  OUT UINTN                             *RuntimeImageLength, OPTIONAL\r
-  OUT UINTN                             *Flags, OPTIONAL\r
-  OUT UINT8                             *OpromRevision, OPTIONAL\r
-  OUT VOID                              **ConfigUtilityCodeHeader OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  LEGACY_BIOS_INSTANCE            *Private;\r
-  EFI_PCI_IO_PROTOCOL             *PciIo;\r
-  UINTN                           LocalRomSize;\r
-  VOID                            *LocalRomImage;\r
-  PCI_TYPE00                      PciConfigHeader;\r
-  VOID                            *LocalConfigUtilityCodeHeader;\r
-\r
-  LocalConfigUtilityCodeHeader = NULL;\r
-  *Flags = NO_ROM;\r
-  Status = gBS->HandleProtocol (\r
-                  PciHandle,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // See if the option ROM for PciHandle has already been executed\r
-  //\r
-  Status = IsLegacyRom (PciHandle);\r
-  if (!EFI_ERROR (Status)) {\r
-    *Flags |= (UINTN)(ROM_FOUND | VALID_LEGACY_ROM);\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Check for PCI ROM Bar\r
-  //\r
-  LocalRomSize  = (UINTN) PciIo->RomSize;\r
-  LocalRomImage = PciIo->RomImage;\r
-  if (LocalRomSize != 0) {\r
-    *Flags |= ROM_FOUND;\r
-  }\r
-\r
-  //\r
-  // PCI specification states you should check VendorId and Device Id.\r
-  //\r
-  PciIo->Pci.Read (\r
-               PciIo,\r
-               EfiPciIoWidthUint32,\r
-               0,\r
-               sizeof (PciConfigHeader) / sizeof (UINT32),\r
-               &PciConfigHeader\r
-               );\r
-\r
-  Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-  Status = GetPciLegacyRom (\r
-             Private->Csm16PciInterfaceVersion,\r
-             PciConfigHeader.Hdr.VendorId,\r
-             PciConfigHeader.Hdr.DeviceId,\r
-             &LocalRomImage,\r
-             &LocalRomSize,\r
-             RuntimeImageLength,\r
-             OpromRevision,\r
-             &LocalConfigUtilityCodeHeader\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  *Flags |= VALID_LEGACY_ROM;\r
-\r
-  //\r
-  // See if Configuration Utility Code Header valid\r
-  //\r
-  if (LocalConfigUtilityCodeHeader != NULL) {\r
-    *Flags |= ROM_WITH_CONFIG;\r
-  }\r
-\r
-  if (ConfigUtilityCodeHeader != NULL) {\r
-    *ConfigUtilityCodeHeader = LocalConfigUtilityCodeHeader;\r
-  }\r
-\r
-  if (RomImage != NULL) {\r
-    *RomImage = LocalRomImage;\r
-  }\r
-\r
-  if (RomSize != NULL) {\r
-    *RomSize = LocalRomSize;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Load a legacy PC-AT OPROM on the PciHandle device. Return information\r
-  about how many disks were added by the OPROM and the shadow address and\r
-  size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:\r
-\r
-  @retval EFI_SUCCESS   Legacy ROM loaded for this device\r
-  @retval EFI_NOT_FOUND No PS2 Keyboard found\r
-\r
-**/\r
-EFI_STATUS\r
-EnablePs2Keyboard (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_HANDLE                          *HandleBuffer;\r
-  UINTN                               HandleCount;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-  UINTN                               Index;\r
-\r
-  //\r
-  // Get SimpleTextIn and find PS2 controller\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiSimpleTextInProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    //\r
-    // Open the IO Abstraction(s) needed to perform the supported test\r
-    //\r
-    Status = gBS->OpenProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiIsaIoProtocolGuid,\r
-                    (VOID **) &IsaIo,\r
-                    NULL,\r
-                    HandleBuffer[Index],\r
-                    EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL\r
-                    );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Use the ISA I/O Protocol to see if Controller is the Keyboard\r
-      // controller\r
-      //\r
-      if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303) || IsaIo->ResourceList->Device.UID != 0) {\r
-        Status = EFI_UNSUPPORTED;\r
-      }\r
-\r
-      gBS->CloseProtocol (\r
-             HandleBuffer[Index],\r
-             &gEfiIsaIoProtocolGuid,\r
-             NULL,\r
-             HandleBuffer[Index]\r
-             );\r
-    }\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE);\r
-    }\r
-  }\r
-  FreePool (HandleBuffer);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Load a legacy PC-AT OpROM for VGA controller.\r
-\r
-  @param  Private                Driver private data.\r
-\r
-  @retval EFI_SUCCESS            Legacy ROM successfully installed for this device.\r
-  @retval EFI_DEVICE_ERROR       No VGA device handle found, or native EFI video\r
-                                 driver cannot be successfully disconnected, or VGA\r
-                                 thunk driver cannot be successfully connected.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosInstallVgaRom (\r
-  IN  LEGACY_BIOS_INSTANCE            *Private\r
-  )\r
-{\r
-  EFI_STATUS                           Status;\r
-  EFI_HANDLE                           VgaHandle;\r
-  UINTN                                HandleCount;\r
-  EFI_HANDLE                           *HandleBuffer;\r
-  EFI_HANDLE                           *ConnectHandleBuffer;\r
-  EFI_PCI_IO_PROTOCOL                  *PciIo;\r
-  PCI_TYPE00                           PciConfigHeader;\r
-  UINT64                               Supports;\r
-  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY  *OpenInfoBuffer;\r
-  UINTN                                EntryCount;\r
-  UINTN                                Index;\r
-  VOID                                 *Interface;\r
-\r
-  //\r
-  // EfiLegacyBiosGuild attached to a device implies that there is a legacy\r
-  // BIOS associated with that device.\r
-  //\r
-  // There are 3 cases to consider.\r
-  //   Case 1: No EFI driver is controlling the video.\r
-  //     Action: Return EFI_SUCCESS from DisconnectController, search\r
-  //             video thunk driver, and connect it.\r
-  //   Case 2: EFI driver is controlling the video and EfiLegacyBiosGuid is\r
-  //           not on the image handle.\r
-  //     Action: Disconnect EFI driver.\r
-  //             ConnectController for video thunk\r
-  //   Case 3: EFI driver is controlling the video and EfiLegacyBiosGuid is\r
-  //           on the image handle.\r
-  //     Action: Do nothing and set Private->VgaInstalled = TRUE.\r
-  //             Then this routine is not called any more.\r
-  //\r
-  //\r
-  // Get the VGA device.\r
-  //\r
-  Status = Private->LegacyBiosPlatform->GetPlatformHandle (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiGetPlatformVgaHandle,\r
-                                          0,\r
-                                          &HandleBuffer,\r
-                                          &HandleCount,\r
-                                          NULL\r
-                                          );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  VgaHandle = HandleBuffer[0];\r
-\r
-  //\r
-  // Check whether video thunk driver already starts.\r
-  //\r
-  Status = gBS->OpenProtocolInformation (\r
-                  VgaHandle,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  &OpenInfoBuffer,\r
-                  &EntryCount\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  for (Index = 0; Index < EntryCount; Index++) {\r
-    if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
-      Status = gBS->HandleProtocol (\r
-                      OpenInfoBuffer[Index].AgentHandle,\r
-                      &gEfiLegacyBiosGuid,\r
-                      (VOID **) &Interface\r
-                      );\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // This should be video thunk driver which is managing video device\r
-        // So it need not start again\r
-        //\r
-        DEBUG ((EFI_D_INFO, "Video thunk driver already start! Return!\n"));\r
-        Private->VgaInstalled = TRUE;\r
-        return EFI_SUCCESS;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Kick off the native EFI driver\r
-  //\r
-  Status = gBS->DisconnectController (\r
-                  VgaHandle,\r
-                  NULL,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    if (Status != EFI_NOT_FOUND) {\r
-      return EFI_DEVICE_ERROR;\r
-    } else {\r
-      return Status;\r
-    }\r
-  }\r
-  //\r
-  // Find all the Thunk Driver\r
-  //\r
-  HandleBuffer = NULL;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiLegacyBiosGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-  ConnectHandleBuffer = (EFI_HANDLE *) AllocatePool (sizeof (EFI_HANDLE) * (HandleCount + 1));\r
-  ASSERT (ConnectHandleBuffer != NULL);\r
-\r
-  CopyMem (\r
-    ConnectHandleBuffer,\r
-    HandleBuffer,\r
-    sizeof (EFI_HANDLE) * HandleCount\r
-    );\r
-  ConnectHandleBuffer[HandleCount] = NULL;\r
-\r
-  FreePool (HandleBuffer);\r
-\r
-  //\r
-  // Enable the device and make sure VGA cycles are being forwarded to this VGA device\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  VgaHandle,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-  PciIo->Pci.Read (\r
-               PciIo,\r
-               EfiPciIoWidthUint32,\r
-               0,\r
-               sizeof (PciConfigHeader) / sizeof (UINT32),\r
-               &PciConfigHeader\r
-               );\r
-\r
-  Status = PciIo->Attributes (\r
-                    PciIo,\r
-                    EfiPciIoAttributeOperationSupported,\r
-                    0,\r
-                    &Supports\r
-                    );\r
-  if (!EFI_ERROR (Status)) {\r
-    Supports &= (UINT64)(EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | \\r
-                         EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16);\r
-    Status = PciIo->Attributes (\r
-                      PciIo,\r
-                      EfiPciIoAttributeOperationEnable,\r
-                      Supports,\r
-                      NULL\r
-                      );\r
-  }\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    Private->VgaInstalled = TRUE;\r
-\r
-    //\r
-    // Attach the VGA thunk driver.\r
-    // Assume the video is installed. This prevents potential of infinite recursion.\r
-    //\r
-    Status = gBS->ConnectController (\r
-                    VgaHandle,\r
-                    ConnectHandleBuffer,\r
-                    NULL,\r
-                    TRUE\r
-                    );\r
-  }\r
-\r
-  FreePool (ConnectHandleBuffer);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-\r
-    Private->VgaInstalled = FALSE;\r
-\r
-    //\r
-    // Reconnect the EFI VGA driver.\r
-    //\r
-    gBS->ConnectController (VgaHandle, NULL, NULL, TRUE);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Load a legacy PC-AT OpROM.\r
-\r
-  @param  This                              Protocol instance pointer.\r
-  @param  Private                          Driver's private data.\r
-  @param  PciHandle                      The EFI handle for the PCI device. It could be\r
-                                                    NULL if the  OpROM image is not associated with\r
-                                                    any device.\r
-  @param  OpromRevision              The revision of PCI PC-AT ROM image.\r
-  @param  RomImage                    Pointer to PCI PC-AT ROM image header. It must not\r
-                                                    be NULL.\r
-  @param  ImageSize                     Size of the PCI PC-AT ROM image.\r
-  @param  RuntimeImageLength      On input is the max runtime image length indicated by the PCIR structure\r
-                                                    On output is the actual runtime image length\r
-  @param  DiskStart                       Disk number of first device hooked by the ROM. If\r
-                                                    DiskStart is the same as DiskEnd no disked were\r
-                                                    hooked.\r
-  @param  DiskEnd                         Disk number of the last device hooked by the ROM.\r
-  @param  RomShadowAddress       Shadow address of PC-AT ROM\r
-\r
-  @retval EFI_SUCCESS            Legacy ROM loaded for this device\r
-  @retval EFI_OUT_OF_RESOURCES   No more space for this ROM\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosInstallRom (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL           *This,\r
-  IN LEGACY_BIOS_INSTANCE               *Private,\r
-  IN EFI_HANDLE                         PciHandle,\r
-  IN UINT8                              OpromRevision,\r
-  IN VOID                               *RomImage,\r
-  IN UINTN                              ImageSize,\r
-  IN OUT UINTN                          *RuntimeImageLength,\r
-  OUT UINT8                             *DiskStart, OPTIONAL\r
-  OUT UINT8                             *DiskEnd, OPTIONAL\r
-  OUT VOID                              **RomShadowAddress OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_STATUS            PciEnableStatus;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-  UINT8                 LocalDiskStart;\r
-  UINT8                 LocalDiskEnd;\r
-  UINTN                 Segment;\r
-  UINTN                 Bus;\r
-  UINTN                 Device;\r
-  UINTN                 Function;\r
-  EFI_IA32_REGISTER_SET Regs;\r
-  UINT8                 VideoMode;\r
-  UINT8                 OldVideoMode;\r
-  EFI_TIME              BootTime;\r
-  UINT32                *BdaPtr;\r
-  UINT32                LocalTime;\r
-  UINT32                StartBbsIndex;\r
-  UINT32                EndBbsIndex;\r
-  UINT32                MaxRomAddr;\r
-  UINTN                 TempData;\r
-  UINTN                 InitAddress;\r
-  UINTN                 RuntimeAddress;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-  UINT32                Granularity;\r
-\r
-  PciIo           = NULL;\r
-  LocalDiskStart  = 0;\r
-  LocalDiskEnd    = 0;\r
-  Segment         = 0;\r
-  Bus             = 0;\r
-  Device          = 0;\r
-  Function        = 0;\r
-  VideoMode       = 0;\r
-  OldVideoMode    = 0;\r
-  PhysicalAddress = 0;\r
-  MaxRomAddr      = PcdGet32 (PcdEndOpromShadowAddress);\r
-\r
-  if ((Private->Legacy16Table->TableLength >= OFFSET_OF(EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) &&\r
-      (Private->Legacy16Table->UmaAddress != 0) &&\r
-      (Private->Legacy16Table->UmaSize != 0) &&\r
-      (MaxRomAddr > (Private->Legacy16Table->UmaAddress))) {\r
-    MaxRomAddr = Private->Legacy16Table->UmaAddress;\r
-  }\r
-\r
-\r
-  PciProgramAllInterruptLineRegisters (Private);\r
-\r
-  if ((OpromRevision >= 3) && (Private->Csm16PciInterfaceVersion >= 0x0300)) {\r
-    //\r
-    // CSM16 3.0 meets PCI 3.0 OpROM\r
-    //   first test if there is enough space for its INIT code\r
-    //\r
-    PhysicalAddress = CONVENTIONAL_MEMORY_TOP;\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiBootServicesCode,\r
-                    EFI_SIZE_TO_PAGES (ImageSize),\r
-                    &PhysicalAddress\r
-                    );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", __LINE__));\r
-      //\r
-      // Report Status Code to indicate that there is no enough space for OpROM\r
-      //\r
-      REPORT_STATUS_CODE (\r
-        EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-        (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_LEGACY_OPROM_NO_SPACE)\r
-        );\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    InitAddress = (UINTN) PhysicalAddress;\r
-    //\r
-    //   then test if there is enough space for its RT code\r
-    //\r
-    RuntimeAddress = Private->OptionRom;\r
-    if (RuntimeAddress + *RuntimeImageLength > MaxRomAddr) {\r
-      DEBUG ((EFI_D_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", __LINE__));\r
-      gBS->FreePages (PhysicalAddress, EFI_SIZE_TO_PAGES (ImageSize));\r
-      //\r
-      // Report Status Code to indicate that there is no enough space for OpROM\r
-      //\r
-      REPORT_STATUS_CODE (\r
-        EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-        (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_LEGACY_OPROM_NO_SPACE)\r
-        );\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-  } else {\r
-    // CSM16 3.0 meets PCI 2.x OpROM\r
-    // CSM16 2.x meets PCI 2.x/3.0 OpROM\r
-    //   test if there is enough space for its INIT code\r
-    //\r
-    InitAddress    = PCI_START_ADDRESS (Private->OptionRom);\r
-    if (InitAddress + ImageSize > MaxRomAddr) {\r
-      DEBUG ((EFI_D_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", __LINE__));\r
-      //\r
-      // Report Status Code to indicate that there is no enough space for OpROM\r
-      //\r
-      REPORT_STATUS_CODE (\r
-        EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-        (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_LEGACY_OPROM_NO_SPACE)\r
-        );\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    RuntimeAddress = InitAddress;\r
-  }\r
-\r
-  Private->LegacyRegion->UnLock (\r
-                           Private->LegacyRegion,\r
-                           0xE0000,\r
-                           0x20000,\r
-                           &Granularity\r
-                           );\r
-\r
-  Private->LegacyRegion->UnLock (\r
-                           Private->LegacyRegion,\r
-                           (UINT32) RuntimeAddress,\r
-                           (UINT32) ImageSize,\r
-                           &Granularity\r
-                           );\r
-\r
-  DEBUG ((EFI_D_INFO, " Shadowing OpROM init/runtime/isize = %x/%x/%x\n", InitAddress, RuntimeAddress, ImageSize));\r
-\r
-  CopyMem ((VOID *) InitAddress, RomImage, ImageSize);\r
-\r
-  //\r
-  // Read the highest disk number "installed: and assume a new disk will\r
-  // show up on the first drive past the current value.\r
-  // There are several considerations here:\r
-  // 1. Non-BBS compliant drives will change 40:75 but 16-bit CSM will undo\r
-  //    the change until boot selection time frame.\r
-  // 2. BBS compliants drives will not change 40:75 until boot time.\r
-  // 3. Onboard IDE controllers will change 40:75\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    LocalDiskStart = (UINT8) ((*(UINT8 *) ((UINTN) 0x475)) + 0x80);\r
-    if ((Private->Disk4075 + 0x80) < LocalDiskStart) {\r
-      //\r
-      // Update table since onboard IDE drives found\r
-      //\r
-      Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciSegment        = 0xff;\r
-      Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciBus            = 0xff;\r
-      Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciDevice         = 0xff;\r
-      Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciFunction       = 0xff;\r
-      Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].StartDriveNumber  = (UINT8) (Private->Disk4075 + 0x80);\r
-      Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber    = LocalDiskStart;\r
-      Private->LegacyEfiHddTableIndex ++;\r
-      Private->Disk4075 = (UINT8) (LocalDiskStart & 0x7f);\r
-      Private->DiskEnd  = LocalDiskStart;\r
-    }\r
-\r
-    if (PciHandle != mVgaHandle) {\r
-\r
-      EnablePs2Keyboard ();\r
-\r
-      //\r
-      // Store current mode settings since PrepareToScanRom may change mode.\r
-      //\r
-      VideoMode = *(UINT8 *) ((UINTN) (0x400 + BDA_VIDEO_MODE));\r
-    }\r
-  );\r
-\r
-  //\r
-  // Notify the platform that we are about to scan the ROM\r
-  //\r
-  Status = Private->LegacyBiosPlatform->PlatformHooks (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiPlatformHookPrepareToScanRom,\r
-                                          0,\r
-                                          PciHandle,\r
-                                          &InitAddress,\r
-                                          NULL,\r
-                                          NULL\r
-                                          );\r
-\r
-  //\r
-  // If Status returned is EFI_UNSUPPORTED then abort due to platform\r
-  // policy.\r
-  //\r
-  if (Status == EFI_UNSUPPORTED) {\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Report corresponding status code\r
-  //\r
-  REPORT_STATUS_CODE (\r
-    EFI_PROGRESS_CODE,\r
-    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_CSM_LEGACY_ROM_INIT)\r
-    );\r
-\r
-  //\r
-  // Generate number of ticks since midnight for BDA. Some OPROMs require\r
-  // this. Place result in 40:6C-6F\r
-  //\r
-  gRT->GetTime (&BootTime, NULL);\r
-  LocalTime = BootTime.Hour * 3600 + BootTime.Minute * 60 + BootTime.Second;\r
-\r
-  //\r
-  // Multiply result by 18.2 for number of ticks since midnight.\r
-  // Use 182/10 to avoid floating point math.\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    LocalTime = (LocalTime * 182) / 10;\r
-    BdaPtr    = (UINT32 *) ((UINTN) 0x46C);\r
-    *BdaPtr   = LocalTime;\r
-  );\r
-\r
-  //\r
-  // Pass in handoff data\r
-  //\r
-  PciEnableStatus = EFI_UNSUPPORTED;\r
-  ZeroMem (&Regs, sizeof (Regs));\r
-  if (PciHandle != NULL) {\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    PciHandle,\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Enable command register.\r
-    //\r
-    PciEnableStatus = PciIo->Attributes (\r
-                               PciIo,\r
-                               EfiPciIoAttributeOperationEnable,\r
-                               EFI_PCI_DEVICE_ENABLE,\r
-                               NULL\r
-                               );\r
-\r
-    PciIo->GetLocation (\r
-             PciIo,\r
-             &Segment,\r
-             &Bus,\r
-             &Device,\r
-             &Function\r
-             );\r
-    DEBUG ((EFI_D_INFO, "Shadowing OpROM on the PCI device %x/%x/%x\n", Bus, Device, Function));\r
-  }\r
-\r
-  mIgnoreBbsUpdateFlag  = FALSE;\r
-  Regs.X.AX             = Legacy16DispatchOprom;\r
-\r
-  //\r
-  // Generate DispatchOpRomTable data\r
-  //\r
-  Private->IntThunk->DispatchOpromTable.PnPInstallationCheckSegment = Private->Legacy16Table->PnPInstallationCheckSegment;\r
-  Private->IntThunk->DispatchOpromTable.PnPInstallationCheckOffset  = Private->Legacy16Table->PnPInstallationCheckOffset;\r
-  Private->IntThunk->DispatchOpromTable.OpromSegment                = (UINT16) (InitAddress >> 4);\r
-  Private->IntThunk->DispatchOpromTable.PciBus                      = (UINT8) Bus;\r
-  Private->IntThunk->DispatchOpromTable.PciDeviceFunction           = (UINT8) ((Device << 3) | Function);\r
-  Private->IntThunk->DispatchOpromTable.NumberBbsEntries            = (UINT8) Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;\r
-  Private->IntThunk->DispatchOpromTable.BbsTablePointer             = (UINT32) (UINTN) Private->BbsTablePtr;\r
-  Private->IntThunk->DispatchOpromTable.RuntimeSegment              = (UINT16)((OpromRevision < 3) ? 0xffff : (RuntimeAddress >> 4));\r
-  TempData = (UINTN) &Private->IntThunk->DispatchOpromTable;\r
-  Regs.X.ES = EFI_SEGMENT ((UINT32) TempData);\r
-  Regs.X.BX = EFI_OFFSET ((UINT32) TempData);\r
-  //\r
-  // Skip dispatching ROM for those PCI devices that can not be enabled by PciIo->Attributes\r
-  // Otherwise, it may cause the system to hang in some cases\r
-  //\r
-  if (!EFI_ERROR (PciEnableStatus)) {\r
-    DEBUG ((EFI_D_INFO, " Legacy16DispatchOprom - %02x/%02x/%02x\n", Bus, Device, Function));\r
-    Private->LegacyBios.FarCall86 (\r
-      &Private->LegacyBios,\r
-      Private->Legacy16CallSegment,\r
-      Private->Legacy16CallOffset,\r
-      &Regs,\r
-      NULL,\r
-      0\r
-      );\r
-  } else {\r
-    Regs.X.BX = 0;\r
-  }\r
-\r
-  if (Private->IntThunk->DispatchOpromTable.NumberBbsEntries != (UINT8) Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries) {\r
-    Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries  = (UINT8) Private->IntThunk->DispatchOpromTable.NumberBbsEntries;\r
-    mIgnoreBbsUpdateFlag = TRUE;\r
-  }\r
-  //\r
-  // Check if non-BBS compliant drives found\r
-  //\r
-  if (Regs.X.BX != 0) {\r
-    LocalDiskEnd  = (UINT8) (LocalDiskStart + Regs.H.BL);\r
-    Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciSegment        = (UINT8) Segment;\r
-    Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciBus            = (UINT8) Bus;\r
-    Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciDevice         = (UINT8) Device;\r
-    Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciFunction       = (UINT8) Function;\r
-    Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].StartDriveNumber  = Private->DiskEnd;\r
-    Private->DiskEnd = LocalDiskEnd;\r
-    Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = Private->DiskEnd;\r
-    Private->LegacyEfiHddTableIndex += 1;\r
-  }\r
-  //\r
-  // Skip video mode set, if installing VGA\r
-  //\r
-  if (PciHandle != mVgaHandle) {\r
-    //\r
-    // Set mode settings since PrepareToScanRom may change mode\r
-    //\r
-    ACCESS_PAGE0_CODE ({\r
-      OldVideoMode = *(UINT8 *) ((UINTN) (0x400 + BDA_VIDEO_MODE));\r
-    });\r
-\r
-    if (VideoMode != OldVideoMode) {\r
-      //\r
-      // The active video mode is changed, restore it to original mode.\r
-      //\r
-      Regs.H.AH = 0x00;\r
-      Regs.H.AL = VideoMode;\r
-      Private->LegacyBios.Int86 (&Private->LegacyBios, 0x10, &Regs);\r
-    }\r
-  }\r
-  //\r
-  // Regs.X.AX from the adapter initializion is ignored since some adapters\r
-  // do not follow the standard of setting AX = 0 on success.\r
-  //\r
-  //\r
-  // The ROM could have updated it's size so we need to read again.\r
-  //\r
-  if (((EFI_LEGACY_EXPANSION_ROM_HEADER *) RuntimeAddress)->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r
-    //\r
-    // Now we check the signature (0xaa55) to judge whether the run-time code is truly generated by INIT function.\r
-    // If signature is not valid, that means the INIT function didn't copy the run-time code to RuntimeAddress.\r
-    //\r
-    *RuntimeImageLength = 0;\r
-  } else {\r
-    *RuntimeImageLength = ((EFI_LEGACY_EXPANSION_ROM_HEADER *) RuntimeAddress)->Size512 * 512;\r
-  }\r
-\r
-  DEBUG ((EFI_D_INFO, " fsize = %x\n", *RuntimeImageLength));\r
-\r
-  //\r
-  // If OpROM runs in 2.0 mode\r
-  //\r
-  if (PhysicalAddress == 0) {\r
-    if (*RuntimeImageLength < ImageSize) {\r
-      //\r
-      // Make area from end of shadowed rom to end of original rom all ffs\r
-      //\r
-      gBS->SetMem ((VOID *) (InitAddress + *RuntimeImageLength), ImageSize - *RuntimeImageLength, 0xff);\r
-    }\r
-  }\r
-\r
-  ACCESS_PAGE0_CODE (\r
-    LocalDiskEnd = (UINT8) ((*(UINT8 *) ((UINTN) 0x475)) + 0x80);\r
-  );\r
-\r
-  //\r
-  // Allow platform to perform any required actions after the\r
-  // OPROM has been initialized.\r
-  //\r
-  Status = Private->LegacyBiosPlatform->PlatformHooks (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiPlatformHookAfterRomInit,\r
-                                          0,\r
-                                          PciHandle,\r
-                                          &RuntimeAddress,\r
-                                          NULL,\r
-                                          NULL\r
-                                          );\r
-  if (PciHandle != NULL) {\r
-    //\r
-    // If no PCI Handle then no header or Bevs.\r
-    //\r
-    if ((*RuntimeImageLength != 0) && (!mIgnoreBbsUpdateFlag)) {\r
-      StartBbsIndex = Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;\r
-      TempData      = RuntimeAddress;\r
-      UpdateBevBcvTable (\r
-        Private,\r
-        (EFI_LEGACY_EXPANSION_ROM_HEADER *) TempData,\r
-        PciIo\r
-        );\r
-      EndBbsIndex   = Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries;\r
-      LocalDiskEnd  = (UINT8) (LocalDiskStart + (UINT8) (EndBbsIndex - StartBbsIndex));\r
-      if (LocalDiskEnd != LocalDiskStart) {\r
-        Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciSegment        = (UINT8) Segment;\r
-        Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciBus            = (UINT8) Bus;\r
-        Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciDevice         = (UINT8) Device;\r
-        Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].PciFunction       = (UINT8) Function;\r
-        Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].StartDriveNumber  = Private->DiskEnd;\r
-        Private->DiskEnd = LocalDiskEnd;\r
-        Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = Private->DiskEnd;\r
-        Private->LegacyEfiHddTableIndex += 1;\r
-      }\r
-    }\r
-    //\r
-    // Mark PCI device as having a legacy BIOS ROM loaded.\r
-    //\r
-    RomShadow (\r
-      PciHandle,\r
-      (UINT32) RuntimeAddress,\r
-      (UINT32) *RuntimeImageLength,\r
-      LocalDiskStart,\r
-      LocalDiskEnd\r
-      );\r
-  }\r
-\r
-  //\r
-  // Stuff caller's OPTIONAL return parameters.\r
-  //\r
-  if (RomShadowAddress != NULL) {\r
-    *RomShadowAddress = (VOID *) RuntimeAddress;\r
-  }\r
-\r
-  if (DiskStart != NULL) {\r
-    *DiskStart = LocalDiskStart;\r
-  }\r
-\r
-  if (DiskEnd != NULL) {\r
-    *DiskEnd = LocalDiskEnd;\r
-  }\r
-\r
-  Private->OptionRom = (UINT32) (RuntimeAddress + *RuntimeImageLength);\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-Done:\r
-  if (PhysicalAddress != 0) {\r
-    //\r
-    // Free pages when OpROM is 3.0\r
-    //\r
-    gBS->FreePages (PhysicalAddress, EFI_SIZE_TO_PAGES (ImageSize));\r
-  }\r
-\r
-  //\r
-  // Insure all shadowed  areas are locked\r
-  //\r
-  Private->LegacyRegion->Lock (\r
-                           Private->LegacyRegion,\r
-                           0xC0000,\r
-                           0x40000,\r
-                           &Granularity\r
-                           );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Let IOMMU grant DMA access for the PCI device.\r
-\r
-  @param  PciHandle             The EFI handle for the PCI device.\r
-  @param  HostAddress           The system memory address to map to the PCI controller.\r
-  @param  NumberOfBytes         The number of bytes to map.\r
-\r
-  @retval EFI_SUCCESS  The DMA access is granted.\r
-**/\r
-EFI_STATUS\r
-IoMmuGrantAccess (\r
-  IN  EFI_HANDLE                        PciHandle,\r
-  IN  EFI_PHYSICAL_ADDRESS              HostAddress,\r
-  IN  UINTN                             NumberOfBytes\r
-  )\r
-{\r
-  EFI_PHYSICAL_ADDRESS            DeviceAddress;\r
-  VOID                            *Mapping;\r
-  EFI_STATUS                      Status;\r
-\r
-  if (PciHandle == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-  if (mIoMmu == NULL) {\r
-    gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **)&mIoMmu);\r
-  }\r
-  if (mIoMmu != NULL) {\r
-    Status = mIoMmu->Map (\r
-                       mIoMmu,\r
-                       EdkiiIoMmuOperationBusMasterCommonBuffer,\r
-                       (VOID *)(UINTN)HostAddress,\r
-                       &NumberOfBytes,\r
-                       &DeviceAddress,\r
-                       &Mapping\r
-                       );\r
-    if (EFI_ERROR(Status)) {\r
-      DEBUG ((DEBUG_ERROR, "LegacyPci - IoMmuMap - %r\n", Status));\r
-    } else {\r
-      ASSERT (DeviceAddress == HostAddress);\r
-      Status = mIoMmu->SetAttribute (\r
-                         mIoMmu,\r
-                         PciHandle,\r
-                         Mapping,\r
-                         EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE\r
-                         );\r
-      if (EFI_ERROR(Status)) {\r
-        DEBUG ((DEBUG_ERROR, "LegacyPci - IoMmuSetAttribute - %r\n", Status));\r
-      }\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Load a legacy PC-AT OPROM on the PciHandle device. Return information\r
-  about how many disks were added by the OPROM and the shadow address and\r
-  size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  PciHandle              The PCI PC-AT OPROM from this devices ROM BAR will\r
-                                 be loaded. This value is NULL if RomImage is\r
-                                 non-NULL. This is the normal case.\r
-  @param  RomImage               A PCI PC-AT ROM image. This argument is non-NULL\r
-                                 if there is no hardware associated with the ROM\r
-                                 and thus no PciHandle, otherwise is must be NULL.\r
-                                 Example is PXE base code.\r
-  @param  Flags                  Indicates if ROM found and if PC-AT.\r
-  @param  DiskStart              Disk number of first device hooked by the ROM. If\r
-                                 DiskStart is the same as DiskEnd no disked were\r
-                                 hooked.\r
-  @param  DiskEnd                Disk number of the last device hooked by the ROM.\r
-  @param  RomShadowAddress       Shadow address of PC-AT ROM\r
-  @param  RomShadowedSize        Size of RomShadowAddress in bytes\r
-\r
-  @retval EFI_SUCCESS            Legacy ROM loaded for this device\r
-  @retval EFI_INVALID_PARAMETER  PciHandle not found\r
-  @retval EFI_UNSUPPORTED        There is no PCI ROM in the ROM BAR or no onboard\r
-                                 ROM\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBiosInstallPciRom (\r
-  IN EFI_LEGACY_BIOS_PROTOCOL           * This,\r
-  IN  EFI_HANDLE                        PciHandle,\r
-  IN  VOID                              **RomImage,\r
-  OUT UINTN                             *Flags,\r
-  OUT UINT8                             *DiskStart, OPTIONAL\r
-  OUT UINT8                             *DiskEnd, OPTIONAL\r
-  OUT VOID                              **RomShadowAddress, OPTIONAL\r
-  OUT UINT32                            *RomShadowedSize OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  LEGACY_BIOS_INSTANCE            *Private;\r
-  VOID                            *LocalRomImage;\r
-  UINTN                           ImageSize;\r
-  UINTN                           RuntimeImageLength;\r
-  EFI_PCI_IO_PROTOCOL             *PciIo;\r
-  PCI_TYPE01                      PciConfigHeader;\r
-  UINTN                           HandleCount;\r
-  EFI_HANDLE                      *HandleBuffer;\r
-  UINTN                           PciSegment;\r
-  UINTN                           PciBus;\r
-  UINTN                           PciDevice;\r
-  UINTN                           PciFunction;\r
-  UINTN                           LastBus;\r
-  UINTN                           Index;\r
-  UINT8                           OpromRevision;\r
-  UINT32                          Granularity;\r
-  PCI_3_0_DATA_STRUCTURE          *Pcir;\r
-\r
-  OpromRevision = 0;\r
-\r
-  Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-  if (Private->Legacy16Table->LastPciBus == 0) {\r
-    //\r
-    // Get last bus number if not already found\r
-    //\r
-    Status = gBS->LocateHandleBuffer (\r
-                    ByProtocol,\r
-                    &gEfiPciIoProtocolGuid,\r
-                    NULL,\r
-                    &HandleCount,\r
-                    &HandleBuffer\r
-                    );\r
-\r
-    LastBus = 0;\r
-    for (Index = 0; Index < HandleCount; Index++) {\r
-      Status = gBS->HandleProtocol (\r
-                      HandleBuffer[Index],\r
-                      &gEfiPciIoProtocolGuid,\r
-                      (VOID **) &PciIo\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        continue;\r
-      }\r
-\r
-      Status = PciIo->GetLocation (\r
-                        PciIo,\r
-                        &PciSegment,\r
-                        &PciBus,\r
-                        &PciDevice,\r
-                        &PciFunction\r
-                        );\r
-      if (PciBus > LastBus) {\r
-        LastBus = PciBus;\r
-      }\r
-    }\r
-\r
-    Private->LegacyRegion->UnLock (\r
-                             Private->LegacyRegion,\r
-                             0xE0000,\r
-                             0x20000,\r
-                             &Granularity\r
-                             );\r
-    Private->Legacy16Table->LastPciBus = (UINT8) LastBus;\r
-    Private->LegacyRegion->Lock (\r
-                             Private->LegacyRegion,\r
-                             0xE0000,\r
-                             0x20000,\r
-                             &Granularity\r
-                             );\r
-  }\r
-\r
-  *Flags = 0;\r
-  if ((PciHandle != NULL) && (RomImage == NULL)) {\r
-    //\r
-    // If PciHandle has OpRom to Execute\r
-    // and OpRom are all associated with Hardware\r
-    //\r
-    Status = gBS->HandleProtocol (\r
-                    PciHandle,\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo\r
-                    );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      PciIo->Pci.Read (\r
-                   PciIo,\r
-                   EfiPciIoWidthUint32,\r
-                   0,\r
-                   sizeof (PciConfigHeader) / sizeof (UINT32),\r
-                   &PciConfigHeader\r
-                   );\r
-\r
-      //\r
-      // if video installed & OPROM is video return\r
-      //\r
-      if (\r
-          (\r
-           ((PciConfigHeader.Hdr.ClassCode[2] == PCI_CLASS_OLD) &&\r
-            (PciConfigHeader.Hdr.ClassCode[1] == PCI_CLASS_OLD_VGA))\r
-           ||\r
-           ((PciConfigHeader.Hdr.ClassCode[2] == PCI_CLASS_DISPLAY) &&\r
-            (PciConfigHeader.Hdr.ClassCode[1] == PCI_CLASS_DISPLAY_VGA))\r
-          )\r
-          &&\r
-          (!Private->VgaInstalled)\r
-         ) {\r
-        mVgaInstallationInProgress = TRUE;\r
-\r
-        //\r
-        //      return EFI_UNSUPPORTED;\r
-        //\r
-      }\r
-    }\r
-    //\r
-    // To run any legacy image, the VGA needs to be installed first.\r
-    // if installing the video, then don't need the thunk as already installed.\r
-    //\r
-    Status = Private->LegacyBiosPlatform->GetPlatformHandle (\r
-                                            Private->LegacyBiosPlatform,\r
-                                            EfiGetPlatformVgaHandle,\r
-                                            0,\r
-                                            &HandleBuffer,\r
-                                            &HandleCount,\r
-                                            NULL\r
-                                            );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      mVgaHandle = HandleBuffer[0];\r
-      if ((!Private->VgaInstalled) && (PciHandle != mVgaHandle)) {\r
-        //\r
-        // A return status of EFI_NOT_FOUND is considered valid (No EFI\r
-        // driver is controlling video.\r
-        //\r
-        mVgaInstallationInProgress  = TRUE;\r
-        Status                      = LegacyBiosInstallVgaRom (Private);\r
-        if (EFI_ERROR (Status)) {\r
-          if (Status != EFI_NOT_FOUND) {\r
-            mVgaInstallationInProgress = FALSE;\r
-            return Status;\r
-          }\r
-        } else {\r
-          mVgaInstallationInProgress = FALSE;\r
-        }\r
-      }\r
-    }\r
-    //\r
-    // See if the option ROM for PciHandle has already been executed\r
-    //\r
-    Status = IsLegacyRom (PciHandle);\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      mVgaInstallationInProgress = FALSE;\r
-      GetShadowedRomParameters (\r
-        PciHandle,\r
-        DiskStart,\r
-        DiskEnd,\r
-        RomShadowAddress,\r
-        (UINTN *) RomShadowedSize\r
-        );\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    Status = LegacyBiosCheckPciRomEx (\r
-               &Private->LegacyBios,\r
-               PciHandle,\r
-               &LocalRomImage,\r
-               &ImageSize,\r
-               &RuntimeImageLength,\r
-               Flags,\r
-               &OpromRevision,\r
-               NULL\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // There is no PCI ROM in the ROM BAR or no onboard ROM\r
-      //\r
-      mVgaInstallationInProgress = FALSE;\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  } else {\r
-    if ((RomImage == NULL) || (*RomImage == NULL)) {\r
-      //\r
-      // If PciHandle is NULL, and no OpRom is to be associated\r
-      //\r
-      mVgaInstallationInProgress = FALSE;\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    Status = Private->LegacyBiosPlatform->GetPlatformHandle (\r
-                                            Private->LegacyBiosPlatform,\r
-                                            EfiGetPlatformVgaHandle,\r
-                                            0,\r
-                                            &HandleBuffer,\r
-                                            &HandleCount,\r
-                                            NULL\r
-                                            );\r
-    if ((!EFI_ERROR (Status)) && (!Private->VgaInstalled)) {\r
-      //\r
-      // A return status of EFI_NOT_FOUND is considered valid (No EFI\r
-      // driver is controlling video.\r
-      //\r
-      mVgaInstallationInProgress  = TRUE;\r
-      Status                      = LegacyBiosInstallVgaRom (Private);\r
-      if (EFI_ERROR (Status)) {\r
-        if (Status != EFI_NOT_FOUND) {\r
-          mVgaInstallationInProgress = FALSE;\r
-          return Status;\r
-        }\r
-      } else {\r
-        mVgaInstallationInProgress = FALSE;\r
-      }\r
-    }\r
-\r
-    LocalRomImage = *RomImage;\r
-    if (((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE ||\r
-        ((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->PcirOffset == 0 ||\r
-        (((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->PcirOffset & 3 ) != 0) {\r
-      mVgaInstallationInProgress = FALSE;\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    Pcir = (PCI_3_0_DATA_STRUCTURE *)\r
-           ((UINT8 *) LocalRomImage + ((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->PcirOffset);\r
-\r
-    if ((Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) || (Pcir->CodeType != PCI_CODE_TYPE_PCAT_IMAGE)) {\r
-      mVgaInstallationInProgress = FALSE;\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    ImageSize = Pcir->ImageLength * 512;\r
-    if (Pcir->Length >= 0x1C) {\r
-      OpromRevision = Pcir->Revision;\r
-    } else {\r
-      OpromRevision = 0;\r
-    }\r
-    if (Pcir->Revision < 3) {\r
-      RuntimeImageLength = 0;\r
-    } else {\r
-      RuntimeImageLength = Pcir->MaxRuntimeImageLength * 512;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Grant access for below 1M\r
-  // BDA/EBDA/LowPMM and scratch memory for OPROM.\r
-  //\r
-  IoMmuGrantAccess (PciHandle, 0, SIZE_1MB);\r
-  //\r
-  // Grant access for HiPmm\r
-  //\r
-  IoMmuGrantAccess (\r
-    PciHandle,\r
-    Private->IntThunk->EfiToLegacy16InitTable.HiPmmMemory,\r
-    Private->IntThunk->EfiToLegacy16InitTable.HiPmmMemorySizeInBytes\r
-    );\r
-\r
-  //\r
-  // Shadow and initialize the OpROM.\r
-  //\r
-  ASSERT (Private->TraceIndex < 0x200);\r
-  Private->Trace[Private->TraceIndex] = LEGACY_PCI_TRACE_000;\r
-  Private->TraceIndex ++;\r
-  Private->TraceIndex = (UINT16) (Private->TraceIndex % 0x200);\r
-  Status = LegacyBiosInstallRom (\r
-             This,\r
-             Private,\r
-             PciHandle,\r
-             OpromRevision,\r
-             LocalRomImage,\r
-             ImageSize,\r
-             &RuntimeImageLength,\r
-             DiskStart,\r
-             DiskEnd,\r
-             RomShadowAddress\r
-             );\r
-  if (RomShadowedSize != NULL) {\r
-    *RomShadowedSize = (UINT32) RuntimeImageLength;\r
-  }\r
-\r
-  mVgaInstallationInProgress = FALSE;\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacySio.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacySio.c
deleted file mode 100644 (file)
index 17720a7..0000000
+++ /dev/null
@@ -1,477 +0,0 @@
-/** @file\r
-  Collect Sio information from Native EFI Drivers.\r
-  Sio is floppy, parallel, serial, ... hardware\r
-\r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-\r
-/**\r
-  Collect EFI Info about legacy devices through Super IO interface.\r
-\r
-  @param  SioPtr       Pointer to SIO data.\r
-\r
-  @retval EFI_SUCCESS   When SIO data is got successfully.\r
-  @retval EFI_NOT_FOUND When ISA IO interface is absent.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildSioDataFromSio (\r
-  IN DEVICE_PRODUCER_DATA_HEADER             *SioPtr\r
-  )\r
-{\r
-  EFI_STATUS                                 Status;\r
-  DEVICE_PRODUCER_SERIAL                     *SioSerial;\r
-  DEVICE_PRODUCER_PARALLEL                   *SioParallel;\r
-  DEVICE_PRODUCER_FLOPPY                     *SioFloppy;\r
-  UINTN                                      HandleCount;\r
-  EFI_HANDLE                                 *HandleBuffer;\r
-  UINTN                                      Index;\r
-  UINTN                                      ChildIndex;\r
-  EFI_SIO_PROTOCOL                           *Sio;\r
-  ACPI_RESOURCE_HEADER_PTR                   Resources;\r
-  EFI_ACPI_IO_PORT_DESCRIPTOR                *IoResource;\r
-  EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *FixedIoResource;\r
-  EFI_ACPI_DMA_DESCRIPTOR                    *DmaResource;\r
-  EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR             *IrqResource;\r
-  UINT16                                     Address;\r
-  UINT8                                      Dma;\r
-  UINT8                                      Irq;\r
-  UINTN                                      EntryCount;\r
-  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY        *OpenInfoBuffer;\r
-  EFI_BLOCK_IO_PROTOCOL                      *BlockIo;\r
-  EFI_SERIAL_IO_PROTOCOL                     *SerialIo;\r
-  EFI_DEVICE_PATH_PROTOCOL                   *DevicePath;\r
-  ACPI_HID_DEVICE_PATH                       *Acpi;\r
-\r
-  //\r
-  // Get the list of ISA controllers in the system\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiSioProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Collect legacy information from each of the ISA controllers in the system\r
-  //\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiSioProtocolGuid, (VOID **) &Sio);\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    Address = MAX_UINT16;\r
-    Dma     = MAX_UINT8;\r
-    Irq     = MAX_UINT8;\r
-    Status = Sio->GetResources (Sio, &Resources);\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Get the base address information from ACPI resource descriptor.\r
-      //\r
-      while (Resources.SmallHeader->Byte != ACPI_END_TAG_DESCRIPTOR) {\r
-        switch (Resources.SmallHeader->Byte) {\r
-        case ACPI_IO_PORT_DESCRIPTOR:\r
-          IoResource = (EFI_ACPI_IO_PORT_DESCRIPTOR *) Resources.SmallHeader;\r
-          Address = IoResource->BaseAddressMin;\r
-          break;\r
-\r
-        case ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR:\r
-          FixedIoResource = (EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *) Resources.SmallHeader;\r
-          Address = FixedIoResource->BaseAddress;\r
-          break;\r
-\r
-        case ACPI_DMA_DESCRIPTOR:\r
-          DmaResource = (EFI_ACPI_DMA_DESCRIPTOR *) Resources.SmallHeader;\r
-          Dma = (UINT8) LowBitSet32 (DmaResource->ChannelMask);\r
-          break;\r
-\r
-        case ACPI_IRQ_DESCRIPTOR:\r
-        case ACPI_IRQ_NOFLAG_DESCRIPTOR:\r
-          IrqResource = (EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR *) Resources.SmallHeader;\r
-          Irq = (UINT8) LowBitSet32 (IrqResource->Mask);\r
-          break;\r
-\r
-        default:\r
-          break;\r
-        }\r
-\r
-        if (Resources.SmallHeader->Bits.Type == 0) {\r
-          Resources.SmallHeader = (ACPI_SMALL_RESOURCE_HEADER *) ((UINT8 *) Resources.SmallHeader\r
-                                                                  + Resources.SmallHeader->Bits.Length\r
-                                                                  + sizeof (*Resources.SmallHeader));\r
-        } else {\r
-          Resources.LargeHeader = (ACPI_LARGE_RESOURCE_HEADER *) ((UINT8 *) Resources.LargeHeader\r
-                                                                  + Resources.LargeHeader->Length\r
-                                                                  + sizeof (*Resources.LargeHeader));\r
-        }\r
-      }\r
-    }\r
-\r
-    DEBUG ((EFI_D_INFO, "LegacySio: Address/Dma/Irq = %x/%d/%d\n", Address, Dma, Irq));\r
-\r
-    DevicePath = DevicePathFromHandle (HandleBuffer[Index]);\r
-    if (DevicePath == NULL) {\r
-      continue;\r
-    }\r
-\r
-    Acpi = NULL;\r
-    while (!IsDevicePathEnd (DevicePath)) {\r
-      Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;\r
-      DevicePath = NextDevicePathNode (DevicePath);\r
-    }\r
-\r
-    if ((Acpi == NULL) || (DevicePathType (Acpi) != ACPI_DEVICE_PATH) ||\r
-        ((DevicePathSubType (Acpi) != ACPI_DP) && (DevicePathSubType (Acpi) != ACPI_EXTENDED_DP))\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // See if this is an ISA serial port\r
-    //\r
-    // Ignore DMA resource since it is always returned NULL\r
-    //\r
-    if (Acpi->HID == EISA_PNP_ID (0x500) || Acpi->HID == EISA_PNP_ID (0x501)) {\r
-\r
-      if (Acpi->UID < 4 && Address != MAX_UINT16 && Irq != MAX_UINT8) {\r
-        //\r
-        // Get the handle of the child device that has opened the Super I/O Protocol\r
-        //\r
-        Status = gBS->OpenProtocolInformation (\r
-                        HandleBuffer[Index],\r
-                        &gEfiSioProtocolGuid,\r
-                        &OpenInfoBuffer,\r
-                        &EntryCount\r
-                        );\r
-        if (EFI_ERROR (Status)) {\r
-          continue;\r
-        }\r
-        for (ChildIndex = 0; ChildIndex < EntryCount; ChildIndex++) {\r
-          if ((OpenInfoBuffer[ChildIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
-            Status = gBS->HandleProtocol (OpenInfoBuffer[ChildIndex].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **) &SerialIo);\r
-            if (!EFI_ERROR (Status)) {\r
-              SioSerial           = &SioPtr->Serial[Acpi->UID];\r
-              SioSerial->Address  = Address;\r
-              SioSerial->Irq      = Irq;\r
-              SioSerial->Mode     = DEVICE_SERIAL_MODE_NORMAL | DEVICE_SERIAL_MODE_DUPLEX_HALF;\r
-              break;\r
-            }\r
-          }\r
-        }\r
-\r
-        FreePool (OpenInfoBuffer);\r
-      }\r
-    }\r
-    //\r
-    // See if this is an ISA parallel port\r
-    //\r
-    // Ignore DMA resource since it is always returned NULL, port\r
-    // only used in output mode.\r
-    //\r
-    if (Acpi->HID == EISA_PNP_ID (0x400) || Acpi->HID == EISA_PNP_ID (0x401)) {\r
-      if (Acpi->UID < 3 && Address != MAX_UINT16 && Irq != MAX_UINT8 && Dma != MAX_UINT8) {\r
-        SioParallel           = &SioPtr->Parallel[Acpi->UID];\r
-        SioParallel->Address  = Address;\r
-        SioParallel->Irq      = Irq;\r
-        SioParallel->Dma      = Dma;\r
-        SioParallel->Mode     = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;\r
-      }\r
-    }\r
-    //\r
-    // See if this is an ISA floppy controller\r
-    //\r
-    if (Acpi->HID == EISA_PNP_ID (0x604)) {\r
-      if (Address != MAX_UINT16 && Irq != MAX_UINT8 && Dma != MAX_UINT8) {\r
-        Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
-        if (!EFI_ERROR (Status)) {\r
-          SioFloppy           = &SioPtr->Floppy;\r
-          SioFloppy->Address  = Address;\r
-          SioFloppy->Irq      = Irq;\r
-          SioFloppy->Dma      = Dma;\r
-          SioFloppy->NumberOfFloppy++;\r
-        }\r
-      }\r
-    }\r
-    //\r
-    // See if this is a mouse\r
-    // Always set mouse found so USB hot plug will work\r
-    //\r
-    // Ignore lower byte of HID. Pnp0fxx is any type of mouse.\r
-    //\r
-    //    Hid = ResourceList->Device.HID & 0xff00ffff;\r
-    //    PnpId = EISA_PNP_ID(0x0f00);\r
-    //    if (Hid == PnpId) {\r
-    //      if (ResourceList->Device.UID == 1) {\r
-    //        Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiSimplePointerProtocolGuid, &SimplePointer);\r
-    //      if (!EFI_ERROR (Status)) {\r
-    //\r
-    SioPtr->MousePresent = 0x01;\r
-    //\r
-    //        }\r
-    //      }\r
-    //    }\r
-    //\r
-  }\r
-\r
-  FreePool (HandleBuffer);\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-/**\r
-  Collect EFI Info about legacy devices through ISA IO interface.\r
-\r
-  @param  SioPtr       Pointer to SIO data.\r
-\r
-  @retval EFI_SUCCESS   When SIO data is got successfully.\r
-  @retval EFI_NOT_FOUND When ISA IO interface is absent.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildSioDataFromIsaIo (\r
-  IN DEVICE_PRODUCER_DATA_HEADER      *SioPtr\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  DEVICE_PRODUCER_SERIAL              *SioSerial;\r
-  DEVICE_PRODUCER_PARALLEL            *SioParallel;\r
-  DEVICE_PRODUCER_FLOPPY              *SioFloppy;\r
-  UINTN                               HandleCount;\r
-  EFI_HANDLE                          *HandleBuffer;\r
-  UINTN                               Index;\r
-  UINTN                               ResourceIndex;\r
-  UINTN                               ChildIndex;\r
-  EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
-  EFI_ISA_ACPI_RESOURCE_LIST          *ResourceList;\r
-  EFI_ISA_ACPI_RESOURCE               *IoResource;\r
-  EFI_ISA_ACPI_RESOURCE               *DmaResource;\r
-  EFI_ISA_ACPI_RESOURCE               *InterruptResource;\r
-  UINTN                               EntryCount;\r
-  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
-  EFI_BLOCK_IO_PROTOCOL               *BlockIo;\r
-  EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
-\r
-  //\r
-  // Get the list of ISA controllers in the system\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Collect legacy information from each of the ISA controllers in the system\r
-  //\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-\r
-    Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiIsaIoProtocolGuid, (VOID **) &IsaIo);\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    ResourceList = IsaIo->ResourceList;\r
-\r
-    if (ResourceList == NULL) {\r
-      continue;\r
-    }\r
-    //\r
-    // Collect the resource types neededto fill in the SIO data structure\r
-    //\r
-    IoResource        = NULL;\r
-    DmaResource       = NULL;\r
-    InterruptResource = NULL;\r
-    for (ResourceIndex = 0;\r
-         ResourceList->ResourceItem[ResourceIndex].Type != EfiIsaAcpiResourceEndOfList;\r
-         ResourceIndex++\r
-        ) {\r
-      switch (ResourceList->ResourceItem[ResourceIndex].Type) {\r
-      case EfiIsaAcpiResourceIo:\r
-        IoResource = &ResourceList->ResourceItem[ResourceIndex];\r
-        break;\r
-\r
-      case EfiIsaAcpiResourceMemory:\r
-        break;\r
-\r
-      case EfiIsaAcpiResourceDma:\r
-        DmaResource = &ResourceList->ResourceItem[ResourceIndex];\r
-        break;\r
-\r
-      case EfiIsaAcpiResourceInterrupt:\r
-        InterruptResource = &ResourceList->ResourceItem[ResourceIndex];\r
-        break;\r
-\r
-      default:\r
-        break;\r
-      }\r
-    }\r
-    //\r
-    // See if this is an ISA serial port\r
-    //\r
-    // Ignore DMA resource since it is always returned NULL\r
-    //\r
-    if (ResourceList->Device.HID == EISA_PNP_ID (0x500) || ResourceList->Device.HID == EISA_PNP_ID (0x501)) {\r
-\r
-      if (ResourceList->Device.UID <= 3 &&\r
-          IoResource != NULL &&\r
-          InterruptResource != NULL\r
-          ) {\r
-        //\r
-        // Get the handle of the child device that has opened the ISA I/O Protocol\r
-        //\r
-        Status = gBS->OpenProtocolInformation (\r
-                        HandleBuffer[Index],\r
-                        &gEfiIsaIoProtocolGuid,\r
-                        &OpenInfoBuffer,\r
-                        &EntryCount\r
-                        );\r
-        if (EFI_ERROR (Status)) {\r
-          continue;\r
-        }\r
-        //\r
-        // We want resource for legacy even if no 32-bit driver installed\r
-        //\r
-        for (ChildIndex = 0; ChildIndex < EntryCount; ChildIndex++) {\r
-          if ((OpenInfoBuffer[ChildIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
-            Status = gBS->HandleProtocol (OpenInfoBuffer[ChildIndex].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **) &SerialIo);\r
-            if (!EFI_ERROR (Status)) {\r
-              SioSerial           = &SioPtr->Serial[ResourceList->Device.UID];\r
-              SioSerial->Address  = (UINT16) IoResource->StartRange;\r
-              SioSerial->Irq      = (UINT8) InterruptResource->StartRange;\r
-              SioSerial->Mode     = DEVICE_SERIAL_MODE_NORMAL | DEVICE_SERIAL_MODE_DUPLEX_HALF;\r
-              break;\r
-            }\r
-          }\r
-        }\r
-\r
-        FreePool (OpenInfoBuffer);\r
-      }\r
-    }\r
-    //\r
-    // See if this is an ISA parallel port\r
-    //\r
-    // Ignore DMA resource since it is always returned NULL, port\r
-    // only used in output mode.\r
-    //\r
-    if (ResourceList->Device.HID == EISA_PNP_ID (0x400) || ResourceList->Device.HID == EISA_PNP_ID (0x401)) {\r
-      if (ResourceList->Device.UID <= 2 &&\r
-          IoResource != NULL &&\r
-          InterruptResource != NULL &&\r
-          DmaResource != NULL\r
-          ) {\r
-        SioParallel           = &SioPtr->Parallel[ResourceList->Device.UID];\r
-        SioParallel->Address  = (UINT16) IoResource->StartRange;\r
-        SioParallel->Irq      = (UINT8) InterruptResource->StartRange;\r
-        SioParallel->Dma      = (UINT8) DmaResource->StartRange;\r
-        SioParallel->Mode     = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;\r
-      }\r
-    }\r
-    //\r
-    // See if this is an ISA floppy controller\r
-    //\r
-    if (ResourceList->Device.HID == EISA_PNP_ID (0x604)) {\r
-      if (IoResource != NULL && InterruptResource != NULL && DmaResource != NULL) {\r
-        Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
-        if (!EFI_ERROR (Status)) {\r
-          SioFloppy           = &SioPtr->Floppy;\r
-          SioFloppy->Address  = (UINT16) IoResource->StartRange;\r
-          SioFloppy->Irq      = (UINT8) InterruptResource->StartRange;\r
-          SioFloppy->Dma      = (UINT8) DmaResource->StartRange;\r
-          SioFloppy->NumberOfFloppy++;\r
-        }\r
-      }\r
-    }\r
-    //\r
-    // See if this is a mouse\r
-    // Always set mouse found so USB hot plug will work\r
-    //\r
-    // Ignore lower byte of HID. Pnp0fxx is any type of mouse.\r
-    //\r
-    //    Hid = ResourceList->Device.HID & 0xff00ffff;\r
-    //    PnpId = EISA_PNP_ID(0x0f00);\r
-    //    if (Hid == PnpId) {\r
-    //      if (ResourceList->Device.UID == 1) {\r
-    //        Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiSimplePointerProtocolGuid, &SimplePointer);\r
-    //      if (!EFI_ERROR (Status)) {\r
-    //\r
-    SioPtr->MousePresent = 0x01;\r
-    //\r
-    //        }\r
-    //      }\r
-    //    }\r
-    //\r
-  }\r
-\r
-  FreePool (HandleBuffer);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Collect EFI Info about legacy devices.\r
-\r
-  @param  Private      Legacy BIOS Instance data\r
-\r
-  @retval EFI_SUCCESS  It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosBuildSioData (\r
-  IN  LEGACY_BIOS_INSTANCE      *Private\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  DEVICE_PRODUCER_DATA_HEADER         *SioPtr;\r
-  EFI_HANDLE                          IsaBusController;\r
-  UINTN                               HandleCount;\r
-  EFI_HANDLE                          *HandleBuffer;\r
-\r
-  //\r
-  // Get the pointer to the SIO data structure\r
-  //\r
-  SioPtr = &Private->IntThunk->EfiToLegacy16BootTable.SioData;\r
-\r
-  //\r
-  // Zero the data in the SIO data structure\r
-  //\r
-  gBS->SetMem (SioPtr, sizeof (DEVICE_PRODUCER_DATA_HEADER), 0);\r
-\r
-  //\r
-  // Find the ISA Bus Controller used for legacy\r
-  //\r
-  Status = Private->LegacyBiosPlatform->GetPlatformHandle (\r
-                                          Private->LegacyBiosPlatform,\r
-                                          EfiGetPlatformIsaBusHandle,\r
-                                          0,\r
-                                          &HandleBuffer,\r
-                                          &HandleCount,\r
-                                          NULL\r
-                                          );\r
-  IsaBusController = HandleBuffer[0];\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Force ISA Bus Controller to produce all ISA devices\r
-    //\r
-    gBS->ConnectController (IsaBusController, NULL, NULL, TRUE);\r
-  }\r
-\r
-  Status = LegacyBiosBuildSioDataFromIsaIo (SioPtr);\r
-  if (EFI_ERROR (Status)) {\r
-    LegacyBiosBuildSioDataFromSio (SioPtr);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/Thunk.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/Thunk.c
deleted file mode 100644 (file)
index a4985ed..0000000
+++ /dev/null
@@ -1,419 +0,0 @@
-/** @file\r
-  Call into 16-bit BIOS code, Use AsmThunk16 function of BaseLib.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-\r
-THUNK_CONTEXT      mThunkContext;\r
-\r
-/**\r
-  Sets the counter value for Timer #0 in a legacy 8254 timer.\r
-\r
-  @param  Count - The 16-bit counter value to program into Timer #0 of the legacy 8254 timer.\r
-\r
-**/\r
-VOID\r
-SetPitCount (\r
-  IN UINT16  Count\r
-  )\r
-{\r
-  IoWrite8 (TIMER_CONTROL_PORT, TIMER0_CONTROL_WORD);\r
-  IoWrite8 (TIMER0_COUNT_PORT, (UINT8) (Count & 0xFF));\r
-  IoWrite8 (TIMER0_COUNT_PORT, (UINT8) ((Count>>8) & 0xFF));\r
-}\r
-\r
-/**\r
-  Thunk to 16-bit real mode and execute a software interrupt with a vector\r
-  of BiosInt. Regs will contain the 16-bit register context on entry and\r
-  exit.\r
-\r
-  @param  This    Protocol instance pointer.\r
-  @param  BiosInt Processor interrupt vector to invoke\r
-  @param  Regs    Register contexted passed into (and returned) from thunk to\r
-                  16-bit mode\r
-\r
-  @retval FALSE   Thunk completed, and there were no BIOS errors in the target code.\r
-                  See Regs for status.\r
-  @retval TRUE    There was a BIOS erro in the target code.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-LegacyBiosInt86 (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL      *This,\r
-  IN  UINT8                         BiosInt,\r
-  IN  EFI_IA32_REGISTER_SET         *Regs\r
-  )\r
-{\r
-  UINT16                Segment;\r
-  UINT16                Offset;\r
-\r
-  Regs->X.Flags.Reserved1 = 1;\r
-  Regs->X.Flags.Reserved2 = 0;\r
-  Regs->X.Flags.Reserved3 = 0;\r
-  Regs->X.Flags.Reserved4 = 0;\r
-  Regs->X.Flags.IOPL      = 3;\r
-  Regs->X.Flags.NT        = 0;\r
-  Regs->X.Flags.IF        = 0;\r
-  Regs->X.Flags.TF        = 0;\r
-  Regs->X.Flags.CF        = 0;\r
-  //\r
-  // The base address of legacy interrupt vector table is 0.\r
-  // We use this base address to get the legacy interrupt handler.\r
-  //\r
-  ACCESS_PAGE0_CODE (\r
-    Segment               = (UINT16)(((UINT32 *)0)[BiosInt] >> 16);\r
-    Offset                = (UINT16)((UINT32 *)0)[BiosInt];\r
-  );\r
-\r
-  return InternalLegacyBiosFarCall (\r
-           This,\r
-           Segment,\r
-           Offset,\r
-           Regs,\r
-           &Regs->X.Flags,\r
-           sizeof (Regs->X.Flags)\r
-           );\r
-}\r
-\r
-/**\r
-  Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the\r
-  16-bit register context on entry and exit. Arguments can be passed on\r
-  the Stack argument\r
-\r
-  @param  This                   Protocol instance pointer.\r
-  @param  Segment                Segemnt of 16-bit mode call\r
-  @param  Offset                 Offset of 16-bit mdoe call\r
-  @param  Regs                   Register contexted passed into (and returned) from\r
-                                 thunk to  16-bit mode\r
-  @param  Stack                  Caller allocated stack used to pass arguments\r
-  @param  StackSize              Size of Stack in bytes\r
-\r
-  @retval FALSE                  Thunk completed, and there were no BIOS errors in\r
-                                 the target code. See Regs for status.\r
-  @retval TRUE                   There was a BIOS erro in the target code.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-LegacyBiosFarCall86 (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL        *This,\r
-  IN  UINT16                          Segment,\r
-  IN  UINT16                          Offset,\r
-  IN  EFI_IA32_REGISTER_SET           *Regs,\r
-  IN  VOID                            *Stack,\r
-  IN  UINTN                           StackSize\r
-  )\r
-{\r
-  Regs->X.Flags.Reserved1 = 1;\r
-  Regs->X.Flags.Reserved2 = 0;\r
-  Regs->X.Flags.Reserved3 = 0;\r
-  Regs->X.Flags.Reserved4 = 0;\r
-  Regs->X.Flags.IOPL      = 3;\r
-  Regs->X.Flags.NT        = 0;\r
-  Regs->X.Flags.IF        = 1;\r
-  Regs->X.Flags.TF        = 0;\r
-  Regs->X.Flags.CF        = 0;\r
-\r
-  return InternalLegacyBiosFarCall (This, Segment, Offset, Regs, Stack, StackSize);\r
-}\r
-\r
-/**\r
-  Provide NULL interrupt handler which is used to check\r
-  if there is more than one HW interrupt registers with the CPU AP.\r
-\r
-  @param  InterruptType - The type of interrupt that occured\r
-  @param  SystemContext - A pointer to the system context when the interrupt occured\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-LegacyBiosNullInterruptHandler (\r
-  IN EFI_EXCEPTION_TYPE   InterruptType,\r
-  IN EFI_SYSTEM_CONTEXT   SystemContext\r
-  )\r
-{\r
-}\r
-\r
-/**\r
-  Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the\r
-  16-bit register context on entry and exit. Arguments can be passed on\r
-  the Stack argument\r
-\r
-  @param  This       Protocol instance pointer.\r
-  @param  Segment    Segemnt of 16-bit mode call\r
-  @param  Offset     Offset of 16-bit mdoe call\r
-  @param  Regs       Register contexted passed into (and returned) from thunk to\r
-                     16-bit mode\r
-  @param  Stack      Caller allocated stack used to pass arguments\r
-  @param  StackSize  Size of Stack in bytes\r
-\r
-  @retval FALSE      Thunk completed, and there were no BIOS errors in the target code.\r
-                     See Regs for status.\r
-  @retval TRUE       There was a BIOS erro in the target code.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-InternalLegacyBiosFarCall (\r
-  IN  EFI_LEGACY_BIOS_PROTOCOL        *This,\r
-  IN  UINT16                          Segment,\r
-  IN  UINT16                          Offset,\r
-  IN  EFI_IA32_REGISTER_SET           *Regs,\r
-  IN  VOID                            *Stack,\r
-  IN  UINTN                           StackSize\r
-  )\r
-{\r
-  UINTN                 Status;\r
-  LEGACY_BIOS_INSTANCE  *Private;\r
-  UINT16                *Stack16;\r
-  EFI_TPL               OriginalTpl;\r
-  IA32_REGISTER_SET     ThunkRegSet;\r
-  BOOLEAN               InterruptState;\r
-  UINT64                TimerPeriod;\r
-\r
-  Private = LEGACY_BIOS_INSTANCE_FROM_THIS (This);\r
-\r
-  ZeroMem (&ThunkRegSet, sizeof (ThunkRegSet));\r
-  ThunkRegSet.X.DI   = Regs->X.DI;\r
-  ThunkRegSet.X.SI   = Regs->X.SI;\r
-  ThunkRegSet.X.BP   = Regs->X.BP;\r
-  ThunkRegSet.X.BX   = Regs->X.BX;\r
-  ThunkRegSet.X.DX   = Regs->X.DX;\r
-  //\r
-  // Sometimes, ECX is used to pass in 32 bit data. For example, INT 1Ah, AX = B10Dh is\r
-  // "PCI BIOS v2.0c + Write Configuration DWORD" and ECX has the dword to write.\r
-  //\r
-  ThunkRegSet.E.ECX   = Regs->E.ECX;\r
-  ThunkRegSet.X.AX   = Regs->X.AX;\r
-  ThunkRegSet.E.DS   = Regs->X.DS;\r
-  ThunkRegSet.E.ES   = Regs->X.ES;\r
-\r
-  CopyMem (&(ThunkRegSet.E.EFLAGS.UintN), &(Regs->X.Flags), sizeof (Regs->X.Flags));\r
-\r
-  //\r
-  // Clear the error flag; thunk code may set it. Stack16 should be the high address\r
-  // Make Statk16 address the low 16 bit must be not zero.\r
-  //\r
-  Stack16 = (UINT16 *)((UINT8 *) mThunkContext.RealModeBuffer + mThunkContext.RealModeBufferSize - sizeof (UINT16));\r
-\r
-  //\r
-  // Save current rate of DXE Timer\r
-  //\r
-  Private->Timer->GetTimerPeriod (Private->Timer, &TimerPeriod);\r
-\r
-  //\r
-  // Disable DXE Timer while executing in real mode\r
-  //\r
-  Private->Timer->SetTimerPeriod (Private->Timer, 0);\r
-\r
-  //\r
-  // Save and disable interrupt of debug timer\r
-  //\r
-  InterruptState = SaveAndSetDebugTimerInterrupt (FALSE);\r
-\r
-  //\r
-  // The call to Legacy16 is a critical section to EFI\r
-  //\r
-  OriginalTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  //\r
-  // Check to see if there is more than one HW interrupt registers with the CPU AP.\r
-  // If there is, then ASSERT() since that is not compatible with the CSM because\r
-  // interupts other than the Timer interrupt that was disabled above can not be\r
-  // handled properly from real mode.\r
-  //\r
-  DEBUG_CODE (\r
-    UINTN  Vector;\r
-    UINTN  Count;\r
-\r
-    for (Vector = 0x20, Count = 0; Vector < 0x100; Vector++) {\r
-      Status = Private->Cpu->RegisterInterruptHandler (Private->Cpu, Vector, LegacyBiosNullInterruptHandler);\r
-      if (Status == EFI_ALREADY_STARTED) {\r
-        Count++;\r
-      }\r
-      if (Status == EFI_SUCCESS) {\r
-        Private->Cpu->RegisterInterruptHandler (Private->Cpu, Vector, NULL);\r
-      }\r
-    }\r
-    if (Count >= 2) {\r
-      DEBUG ((EFI_D_ERROR, "ERROR: More than one HW interrupt active with CSM enabled\n"));\r
-    }\r
-    ASSERT (Count < 2);\r
-  );\r
-\r
-  //\r
-  // If the Timer AP has enabled the 8254 timer IRQ and the current 8254 timer\r
-  // period is less than the CSM required rate of 54.9254, then force the 8254\r
-  // PIT counter to 0, which is the CSM required rate of 54.9254 ms\r
-  //\r
-  if (Private->TimerUses8254 && TimerPeriod < 549254) {\r
-    SetPitCount (0);\r
-  }\r
-\r
-  if (Stack != NULL && StackSize != 0) {\r
-    //\r
-    // Copy Stack to low memory stack\r
-    //\r
-    Stack16 -= StackSize / sizeof (UINT16);\r
-    CopyMem (Stack16, Stack, StackSize);\r
-  }\r
-\r
-  ThunkRegSet.E.SS   = (UINT16) (((UINTN) Stack16 >> 16) << 12);\r
-  ThunkRegSet.E.ESP  = (UINT16) (UINTN) Stack16;\r
-  ThunkRegSet.E.CS   = Segment;\r
-  ThunkRegSet.E.Eip  = Offset;\r
-\r
-  mThunkContext.RealModeState      = &ThunkRegSet;\r
-\r
-  //\r
-  // Set Legacy16 state. 0x08, 0x70 is legacy 8259 vector bases.\r
-  //\r
-  Status = Private->Legacy8259->SetMode (Private->Legacy8259, Efi8259LegacyMode, NULL, NULL);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  AsmThunk16 (&mThunkContext);\r
-\r
-  if (Stack != NULL && StackSize != 0) {\r
-    //\r
-    // Copy low memory stack to Stack\r
-    //\r
-    CopyMem (Stack, Stack16, StackSize);\r
-  }\r
-\r
-  //\r
-  // Restore protected mode interrupt state\r
-  //\r
-  Status = Private->Legacy8259->SetMode (Private->Legacy8259, Efi8259ProtectedMode, NULL, NULL);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  mThunkContext.RealModeState = NULL;\r
-\r
-  //\r
-  // Enable and restore rate of DXE Timer\r
-  //\r
-  Private->Timer->SetTimerPeriod (Private->Timer, TimerPeriod);\r
-\r
-  //\r
-  // End critical section\r
-  //\r
-  gBS->RestoreTPL (OriginalTpl);\r
-\r
-  //\r
-  // OPROM may allocate EBDA range by itself and change EBDA base and EBDA size.\r
-  // Get the current EBDA base address, and compared with pre-allocate minimum\r
-  // EBDA base address, if the current EBDA base address is smaller, it indicates\r
-  // PcdEbdaReservedMemorySize should be adjusted to larger for more OPROMs.\r
-  //\r
-  DEBUG_CODE (\r
-    {\r
-      UINTN                 EbdaBaseAddress;\r
-      UINTN                 ReservedEbdaBaseAddress;\r
-\r
-      ACCESS_PAGE0_CODE (\r
-        EbdaBaseAddress = (*(UINT16 *) (UINTN) 0x40E) << 4;\r
-        ReservedEbdaBaseAddress = CONVENTIONAL_MEMORY_TOP\r
-                                  - PcdGet32 (PcdEbdaReservedMemorySize);\r
-        ASSERT (ReservedEbdaBaseAddress <= EbdaBaseAddress);\r
-      );\r
-    }\r
-  );\r
-\r
-  //\r
-  // Restore interrupt of debug timer\r
-  //\r
-  SaveAndSetDebugTimerInterrupt (InterruptState);\r
-\r
-  Regs->E.EDI      = ThunkRegSet.E.EDI;\r
-  Regs->E.ESI      = ThunkRegSet.E.ESI;\r
-  Regs->E.EBP      = ThunkRegSet.E.EBP;\r
-  Regs->E.EBX      = ThunkRegSet.E.EBX;\r
-  Regs->E.EDX      = ThunkRegSet.E.EDX;\r
-  Regs->E.ECX      = ThunkRegSet.E.ECX;\r
-  Regs->E.EAX      = ThunkRegSet.E.EAX;\r
-  Regs->X.SS       = ThunkRegSet.E.SS;\r
-  Regs->X.CS       = ThunkRegSet.E.CS;\r
-  Regs->X.DS       = ThunkRegSet.E.DS;\r
-  Regs->X.ES       = ThunkRegSet.E.ES;\r
-\r
-  CopyMem (&(Regs->X.Flags), &(ThunkRegSet.E.EFLAGS.UintN), sizeof (Regs->X.Flags));\r
-\r
-  return (BOOLEAN) (Regs->X.Flags.CF == 1);\r
-}\r
-\r
-/**\r
-  Allocate memory < 1 MB and copy the thunker code into low memory. Se up\r
-  all the descriptors.\r
-\r
-  @param  Private                Private context for Legacy BIOS\r
-\r
-  @retval EFI_SUCCESS            Should only pass.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosInitializeThunk (\r
-  IN  LEGACY_BIOS_INSTANCE    *Private\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_PHYSICAL_ADDRESS    MemoryAddress;\r
-  UINT8                   TimerVector;\r
-\r
-  MemoryAddress   = (EFI_PHYSICAL_ADDRESS) (UINTN) Private->IntThunk;\r
-\r
-  mThunkContext.RealModeBuffer     = (VOID *) (UINTN) (MemoryAddress + ((sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 1) * EFI_PAGE_SIZE);\r
-  mThunkContext.RealModeBufferSize = EFI_PAGE_SIZE;\r
-  mThunkContext.ThunkAttributes    = THUNK_ATTRIBUTE_BIG_REAL_MODE | THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15;\r
-\r
-  AsmPrepareThunk16 (&mThunkContext);\r
-\r
-  //\r
-  // Get the interrupt vector number corresponding to IRQ0 from the 8259 driver\r
-  //\r
-  TimerVector = 0;\r
-  Status = Private->Legacy8259->GetVector (Private->Legacy8259, Efi8259Irq0, &TimerVector);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Check to see if the Timer AP has hooked the IRQ0 from the 8254 PIT\r
-  //\r
-  Status = Private->Cpu->RegisterInterruptHandler (\r
-                           Private->Cpu,\r
-                           TimerVector,\r
-                           LegacyBiosNullInterruptHandler\r
-                           );\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // If the Timer AP has not enabled the 8254 timer IRQ, then force the 8254 PIT\r
-    // counter to 0, which is the CSM required rate of 54.9254 ms\r
-    //\r
-    Private->Cpu->RegisterInterruptHandler (\r
-                    Private->Cpu,\r
-                    TimerVector,\r
-                    NULL\r
-                    );\r
-    SetPitCount (0);\r
-\r
-    //\r
-    // Save status that the Timer AP is not using the 8254 PIT\r
-    //\r
-    Private->TimerUses8254 = FALSE;\r
-  } else if (Status == EFI_ALREADY_STARTED) {\r
-    //\r
-    // Save status that the Timer AP is using the 8254 PIT\r
-    //\r
-    Private->TimerUses8254 = TRUE;\r
-  } else {\r
-    //\r
-    // Unexpected status from CPU AP RegisterInterruptHandler()\r
-    //\r
-    ASSERT (FALSE);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/X64/InterruptTable.nasm b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/X64/InterruptTable.nasm
deleted file mode 100644 (file)
index afc2f0e..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-;; @file\r
-;  Interrupt Redirection Template\r
-;\r
-; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
-;\r
-; SPDX-License-Identifier: BSD-2-Clause-Patent\r
-;\r
-;;\r
-\r
-    DEFAULT REL\r
-    SECTION .text\r
-\r
-;----------------------------------------------------------------------------\r
-; Procedure:    InterruptRedirectionTemplate: Redirects interrupts 0x68-0x6F\r
-;\r
-; Input:        None\r
-;\r
-; Output:       None\r
-;\r
-; Prototype:    VOID\r
-;               InterruptRedirectionTemplate (\r
-;                                VOID\r
-;                                );\r
-;\r
-; Saves:        None\r
-;\r
-; Modified:     None\r
-;\r
-; Description:  Contains the code that is copied into low memory (below 640K).\r
-;               This code reflects interrupts 0x68-0x6f to interrupts 0x08-0x0f.\r
-;               This template must be copied into low memory, and the IDT entries\r
-;               0x68-0x6F must be point to the low memory copy of this code.  Each\r
-;               entry is 4 bytes long, so IDT entries 0x68-0x6F can be easily\r
-;               computed.\r
-;\r
-;----------------------------------------------------------------------------\r
-\r
-global ASM_PFX(InterruptRedirectionTemplate)\r
-ASM_PFX(InterruptRedirectionTemplate):\r
-  int     0x8\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0x9\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xa\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xb\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xc\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xd\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xe\r
-  DB      0xcf          ; IRET\r
-  nop\r
-  int     0xf\r
-  DB      0xcf          ; IRET\r
-  nop\r
-\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/AcpiVariableCompatibility.h b/IntelFrameworkModulePkg/Include/Guid/AcpiVariableCompatibility.h
deleted file mode 100644 (file)
index 578b6b5..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/** @file\r
-  Definitions for data structures used in S3 resume.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _ACPI_VARIABLE_COMPATIBILITY_H_\r
-#define _ACPI_VARIABLE_COMPATIBILITY_H_\r
-\r
-#define EFI_ACPI_VARIABLE_COMPATIBILITY_GUID \\r
-  { \\r
-    0xc020489e, 0x6db2, 0x4ef2, {0x9a, 0xa5, 0xca, 0x6, 0xfc, 0x11, 0xd3, 0x6a } \\r
-  }\r
-\r
-#define ACPI_GLOBAL_VARIABLE  L"AcpiGlobalVariable"\r
-\r
-extern EFI_GUID gEfiAcpiVariableCompatiblityGuid;\r
-\r
-typedef struct {\r
-  BOOLEAN               APState;\r
-  BOOLEAN               S3BootPath;\r
-  EFI_PHYSICAL_ADDRESS  WakeUpBuffer;\r
-  EFI_PHYSICAL_ADDRESS  GdtrProfile;\r
-  EFI_PHYSICAL_ADDRESS  IdtrProfile;\r
-  EFI_PHYSICAL_ADDRESS  CpuPrivateData;\r
-  EFI_PHYSICAL_ADDRESS  StackAddress;\r
-  EFI_PHYSICAL_ADDRESS  MicrocodePointerBuffer;\r
-  EFI_PHYSICAL_ADDRESS  SmramBase;\r
-  EFI_PHYSICAL_ADDRESS  SmmStartImageBase;\r
-  UINT32                SmmStartImageSize;\r
-  UINT32                NumberOfCpus;\r
-} ACPI_CPU_DATA_COMPATIBILITY;\r
-\r
-typedef struct {\r
-  //\r
-  // Acpi Related variables\r
-  //\r
-  EFI_PHYSICAL_ADDRESS  AcpiReservedMemoryBase;\r
-  UINT32                AcpiReservedMemorySize;\r
-  EFI_PHYSICAL_ADDRESS  S3ReservedLowMemoryBase;\r
-  EFI_PHYSICAL_ADDRESS  AcpiBootScriptTable;\r
-  EFI_PHYSICAL_ADDRESS  RuntimeScriptTableBase;\r
-  EFI_PHYSICAL_ADDRESS  AcpiFacsTable;\r
-  UINT64                SystemMemoryLength;\r
-  ACPI_CPU_DATA_COMPATIBILITY         AcpiCpuData;\r
-  //\r
-  // VGA OPROM to support Video Re-POST for Linux S3\r
-  //\r
-  EFI_PHYSICAL_ADDRESS  VideoOpromAddress;\r
-  UINT32                VideoOpromSize;\r
-\r
-  //\r
-  // S3 Debug extension\r
-  //\r
-  EFI_PHYSICAL_ADDRESS  S3DebugBufferAddress;\r
-  EFI_PHYSICAL_ADDRESS  S3ResumeNvsEntryPoint;\r
-} ACPI_VARIABLE_SET_COMPATIBILITY;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/BdsHii.h b/IntelFrameworkModulePkg/Include/Guid/BdsHii.h
deleted file mode 100644 (file)
index 56c699c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/** @file\r
-  GUIDs used as HII FormSet and HII Package list GUID in BdsDxe driver.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __BDS_HII_GUIDS_H__\r
-#define __BDS_HII_GUIDS_H__\r
-\r
-#define FRONT_PAGE_FORMSET_GUID \\r
-  { \\r
-    0x9e0c30bc, 0x3f06, 0x4ba6, {0x82, 0x88, 0x9, 0x17, 0x9b, 0x85, 0x5d, 0xbe} \\r
-  }\r
-\r
-#define BOOT_MANAGER_FORMSET_GUID \\r
-  { \\r
-  0x847bc3fe, 0xb974, 0x446d, {0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b} \\r
-  }\r
-\r
-#define DEVICE_MANAGER_FORMSET_GUID  \\r
-  { \\r
-  0x3ebfa8e6, 0x511d, 0x4b5b, {0xa9, 0x5f, 0xfb, 0x38, 0x26, 0xf, 0x1c, 0x27} \\r
-  }\r
-\r
-#define DRIVER_HEALTH_FORMSET_GUID  \\r
-  { \\r
-  0xf76e0a70, 0xb5ed, 0x4c38, {0xac, 0x9a, 0xe5, 0xf5, 0x4b, 0xf1, 0x6e, 0x34} \\r
-  }\r
-\r
-#define BOOT_MAINT_FORMSET_GUID \\r
-  { \\r
-  0x642237c7, 0x35d4, 0x472d, {0x83, 0x65, 0x12, 0xe0, 0xcc, 0xf2, 0x7a, 0x22} \\r
-  }\r
-\r
-#define FILE_EXPLORE_FORMSET_GUID \\r
-  { \\r
-  0x1f2d63e1, 0xfebd, 0x4dc7, {0x9c, 0xc5, 0xba, 0x2b, 0x1c, 0xef, 0x9c, 0x5b} \\r
-  }\r
-\r
-extern EFI_GUID gFrontPageFormSetGuid;\r
-extern EFI_GUID gBootMaintFormSetGuid;\r
-extern EFI_GUID gFileExploreFormSetGuid;\r
-extern EFI_GUID gBootManagerFormSetGuid;\r
-extern EFI_GUID gDeviceManagerFormSetGuid;\r
-extern EFI_GUID gDriverHealthFormSetGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/BdsLibHii.h b/IntelFrameworkModulePkg/Include/Guid/BdsLibHii.h
deleted file mode 100644 (file)
index 0bdcb7f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/** @file\r
-  GUID used as HII Package list GUID in GenericBdsLib module.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __BDS_LIB_HII_GUID_H__\r
-#define __BDS_LIB_HII_GUID_H__\r
-\r
-#define BDS_LIB_STRING_PACKAGE_GUID \\r
-  { \\r
-  0x3b4d9b23, 0x95ac, 0x44f6, { 0x9f, 0xcd, 0xe, 0x95, 0x94, 0x58, 0x6c, 0x72 } \\r
-  }\r
-\r
-extern EFI_GUID gBdsLibStringPackageGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/BlockIoVendor.h b/IntelFrameworkModulePkg/Include/Guid/BlockIoVendor.h
deleted file mode 100644 (file)
index 6b0ee2d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/** @file\r
-  Guid for unrecognized EDD 3.0 device.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __BLOCKIO_VENDOR_H__\r
-#define __BLOCKIO_VENDOR_H__\r
-\r
-//\r
-// Guid is to specifiy the unrecognized EDD 3.0 device.\r
-//\r
-#define BLOCKIO_VENDOR_GUID \\r
-  { 0xcf31fac5, 0xc24e, 0x11d2,  {0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b}  }\r
-\r
-typedef struct {\r
-  VENDOR_DEVICE_PATH              DevicePath;\r
-  UINT8                           LegacyDriveLetter;\r
-} BLOCKIO_VENDOR_DEVICE_PATH;\r
-\r
-extern GUID gBlockIoVendorGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/CapsuleDataFile.h b/IntelFrameworkModulePkg/Include/Guid/CapsuleDataFile.h
deleted file mode 100644 (file)
index 13ba778..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/** @file\r
-  GUID to specify which FFS file to store the updated capsule data.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __UPDATE_DATA_FILE_GUID_H__\r
-#define __UPDATE_DATA_FILE_GUID_H__\r
-\r
-#define EFI_UPDATE_DATA_FILE_GUID \\r
- { 0x283fa2ee, 0x532c, 0x484d, { 0x93, 0x83, 0x9f, 0x93, 0xb3, 0x6f, 0xb, 0x7e } }\r
-\r
-extern GUID gEfiUpdateDataFileGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/DataHubStatusCodeRecord.h b/IntelFrameworkModulePkg/Include/Guid/DataHubStatusCodeRecord.h
deleted file mode 100644 (file)
index 3f1b918..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/** @file\r
-  GUID used to identify Data Hub records logged by Status Code Protocol.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __DATA_HUB_STATUS_CODE_RECORD_H__\r
-#define __DATA_HUB_STATUS_CODE_RECORD_H__\r
-\r
-///\r
-/// The Global ID used to identify a structure of type DATA_HUB_STATUS_CODE_DATA_RECORD.\r
-///\r
-#define EFI_DATA_HUB_STATUS_CODE_RECORD_GUID \\r
-  { \\r
-    0xd083e94c, 0x6560, 0x42e4, {0xb6, 0xd4, 0x2d, 0xf7, 0x5a, 0xdf, 0x6a, 0x2a } \\r
-  }\r
-\r
-///\r
-/// The Data Hub data record that is used to store all the parameters passed into\r
-/// the ReportStatusCode() service of the EFI_STATUS_CODE_PROTOCOL.\r
-///\r
-typedef struct {\r
-  ///\r
-  /// Status Code type to be reported.\r
-  ///\r
-  EFI_STATUS_CODE_TYPE   CodeType;\r
-\r
-  ///\r
-  /// An operation, plus value information about the class and subclass, used to\r
-  /// classify the hardware and software entity.\r
-  ///\r
-  EFI_STATUS_CODE_VALUE  Value;\r
-\r
-  ///\r
-  /// The enumeration of a hardware or software entity within\r
-  /// the system.  Valid instance numbers start with 1.\r
-  ///\r
-  UINT32                 Instance;\r
-\r
-  ///\r
-  /// Identify the caller.\r
-  ///\r
-  EFI_GUID               CallerId;\r
-\r
-  ///\r
-  /// Additional status code data.\r
-  ///\r
-  EFI_STATUS_CODE_DATA   Data;\r
-} DATA_HUB_STATUS_CODE_DATA_RECORD;\r
-\r
-extern EFI_GUID gEfiDataHubStatusCodeRecordGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/HdBootVariable.h b/IntelFrameworkModulePkg/Include/Guid/HdBootVariable.h
deleted file mode 100644 (file)
index 5016364..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/** @file\r
-  GUID used as EFI Variable for the device path of Boot file on HardDevice.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __HD_DEVICE_PATH_VARIABLE_GUID_H__\r
-#define __HD_DEVICE_PATH_VARIABLE_GUID_H__\r
-\r
-///\r
-/// This GUID is used for an EFI Variable that stores the front device pathes\r
-/// for a partial device path that starts with the HD node.\r
-///\r
-#define HD_BOOT_DEVICE_PATH_VARIABLE_GUID \\r
-  { \\r
-  0xfab7e9e1, 0x39dd, 0x4f2b, { 0x84, 0x8, 0xe2, 0xe, 0x90, 0x6c, 0xb6, 0xde } \\r
-  }\r
-\r
-#define HD_BOOT_DEVICE_PATH_VARIABLE_NAME L"HDDP"\r
-\r
-extern EFI_GUID gHdBootDevicePathVariablGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/IntelFrameworkModulePkgTokenSpace.h b/IntelFrameworkModulePkg/Include/Guid/IntelFrameworkModulePkgTokenSpace.h
deleted file mode 100644 (file)
index 7f0a008..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/** @file\r
-  GUID for IntelFrameworkModulePkg PCD Token Space\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-**/\r
-\r
-#ifndef _INTEL_FRAMEWOKR_MODULEPKG_TOKEN_SPACE_GUID_H_\r
-#define _INTEL_FRAMEWOKR_MODULEPKG_TOKEN_SPACE_GUID_H_\r
-\r
-///\r
-/// The Global ID for the IntelFrameworkModulePkg PCD Token Space .\r
-///\r
-#define INTEL_FRAMEWORK_MODULEPKG_TOKEN_SPACE_GUID \\r
-  { \\r
-    0xD3705011, 0xBC19, 0x4af7, { 0xBE, 0x16, 0xF6, 0x80, 0x30, 0x37, 0x8C, 0x15 } \\r
-  }\r
-\r
-extern EFI_GUID gEfiIntelFrameworkModulePkgTokenSpaceGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/LastEnumLang.h b/IntelFrameworkModulePkg/Include/Guid/LastEnumLang.h
deleted file mode 100644 (file)
index 1a2d66a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/** @file\r
-  GUID used as EFI variable to store platform language at last time enumeration.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __LAST_ENUM_LANGUAGE_GUID_H__\r
-#define __LAST_ENUM_LANGUAGE_GUID_H__\r
-\r
-///\r
-/// This GUID is used for Set/Get platform language into/from variable at last time enumeration\r
-/// to ensure the enumeration will only execute once.\r
-///\r
-#define LAST_ENUM_LANGUAGE_GUID \\r
-  { \\r
-  0xe8c545b, 0xa2ee, 0x470d, { 0x8e, 0x26, 0xbd, 0xa1, 0xa1, 0x3c, 0xa, 0xa3 } \\r
-  }\r
-\r
-#define LAST_ENUM_LANGUAGE_VARIABLE_NAME L"LastEnumLang"\r
-\r
-extern EFI_GUID gLastEnumLangGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/LegacyBios.h b/IntelFrameworkModulePkg/Include/Guid/LegacyBios.h
deleted file mode 100644 (file)
index e35fbff..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/** @file\r
-  Defines a Tag GUID used to mark a UEFI legacy BIOS thunk driver based\r
-  on legacy BIOS services and legacy option ROM. This Tag GUID must be installed on\r
-  the ImageHandle of any module that follows the EFI Driver Model and uses\r
-  the Int86() or FarCall() services of the Legacy Bios Protocol to produce\r
-  a standard UEFI I/O Protocol.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _LEGACY_BIOS_H_\r
-#define _LEGACY_BIOS_H_\r
-\r
-///\r
-/// The Global ID for the Legacy BIOS GUID that must be installed onto the ImageHandle\r
-/// of any module follows the EFI Driver Model and uses the Int86() or FarCall()\r
-/// services of the Legacy BIOS Protocol to produce a standard UEFI I/O Protocol.\r
-///\r
-#define EFI_LEGACY_BIOS_GUID \\r
-  { \\r
-    0x2e3044ac, 0x879f, 0x490f, {0x97, 0x60, 0xbb, 0xdf, 0xaf, 0x69, 0x5f, 0x50 } \\r
-  }\r
-\r
-extern EFI_GUID gEfiLegacyBiosGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Guid/LegacyDevOrder.h b/IntelFrameworkModulePkg/Include/Guid/LegacyDevOrder.h
deleted file mode 100644 (file)
index 8ec3de5..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/** @file\r
-  Guid of a NV Variable which store the information about the\r
-  FD/HD/CD/NET/BEV order.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __LEGACY_DEV_ORDER_VARIABLE_GUID_H__\r
-#define __LEGACY_DEV_ORDER_VARIABLE_GUID_H__\r
-\r
-///\r
-/// Name and Guid of a NV Variable which stores the information about the\r
-/// FD/HD/CD/NET/BEV order\r
-///\r
-#define EFI_LEGACY_DEV_ORDER_VARIABLE_GUID \\r
-  { \\r
-  0xa56074db, 0x65fe, 0x45f7, {0xbd, 0x21, 0x2d, 0x2b, 0xdd, 0x8e, 0x96, 0x52} \\r
-  }\r
-\r
-typedef UINT8 BBS_TYPE;\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  BBS_TYPE  BbsType;\r
-  ///\r
-  /// Length = sizeof (UINT16) + sizeof (Data)\r
-  ///\r
-  UINT16    Length;\r
-  UINT16    Data[1];\r
-} LEGACY_DEV_ORDER_ENTRY;\r
-#pragma pack()\r
-\r
-#define VAR_LEGACY_DEV_ORDER L"LegacyDevOrder"\r
-\r
-extern EFI_GUID gEfiLegacyDevOrderVariableGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h b/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
deleted file mode 100644 (file)
index c0a4c8a..0000000
+++ /dev/null
@@ -1,1108 +0,0 @@
-/** @file\r
-  Generic BDS library defines general interfaces for a BDS driver, including:\r
-    1) BDS boot policy interface.\r
-    2) BDS boot device connect interface.\r
-    3) BDS Misc interfaces for mainting boot variable, ouput string.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _GENERIC_BDS_LIB_H_\r
-#define _GENERIC_BDS_LIB_H_\r
-\r
-#include <Protocol/UserManager.h>\r
-\r
-///\r
-/// Constants which are variable names used to access variables.\r
-///\r
-#define VAR_LEGACY_DEV_ORDER L"LegacyDevOrder"\r
-\r
-///\r
-/// Data structures and defines.\r
-///\r
-#define FRONT_PAGE_QUESTION_ID  0x0000\r
-#define FRONT_PAGE_DATA_WIDTH   0x01\r
-\r
-///\r
-/// ConnectType\r
-///\r
-#define CONSOLE_OUT 0x00000001\r
-#define STD_ERROR   0x00000002\r
-#define CONSOLE_IN  0x00000004\r
-#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
-\r
-///\r
-/// Load Option Attributes\r
-///\r
-#define LOAD_OPTION_ACTIVE              0x00000001\r
-#define LOAD_OPTION_FORCE_RECONNECT     0x00000002\r
-\r
-#define LOAD_OPTION_HIDDEN              0x00000008\r
-#define LOAD_OPTION_CATEGORY            0x00001F00\r
-\r
-#define LOAD_OPTION_CATEGORY_BOOT       0x00000000\r
-#define LOAD_OPTION_CATEGORY_APP        0x00000100\r
-\r
-#define EFI_BOOT_OPTION_SUPPORT_KEY     0x00000001\r
-#define EFI_BOOT_OPTION_SUPPORT_APP     0x00000002\r
-\r
-#define IS_LOAD_OPTION_TYPE(_c, _Mask)  (BOOLEAN) (((_c) & (_Mask)) != 0)\r
-\r
-///\r
-/// Define the maximum characters that will be accepted.\r
-///\r
-#define MAX_CHAR            480\r
-#define MAX_CHAR_SIZE       (MAX_CHAR * 2)\r
-\r
-///\r
-/// Define maximum characters for boot option variable "BootXXXX".\r
-///\r
-#define BOOT_OPTION_MAX_CHAR 10\r
-\r
-//\r
-// This data structure is the part of BDS_CONNECT_ENTRY\r
-//\r
-#define BDS_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'C', 'O')\r
-\r
-typedef struct {\r
-\r
-  UINTN                     Signature;\r
-  LIST_ENTRY                Link;\r
-\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-\r
-  CHAR16                    *OptionName;\r
-  UINTN                     OptionNumber;\r
-  UINT16                    BootCurrent;\r
-  UINT32                    Attribute;\r
-  CHAR16                    *Description;\r
-  VOID                      *LoadOptions;\r
-  UINT32                    LoadOptionsSize;\r
-  CHAR16                    *StatusString;\r
-\r
-} BDS_COMMON_OPTION;\r
-\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  UINTN                     ConnectType;\r
-} BDS_CONSOLE_CONNECT_ENTRY;\r
-\r
-//\r
-// Bds boot related lib functions\r
-//\r
-/**\r
-  Boot from the UEFI spec defined "BootNext" variable.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibBootNext (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Process the boot option according to the UEFI specification. The legacy boot option device path includes BBS_DEVICE_PATH.\r
-\r
-  @param  Option                 The boot option to be processed.\r
-  @param  DevicePath             The device path describing where to load the\r
-                                 boot image or the legcy BBS device path to boot\r
-                                 the legacy OS.\r
-  @param  ExitDataSize           The size of exit data.\r
-  @param  ExitData               Data returned when Boot image failed.\r
-\r
-  @retval EFI_SUCCESS            Boot from the input boot option succeeded.\r
-  @retval EFI_NOT_FOUND          The Device Path is not found in the system.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibBootViaBootOption (\r
-  IN  BDS_COMMON_OPTION             * Option,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL      * DevicePath,\r
-  OUT UINTN                         *ExitDataSize,\r
-  OUT CHAR16                        **ExitData OPTIONAL\r
-  );\r
-\r
-\r
-/**\r
-  This function will enumerate all possible boot devices in the system, and\r
-  automatically create boot options for Network, Shell, Removable BlockIo,\r
-  and Non-BlockIo Simplefile devices.\r
-\r
-  BDS separates EFI boot options into six types:\r
-  1. Network - The boot option points to the SimpleNetworkProtocol device.\r
-               Bds will try to automatically create this type of boot option during enumeration.\r
-  2. Shell   - The boot option points to internal flash shell.\r
-               Bds will try to automatically create this type of boot option during enumeration.\r
-  3. Removable BlockIo      - The boot option points to a removable media\r
-                              device, such as a USB flash drive or DVD drive.\r
-                              These devices should contain a *removable* blockIo\r
-                              protocol in their device handle.\r
-                              Bds will try to automatically create this type boot option\r
-                              when enumerate.\r
-  4. Fixed BlockIo          - The boot option points to a Fixed blockIo device,\r
-                              such as a hard disk.\r
-                              These devices should contain a *fixed* blockIo\r
-                              protocol in their device handle.\r
-                              BDS will skip fixed blockIo devices, and not\r
-                              automatically create boot option for them. But BDS\r
-                              will help to delete those fixed blockIo boot options,\r
-                              whose description rules conflict with other auto-created\r
-                              boot options.\r
-  5. Non-BlockIo Simplefile - The boot option points to a device whose handle\r
-                              has SimpleFileSystem Protocol, but has no blockio\r
-                              protocol. These devices do not offer blockIo\r
-                              protocol, but BDS still can get the\r
-                              \EFI\BOOT\boot{machinename}.EFI by SimpleFileSystem\r
-                              Protocol.\r
-  6. File    - The boot option points to a file. These boot options are usually\r
-               created by the user, either manually or with an OS loader. BDS will not delete or modify\r
-               these boot options.\r
-\r
-  This function will enumerate all possible boot devices in the system, and\r
-  automatically create boot options for Network, Shell, Removable BlockIo,\r
-  and Non-BlockIo Simplefile devices.\r
-  It will execute once every boot.\r
-\r
-  @param  BdsBootOptionList      The header of the linked list that indexed all\r
-                                 current boot options.\r
-\r
-  @retval EFI_SUCCESS            Finished all the boot device enumerations and\r
-                                 created the boot option based on the boot device.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to enumerate the boot device and create\r
-                                 the boot option list.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibEnumerateAllBootOption (\r
-  IN OUT LIST_ENTRY          *BdsBootOptionList\r
-  );\r
-\r
-/**\r
-  Build the boot option with the handle parsed in.\r
-\r
-  @param  Handle                 The handle representing the device path for which\r
-                                 to create a boot option.\r
-  @param  BdsBootOptionList      The header of the link list that indexed all\r
-                                 current boot options.\r
-  @param  String                 The description of the boot option.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibBuildOptionFromHandle (\r
-  IN  EFI_HANDLE                 Handle,\r
-  IN  LIST_ENTRY                 *BdsBootOptionList,\r
-  IN  CHAR16                     *String\r
-  );\r
-\r
-\r
-/**\r
-  Build the on flash shell boot option with the handle parsed in.\r
-\r
-  @param  Handle                 The handle which present the device path to create\r
-                                 the on flash shell boot option.\r
-  @param  BdsBootOptionList      The header of the link list that indexed all\r
-                                 current boot options.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibBuildOptionFromShell (\r
-  IN EFI_HANDLE                  Handle,\r
-  IN OUT LIST_ENTRY              *BdsBootOptionList\r
-  );\r
-\r
-//\r
-// Bds misc lib functions\r
-//\r
-/**\r
-  Get boot mode by looking up the configuration table and parsing the HOB list.\r
-\r
-  @param  BootMode              The boot mode from PEI handoff HOB.\r
-\r
-  @retval EFI_SUCCESS           Successfully got boot mode.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibGetBootMode (\r
-  OUT EFI_BOOT_MODE       *BootMode\r
-  );\r
-\r
-\r
-/**\r
-  The function will go through the driver option link list, and then load and start\r
-  every driver to which the driver option device path points.\r
-\r
-  @param  BdsDriverLists        The header of the current driver option link list.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibLoadDrivers (\r
-  IN LIST_ENTRY                   *BdsDriverLists\r
-  );\r
-\r
-\r
-/**\r
-  This function processes BootOrder or DriverOrder variables, by calling\r
-\r
-  BdsLibVariableToOption () for each UINT16 in the variables.\r
-\r
-  @param  BdsCommonOptionList   The header of the option list base on the variable\r
-                                VariableName.\r
-  @param  VariableName          An EFI Variable name indicate the BootOrder or\r
-                                DriverOrder.\r
-\r
-  @retval EFI_SUCCESS           Successfully created the boot option or driver option\r
-                                list.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to get the boot option or the driver option list.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibBuildOptionFromVar (\r
-  IN  LIST_ENTRY                      *BdsCommonOptionList,\r
-  IN  CHAR16                          *VariableName\r
-  );\r
-\r
-/**\r
-  This function reads the EFI variable (VendorGuid/Name) and returns a dynamically allocated\r
-  buffer and the size of the buffer. If it fails, return NULL.\r
-\r
-  @param  Name                  The string part of the  EFI variable name.\r
-  @param  VendorGuid            The GUID part of the EFI variable name.\r
-  @param  VariableSize          Returns the size of the EFI variable that was read.\r
-\r
-  @return                       Dynamically allocated memory that contains a copy\r
-                                of the EFI variable. The caller is responsible for\r
-                                freeing the buffer.\r
-  @retval NULL                  The variable was not read.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-BdsLibGetVariableAndSize (\r
-  IN  CHAR16              *Name,\r
-  IN  EFI_GUID            *VendorGuid,\r
-  OUT UINTN               *VariableSize\r
-  );\r
-\r
-\r
-/**\r
-  This function prints a series of strings.\r
-\r
-  @param  ConOut                A pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.\r
-  @param  ...                   A variable argument list containing a series of\r
-                                strings, the last string must be NULL.\r
-\r
-  @retval EFI_SUCCESS           Successfully printed out the string using ConOut.\r
-  @retval EFI_STATUS            Return the status of the ConOut->OutputString ().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibOutputStrings (\r
-  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *ConOut,\r
-  ...\r
-  );\r
-\r
-/**\r
-  Build the boot#### or driver#### option from the VariableName. The\r
-  build boot#### or driver#### will also be linked to BdsCommonOptionList.\r
-\r
-  @param  BdsCommonOptionList   The header of the boot#### or driver#### option\r
-                                link list.\r
-  @param  VariableName          EFI Variable name, indicates if it is boot#### or\r
-                                driver####.\r
-\r
-  @retval BDS_COMMON_OPTION     The option that was created.\r
-  @retval NULL                  Failed to get the new option.\r
-\r
-**/\r
-BDS_COMMON_OPTION *\r
-EFIAPI\r
-BdsLibVariableToOption (\r
-  IN OUT LIST_ENTRY                   *BdsCommonOptionList,\r
-  IN  CHAR16                          *VariableName\r
-  );\r
-\r
-/**\r
-  This function registers the new boot#### or driver#### option based on\r
-  the VariableName. The new registered boot#### or driver#### will be linked\r
-  to BdsOptionList and also update to the VariableName. After the boot#### or\r
-  driver#### updated, the BootOrder or DriverOrder will also be updated.\r
-\r
-  @param  BdsOptionList         The header of the boot#### or driver#### link list.\r
-  @param  DevicePath            The device path that the boot#### or driver####\r
-                                option present.\r
-  @param  String                The description of the boot#### or driver####.\r
-  @param  VariableName          Indicate if the boot#### or driver#### option.\r
-\r
-  @retval EFI_SUCCESS           The boot#### or driver#### have been successfully\r
-                                registered.\r
-  @retval EFI_STATUS            Return the status of gRT->SetVariable ().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibRegisterNewOption (\r
-  IN  LIST_ENTRY                     *BdsOptionList,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL       *DevicePath,\r
-  IN  CHAR16                         *String,\r
-  IN  CHAR16                         *VariableName\r
-  );\r
-\r
-//\r
-// Bds connect and disconnect driver lib funcions\r
-//\r
-/**\r
-  This function connects all system drivers with the corresponding controllers.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibConnectAllDriversToAllControllers (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function connects all system drivers to controllers.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibConnectAll (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function will create all handles associate with every device\r
-  path node. If the handle associate with one device path node can not\r
-  be created successfully, then still give chance to do the dispatch,\r
-  which load the missing drivers if possible.\r
-\r
-  @param  DevicePathToConnect   The device path to be connected. Can be\r
-                                a multi-instance device path.\r
-\r
-  @retval EFI_SUCCESS           All handles associates with every device path node\r
-                                were created.\r
-  @retval EFI_OUT_OF_RESOURCES  Not enough resources to create new handles.\r
-  @retval EFI_NOT_FOUND         At least one handle could not be created.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect\r
-  );\r
-\r
-/**\r
-  This function will connect all current system handles recursively.\r
-  gBS->ConnectController() service is invoked for each handle exist in system handler buffer.\r
-  If the handle is bus type handler, all childrens also will be connected recursively  by gBS->ConnectController().\r
-\r
-  @retval EFI_SUCCESS           All handles and child handles have been\r
-                                connected.\r
-  @retval EFI_STATUS            Return the status of gBS->LocateHandleBuffer().\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectAllEfi (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function will disconnect all current system handles.\r
-  gBS->DisconnectController() is invoked for each handle exists in system handle buffer.\r
-  If handle is a bus type handle, all childrens also are disconnected recursively by  gBS->DisconnectController().\r
-\r
-  @retval EFI_SUCCESS           All handles have been disconnected.\r
-  @retval EFI_STATUS            Error status returned by of gBS->LocateHandleBuffer().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibDisconnectAllEfi (\r
-  VOID\r
-  );\r
-\r
-//\r
-// Bds console related lib functions\r
-//\r
-/**\r
-  This function will search every simpletxt device in the current system,\r
-  and make every simpletxt device a potential console device.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibConnectAllConsoles (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  This function will connect console device based on the console\r
-  device variable ConIn, ConOut and ErrOut.\r
-\r
-  @retval EFI_SUCCESS              At least one of the ConIn and ConOut devices have\r
-                                   been connected.\r
-  @retval EFI_STATUS               Return the status of BdsLibConnectConsoleVariable ().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectAllDefaultConsoles (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  This function will connect console device except ConIn base on the console\r
-  device variable ConOut and ErrOut.\r
-\r
-  @retval EFI_SUCCESS              At least one of the ConOut device have\r
-                                   been connected success.\r
-  @retval EFI_STATUS               Return the status of BdsLibConnectConsoleVariable ().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectAllDefaultConsolesWithOutConIn (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  This function updates the console variable based on ConVarName. It can\r
-  add or remove one specific console device path from the variable\r
-\r
-  @param  ConVarName               The console-related variable name: ConIn, ConOut,\r
-                                   ErrOut.\r
-  @param  CustomizedConDevicePath  The console device path to be added to\r
-                                   the console variable ConVarName. Cannot be multi-instance.\r
-  @param  ExclusiveDevicePath      The console device path to be removed\r
-                                   from the console variable ConVarName. Cannot be multi-instance.\r
-\r
-  @retval EFI_UNSUPPORTED          The added device path is the same as a removed one.\r
-  @retval EFI_SUCCESS              Successfully added or removed the device path from the\r
-                                   console variable.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibUpdateConsoleVariable (\r
-  IN  CHAR16                    *ConVarName,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *CustomizedConDevicePath,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *ExclusiveDevicePath\r
-  );\r
-\r
-/**\r
-  Connect the console device base on the variable ConVarName, if\r
-  device path of the ConVarName is multi-instance device path and\r
-  anyone of the instances is connected success, then this function\r
-  will return success.\r
-  If the handle associate with one device path node can not\r
-  be created successfully, then still give chance to do the dispatch,\r
-  which load the missing drivers if possible.\r
-\r
-  @param  ConVarName               Console related variable name, ConIn, ConOut,\r
-                                   ErrOut.\r
-\r
-  @retval EFI_NOT_FOUND            There is not any console devices connected\r
-                                   success\r
-  @retval EFI_SUCCESS              Success connect any one instance of the console\r
-                                   device path base on the variable ConVarName.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectConsoleVariable (\r
-  IN  CHAR16                 *ConVarName\r
-  );\r
-\r
-//\r
-// Bds device path related lib functions\r
-//\r
-/**\r
-  Delete the instance in Multi that overlaps with Single.\r
-\r
-  @param  Multi                 A pointer to a multi-instance device path data\r
-                                structure.\r
-  @param  Single                A pointer to a single-instance device path data\r
-                                structure.\r
-\r
-  @return This function removes the device path instances in Multi that overlap\r
-          Single, and returns the resulting device path. If there is no\r
-          remaining device path as a result, this function will return NULL.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-BdsLibDelPartMatchInstance (\r
-  IN     EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
-  IN     EFI_DEVICE_PATH_PROTOCOL  *Single\r
-  );\r
-\r
-/**\r
-  This function compares a device path data structure to that of all the nodes of a\r
-  second device path instance.\r
-\r
-  @param  Multi                 A pointer to a multi-instance device path data\r
-                                structure.\r
-  @param  Single                A pointer to a single-instance device path data\r
-                                structure.\r
-\r
-  @retval TRUE                  If the Single device path is contained within a\r
-                                Multi device path.\r
-  @retval FALSE                 The Single device path is not contained within a\r
-                                Multi device path.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-BdsLibMatchDevicePaths (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *Single\r
-  );\r
-\r
-/**\r
-  This function converts an input device structure to a Unicode string.\r
-\r
-  @param DevPath                  A pointer to the device path structure.\r
-\r
-  @return A newly allocated Unicode string that represents the device path.\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-DevicePathToStr (\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
-  );\r
-\r
-//\r
-// Internal definitions\r
-//\r
-typedef struct {\r
-  CHAR16  *Str;\r
-  UINTN   Len;\r
-  UINTN   Maxlen;\r
-} POOL_PRINT;\r
-\r
-typedef\r
-VOID\r
-(*DEV_PATH_FUNCTION) (\r
-  IN OUT POOL_PRINT       *Str,\r
-  IN VOID                 *DevPath\r
-  );\r
-\r
-typedef struct {\r
-  UINT8             Type;\r
-  UINT8             SubType;\r
-  DEV_PATH_FUNCTION Function;\r
-} DEVICE_PATH_STRING_TABLE;\r
-\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  Header;\r
-  EFI_GUID                  Guid;\r
-  UINT8                     VendorDefinedData[1];\r
-} VENDOR_DEVICE_PATH_WITH_DATA;\r
-\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  Header;\r
-  UINT16                    NetworkProtocol;\r
-  UINT16                    LoginOption;\r
-  UINT64                    Lun;\r
-  UINT16                    TargetPortalGroupTag;\r
-  CHAR16                    TargetName[1];\r
-} ISCSI_DEVICE_PATH_WITH_NAME;\r
-\r
-//\r
-// BBS support macros and functions\r
-//\r
-\r
-#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)\r
-#define REFRESH_LEGACY_BOOT_OPTIONS \\r
-        BdsDeleteAllInvalidLegacyBootOptions ();\\r
-        BdsAddNonExistingLegacyBootOptions (); \\r
-        BdsUpdateLegacyDevOrder ()\r
-#else\r
-#define REFRESH_LEGACY_BOOT_OPTIONS\r
-#endif\r
-\r
-/**\r
-  Delete all the invalid legacy boot options.\r
-\r
-  @retval EFI_SUCCESS             All invalid legacy boot options are deleted.\r
-  @retval EFI_OUT_OF_RESOURCES    Failed to allocate necessary memory.\r
-  @retval EFI_NOT_FOUND           Failed to retrieve variable of boot order.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsDeleteAllInvalidLegacyBootOptions (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Add the legacy boot options from BBS table if they do not exist.\r
-\r
-  @retval EFI_SUCCESS          The boot options were added successfully,\r
-                               or they are already in boot options.\r
-  @retval EFI_NOT_FOUND        No legacy boot options is found.\r
-  @retval EFI_OUT_OF_RESOURCE  No enough memory.\r
-  @return Other value          LegacyBoot options are not added.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsAddNonExistingLegacyBootOptions (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Add the legacy boot devices from BBS table into\r
-  the legacy device boot order.\r
-\r
-  @retval EFI_SUCCESS           The boot devices were added successfully.\r
-  @retval EFI_NOT_FOUND         The legacy boot devices are not found.\r
-  @retval EFI_OUT_OF_RESOURCES  Memory or storage is not enough.\r
-  @retval EFI_DEVICE_ERROR      Failed to add the legacy device boot order into EFI variable\r
-                                because of a hardware error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsUpdateLegacyDevOrder (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Refresh the boot priority for BBS entries based on boot option entry and boot order.\r
-\r
-  @param  Entry             The boot option is to be checked for a refreshed BBS table.\r
-\r
-  @retval EFI_SUCCESS           The boot priority for BBS entries refreshed successfully.\r
-  @retval EFI_NOT_FOUND         BBS entries can't be found.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to get the legacy device boot order.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsRefreshBbsTableForBoot (\r
-  IN BDS_COMMON_OPTION        *Entry\r
-  );\r
-\r
-/**\r
-  Delete the Boot Option from EFI Variable. The Boot Order Arrray\r
-  is also updated.\r
-\r
-  @param OptionNumber    The number of Boot options wanting to be deleted.\r
-  @param BootOrder       The Boot Order array.\r
-  @param BootOrderSize   The size of the Boot Order Array.\r
-\r
-  @retval  EFI_SUCCESS           The Boot Option Variable was found and removed.\r
-  @retval  EFI_UNSUPPORTED       The Boot Option Variable store was inaccessible.\r
-  @retval  EFI_NOT_FOUND         The Boot Option Variable was not found.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsDeleteBootOption (\r
-  IN UINTN                       OptionNumber,\r
-  IN OUT UINT16                  *BootOrder,\r
-  IN OUT UINTN                   *BootOrderSize\r
-  );\r
-\r
-//\r
-//The interface functions related to the Setup Browser Reset Reminder feature\r
-//\r
-/**\r
-  Enable the setup browser reset reminder feature.\r
-  This routine is used in a platform tip. If the platform policy needs the feature, use the routine to enable it.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-EnableResetReminderFeature (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Disable the setup browser reset reminder feature.\r
-  This routine is used in a platform tip. If the platform policy does not want the feature, use the routine to disable it.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-DisableResetReminderFeature (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Record the info that a reset is required.\r
-  A module boolean variable is used to record whether a reset is required.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-EnableResetRequired (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Record the info that no reset is required.\r
-  A module boolean variable is used to record whether a reset is required.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-DisableResetRequired (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Check whether platform policy enables the reset reminder feature. The default is enabled.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsResetReminderFeatureEnable (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Check if the user changed any option setting that needs a system reset to be effective.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsResetRequired (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Check whether a reset is needed, and finish the reset reminder feature.\r
-  If a reset is needed, pop up a menu to notice user, and finish the feature\r
-  according to the user selection.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SetupResetReminder (\r
-  VOID\r
-  );\r
-\r
-\r
-///\r
-/// Define the boot type with which to classify the boot option type.\r
-/// Different boot option types could have different boot behaviors.\r
-/// Use their device path node (Type + SubType) as the type value.\r
-/// The boot type here can be added according to requirements.\r
-///\r
-\r
-///\r
-/// ACPI boot type. For ACPI devices, using sub-types to distinguish devices is not allowed, so hardcode their values.\r
-///\r
-#define  BDS_EFI_ACPI_FLOPPY_BOOT         0x0201\r
-///\r
-/// Message boot type\r
-/// If a device path of boot option only points to a message node, the boot option is a message boot type.\r
-///\r
-#define  BDS_EFI_MESSAGE_ATAPI_BOOT       0x0301 // Type 03; Sub-Type 01\r
-#define  BDS_EFI_MESSAGE_SCSI_BOOT        0x0302 // Type 03; Sub-Type 02\r
-#define  BDS_EFI_MESSAGE_USB_DEVICE_BOOT  0x0305 // Type 03; Sub-Type 05\r
-#define  BDS_EFI_MESSAGE_SATA_BOOT        0x0312 // Type 03; Sub-Type 18\r
-#define  BDS_EFI_MESSAGE_MAC_BOOT         0x030b // Type 03; Sub-Type 11\r
-#define  BDS_EFI_MESSAGE_MISC_BOOT        0x03FF\r
-\r
-///\r
-/// Media boot type\r
-/// If a device path of boot option contains a media node, the boot option is media boot type.\r
-///\r
-#define  BDS_EFI_MEDIA_HD_BOOT            0x0401 // Type 04; Sub-Type 01\r
-#define  BDS_EFI_MEDIA_CDROM_BOOT         0x0402 // Type 04; Sub-Type 02\r
-///\r
-/// BBS boot type\r
-/// If a device path of boot option contains a BBS node, the boot option is BBS boot type.\r
-///\r
-#define  BDS_LEGACY_BBS_BOOT              0x0501 //  Type 05; Sub-Type 01\r
-\r
-#define  BDS_EFI_UNSUPPORT                0xFFFF\r
-\r
-/**\r
-  Check whether an instance in BlockIoDevicePath has the same partition node as the HardDriveDevicePath device path.\r
-\r
-  @param  BlockIoDevicePath      Multi device path instances to check.\r
-  @param  HardDriveDevicePath    A device path starting with a hard drive media\r
-                                 device path.\r
-\r
-  @retval TRUE                   There is a matched device path instance.\r
-  @retval FALSE                  There is no matched device path instance.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-MatchPartitionDevicePathNode (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL   *BlockIoDevicePath,\r
-  IN  HARDDRIVE_DEVICE_PATH      *HardDriveDevicePath\r
-  );\r
-\r
-\r
-/**\r
-  Expand a device path that starts with a hard drive media device path node to be a\r
-  full device path that includes the full hardware path to the device. This function enables the device to boot.\r
-  To avoid requiring a connect on every boot, the front match is saved in a variable (the part point\r
-  to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ).\r
-  All successful history device paths\r
-  that point to the front part of the partition node will be saved.\r
-\r
-  @param  HardDriveDevicePath    EFI Device Path to boot, if it starts with a hard\r
-                                 drive media device path.\r
-  @return A Pointer to the full device path, or NULL if a valid Hard Drive devic path\r
-          cannot be found.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-BdsExpandPartitionPartialDevicePathToFull (\r
-  IN  HARDDRIVE_DEVICE_PATH      *HardDriveDevicePath\r
-  );\r
-\r
-/**\r
-  Return the bootable media handle.\r
-  First, check whether the device is connected.\r
-  Second, check whether the device path points to a device that supports SimpleFileSystemProtocol.\r
-  Third, detect the the default boot file in the Media, and return the removable Media handle.\r
-\r
-  @param  DevicePath             The Device Path to a  bootable device.\r
-\r
-  @return  The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.\r
-\r
-**/\r
-EFI_HANDLE\r
-EFIAPI\r
-BdsLibGetBootableHandle (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
-  );\r
-\r
-\r
-/**\r
-  Checks whether the Device path in a boot option points to a valid bootable device, and if the device\r
-  is ready to boot now.\r
-\r
-  @param  DevPath     The Device path in a boot option.\r
-  @param  CheckMedia  If true, check whether the device is ready to boot now.\r
-\r
-  @retval TRUE        The Device path is valid.\r
-  @retval FALSE       The Device path is invalid.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-BdsLibIsValidEFIBootOptDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath,\r
-  IN BOOLEAN                      CheckMedia\r
-  );\r
-\r
-/**\r
-  Checks whether the Device path in a boot option points to a valid bootable device, and if the device\r
-  is ready to boot now.\r
-  If Description is not NULL and the device path points to a fixed BlockIo\r
-  device, this function checks whether the description conflicts with other auto-created\r
-  boot options.\r
-\r
-  @param  DevPath     The Device path in a boot option.\r
-  @param  CheckMedia  If true, checks if the device is ready to boot now.\r
-  @param  Description The description of a boot option.\r
-\r
-  @retval TRUE        The Device path is valid.\r
-  @retval FALSE       The Device path is invalid.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-BdsLibIsValidEFIBootOptDevicePathExt (\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath,\r
-  IN BOOLEAN                      CheckMedia,\r
-  IN CHAR16                       *Description\r
-  );\r
-\r
-/**\r
-  For a bootable Device path, return its boot type.\r
-\r
-  @param  DevicePath                      The bootable device Path to check.\r
-\r
-  @retval BDS_EFI_MEDIA_HD_BOOT           The given device path contains MEDIA_DEVICE_PATH type device path node,\r
-                                          whose subtype is MEDIA_HARDDRIVE_DP.\r
-  @retval BDS_EFI_MEDIA_CDROM_BOOT        If given device path contains MEDIA_DEVICE_PATH type device path node,\r
-                                          whose subtype is MEDIA_CDROM_DP.\r
-  @retval BDS_EFI_ACPI_FLOPPY_BOOT        A given device path contains ACPI_DEVICE_PATH type device path node,\r
-                                          whose HID is floppy device.\r
-  @retval BDS_EFI_MESSAGE_ATAPI_BOOT      A given device path contains MESSAGING_DEVICE_PATH type device path node,\r
-                                          and its last device path node's subtype is MSG_ATAPI_DP.\r
-  @retval BDS_EFI_MESSAGE_SCSI_BOOT       A given device path contains MESSAGING_DEVICE_PATH type device path node,\r
-                                          and its last device path node's subtype is MSG_SCSI_DP.\r
-  @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node,\r
-                                          and its last device path node's subtype is MSG_USB_DP.\r
-  @retval BDS_EFI_MESSAGE_MISC_BOOT       The device path does not contain any media device path node, and\r
-                                          its last device path node points to a message device path node.\r
-  @retval BDS_LEGACY_BBS_BOOT             A given device path contains BBS_DEVICE_PATH type device path node.\r
-  @retval BDS_EFI_UNSUPPORT               An EFI Removable BlockIO device path does not point to a media and message device.\r
-\r
-  **/\r
-UINT32\r
-EFIAPI\r
-BdsGetBootTypeFromDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
-  );\r
-\r
-\r
-/**\r
-  This routine registers a function to adjust the different types of memory page numbers\r
-  just before booting, and saves the updated info into the variable for the next boot to use.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibSaveMemoryTypeInformation (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Identify a user and, if authenticated, returns the current user profile handle.\r
-\r
-  @param[out]  User           Points to the user profile handle.\r
-\r
-  @retval EFI_SUCCESS         The user is successfully identified, or user identification\r
-                              is not supported.\r
-  @retval EFI_ACCESS_DENIED   The user was not successfully identified.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibUserIdentify (\r
-  OUT EFI_USER_PROFILE_HANDLE         *User\r
-  );\r
-\r
-/**\r
-  This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid,\r
-  it tries to return the valid device path.\r
-  FV address maybe changes for memory layout adjust from time to time, use this function\r
-  could promise the Fv file device path is right.\r
-\r
-  @param  DevicePath             On input, the Fv file device path to check. On\r
-                                 output, the updated valid Fv file device path\r
-  @param  FileGuid               the Fv file GUID.\r
-\r
-  @retval EFI_INVALID_PARAMETER  The input DevicePath or FileGuid is invalid.\r
-  @retval EFI_UNSUPPORTED        The input DevicePath does not contain an Fv file\r
-                                 GUID at all.\r
-  @retval EFI_ALREADY_STARTED    The input DevicePath has pointed to the Fv file and is\r
-                                 valid.\r
-  @retval EFI_SUCCESS            Successfully updated the invalid DevicePath\r
-                                 and returned the updated device path in DevicePath.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibUpdateFvFileDevicePath (\r
-  IN  OUT EFI_DEVICE_PATH_PROTOCOL      ** DevicePath,\r
-  IN  EFI_GUID                          *FileGuid\r
-  );\r
-\r
-\r
-/**\r
-  Connect the specific USB device that matches the RemainingDevicePath,\r
-  and whose bus is determined by Host Controller (Uhci or Ehci).\r
-\r
-  @param  HostControllerPI      Uhci (0x00) or Ehci (0x20) or Both uhci and ehci\r
-                                (0xFF).\r
-  @param  RemainingDevicePath   A short-form device path that starts with the first\r
-                                element being a USB WWID or a USB Class device\r
-                                path.\r
-\r
-  @retval EFI_SUCCESS           The specific Usb device is connected successfully.\r
-  @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF)\r
-                                or RemainingDevicePath is not the USB class device path.\r
-  @retval EFI_NOT_FOUND         The device specified by device path is not found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectUsbDevByShortFormDP(\r
-  IN UINT8                      HostControllerPI,\r
-  IN EFI_DEVICE_PATH_PROTOCOL   *RemainingDevicePath\r
-  );\r
-\r
-\r
-//\r
-// The implementation of this function is provided by Platform code.\r
-//\r
-/**\r
-  Convert Vendor device path to a device name.\r
-\r
-  @param  Str      The buffer storing device name.\r
-  @param  DevPath  The pointer to vendor device path.\r
-\r
-**/\r
-VOID\r
-DevPathVendor (\r
-  IN OUT POOL_PRINT       *Str,\r
-  IN VOID                 *DevPath\r
-  );\r
-\r
-/**\r
-  Concatenates a formatted unicode string to an allocated pool.\r
-  The caller must free the resulting buffer.\r
-\r
-  @param  Str      Tracks the allocated pool, size in use, and amount of pool allocated.\r
-  @param  Fmt      The format string.\r
-  @param  ...      The data will be printed.\r
-\r
-  @return Allocated buffer with the formatted string printed in it.\r
-          The caller must free the allocated buffer.\r
-          The buffer allocation is not packed.\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-CatPrint (\r
-  IN OUT POOL_PRINT   *Str,\r
-  IN CHAR16           *Fmt,\r
-  ...\r
-  );\r
-\r
-/**\r
-  Use SystemTable ConOut to stop video based Simple Text Out consoles from going\r
-  to the video device. Put up LogoFile on every video device that is a console.\r
-\r
-  @param[in]  LogoFile   The file name of logo to display on the center of the screen.\r
-\r
-  @retval EFI_SUCCESS     ConsoleControl has been flipped to graphics and logo displayed.\r
-  @retval EFI_UNSUPPORTED Logo not found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EnableQuietBoot (\r
-  IN  EFI_GUID  *LogoFile\r
-  );\r
-\r
-\r
-/**\r
-  Use SystemTable ConOut to turn on video based Simple Text Out consoles. The\r
-  Simple Text Out screens will now be synced up with all non-video output devices.\r
-\r
-  @retval EFI_SUCCESS     UGA devices are back in text mode and synced up.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DisableQuietBoot (\r
-  VOID\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Include/Library/PlatformBdsLib.h b/IntelFrameworkModulePkg/Include/Library/PlatformBdsLib.h
deleted file mode 100644 (file)
index c41d552..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/** @file\r
-  Platform BDS library definition. A platform can implement\r
-  instances to support platform-specific behavior.\r
-\r
-Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __PLATFORM_BDS_LIB_H_\r
-#define __PLATFORM_BDS_LIB_H_\r
-\r
-#include <Protocol/GenericMemoryTest.h>\r
-#include <Library/GenericBdsLib.h>\r
-\r
-/**\r
-  Perform the memory test base on the memory test intensive level,\r
-  and update the memory resource.\r
-\r
-  @param  Level         The memory test intensive level.\r
-\r
-  @retval EFI_STATUS    Successfully test all the system memory, and update\r
-                        the memory resource\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *BASEM_MEMORY_TEST)(\r
-  IN EXTENDMEM_COVERAGE_LEVEL Level\r
-  );\r
-\r
-/**\r
-  This routine is called to see if there are any capsules we need to process.\r
-  If the boot mode is not UPDATE, then we do nothing. Otherwise, find the\r
-  capsule HOBS and produce firmware volumes for them via the DXE service.\r
-  Then call the dispatcher to dispatch drivers from them. Finally, check\r
-  the status of the updates.\r
-\r
-  This function should be called by BDS in case we need to do some\r
-  sort of processing even if there is no capsule to process. We\r
-  need to do this if an earlier update went away and we need to\r
-  clear the capsule variable so on the next reset PEI does not see it and\r
-  think there is a capsule available.\r
-\r
-  @param BootMode                 The current boot mode\r
-\r
-  @retval EFI_INVALID_PARAMETER   The boot mode is not correct for an update.\r
-  @retval EFI_SUCCESS             There is no error when processing a capsule.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *PROCESS_CAPSULES)(\r
-  IN EFI_BOOT_MODE BootMode\r
-  );\r
-\r
-/**\r
-  Platform Bds initialization. Includes the platform firmware vendor, revision\r
-  and so crc check.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsInit (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  The function will execute with as the platform policy, current policy\r
-  is driven by boot mode. IBV/OEM can customize this code for their specific\r
-  policy action.\r
-\r
-  @param  DriverOptionList        The header of the driver option link list\r
-  @param  BootOptionList          The header of the boot option link list\r
-  @param  ProcessCapsules         A pointer to ProcessCapsules()\r
-  @param  BaseMemoryTest          A pointer to BaseMemoryTest()\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsPolicyBehavior (\r
-  IN LIST_ENTRY                      *DriverOptionList,\r
-  IN LIST_ENTRY                      *BootOptionList,\r
-  IN PROCESS_CAPSULES                ProcessCapsules,\r
-  IN BASEM_MEMORY_TEST               BaseMemoryTest\r
-  );\r
-\r
-/**\r
-  Hook point for a user-provided function, for after a boot attempt fails.\r
-\r
-  @param  Option                  A pointer to Boot Option that failed to boot.\r
-  @param  Status                  The status returned from failed boot.\r
-  @param  ExitData                The exit data returned from failed boot.\r
-  @param  ExitDataSize            The exit data size returned from failed boot.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootFail (\r
-  IN  BDS_COMMON_OPTION  *Option,\r
-  IN  EFI_STATUS         Status,\r
-  IN  CHAR16             *ExitData,\r
-  IN  UINTN              ExitDataSize\r
-  );\r
-\r
-/**\r
-  Hook point after a boot attempt succeeds. We don't expect a boot option to\r
-  return, so the UEFI 2.0 specification defines that you will default to an\r
-  interactive mode and stop processing the BootOrder list in this case. This\r
-  is also a platform implementation, and can be customized by an IBV/OEM.\r
-\r
-  @param  Option                  A pointer to the Boot Option that successfully booted.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootSuccess (\r
-  IN  BDS_COMMON_OPTION  *Option\r
-  );\r
-\r
-\r
-/**\r
-  This function locks platform flash that is not allowed to be updated during normal boot path.\r
-  The flash layout is platform specific.\r
-\r
-  **/\r
-VOID\r
-EFIAPI\r
-PlatformBdsLockNonUpdatableFlash (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Lock the ConsoleIn device in system table. All key\r
-  presses will be ignored until the Password is typed in. The only way to\r
-  disable the password is to type it in to a ConIn device.\r
-\r
-  @param  Password        The password used to lock ConIn device.\r
-\r
-  @retval EFI_SUCCESS     Lock the Console In Spliter virtual handle successfully.\r
-  @retval EFI_UNSUPPORTED Password not found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LockKeyboards (\r
-  IN  CHAR16    *Password\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Protocol/ExitPmAuth.h b/IntelFrameworkModulePkg/Include/Protocol/ExitPmAuth.h
deleted file mode 100644 (file)
index 02487c5..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/** @file\r
-  Defines the ExitPmAuth protocol.\r
-\r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _EXIT_PM_AUTH_PROTOCOL_H_\r
-#define _EXIT_PM_AUTH_PROTOCOL_H_\r
-\r
-#define EXIT_PM_AUTH_PROTOCOL_GUID \\r
-  { 0xd088a413, 0xa70, 0x4217, { 0xba, 0x55, 0x9a, 0x3c, 0xb6, 0x5c, 0x41, 0xb3 }}\r
-\r
-extern EFI_GUID gExitPmAuthProtocolGuid;\r
-\r
-#endif // #ifndef _EXIT_PM_AUTH_PROTOCOL_H_\r
diff --git a/IntelFrameworkModulePkg/Include/Protocol/IsaAcpi.h b/IntelFrameworkModulePkg/Include/Protocol/IsaAcpi.h
deleted file mode 100644 (file)
index 12aeb12..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-/** @file\r
-  EFI ISA ACPI Protocol is used to enumerate and manage all the ISA controllers on\r
-  the platform's ISA Bus.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __ISA_ACPI_H_\r
-#define __ISA_ACPI_H_\r
-\r
-///\r
-/// Global ID for the EFI ISA ACPI Protocol.\r
-///\r
-#define EFI_ISA_ACPI_PROTOCOL_GUID \\r
-  { \\r
-    0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \\r
-  }\r
-\r
-///\r
-/// Forward declaration fo the EFI ISA ACPI Protocol\r
-///\r
-typedef struct _EFI_ISA_ACPI_PROTOCOL EFI_ISA_ACPI_PROTOCOL;\r
-\r
-///\r
-/// ISA ACPI Protocol interrupt resource attributes.\r
-///\r
-#define EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_EDGE_SENSITIVE   0x01   ///< Edge triggered interrupt on a rising edge.\r
-#define EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_EDGE_SENSITIVE    0x02   ///< Edge triggered interrupt on a falling edge.\r
-#define EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_LEVEL_SENSITIVE  0x04   ///< Level sensitive interrupt active high.\r
-#define EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_LEVEL_SENSITIVE   0x08   ///< Level sensitive interrupt active low.\r
-\r
-///\r
-/// ISA ACPI Protocol DMA resource attributes.\r
-///\r
-#define EFI_ISA_ACPI_DMA_SPEED_TYPE_MASK                 0x03   ///< Bit mask of supported DMA speed attributes.\r
-#define EFI_ISA_ACPI_DMA_SPEED_TYPE_COMPATIBILITY        0x00   ///< ISA controller supports compatibility mode DMA transfers.\r
-#define EFI_ISA_ACPI_DMA_SPEED_TYPE_A                    0x01   ///< ISA controller supports type A DMA transfers.\r
-#define EFI_ISA_ACPI_DMA_SPEED_TYPE_B                    0x02   ///< ISA controller supports type B DMA transfers.\r
-#define EFI_ISA_ACPI_DMA_SPEED_TYPE_F                    0x03   ///< ISA controller supports type F DMA transfers.\r
-#define EFI_ISA_ACPI_DMA_COUNT_BY_BYTE                   0x04   ///< ISA controller increments DMA address by bytes (8-bit).\r
-#define EFI_ISA_ACPI_DMA_COUNT_BY_WORD                   0x08   ///< ISA controller increments DMA address by words (16-bit).\r
-#define EFI_ISA_ACPI_DMA_BUS_MASTER                      0x10   ///< ISA controller is a DMA bus master.\r
-#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_8_BIT             0x20   ///< ISA controller only supports 8-bit DMA transfers.\r
-#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT  0x40   ///< ISA controller both 8-bit and 16-bit DMA transfers.\r
-#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_16_BIT            0x80   ///< ISA controller only supports 16-bit DMA transfers.\r
-\r
-///\r
-/// ISA ACPI Protocol MMIO resource attributes\r
-///\r
-#define EFI_ISA_ACPI_MEMORY_WIDTH_MASK                   0x03   ///< Bit mask of supported ISA memory width attributes.\r
-#define EFI_ISA_ACPI_MEMORY_WIDTH_8_BIT                  0x00   ///< ISA MMIO region only supports 8-bit access.\r
-#define EFI_ISA_ACPI_MEMORY_WIDTH_16_BIT                 0x01   ///< ISA MMIO region only supports 16-bit access.\r
-#define EFI_ISA_ACPI_MEMORY_WIDTH_8_BIT_AND_16_BIT       0x02   ///< ISA MMIO region supports both 8-bit and 16-bit access.\r
-#define EFI_ISA_ACPI_MEMORY_WRITEABLE                    0x04   ///< ISA MMIO region supports write transactions.\r
-#define EFI_ISA_ACPI_MEMORY_CACHEABLE                    0x08   ///< ISA MMIO region supports being cached.\r
-#define EFI_ISA_ACPI_MEMORY_SHADOWABLE                   0x10   ///< ISA MMIO region may be shadowed.\r
-#define EFI_ISA_ACPI_MEMORY_EXPANSION_ROM                0x20   ///< ISA MMIO region is an expansion ROM.\r
-\r
-///\r
-/// ISA ACPI Protocol I/O resource attributes\r
-///\r
-#define EFI_ISA_ACPI_IO_DECODE_10_BITS                   0x01    ///< ISA controllers uses a 10-bit address decoder for I/O cycles.\r
-#define EFI_ISA_ACPI_IO_DECODE_16_BITS                   0x02    ///< ISA controllers uses a 16-bit address decoder for I/O cycles.\r
-\r
-///\r
-/// EFI ISA ACPI resource type\r
-///\r
-typedef enum {\r
-  EfiIsaAcpiResourceEndOfList,    ///< Marks the end if a resource list.\r
-  EfiIsaAcpiResourceIo,           ///< ISA I/O port resource range.\r
-  EfiIsaAcpiResourceMemory,       ///< ISA MMIO resource range.\r
-  EfiIsaAcpiResourceDma,          ///< ISA DMA resource.\r
-  EfiIsaAcpiResourceInterrupt     ///< ISA interrupt resource.\r
-} EFI_ISA_ACPI_RESOURCE_TYPE;\r
-\r
-///\r
-/// EFI ISA ACPI generic resource structure\r
-///\r
-typedef struct {\r
-  EFI_ISA_ACPI_RESOURCE_TYPE  Type;         ///< The type of resource (I/O, MMIO, DMA, Interrupt).\r
-  UINT32                      Attribute;    ///< Bit mask of attributes associated with this resource.  See EFI_ISA_ACPI_xxx macros for valid combinations.\r
-  UINT32                      StartRange;   ///< The start of the resource range.\r
-  UINT32                      EndRange;     ///< The end of the resource range.\r
-} EFI_ISA_ACPI_RESOURCE;\r
-\r
-///\r
-/// EFI ISA ACPI resource device identifier\r
-///\r
-typedef struct {\r
-  UINT32  HID;   ///< The ACPI Hardware Identifier value associated with an ISA controller.  Matchs ACPI DSDT contents.\r
-  UINT32  UID;   ///< The ACPI Unique Identifier value associated with an ISA controller.  Matches ACPI DSDT contents.\r
-} EFI_ISA_ACPI_DEVICE_ID;\r
-\r
-///\r
-/// EFI ISA ACPI resource list\r
-///\r
-typedef struct {\r
-  EFI_ISA_ACPI_DEVICE_ID  Device;          ///< The ACPI HID/UID associated with an ISA controller.\r
-  EFI_ISA_ACPI_RESOURCE   *ResourceItem;   ///< A pointer to the list of resources associated with an ISA controller.\r
-} EFI_ISA_ACPI_RESOURCE_LIST;\r
-\r
-/**\r
-  Enumerates the ISA controllers on an ISA bus.\r
-\r
-  This service allows all the ISA controllers on an ISA bus to be enumerated.  If\r
-  Device is a pointer to a NULL value, then the first ISA controller on the ISA\r
-  bus is returned in Device and EFI_SUCCESS is returned.  If Device is a pointer\r
-  to a value that was returned on a prior call to DeviceEnumerate(), then the next\r
-  ISA controller on the ISA bus is returned in Device and EFI_SUCCESS is returned.\r
-  If Device is a pointer to the last ISA controller on the ISA bus, then\r
-  EFI_NOT_FOUND is returned.\r
-\r
-  @param[in]  This     The pointer to the EFI_ISA_ACPI_PROTOCOL instance.\r
-  @param[out] Device   The pointer to an ISA controller named by ACPI HID/UID.\r
-\r
-  @retval EFI_SUCCESS    The next ISA controller on the ISA bus was returned.\r
-  @retval EFI_NOT_FOUND  No device found.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_ACPI_DEVICE_ENUMERATE)(\r
-  IN  EFI_ISA_ACPI_PROTOCOL   *This,\r
-  OUT EFI_ISA_ACPI_DEVICE_ID  **Device\r
-  );\r
-\r
-/**\r
-  Sets the power state of an ISA controller.\r
-\r
-  This services sets the power state of the ISA controller specified by Device to\r
-  the power state specified by OnOff.  TRUE denotes on, FALSE denotes off.\r
-  If the power state is sucessfully set on the ISA Controller, then\r
-  EFI_SUCCESS is returned.\r
-\r
-  @param[in] This     The pointer to the EFI_ISA_ACPI_PROTOCOL instance.\r
-  @param[in] Device   The pointer to an ISA controller named by ACPI HID/UID.\r
-  @param[in] OnOff    TRUE denotes on, FALSE denotes off.\r
-\r
-  @retval EFI_SUCCESS   Successfully set the power state of the ISA controller.\r
-  @retval Other         The ISA controller could not be placed in the requested power state.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_ACPI_SET_DEVICE_POWER)(\r
-  IN EFI_ISA_ACPI_PROTOCOL   *This,\r
-  IN EFI_ISA_ACPI_DEVICE_ID  *Device,\r
-  IN BOOLEAN                 OnOff\r
-  );\r
-\r
-/**\r
-  Retrieves the current set of resources associated with an ISA controller.\r
-\r
-  Retrieves the set of I/O, MMIO, DMA, and interrupt resources currently\r
-  assigned to the ISA controller specified by Device.  These resources\r
-  are returned in ResourceList.\r
-\r
-  @param[in]  This          The pointer to the EFI_ISA_ACPI_PROTOCOL instance.\r
-  @param[in]  Device        The pointer to an ISA controller named by ACPI HID/UID.\r
-  @param[out] ResourceList  The pointer to the current resource list for Device.\r
-\r
-  @retval EFI_SUCCESS    Successfully retrieved the current resource list.\r
-  @retval EFI_NOT_FOUND  The resource list could not be retrieved.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_ACPI_GET_CUR_RESOURCE)(\r
-  IN  EFI_ISA_ACPI_PROTOCOL       *This,\r
-  IN  EFI_ISA_ACPI_DEVICE_ID      *Device,\r
-  OUT EFI_ISA_ACPI_RESOURCE_LIST  **ResourceList\r
-  );\r
-\r
-/**\r
-  Retrieves the set of possible resources that may be assigned to an ISA controller\r
-  with SetResource().\r
-\r
-  Retrieves the possible sets of I/O, MMIO, DMA, and interrupt resources for the\r
-  ISA controller specified by Device.  The sets are returned in ResourceList.\r
-\r
-  @param[in]  This           The pointer to the EFI_ISA_ACPI_PROTOCOL instance.\r
-  @param[in]  Device         The pointer to an ISA controller named by ACPI HID/UID.\r
-  @param[out] ResourceList   The pointer to the returned list of resource lists.\r
-\r
-  @retval EFI_UNSUPPORTED  This service is not supported.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_ACPI_GET_POS_RESOURCE)(\r
-  IN EFI_ISA_ACPI_PROTOCOL        *This,\r
-  IN EFI_ISA_ACPI_DEVICE_ID       *Device,\r
-  OUT EFI_ISA_ACPI_RESOURCE_LIST  **ResourceList\r
-  );\r
-\r
-/**\r
-  Assigns resources to an ISA controller.\r
-\r
-  Assigns the I/O, MMIO, DMA, and interrupt resources specified by ResourceList\r
-  to the ISA controller specified by Device.  ResourceList must match a resource list returned by GetPosResource() for the same ISA controller.\r
-\r
-  @param[in] This           The pointer to the EFI_ISA_ACPI_PROTOCOL instance.\r
-  @param[in] Device         The pointer to an ISA controller named by ACPI HID/UID.\r
-  @param[in] ResourceList   The pointer to a resources list that must be one of the\r
-                            resource lists returned by GetPosResource() for the\r
-                            ISA controller specified by Device.\r
-\r
-  @retval EFI_SUCCESS  Successfully set resources on the ISA controller.\r
-  @retval Other        The resources could not be set for the ISA controller.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_ACPI_SET_RESOURCE)(\r
-  IN EFI_ISA_ACPI_PROTOCOL       *This,\r
-  IN EFI_ISA_ACPI_DEVICE_ID      *Device,\r
-  IN EFI_ISA_ACPI_RESOURCE_LIST  *ResourceList\r
-  );\r
-\r
-/**\r
-  Enables or disables an ISA controller.\r
-\r
-  @param[in] This     The pointer to the EFI_ISA_ACPI_PROTOCOL instance.\r
-  @param[in] Device   The pointer to the ISA controller to enable/disable.\r
-  @param[in] Enable   TRUE to enable the ISA controller.  FALSE to disable the\r
-                      ISA controller.\r
-\r
-  @retval EFI_SUCCESS   Successfully enabled/disabled the ISA controller.\r
-  @retval Other         The ISA controller could not be placed in the requested state.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_ACPI_ENABLE_DEVICE)(\r
-  IN EFI_ISA_ACPI_PROTOCOL   *This,\r
-  IN EFI_ISA_ACPI_DEVICE_ID  *Device,\r
-  IN BOOLEAN                 Enable\r
-  );\r
-\r
-/**\r
-  Initializes an ISA controller, so that it can be used.  This service must be called\r
-  before SetResource(), EnableDevice(), or SetPower() will behave as expected.\r
-\r
-  @param[in] This     The pointer to the EFI_ISA_ACPI_PROTOCOL instance.\r
-  @param[in] Device   The pointer to an ISA controller named by ACPI HID/UID.\r
-\r
-  @retval EFI_SUCCESS   Successfully initialized an ISA controller.\r
-  @retval Other         The ISA controller could not be initialized.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_ACPI_INIT_DEVICE)(\r
-  IN EFI_ISA_ACPI_PROTOCOL   *This,\r
-  IN EFI_ISA_ACPI_DEVICE_ID  *Device\r
-  );\r
-\r
-/**\r
-  Initializes all the HW states required for the ISA controllers on the ISA bus\r
-  to be enumerated and managed by the rest of the services in this prorotol.\r
-  This service must be called before any of the other services in this\r
-  protocol will function as expected.\r
-\r
-  @param[in] This  The pointer to the EFI_ISA_ACPI_PROTOCOL instance.\r
-\r
-  @retval EFI_SUCCESS   Successfully initialized all required hardware states.\r
-  @retval Other         The ISA interface could not be initialized.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_ACPI_INTERFACE_INIT)(\r
-  IN EFI_ISA_ACPI_PROTOCOL  *This\r
-  );\r
-\r
-///\r
-/// The EFI_ISA_ACPI_PROTOCOL provides the services to enumerate and manage\r
-/// ISA controllers on an ISA bus.  These services include the ability to initialize,\r
-/// enable, disable, and manage the power state of ISA controllers.  It also\r
-/// includes services to query current resources, query possible resources,\r
-/// and assign resources to an ISA controller.\r
-///\r
-struct _EFI_ISA_ACPI_PROTOCOL {\r
-  EFI_ISA_ACPI_DEVICE_ENUMERATE  DeviceEnumerate;\r
-  EFI_ISA_ACPI_SET_DEVICE_POWER  SetPower;\r
-  EFI_ISA_ACPI_GET_CUR_RESOURCE  GetCurResource;\r
-  EFI_ISA_ACPI_GET_POS_RESOURCE  GetPosResource;\r
-  EFI_ISA_ACPI_SET_RESOURCE      SetResource;\r
-  EFI_ISA_ACPI_ENABLE_DEVICE     EnableDevice;\r
-  EFI_ISA_ACPI_INIT_DEVICE       InitDevice;\r
-  EFI_ISA_ACPI_INTERFACE_INIT    InterfaceInit;\r
-};\r
-\r
-extern EFI_GUID gEfiIsaAcpiProtocolGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Protocol/IsaIo.h b/IntelFrameworkModulePkg/Include/Protocol/IsaIo.h
deleted file mode 100644 (file)
index 3000030..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-/** @file\r
-  ISA I/O Protocol is used by ISA device drivers to perform I/O, MMIO and DMA\r
-  operations on the ISA controllers they manage.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _EFI_ISA_IO_H_\r
-#define _EFI_ISA_IO_H_\r
-\r
-#include <Protocol/IsaAcpi.h>\r
-\r
-///\r
-/// Global ID for the EFI_ISA_IO_PROTOCOL\r
-///\r
-#define EFI_ISA_IO_PROTOCOL_GUID \\r
-  { \\r
-    0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \\r
-  }\r
-\r
-///\r
-/// Forward declaration for the EFI_ISA_IO_PROTOCOL.\r
-///\r
-typedef struct _EFI_ISA_IO_PROTOCOL EFI_ISA_IO_PROTOCOL;\r
-\r
-///\r
-/// Width of EFI_ISA_IO_PROTOCOL I/O Port and MMIO operations.\r
-///\r
-typedef enum {\r
-  EfiIsaIoWidthUint8 = 0,      ///< 8-bit operation.\r
-  EfiIsaIoWidthUint16,         ///< 16-bit operation.\r
-  EfiIsaIoWidthUint32,         ///< 32-bit operation\r
-  EfiIsaIoWidthReserved,\r
-  EfiIsaIoWidthFifoUint8,      ///< 8-bit FIFO operation.\r
-  EfiIsaIoWidthFifoUint16,     ///< 16-bit FIFO operation.\r
-  EfiIsaIoWidthFifoUint32,     ///< 32-bit FIFO operation.\r
-  EfiIsaIoWidthFifoReserved,\r
-  EfiIsaIoWidthFillUint8,      ///< 8-bit Fill operation.\r
-  EfiIsaIoWidthFillUint16,     ///< 16-bit Fill operation.\r
-  EfiIsaIoWidthFillUint32,     ///< 32-bit Fill operation.\r
-  EfiIsaIoWidthFillReserved,\r
-  EfiIsaIoWidthMaximum\r
-} EFI_ISA_IO_PROTOCOL_WIDTH;\r
-\r
-///\r
-/// Attributes for the EFI_ISA_IO_PROTOCOL common DMA buffer allocations.\r
-///\r
-#define EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE  0x080    ///< Map a memory range so write are combined.\r
-#define EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED         0x800    ///< Map a memory range so all read and write accesses are cached.\r
-#define EFI_ISA_IO_ATTRIBUTE_MEMORY_DISABLE        0x1000   ///< Disable a memory range.\r
-\r
-///\r
-/// Channel attribute for EFI_ISA_IO_PROTOCOL slave DMA requests\r
-///\r
-#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE  0x001   ///< Set the speed of the DMA transfer in compatible mode.\r
-#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A           0x002   ///< Not supported.\r
-#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B           0x004   ///< Not supported.\r
-#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C           0x008   ///< Not supported.\r
-#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8           0x010   ///< Request 8-bit DMA transfers.  Only available on channels 0..3.\r
-#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16          0x020   ///< Request 16-bit DMA transfers.  Only available on channels 4..7.\r
-#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE       0x040   ///< Request a single DMA transfer.\r
-#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE       0x080   ///< Request multiple DMA transfers until TC (Terminal Count) or EOP (End of Process).\r
-#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE   0x100   ///< Automatically reload base and count at the end of the DMA transfer.\r
-\r
-///\r
-/// The DMA opreration type for EFI_ISA_IO_PROTOCOL DMA requests.\r
-///\r
-typedef enum {\r
-  ///\r
-  /// A read operation from system memory by a bus master.\r
-  ///\r
-  EfiIsaIoOperationBusMasterRead,\r
-  ///\r
-  /// A write operation to system memory by a bus master.\r
-  ///\r
-  EfiIsaIoOperationBusMasterWrite,\r
-  ///\r
-  /// Provides both read and write access to system memory by both the processor\r
-  /// and a bus master. The buffer is coherent from both the processor's and the\r
-  /// bus master's point of view.\r
-  ///\r
-  EfiIsaIoOperationBusMasterCommonBuffer,\r
-  ///\r
-  /// A read operation from system memory by a slave device.\r
-  ///\r
-  EfiIsaIoOperationSlaveRead,\r
-  ///\r
-  /// A write operation to system memory by a slave master.\r
-  ///\r
-  EfiIsaIoOperationSlaveWrite,\r
-  EfiIsaIoOperationMaximum\r
-} EFI_ISA_IO_PROTOCOL_OPERATION;\r
-\r
-/**\r
-  Performs ISA I/O and MMIO Read/Write Cycles\r
-\r
-  @param[in]      This     A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]      Width    Specifies the width of the I/O or MMIO operation.\r
-  @param[in]      Offset   The offset into the ISA I/O or MMIO space to start the\r
-                           operation.\r
-  @param[in]      Count    The number of I/O or MMIO operations to perform.\r
-  @param[in, out] Buffer   For read operations, the destination buffer to store\r
-                           the results. For write operations, the source buffer to\r
-                           write data from.\r
-\r
-  @retval EFI_SUCCESS             The data was successfully read from or written to the device.\r
-  @retval EFI_UNSUPPORTED         The Offset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER   Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES    The request could not be completed due to a lack of resources.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_IO_PROTOCOL_IO_MEM)(\r
-  IN     EFI_ISA_IO_PROTOCOL        *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT32                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-  );\r
-\r
-///\r
-/// Structure of functions for accessing ISA I/O and MMIO space.\r
-///\r
-typedef struct {\r
-  ///\r
-  /// Read from ISA I/O or MMIO space.\r
-  ///\r
-  EFI_ISA_IO_PROTOCOL_IO_MEM  Read;\r
-  ///\r
-  /// Write to ISA I/O or MMIO space.\r
-  ///\r
-  EFI_ISA_IO_PROTOCOL_IO_MEM  Write;\r
-} EFI_ISA_IO_PROTOCOL_ACCESS;\r
-\r
-/**\r
-  Copies data from one region of ISA MMIO space to another region of ISA\r
-  MMIO space.\r
-\r
-  @param[in] This         A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Width        Specifies the width of the MMIO copy operation.\r
-  @param[in] DestOffset   The offset of the destination in ISA MMIO space.\r
-  @param[in] SrcOffset    The offset of the source in ISA MMIO space.\r
-  @param[in] Count        The number tranfers to perform for this copy operation.\r
-\r
-  @retval EFI_SUCCESS             The data was copied sucessfully.\r
-  @retval EFI_UNSUPPORTED         The DestOffset or SrcOffset is not valid for this device.\r
-  @retval EFI_INVALID_PARAMETER   Width or Count, or both, were invalid.\r
-  @retval EFI_OUT_OF_RESOURCES    The request could not be completed due to a lack of resources.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_IO_PROTOCOL_COPY_MEM)(\r
-  IN EFI_ISA_IO_PROTOCOL         *This,\r
-  IN EFI_ISA_IO_PROTOCOL_WIDTH   Width,\r
-  IN UINT32                      DestOffset,\r
-  IN UINT32                      SrcOffset,\r
-  IN UINTN                       Count\r
-  );\r
-\r
-/**\r
-  Maps a memory region for DMA.\r
-\r
-  This function returns the device-specific addresses required to access system memory.\r
-  This function is used to map system memory for ISA DMA operations.  All ISA DMA\r
-  operations must be performed through their mapped addresses, and such mappings must\r
-  be freed with EFI_ISA_IO_PROTOCOL.Unmap() after the DMA operation is completed.\r
-\r
-  If the DMA operation is a single read or write data transfer through an ISA bus\r
-  master, then EfiIsaIoOperationBusMasterRead or EfiIsaIoOperationBusMasterWrite\r
-  is used and the range is unmapped to complete the operation. If the DMA operation\r
-  is a single read or write data transfer through an ISA slave controller, then\r
-  EfiIsaIoOperationSlaveRead or EfiIsaIoOperationSlaveWrite is used and the range\r
-  is unmapped to complete the operation.\r
-\r
-  If performing a DMA read operation, all the data must be present in system memory before the Map() is performed.  Similarly,\r
-  if performing a DMA write operation, the data must not be accessed in system\r
-  memory until EFI_ISA_IO_PROTOCOL.Unmap() is performed.  Bus master operations that\r
-  require both read and write access or require multiple host device interactions\r
-  within the same mapped region must use EfiIsaIoOperationBusMasterCommonBuffer.\r
-  However, only memory allocated via the EFI_ISA_IO_PROTOCOL.AllocateBuffer() interface\r
-  is guaranteed to be able to be mapped for this operation type.  In all mapping\r
-  requests the NumberOfBytes returned may be less than originally requested.  It is\r
-  the caller's responsibility to make additional requests to complete the entire\r
-  transfer.\r
-\r
-  @param[in]      This                A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]      Operation           Indicates the type of DMA (slave or bus master),\r
-                                      and if the DMA operation is going to read or\r
-                                      write to system memory.\r
-  @param[in]      ChannelNumber       The slave channel number to use for this DMA\r
-                                      operation.  If Operation and ChannelAttributes\r
-                                      shows that this device performs bus mastering\r
-                                      DMA, then this field is ignored.  The legal\r
-                                      range for this field is 0..7.\r
-  @param[in]      ChannelAttributes   A bitmask of the attributes used to configure\r
-                                      the slave DMA channel for this DMA operation.\r
-                                      See EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_* for the\r
-                                      legal bit combinations.\r
-  @param[in]      HostAddress         The system memory address to map to the device.\r
-  @param[in, out] NumberOfBytes       On input the number of bytes to map.  On\r
-                                      output the number of bytes that were mapped.\r
-  @param[out]     DeviceAddress       The resulting map address for the bus master\r
-                                      device to use to access the hosts HostAddress.\r
-  @param[out]     Mapping             A returned value that must be passed to into\r
-                                      EFI_ISA_IO_PROTOCOL.Unmap() to free all the the\r
-                                      resources associated with this map request.\r
-\r
-  @retval EFI_SUCCESS             The range was mapped for the returned NumberOfBytes.\r
-  @retval EFI_INVALID_PARAMETER   The Operation is undefined.\r
-  @retval EFI_INVALID_PARAMETER   The HostAddress is undefined.\r
-  @retval EFI_UNSUPPORTED         The HostAddress can not be mapped as a common buffer.\r
-  @retval EFI_DEVICE_ERROR        The system hardware could not map the requested address.\r
-  @retval EFI_OUT_OF_RESOURCES    The memory pages could not be allocated.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_IO_PROTOCOL_MAP)(\r
-  IN     EFI_ISA_IO_PROTOCOL            *This,\r
-  IN     EFI_ISA_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     UINT8                          ChannelNumber      OPTIONAL,\r
-  IN     UINT32                         ChannelAttributes,\r
-  IN     VOID                           *HostAddress,\r
-  IN OUT UINTN                          *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
-  OUT    VOID                           **Mapping\r
-  );\r
-\r
-/**\r
-  Unmaps a memory region that was previously mapped with EFI_ISA_IO_PROTOCOL.Map().\r
-\r
-  The EFI_ISA_IO_PROTOCOL.Map() operation is completed and any corresponding\r
-  resources are released.  If the operation was EfiIsaIoOperationSlaveWrite\r
-  or EfiIsaIoOperationBusMasterWrite, the data is committed to system memory.\r
-  Any resources used for the mapping are freed.\r
-\r
-  @param[in] This           A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Mapping        The mapping value returned from EFI_ISA_IO_PROTOCOL.Map().\r
-\r
-  @retval EFI_SUCCESS       The memory region was unmapped.\r
-  @retval EFI_DEVICE_ERROR  The data was not committed to the target system memory.\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_IO_PROTOCOL_UNMAP)(\r
-  IN  EFI_ISA_IO_PROTOCOL  *This,\r
-  IN  VOID                 *Mapping\r
-  );\r
-\r
-/**\r
-  Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer\r
-  mapping.\r
-\r
-  @param[in]  This          A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in]  Type          The type allocation to perform.\r
-  @param[in]  MemoryType    The type of memory to allocate.\r
-  @param[in]  Pages         The number of pages to allocate.\r
-  @param[out] HostAddress   A pointer to store the base address of the allocated range.\r
-  @param[in]  Attributes    The requested bit mask of attributes for the allocated range.\r
-\r
-  @retval EFI_SUCCESS             The requested memory pages were allocated.\r
-  @retval EFI_INVALID_PARAMETER   Type is invalid.\r
-  @retval EFI_INVALID_PARAMETER   MemoryType is invalid.\r
-  @retval EFI_INVALID_PARAMETER   HostAddress is NULL.\r
-  @retval EFI_UNSUPPORTED         Attributes is unsupported.\r
-  @retval EFI_UNSUPPORTED         The memory range specified by HostAddress, Pages,\r
-                                  and Type is not available for common buffer use.\r
-  @retval EFI_OUT_OF_RESOURCES    The memory pages could not be allocated.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER)(\r
-  IN  EFI_ISA_IO_PROTOCOL  *This,\r
-  IN  EFI_ALLOCATE_TYPE    Type,\r
-  IN  EFI_MEMORY_TYPE      MemoryType,\r
-  IN  UINTN                Pages,\r
-  OUT VOID                 **HostAddress,\r
-  IN  UINT64               Attributes\r
-  );\r
-\r
-/**\r
-  Frees a common buffer that was allocated with EFI_ISA_IO_PROTOCOL.AllocateBuffer().\r
-\r
-  @param[in] This          A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-  @param[in] Pages         The number of pages to free from the previously allocated common buffer.\r
-  @param[in] HostAddress   The base address of the previously allocated common buffer.\r
-\r
-\r
-  @retval EFI_SUCCESS             The requested memory pages were freed.\r
-  @retval EFI_INVALID_PARAMETER   The memory was not allocated with EFI_ISA_IO.AllocateBufer().\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_IO_PROTOCOL_FREE_BUFFER)(\r
-  IN  EFI_ISA_IO_PROTOCOL  *This,\r
-  IN  UINTN                Pages,\r
-  IN  VOID                 *HostAddress\r
-  );\r
-\r
-/**\r
-  Flushes a DMA buffer, which forces all DMA posted write transactions to complete.\r
-\r
-  @param[in] This   A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
-\r
-  @retval  EFI_SUCCESS        The DMA buffers were flushed.\r
-  @retval  EFI_DEVICE_ERROR   The buffers were not flushed due to a hardware error.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_ISA_IO_PROTOCOL_FLUSH)(\r
-  IN EFI_ISA_IO_PROTOCOL  *This\r
-  );\r
-\r
-///\r
-/// The EFI_ISA_IO_PROTOCOL provides the basic Memory, I/O, and DMA interfaces\r
-/// used to abstract accesses to ISA controllers.  There is one EFI_ISA_IO_PROTOCOL\r
-/// instance for each ISA controller on a ISA bus. A device driver that wishes\r
-/// to manage an ISA controller in a system will have to retrieve the\r
-/// ISA_PCI_IO_PROTOCOL instance associated with the ISA controller.\r
-///\r
-struct _EFI_ISA_IO_PROTOCOL {\r
-  EFI_ISA_IO_PROTOCOL_ACCESS           Mem;\r
-  EFI_ISA_IO_PROTOCOL_ACCESS           Io;\r
-  EFI_ISA_IO_PROTOCOL_COPY_MEM         CopyMem;\r
-  EFI_ISA_IO_PROTOCOL_MAP              Map;\r
-  EFI_ISA_IO_PROTOCOL_UNMAP            Unmap;\r
-  EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER  AllocateBuffer;\r
-  EFI_ISA_IO_PROTOCOL_FREE_BUFFER      FreeBuffer;\r
-  EFI_ISA_IO_PROTOCOL_FLUSH            Flush;\r
-  ///\r
-  /// The list of I/O , MMIO, DMA, and Interrupt resources associated with the\r
-  /// ISA controller abstracted by this instance of the EFI_ISA_IO_PROTOCOL.\r
-  ///\r
-  EFI_ISA_ACPI_RESOURCE_LIST           *ResourceList;\r
-  ///\r
-  /// The size, in bytes, of the ROM image.\r
-  ///\r
-  UINT32                               RomSize;\r
-  ///\r
-  /// A pointer to the in memory copy of the ROM image. The ISA Bus Driver is responsible\r
-  /// for allocating memory for the ROM image, and copying the contents of the ROM to memory\r
-  /// during ISA Bus initialization.\r
-  ///\r
-  VOID                                 *RomImage;\r
-};\r
-\r
-extern EFI_GUID gEfiIsaIoProtocolGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Protocol/OEMBadging.h b/IntelFrameworkModulePkg/Include/Protocol/OEMBadging.h
deleted file mode 100644 (file)
index 043ab5f..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/** @file\r
-  The OEM Badging Protocol defines the interface to get the OEM badging\r
-  image with the display attribute. This protocol can be produced based on OEM badging images.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __EFI_OEM_BADGING_H__\r
-#define __EFI_OEM_BADGING_H__\r
-\r
-//\r
-// GUID for EFI OEM Badging Protocol\r
-//\r
-#define EFI_OEM_BADGING_PROTOCOL_GUID \\r
-  { 0x170e13c0, 0xbf1b, 0x4218, {0x87, 0x1d, 0x2a, 0xbd, 0xc6, 0xf8, 0x87, 0xbc } }\r
-\r
-\r
-typedef struct _EFI_OEM_BADGING_PROTOCOL EFI_OEM_BADGING_PROTOCOL;\r
-\r
-typedef enum {\r
-  EfiBadgingFormatBMP,\r
-  EfiBadgingFormatJPEG,\r
-  EfiBadgingFormatTIFF,\r
-  EfiBadgingFormatGIF,\r
-  EfiBadgingFormatUnknown\r
-} EFI_BADGING_FORMAT;\r
-\r
-typedef enum {\r
-  EfiBadgingDisplayAttributeLeftTop,\r
-  EfiBadgingDisplayAttributeCenterTop,\r
-  EfiBadgingDisplayAttributeRightTop,\r
-  EfiBadgingDisplayAttributeCenterRight,\r
-  EfiBadgingDisplayAttributeRightBottom,\r
-  EfiBadgingDisplayAttributeCenterBottom,\r
-  EfiBadgingDisplayAttributeLeftBottom,\r
-  EfiBadgingDisplayAttributeCenterLeft,\r
-  EfiBadgingDisplayAttributeCenter,\r
-  EfiBadgingDisplayAttributeCustomized\r
-} EFI_BADGING_DISPLAY_ATTRIBUTE;\r
-\r
-/**\r
-\r
-  Load an OEM badge image and return its data and attributes.\r
-\r
-  @param This              The pointer to this protocol instance.\r
-  @param Instance          The visible image instance is found.\r
-  @param Format            The format of the image. Examples: BMP, JPEG.\r
-  @param ImageData         The image data for the badge file. Currently only\r
-                           supports the .bmp file format.\r
-  @param ImageSize         The size of the image returned.\r
-  @param Attribute         The display attributes of the image returned.\r
-  @param CoordinateX       The X coordinate of the image.\r
-  @param CoordinateY       The Y coordinate of the image.\r
-\r
-  @retval EFI_SUCCESS      The image was fetched successfully.\r
-  @retval EFI_NOT_FOUND    The specified image could not be found.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_BADGING_GET_IMAGE)(\r
-  IN     EFI_OEM_BADGING_PROTOCOL          *This,\r
-  IN OUT UINT32                            *Instance,\r
-     OUT EFI_BADGING_FORMAT                *Format,\r
-     OUT UINT8                             **ImageData,\r
-     OUT UINTN                             *ImageSize,\r
-     OUT EFI_BADGING_DISPLAY_ATTRIBUTE     *Attribute,\r
-     OUT UINTN                             *CoordinateX,\r
-     OUT UINTN                             *CoordinateY\r
-);\r
-\r
-\r
-struct _EFI_OEM_BADGING_PROTOCOL {\r
-  EFI_BADGING_GET_IMAGE       GetImage;\r
-};\r
-\r
-\r
-extern EFI_GUID gEfiOEMBadgingProtocolGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Include/Protocol/VgaMiniPort.h b/IntelFrameworkModulePkg/Include/Protocol/VgaMiniPort.h
deleted file mode 100644 (file)
index 41ff58e..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/** @file\r
-  The VGA Mini Port Protocol used to set the text display mode of a VGA controller.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __VGA_MINI_PORT_H_\r
-#define __VGA_MINI_PORT_H_\r
-\r
-///\r
-/// Global ID for the EFI_VGA_MINI_PORT_PROTOCOL.\r
-///\r
-#define EFI_VGA_MINI_PORT_PROTOCOL_GUID \\r
-  { \\r
-    0xc7735a2f, 0x88f5, 0x4882, {0xae, 0x63, 0xfa, 0xac, 0x8c, 0x8b, 0x86, 0xb3 } \\r
-  }\r
-\r
-///\r
-/// Forward declaration for the EFI_VGA_MINI_PORT_PROTOCOL.\r
-///\r
-typedef struct _EFI_VGA_MINI_PORT_PROTOCOL  EFI_VGA_MINI_PORT_PROTOCOL;\r
-\r
-/**\r
-  Sets the text display mode of a VGA controller.\r
-\r
-  Sets the text display mode of the VGA controller to the mode specified by\r
-  ModeNumber.  A ModeNumber of 0 is a request for an 80x25 text mode.  A\r
-  ModeNumber of 1 is a request for an 80x50 text mode.  If ModeNumber is greater\r
-  than MaxModeNumber, then EFI_UNSUPPORTED is returned.  If the VGA controller\r
-  is not functioning properly, then EFI_DEVICE_ERROR is returned.  If the VGA\r
-  controller is sucessfully set to the mode number specified by ModeNumber, then\r
-  EFI_SUCCESS is returned.\r
-\r
-  @param[in] This         A pointer to the EFI_VGA_MINI_PORT_PROTOCOL instance.\r
-  @param[in] ModeNumber   The requested mode number.  0 for 80x25.  1 for 80x5.\r
-\r
-  @retval EFI_SUCCESS        The mode number was set.\r
-  @retval EFI_UNSUPPORTED    The mode number specified by ModeNumber is not supported.\r
-  @retval EFI_DEVICE_ERROR   The device is not functioning properly.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_VGA_MINI_PORT_SET_MODE)(\r
-  IN EFI_VGA_MINI_PORT_PROTOCOL  *This,\r
-  IN UINTN                        ModeNumber\r
-  );\r
-\r
-struct _EFI_VGA_MINI_PORT_PROTOCOL {\r
-  EFI_VGA_MINI_PORT_SET_MODE  SetMode;\r
-  ///\r
-  /// MMIO base address of the VGA text mode framebuffer.  Typically set to 0xB8000.\r
-  ///\r
-  UINT64                      VgaMemoryOffset;\r
-  ///\r
-  /// I/O Port address for the VGA CRTC address register. Typically set to 0x3D4.\r
-  ///\r
-  UINT64                      CrtcAddressRegisterOffset;\r
-  ///\r
-  /// I/O Port address for the VGA CRTC data register.  Typically set to 0x3D5.\r
-  ///\r
-  UINT64                      CrtcDataRegisterOffset;\r
-  ///\r
-  /// PCI Controller MMIO BAR index of the VGA text mode frame buffer.  Typically\r
-  /// set to EFI_PCI_IO_PASS_THROUGH_BAR\r
-  ///\r
-  UINT8                       VgaMemoryBar;\r
-  ///\r
-  /// PCI Controller I/O BAR index of the VGA CRTC address register.  Typically\r
-  /// set to EFI_PCI_IO_PASS_THROUGH_BAR\r
-  ///\r
-  UINT8                       CrtcAddressRegisterBar;\r
-  ///\r
-  /// PCI Controller I/O BAR index of the VGA CRTC data register.  Typically set\r
-  /// to EFI_PCI_IO_PASS_THROUGH_BAR\r
-  ///\r
-  UINT8                       CrtcDataRegisterBar;\r
-  ///\r
-  /// The maximum number of text modes that this VGA controller supports.\r
-  ///\r
-  UINT8                       MaxMode;\r
-};\r
-\r
-extern EFI_GUID gEfiVgaMiniPortProtocolGuid;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
deleted file mode 100644 (file)
index b29ba64..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-## @file\r
-# Intel Framework Module Package.\r
-#\r
-# This package contains the definitions and module implementation\r
-# which follows Intel EFI Framework Specification.\r
-#\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  DEC_SPECIFICATION              = 0x00010005\r
-  PACKAGE_NAME                   = IntelFrameworkModulePkg\r
-  PACKAGE_UNI_FILE               = IntelFrameworkModulePkg.uni\r
-  PACKAGE_GUID                   = 88894582-7553-4822-B484-624E24B6DECF\r
-  PACKAGE_VERSION                = 0.96\r
-\r
-[Includes]\r
-  Include                        # Root include for the package\r
-\r
-[LibraryClasses]\r
-  ##  @libraryclass  Platform BDS library definition about platform specific behavior.\r
-  PlatformBdsLib|Include/Library/PlatformBdsLib.h\r
-\r
-  ##  @libraryclass  Generic BDS library definition, include the data structure and function.\r
-  GenericBdsLib|Include/Library/GenericBdsLib.h\r
-\r
-[Guids]\r
-  ## IntelFrameworkModule package token space guid\r
-  #  Include/Guid/IntelFrameworkModulePkgTokenSpace.h\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid = { 0xD3705011, 0xBC19, 0x4af7, { 0xBE, 0x16, 0xF6, 0x80, 0x30, 0x37, 0x8C, 0x15 }}\r
-\r
-  ## GUID identifies Data Hub records logged by Status Code Runtime Protocol.\r
-  #  Include/Guid/DataHubStatusCodeRecord.h\r
-  gEfiDataHubStatusCodeRecordGuid = { 0xD083E94C, 0x6560, 0x42E4, { 0xB6, 0xD4, 0x2D, 0xF7, 0x5A, 0xDF, 0x6A, 0x2A }}\r
-\r
-  ## Include/Guid/AcpiVariable.h\r
-  gEfiAcpiVariableCompatiblityGuid   = { 0xc020489e, 0x6db2, 0x4ef2, { 0x9a, 0xa5, 0xca, 0x6,  0xfc, 0x11, 0xd3, 0x6a }}\r
-\r
-  ## Include/Guid/LegacyBios.h\r
-  gEfiLegacyBiosGuid                 = { 0x2E3044AC, 0x879F, 0x490F, { 0x97, 0x60, 0xBB, 0xDF, 0xAF, 0x69, 0x5F, 0x50 }}\r
-\r
-  ## Include/Guid/LegacyDevOrder.h\r
-  gEfiLegacyDevOrderVariableGuid     = { 0xa56074db, 0x65fe, 0x45f7, {0xbd, 0x21, 0x2d, 0x2b, 0xdd, 0x8e, 0x96, 0x52 }}\r
-\r
-  ## Include/Guid/CapsuleDataFile.h\r
-  gEfiUpdateDataFileGuid             = { 0x283fa2ee, 0x532c, 0x484d, { 0x93, 0x83, 0x9f, 0x93, 0xb3, 0x6f, 0xb, 0x7e }}\r
-\r
-  ## Include/Guid/BlockIoVendor.h\r
-  gBlockIoVendorGuid                 = { 0xcf31fac5, 0xc24e, 0x11d2,  {0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b }}\r
-\r
-  ## Include/Guid/BdsHii.h\r
-  gFrontPageFormSetGuid              = { 0x9e0c30bc, 0x3f06, 0x4ba6, {0x82, 0x88, 0x9, 0x17, 0x9b, 0x85, 0x5d, 0xbe }}\r
-  gBootManagerFormSetGuid            = { 0x847bc3fe, 0xb974, 0x446d, {0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b }}\r
-  gDeviceManagerFormSetGuid          = { 0x3ebfa8e6, 0x511d, 0x4b5b, {0xa9, 0x5f, 0xfb, 0x38, 0x26, 0xf, 0x1c, 0x27 }}\r
-  gDriverHealthFormSetGuid           = { 0xf76e0a70, 0xb5ed, 0x4c38, {0xac, 0x9a, 0xe5, 0xf5, 0x4b, 0xf1, 0x6e, 0x34 }}\r
-  gBootMaintFormSetGuid              = { 0x642237c7, 0x35d4, 0x472d, {0x83, 0x65, 0x12, 0xe0, 0xcc, 0xf2, 0x7a, 0x22 }}\r
-  gFileExploreFormSetGuid            = { 0x1f2d63e1, 0xfebd, 0x4dc7, {0x9c, 0xc5, 0xba, 0x2b, 0x1c, 0xef, 0x9c, 0x5b }}\r
-\r
-  ## Include/Guid/BdsLibHii.h\r
-  gBdsLibStringPackageGuid           = { 0x3b4d9b23, 0x95ac, 0x44f6, {0x9f, 0xcd, 0xe, 0x95, 0x94, 0x58, 0x6c, 0x72 }}\r
-\r
-  ## Include/Guid/LastEnumLang.h\r
-  gLastEnumLangGuid                  = { 0xe8c545b, 0xa2ee, 0x470d, {0x8e, 0x26, 0xbd, 0xa1, 0xa1, 0x3c, 0xa, 0xa3 }}\r
-\r
-  ## Include/Guid/HdBootVariable.h\r
-  gHdBootDevicePathVariablGuid       = { 0xfab7e9e1, 0x39dd, 0x4f2b, {0x84, 0x8, 0xe2, 0xe, 0x90, 0x6c, 0xb6, 0xde }}\r
-\r
-[Protocols]\r
-  ## Vga Mini port binding for a VGA controller\r
-  #  Include/Protocol/VgaMiniPort.h\r
-  gEfiVgaMiniPortProtocolGuid    = { 0xc7735a2f, 0x88f5, 0x4882, { 0xae, 0x63, 0xfa, 0xac, 0x8c, 0x8b, 0x86, 0xb3 }}\r
-\r
-  ## ISA I/O Protocol is used to perform ISA device Io/Mem operations.\r
-  #  Include/Protocol/IsaIo.h\r
-  gEfiIsaIoProtocolGuid          = { 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }}\r
-\r
-  ## ISA Acpi Protocol is used to operate and communicate with ISA device.\r
-  #  Include/Protocol/IsaAcpi.h\r
-  gEfiIsaAcpiProtocolGuid        = { 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 }}\r
-\r
-  ## OEM Badging Protocol defines the interface to get the OEM badging image with the dispaly attribute.\r
-  #  Include/Protocol/OEMBadging.h\r
-  gEfiOEMBadgingProtocolGuid     = { 0x170E13C0, 0xBF1B, 0x4218, { 0x87, 0x1D, 0x2A, 0xBD, 0xC6, 0xF8, 0x87, 0xBC }}\r
-\r
-  ## Include/Protocol/ExitPmAuth.h\r
-  gExitPmAuthProtocolGuid        = { 0xd088a413, 0xa70, 0x4217, { 0xba, 0x55, 0x9a, 0x3c, 0xb6, 0x5c, 0x41, 0xb3 }}\r
-\r
-#\r
-# [Error.gEfiIntelFrameworkModulePkgTokenSpaceGuid]\r
-#   0x80000001 | Invalid value provided.\r
-#   0x80000002 | Reserved bits must be set to zero.\r
-#\r
-\r
-[PcdsFeatureFlag]\r
-  ## Indicates if OEM device is enabled as StatusCode report device.\r
-  #  It is only used in Framework StatusCode implementation. <BR><BR>\r
-  #   TRUE  - Enable OEM device.<BR>\r
-  #   FALSE - Disable OEM device.<BR>\r
-  # @Prompt Report StatusCode via OEM Device\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseOEM|FALSE|BOOLEAN|0x00010024\r
-\r
-  ## Indicates if StatusCode report is loged into DataHub.<BR><BR>\r
-  #   TRUE  - Log StatusCode report into DataHub.<BR>\r
-  #   FALSE - Does not log StatusCode report into DataHub.<BR>\r
-  # @Prompt Log StatusCode into DataHub\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseDataHub|FALSE|BOOLEAN|0x00010029\r
-\r
-  ## Indicates if Serial device uses half hand shake.<BR><BR>\r
-  #   TRUE  - Serial device uses half hand shake.<BR>\r
-  #   FALSE - Serial device doesn't use half hand shake.<BR>\r
-  # @Prompt Enable Serial device Half Hand Shake\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSerialUseHalfHandshake|FALSE|BOOLEAN|0x00010043\r
-\r
-  ## Indicates if Legacy support is needed for ACPI S3 Save.<BR><BR>\r
-  #   TRUE  - Support Legacy OS with S3 boot.<BR>\r
-  #   FALSE - Does not support Legacy OS with S3 boot.<BR>\r
-  # @Prompt Turn on Legacy Support in S3 Boot\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformCsmSupport|TRUE|BOOLEAN|0x00010044\r
-\r
-  ## Indicates if Framework Acpi Support protocol is installed.<BR><BR>\r
-  #   TRUE  - Install Framework Acpi Support protocol.<BR>\r
-  #   FALSE - Doesn't install Framework Acpi Support protocol.<BR>\r
-  # @Prompt Enable Framework Acpi Support\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdInstallAcpiSupportProtocol|TRUE|BOOLEAN|0x00010046\r
-\r
-  ## Indicates if only Boot logo is showed and all message output is disabled in BDS.<BR><BR>\r
-  #   TRUE  - Only Boot Logo is showed in boot.<BR>\r
-  #   FALSE - All messages and Boot Logo are showed in boot.<BR>\r
-  # @Prompt Enable Boot Logo only\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootlogoOnlyEnable|FALSE|BOOLEAN|0x00010048\r
-\r
-[PcdsFixedAtBuild, PcdsPatchableInModule]\r
-  ## FFS filename to find the default BMP Logo file.\r
-  # @Prompt FFS Name of Boot Logo File\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile |{ 0x99, 0x8b, 0xB2, 0x7B, 0xBB, 0x61, 0xD5, 0x11, 0x9A, 0x5D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }|VOID*|0x40000003\r
-\r
-  ## FFS filename to find the shell application.\r
-  # @Prompt FFS Name of Shell Application\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0xB7, 0xD6, 0x7A, 0xC5, 0x15, 0x05, 0xA8, 0x40, 0x9D, 0x21, 0x55, 0x16, 0x52, 0x85, 0x4E, 0x37 }|VOID*|0x40000004\r
-\r
-  ## ISA Bus features to support DMA, SlaveDMA and ISA Memory. <BR><BR>\r
-  #  BIT0 indicates if DMA is supported<BR>\r
-  #  BIT1 indicates if only slave DMA is supported<BR>\r
-  #  BIT2 indicates if ISA memory is supported<BR>\r
-  #  Other BITs are reseved and must be zero.\r
-  #  If more than one features are supported, the different BIT will be enabled at the same time.\r
-  # @Prompt ISA Bus Features\r
-  # @Expression 0x80000002 | (gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSupportedFeatures & 0xF8) == 0\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSupportedFeatures|0x05|UINT8|0x00010040\r
-\r
-[PcdsDynamic, PcdsDynamicEx]\r
-  ## Indicates if the machine has completed one boot cycle before.\r
-  #  After the complete boot, BootState will be set to FALSE.<BR><BR>\r
-  #   TRUE  - The complete boot cycle has not happened before.<BR>\r
-  #   FALSE - The complete boot cycle has happened before.<BR>\r
-  # @Prompt Boot State Flag\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootState|TRUE|BOOLEAN|0x0001002f\r
-\r
-[PcdsFixedAtBuild, PcdsDynamic, PcdsDynamicEx, PcdsPatchableInModule]\r
-  ## I/O Base address of floppy device controller.\r
-  # @Prompt I/O Base Address of Floppy Device Controller\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdFdcBaseAddress|0x3f0|UINT16|0x30000000\r
-\r
-  ## Indicates if BiosVideo driver will switch to 80x25 Text VGA Mode when exiting boot service.<BR><BR>\r
-  #   TRUE  - Switch to Text VGA Mode.<BR>\r
-  #   FALSE - Does not switch to Text VGA Mode.<BR>\r
-  # @Prompt Switch to Text VGA Mode on UEFI Boot\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBiosVideoSetTextVgaModeEnable|FALSE|BOOLEAN|0x30000001\r
-\r
-  ## Indicates if BiosVideo driver will check for VESA BIOS Extension service support.<BR><BR>\r
-  #   TRUE  - Check for VESA BIOS Extension service.<BR>\r
-  #   FALSE - Does not check for VESA BIOS Extension service.<BR>\r
-  # @Prompt Enable Check for VESA BIOS Extension Service\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBiosVideoCheckVbeEnable|TRUE|BOOLEAN|0x30000002\r
-\r
-  ## Indicates if BiosVideo driver will check for VGA service support.\r
-  #  NOTE: If both PcdBiosVideoCheckVbeEnable and PcdBiosVideoCheckVgaEnable are set to FALSE,\r
-  #  that means Graphics Output protocol will not be installed, the VGA miniport protocol will be installed instead.<BR><BR>\r
-  #   TRUE  - Check for VGA service.<BR>\r
-  #   FALSE - Does not check for VGA service.<BR>\r
-  # @Prompt Enable Check for VGA Service\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBiosVideoCheckVgaEnable|TRUE|BOOLEAN|0x30000003\r
-\r
-  ## Indicates if memory space for legacy region will be set as cacheable.<BR><BR>\r
-  #   TRUE  - Set cachebility for legacy region.<BR>\r
-  #   FALSE - Does not set cachebility for legacy region.<BR>\r
-  # @Prompt Enable Cachebility for Legacy Region\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLegacyBiosCacheLegacyRegion|TRUE|BOOLEAN|0x00000004\r
-\r
-  ## Specify memory size with bytes to reserve EBDA below 640K for OPROM.\r
-  # The value should be a multiple of 4KB.\r
-  # @Prompt Reserved EBDA Memory Size\r
-  # @Expression 0x80000001 | (gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEbdaReservedMemorySize < 0xA0000) AND ((gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEbdaReservedMemorySize & 0x1000) == 0)\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEbdaReservedMemorySize|0x8000|UINT32|0x30000005\r
-\r
-  ## Specify memory base address for OPROM to find free memory.\r
-  # Some OPROMs do not use EBDA or PMM to allocate memory for its usage,\r
-  # instead they find the memory filled with zero from 0x20000.\r
-  # The value should be a multiple of 4KB.\r
-  # The range should be below the EBDA reserved range from\r
-  # (CONVENTIONAL_MEMORY_TOP - Reserved EBDA Memory Size) to CONVENTIONAL_MEMORY_TOP.\r
-  # @Prompt Reserved Memory Base Address for OPROM\r
-  # @Expression 0x80000001 | (gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdOpromReservedMemoryBase >= 0x20000) AND ((gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdOpromReservedMemoryBase & 0x1000) == 0)\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdOpromReservedMemoryBase|0x60000|UINT32|0x3000000c\r
-\r
-  ## Specify memory size with bytes for OPROM to find free memory.\r
-  #  The value should be a multiple of 4KB. And the range should be below the EBDA reserved range from\r
-  # (CONVENTIONAL_MEMORY_TOP - Reserved EBDA Memory Size) to CONVENTIONAL_MEMORY_TOP.\r
-  # @Prompt Reserved Memory Size for OPROM\r
-  # @Expression 0x80000001 | (gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdOpromReservedMemorySize < 0x80000) AND ((gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdOpromReservedMemorySize & 0x1000) == 0)\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdOpromReservedMemorySize|0x28000|UINT32|0x3000000d\r
-\r
-  ## Specify memory size with page number for a pre-allocated reserved memory to be used\r
-  #  by PEI in S3 phase. The default size 32K. When changing the value make sure the memory size\r
-  #  is large enough to meet PEI requirement in the S3 phase.\r
-  # @Prompt Reserved S3 Boot ACPI Memory Size\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x8000|UINT32|0x30000006\r
-\r
-  ## Specify the end of address below 1MB for the OPROM.\r
-  #  The last shadowed OpROM should not exceed this address.\r
-  # @Prompt Top Address of Shadowed Legacy OpROM\r
-  # @Expression 0x80000001 | gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEndOpromShadowAddress < 0x100000\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEndOpromShadowAddress|0xdffff|UINT32|0x30000008\r
-\r
-  ## Specify the low PMM (Post Memory Manager) size with bytes below 1MB.\r
-  #  The value should be a multiple of 4KB.\r
-  # @Prompt Low PMM (Post Memory Manager) Size\r
-  # @Expression 0x80000001 | (gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLowPmmMemorySize < 0x100000) AND ((gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLowPmmMemorySize & 0x1000) == 0)\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLowPmmMemorySize|0x10000|UINT32|0x30000009\r
-\r
-  ## Specify the high PMM (Post Memory Manager) size with bytes above 1MB.\r
-  #  The value should be a multiple of 4KB.\r
-  # @Prompt High PMM (Post Memory Manager) Size\r
-  # @Expression 0x80000001 | (gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdHighPmmMemorySize & 0x1000) == 0\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdHighPmmMemorySize|0x400000|UINT32|0x3000000a\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  IntelFrameworkModulePkgExtra.uni\r
diff --git a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
deleted file mode 100644 (file)
index c56c0f8..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-## @file\r
-# Intel Framework Reference Module Package for All Architectures\r
-#\r
-# This file is used to build all modules in IntelFrameworkModulePkg.\r
-#\r
-#Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-################################################################################\r
-#\r
-# Defines Section - statements that will be processed to create a Makefile.\r
-#\r
-################################################################################\r
-[Defines]\r
-  PLATFORM_NAME                  = IntelFrameworkModuleAll\r
-  PLATFORM_GUID                  = FFF87D9A-E5BB-4AFF-9ADE-8645492E8087\r
-  PLATFORM_VERSION               = 0.96\r
-  DSC_SPECIFICATION              = 0x00010005\r
-  OUTPUT_DIRECTORY               = Build/IntelFrameworkModuleAll\r
-  SUPPORTED_ARCHITECTURES        = IA32|X64|EBC|ARM|AARCH64\r
-  BUILD_TARGETS                  = DEBUG|RELEASE|NOOPT\r
-  SKUID_IDENTIFIER               = DEFAULT\r
-\r
-################################################################################\r
-#\r
-# SKU Identification section - list of all SKU IDs supported by this\r
-#                              Platform.\r
-#\r
-################################################################################\r
-[SkuIds]\r
-  0|DEFAULT              # The entry: 0|DEFAULT is reserved and always required.\r
-\r
-[LibraryClasses]\r
-  CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf\r
-  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf\r
-  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
-  DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf\r
-  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
-  SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf\r
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
-  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
-  PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
-  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-  TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
-  OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
-  SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf\r
-  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
-  GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
-  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf\r
-  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf\r
-  UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
-  HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
-  PlatformBdsLib|IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf\r
-  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
-  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
-  PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf\r
-  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
-  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
-  ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf\r
-  PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf\r
-  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
-  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
-  UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
-  UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
-  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
-  UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
-  DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
-  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
-  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
-\r
-[LibraryClasses.ARM, LibraryClasses.AARCH64]\r
-  #\r
-  # It is not possible to prevent the ARM compiler for generic intrinsic functions.\r
-  # This library provides the instrinsic functions generate by a given compiler.\r
-  # And NULL mean link this library into all ARM images.\r
-  #\r
-  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf\r
-\r
-  # Add support for GCC stack protector\r
-  NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf\r
-\r
-[LibraryClasses.common.PEIM]\r
-  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
-  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
-  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
-\r
-[LibraryClasses.EBC.PEIM]\r
-  IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf\r
-\r
-[LibraryClasses.common.DXE_DRIVER]\r
-  LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf\r
-\r
-[LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.UEFI_DRIVER]\r
-  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
-  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
-\r
-[LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
-  DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf\r
-\r
-################################################################################\r
-#\r
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform\r
-#\r
-################################################################################\r
-[PcdsFeatureFlag]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSerialUseHalfHandshake|FALSE\r
-\r
-[PcdsFixedAtBuild]\r
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0f\r
-  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x06\r
-  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000\r
-\r
-[Components]\r
-  IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
-  IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.inf\r
-  IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.inf\r
-  IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
-  IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeReportStatusCodeLibFramework.inf\r
-  IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
-  IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf\r
-  IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
-  IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.inf\r
-  IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf\r
-  IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf\r
-\r
-  IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf\r
-\r
-  IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf\r
-  IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf\r
-  IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BlockIoDxe.inf\r
-  IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Snp16Dxe.inf\r
-\r
-  IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.inf\r
-  IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.inf\r
-  IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.inf\r
-  IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxe.inf\r
-  IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
-  IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf\r
-  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
-  IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxe.inf\r
-  IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.inf\r
-  IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxe.inf\r
-  IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxe.inf\r
-\r
-[Components.IA32,Components.X64]\r
-  IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.inf\r
-  IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaArchCustomDecompressLib.inf\r
-\r
-[Components.IA32,Components.X64]\r
-  IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf\r
-\r
-[Components.IA32]\r
-  IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf\r
-  IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxe.inf {\r
-    <LibraryClasses>\r
-      IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
-  }\r
-\r
-[Components.X64]\r
-  IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf\r
-  IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxe.inf {\r
-    <LibraryClasses>\r
-      IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
-  }\r
-\r
-[BuildOptions]\r
-  *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES\r
diff --git a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.uni b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.uni
deleted file mode 100644 (file)
index 9a9442e..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-// /** @file\r
-// Intel Framework Module Package.\r
-//\r
-// This package contains the definitions and module implementation\r
-// which follows Intel EFI Framework Specification.\r
-//\r
-// Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_PACKAGE_ABSTRACT            #language en-US "Intel Framework Module Package"\r
-\r
-#string STR_PACKAGE_DESCRIPTION         #language en-US "This package contains the definitions and module implementation that follow the Intel EFI Framework Specification."\r
-\r
-\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdLogoFile_PROMPT  #language en-US "FFS Name of Boot Logo File"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdLogoFile_HELP  #language en-US "FFS filename to find the default BMP Logo file."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdShellFile_PROMPT  #language en-US "FFS Name of Shell Application"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdShellFile_HELP  #language en-US "FFS filename to find the shell application."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdIsaBusSupportedFeatures_PROMPT  #language en-US "ISA Bus Features"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdIsaBusSupportedFeatures_HELP  #language en-US "ISA Bus features to support DMA, Slave DMA and ISA Memory. <BR><BR>\n"\r
-                                                                                                       "BIT0 indicates if DMA is supported<BR>\n"\r
-                                                                                                       "BIT1 indicates if only slave DMA is supported<BR>\n"\r
-                                                                                                       "BIT2 indicates if ISA memory is supported<BR>\n"\r
-                                                                                                       "Other BITs are reserved and must be zero. If more than one features are supported, the different BIT will be enabled at the same time."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_ERR_80000002 #language en-US "Reserved bits must be set to zero."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdFdcBaseAddress_PROMPT  #language en-US "I/O Base Address of Floppy Device Controller"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdFdcBaseAddress_HELP  #language en-US "I/O Base address of floppy device controller."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBiosVideoSetTextVgaModeEnable_PROMPT  #language en-US "Switch to Text VGA Mode on UEFI Boot"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBiosVideoSetTextVgaModeEnable_HELP  #language en-US "Indicates if BiosVideo driver will switch to 80x25 Text VGA Mode when exiting boot service.<BR><BR>\n"\r
-                                                                                                             "TRUE  - Switch to Text VGA Mode.<BR>\n"\r
-                                                                                                             "FALSE - Does not switch to Text VGA Mode.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBiosVideoCheckVbeEnable_PROMPT  #language en-US "Enable Check for VESA BIOS Extension Service"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBiosVideoCheckVbeEnable_HELP  #language en-US "Indicates if BiosVideo driver will check for VESA BIOS Extension service support.<BR><BR>\n"\r
-                                                                                                       "TRUE  - Check for VESA BIOS Extension service.<BR>\n"\r
-                                                                                                       "FALSE - Does not check for VESA BIOS Extension service.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBiosVideoCheckVgaEnable_PROMPT  #language en-US "Enable Check for VGA Service"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBiosVideoCheckVgaEnable_HELP  #language en-US "Indicates if BiosVideo driver will check for VGA service support. NOTE: If both PcdBiosVideoCheckVbeEnable and PcdBiosVideoCheckVgaEnable are set to FALSE, that means Graphics Output protocol will not be installed, the VGA miniport protocol will be installed instead.<BR><BR>\n"\r
-                                                                                                       "TRUE  - Check for VGA service<BR>\n"\r
-                                                                                                       "FALSE - Does not check for VGA service<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdLegacyBiosCacheLegacyRegion_PROMPT  #language en-US "Enable Cacheability for Legacy Region"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdLegacyBiosCacheLegacyRegion_HELP  #language en-US "Set memory space for legacy region cacheable?<BR><BR>\n"\r
-                                                                                                           "TRUE  - Cacheable<BR>\n"\r
-                                                                                                           "FALSE - Non cacheable<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdEbdaReservedMemorySize_PROMPT  #language en-US "Reserved EBDA Memory Size"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdEbdaReservedMemorySize_HELP  #language en-US "Specify memory size with bytes to reserve EBDA below 640K for OPROM. The value should be a multiple of 4KB."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_ERR_80000001 #language en-US "Invalid value provided."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdS3AcpiReservedMemorySize_PROMPT  #language en-US "Reserved S3 Boot ACPI Memory Size"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdS3AcpiReservedMemorySize_HELP  #language en-US "Specify memory size with page number for a pre-allocated reserved memory to be used by PEI in S3 phase. The default size 32K. When changing the value make sure the memory size is large enough to meet PEI requirement in the S3 phase."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdEndOpromShadowAddress_PROMPT  #language en-US "Top Address of Shadowed Legacy OpROM"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdEndOpromShadowAddress_HELP  #language en-US "Specify the end of address below 1MB for the OPROM. The last shadowed OpROM should not exceed this address."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdLowPmmMemorySize_PROMPT  #language en-US "Low PMM (Post Memory Manager) Size"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdLowPmmMemorySize_HELP  #language en-US "Specify the low PMM (Post Memory Manager) size with bytes below 1MB. The value should be a multiple of 4KB."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdHighPmmMemorySize_PROMPT  #language en-US "High PMM (Post Memory Manager) Size"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdHighPmmMemorySize_HELP  #language en-US "Specify the high PMM (Post Memory Manager) size with bytes above 1MB. The value should be a multiple of 4KB."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdFastPS2Detection_PROMPT  #language en-US "Enable fast PS2 detection"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdFastPS2Detection_HELP  #language en-US "Indicates if to use the optimized timing for best PS2 detection performance.\n"\r
-                                                                                                "Note this PCD could be set to TRUE for best boot performance and set to FALSE for best device compatibility.<BR><BR>\n"\r
-                                                                                                "TRUE  - Use the optimized timing for best PS2 detection performance.<BR>\n"\r
-                                                                                                "FALSE - Use the normal timing to detect PS2.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdStatusCodeUseOEM_PROMPT  #language en-US "Report StatusCode via OEM Device"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdStatusCodeUseOEM_HELP  #language en-US "Indicates if OEM device is enabled as StatusCode report device. It is only used in Framework StatusCode implementation. <BR><BR>\n"\r
-                                                                                                "TRUE  - Enable OEM device.<BR>\n"\r
-                                                                                                "FALSE - Disable OEM device.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdStatusCodeUseDataHub_PROMPT  #language en-US "Log StatusCode into DataHub"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdStatusCodeUseDataHub_HELP  #language en-US "Indicates if StatusCode report is loged into DataHub.<BR><BR>\n"\r
-                                                                                                    "TRUE  - Log StatusCode report into DataHub.<BR>\n"\r
-                                                                                                    "FALSE - Does not log StatusCode report into DataHub.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdIsaBusSerialUseHalfHandshake_PROMPT  #language en-US "Enable Serial device Half Hand Shake"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdIsaBusSerialUseHalfHandshake_HELP  #language en-US "Indicates if Serial device uses half hand shake.<BR><BR>\n"\r
-                                                                                                            "TRUE  - Serial device uses half hand shake.<BR>\n"\r
-                                                                                                            "FALSE - Serial device doesn't use half hand shake.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdPlatformCsmSupport_PROMPT  #language en-US "Turn on Legacy Support in S3 boot"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdPlatformCsmSupport_HELP  #language en-US "Enable Legacy OS support during ACPI S3 boot.<BR><BR>\n"\r
-                                                                                                  "TRUE  - Support Legacy OS with S3 boot.<BR>\n"\r
-                                                                                                  "FALSE - Does not support Legacy OS with S3 boot.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdPs2KbdExtendedVerification_PROMPT  #language en-US "Turn on PS2 Keyboard Extended Verification"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdPs2KbdExtendedVerification_HELP  #language en-US "Enable PS2 keyboard extended verification. Extended verification will increase boot time.<BR><BR>\n"\r
-                                                                                                          "TRUE  - Enable extended verification.<BR>\n"\r
-                                                                                                          "FALSE - Disable extended verification.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdInstallAcpiSupportProtocol_PROMPT  #language en-US "Enable Framework ACPI Support"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdInstallAcpiSupportProtocol_HELP  #language en-US "Indicates if Framework Acpi Support protocol is installed.<BR><BR>\n"\r
-                                                                                                          "TRUE  - Install Framework Acpi Support protocol.<BR>\n"\r
-                                                                                                          "FALSE - Doesn't install Framework Acpi Support protocol.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdPs2MouseExtendedVerification_PROMPT  #language en-US "Turn on PS2 Mouse Extended Verification"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdPs2MouseExtendedVerification_HELP  #language en-US "Enable PS2 mouse extended verification. Extended verification will increase boot time.<BR><BR>\n"\r
-                                                                                                            "TRUE  - Enable extended verification.<BR>\n"\r
-                                                                                                            "FALSE - Disable extended verification.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBootlogoOnlyEnable_PROMPT  #language en-US "Enable Boot Logo only"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBootlogoOnlyEnable_HELP  #language en-US "Indicates if only Boot logo is showed and all message output is disabled in BDS.<BR><BR>\n"\r
-                                                                                                  "TRUE  - Only Boot Logo is showed in boot.<BR>\n"\r
-                                                                                                  "FALSE - All messages and Boot Logo are showed in boot.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBootState_PROMPT  #language en-US "Boot State Flag"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdBootState_HELP  #language en-US "Indicates if the machine has completed one boot cycle before. After the complete boot, BootState will be set to FALSE.<BR><BR>\n"\r
-                                                                                         "TRUE  - The complete boot cycle has not happened before.<BR>\n"\r
-                                                                                         "FALSE - The complete boot cycle has happened before.<BR>"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdOpromReservedMemoryBase_PROMPT  #language en-US "Reserved Memory Base Address for OPROM"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdOpromReservedMemoryBase_HELP  #language en-US "Specify memory base address for OPROM to find free memory.\n"\r
-                                                                                                       "Some OPROMs do not use EBDA or PMM to allocate memory for its usage,\n"\r
-                                                                                                       "instead they find the memory filled with zero from 0x20000.\n"\r
-                                                                                                       "The value should be a multiple of 4KB.\n"\r
-                                                                                                       "The range should be below the EBDA reserved range from\n"\r
-                                                                                                       "(CONVENTIONAL_MEMORY_TOP - Reserved EBDA Memory Size) to CONVENTIONAL_MEMORY_TOP."\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdOpromReservedMemorySize_PROMPT  #language en-US "Reserved Memory Size for OPROM"\r
-\r
-#string STR_gEfiIntelFrameworkModulePkgTokenSpaceGuid_PcdOpromReservedMemorySize_HELP  #language en-US "Specify memory size with bytes for OPROM to find free memory.\n"\r
-                                                                                                       "The value should be a multiple of 4KB. And the range should be below the EBDA reserved range from\n"\r
-                                                                                                       "(CONVENTIONAL_MEMORY_TOP - Reserved EBDA Memory Size) to CONVENTIONAL_MEMORY_TOP."\r
-\r
diff --git a/IntelFrameworkModulePkg/IntelFrameworkModulePkgExtra.uni b/IntelFrameworkModulePkg/IntelFrameworkModulePkgExtra.uni
deleted file mode 100644 (file)
index c80101b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// IntelFrameworkModule Package Localized Strings and Content.\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_PACKAGE_NAME\r
-#language en-US\r
-"IntelFrameworkModule package"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.c b/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.c
deleted file mode 100644 (file)
index 002b258..0000000
+++ /dev/null
@@ -1,550 +0,0 @@
-/** @file\r
-  Capsule Library instance to process capsule images.\r
-\r
-  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-#include <PiDxe.h>\r
-\r
-#include <Guid/Capsule.h>\r
-#include <Guid/FmpCapsule.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/CapsuleLib.h>\r
-#include <Library/GenericBdsLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-#include <Protocol/FirmwareManagement.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-\r
-/**\r
-  Function indicate the current completion progress of the firmware\r
-  update. Platform may override with own specific progress function.\r
-\r
-  @param  Completion    A value between 1 and 100 indicating the current completion progress of the firmware update\r
-\r
-  @retval EFI_SUCESS    Input capsule is a correct FMP capsule.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Update_Image_Progress (\r
-   IN UINTN Completion\r
-)\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Validate Fmp capsules layout.\r
-\r
-  @param  CapsuleHeader    Points to a capsule header.\r
-\r
-  @retval EFI_SUCESS                     Input capsule is a correct FMP capsule.\r
-  @retval EFI_INVALID_PARAMETER  Input capsule is not a correct FMP capsule.\r
-**/\r
-EFI_STATUS\r
-ValidateFmpCapsule (\r
-  IN EFI_CAPSULE_HEADER *CapsuleHeader\r
-  )\r
-{\r
-  EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER       *FmpCapsuleHeader;\r
-  UINT8                                        *EndOfCapsule;\r
-  EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;\r
-  UINT8                                        *EndOfPayload;\r
-  UINT64                                       *ItemOffsetList;\r
-  UINT32                                       ItemNum;\r
-  UINTN                                        Index;\r
-\r
-  FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);\r
-  EndOfCapsule     = (UINT8 *) CapsuleHeader + CapsuleHeader->CapsuleImageSize;\r
-\r
-  if (FmpCapsuleHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);\r
-\r
-  ItemNum = FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount;\r
-\r
-  if (ItemNum == FmpCapsuleHeader->EmbeddedDriverCount) {\r
-    //\r
-    // No payload element\r
-    //\r
-    if (((UINT8 *)FmpCapsuleHeader + ItemOffsetList[ItemNum - 1]) < EndOfCapsule) {\r
-      return EFI_SUCCESS;\r
-    } else {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-\r
-  if (FmpCapsuleHeader->PayloadItemCount != 0) {\r
-    //\r
-    // Check if the last payload is within capsule image range\r
-    //\r
-    ImageHeader  = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[ItemNum - 1]);\r
-    EndOfPayload = (UINT8 *)(ImageHeader + 1) + ImageHeader->UpdateImageSize + ImageHeader->UpdateVendorCodeSize;\r
-  } else {\r
-    //\r
-    // No driver & payload element in FMP\r
-    //\r
-    EndOfPayload = (UINT8 *)(FmpCapsuleHeader + 1);\r
-  }\r
-\r
-  if (EndOfPayload != EndOfCapsule) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // All the address in ItemOffsetList must be stored in ascending order\r
-  //\r
-  if (ItemNum >= 2) {\r
-    for (Index = 0; Index < ItemNum - 1; Index++) {\r
-      if (ItemOffsetList[Index] >= ItemOffsetList[Index + 1]) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Process Firmware management protocol data capsule.\r
-\r
-  @param  CapsuleHeader         Points to a capsule header.\r
-\r
-  @retval EFI_SUCESS            Process Capsule Image successfully.\r
-  @retval EFI_UNSUPPORTED       Capsule image is not supported by the firmware.\r
-  @retval EFI_VOLUME_CORRUPTED  FV volume in the capsule is corrupted.\r
-  @retval EFI_OUT_OF_RESOURCES  Not enough memory.\r
-**/\r
-EFI_STATUS\r
-ProcessFmpCapsuleImage (\r
-  IN EFI_CAPSULE_HEADER *CapsuleHeader\r
-  )\r
-{\r
-  EFI_STATUS                                    Status;\r
-  EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER        *FmpCapsuleHeader;\r
-  EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER  *ImageHeader;\r
-  EFI_HANDLE                                    ImageHandle;\r
-  UINT64                                        *ItemOffsetList;\r
-  UINT32                                        ItemNum;\r
-  UINTN                                         Index;\r
-  UINTN                                         ExitDataSize;\r
-  EFI_HANDLE                                    *HandleBuffer;\r
-  EFI_FIRMWARE_MANAGEMENT_PROTOCOL              *Fmp;\r
-  UINTN                                         NumberOfHandles;\r
-  UINTN                                         DescriptorSize;\r
-  UINT8                                         FmpImageInfoCount;\r
-  UINT32                                        FmpImageInfoDescriptorVer;\r
-  UINTN                                         ImageInfoSize;\r
-  UINT32                                        PackageVersion;\r
-  CHAR16                                        *PackageVersionName;\r
-  CHAR16                                        *AbortReason;\r
-  EFI_FIRMWARE_IMAGE_DESCRIPTOR                 *FmpImageInfoBuf;\r
-  EFI_FIRMWARE_IMAGE_DESCRIPTOR                 *TempFmpImageInfo;\r
-  UINTN                                         DriverLen;\r
-  UINTN                                         Index1;\r
-  UINTN                                         Index2;\r
-  MEMMAP_DEVICE_PATH                            MemMapNode;\r
-  EFI_DEVICE_PATH_PROTOCOL                      *DriverDevicePath;\r
-\r
-  Status           = EFI_SUCCESS;\r
-  HandleBuffer     = NULL;\r
-  ExitDataSize     = 0;\r
-  DriverDevicePath = NULL;\r
-\r
-  FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);\r
-\r
-  if (FmpCapsuleHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);\r
-\r
-  ItemNum = FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount;\r
-\r
-  //\r
-  // capsule in which driver count and payload count are both zero is not processed.\r
-  //\r
-  if (ItemNum == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // 1. ConnectAll to ensure\r
-  //    All the communication protocol required by driver in capsule installed\r
-  //    All FMP protocols are installed\r
-  //\r
-  BdsLibConnectAll();\r
-\r
-\r
-  //\r
-  // 2. Try to load & start all the drivers within capsule\r
-  //\r
-  SetDevicePathNodeLength (&MemMapNode.Header, sizeof (MemMapNode));\r
-  MemMapNode.Header.Type     = HARDWARE_DEVICE_PATH;\r
-  MemMapNode.Header.SubType  = HW_MEMMAP_DP;\r
-  MemMapNode.MemoryType      = EfiBootServicesCode;\r
-  MemMapNode.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CapsuleHeader;\r
-  MemMapNode.EndingAddress   = (EFI_PHYSICAL_ADDRESS)(UINTN)((UINT8 *)CapsuleHeader + CapsuleHeader->CapsuleImageSize - 1);\r
-\r
-  DriverDevicePath = AppendDevicePathNode (NULL, &MemMapNode.Header);\r
-  if (DriverDevicePath == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  for (Index = 0; Index < FmpCapsuleHeader->EmbeddedDriverCount; Index++) {\r
-    if (FmpCapsuleHeader->PayloadItemCount == 0 && Index == (UINTN)FmpCapsuleHeader->EmbeddedDriverCount - 1) {\r
-      //\r
-      // When driver is last element in the ItemOffsetList array, the driver size is calculated by reference CapsuleImageSize in EFI_CAPSULE_HEADER\r
-      //\r
-      DriverLen = CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize - (UINTN)ItemOffsetList[Index];\r
-    } else {\r
-      DriverLen = (UINTN)ItemOffsetList[Index + 1] - (UINTN)ItemOffsetList[Index];\r
-    }\r
-\r
-    Status = gBS->LoadImage(\r
-                    FALSE,\r
-                    gImageHandle,\r
-                    DriverDevicePath,\r
-                    (UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index],\r
-                    DriverLen,\r
-                    &ImageHandle\r
-                    );\r
-    if (EFI_ERROR(Status)) {\r
-      goto EXIT;\r
-    }\r
-\r
-    Status = gBS->StartImage(\r
-                    ImageHandle,\r
-                    &ExitDataSize,\r
-                    NULL\r
-                    );\r
-    if (EFI_ERROR(Status)) {\r
-      DEBUG ((DEBUG_ERROR, "Driver Return Status = %r\n", Status));\r
-      goto EXIT;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Connnect all again to connect drivers within capsule\r
-  //\r
-  if (FmpCapsuleHeader->EmbeddedDriverCount > 0) {\r
-    BdsLibConnectAll();\r
-  }\r
-\r
-  //\r
-  // 3. Route payload to right FMP instance\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiFirmwareManagementProtocolGuid,\r
-                  NULL,\r
-                  &NumberOfHandles,\r
-                  &HandleBuffer\r
-                  );\r
-\r
-  if (!EFI_ERROR(Status)) {\r
-    for(Index1 = 0; Index1 < NumberOfHandles; Index1++) {\r
-      Status = gBS->HandleProtocol(\r
-                      HandleBuffer[Index1],\r
-                      &gEfiFirmwareManagementProtocolGuid,\r
-                      (VOID **)&Fmp\r
-                      );\r
-      if (EFI_ERROR(Status)) {\r
-        continue;\r
-      }\r
-\r
-      ImageInfoSize = 0;\r
-      Status = Fmp->GetImageInfo (\r
-                      Fmp,\r
-                      &ImageInfoSize,\r
-                      NULL,\r
-                      NULL,\r
-                      NULL,\r
-                      NULL,\r
-                      NULL,\r
-                      NULL\r
-                      );\r
-      if (Status != EFI_BUFFER_TOO_SMALL) {\r
-        continue;\r
-      }\r
-\r
-      FmpImageInfoBuf = NULL;\r
-      FmpImageInfoBuf = AllocateZeroPool (ImageInfoSize);\r
-      if (FmpImageInfoBuf == NULL) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        goto EXIT;\r
-      }\r
-\r
-      PackageVersionName = NULL;\r
-      Status = Fmp->GetImageInfo (\r
-                      Fmp,\r
-                      &ImageInfoSize,               // ImageInfoSize\r
-                      FmpImageInfoBuf,              // ImageInfo\r
-                      &FmpImageInfoDescriptorVer,   // DescriptorVersion\r
-                      &FmpImageInfoCount,           // DescriptorCount\r
-                      &DescriptorSize,              // DescriptorSize\r
-                      &PackageVersion,              // PackageVersion\r
-                      &PackageVersionName           // PackageVersionName\r
-                      );\r
-\r
-      //\r
-      // If FMP GetInformation interface failed, skip this resource\r
-      //\r
-      if (EFI_ERROR(Status)) {\r
-        FreePool(FmpImageInfoBuf);\r
-        continue;\r
-      }\r
-\r
-      if (PackageVersionName != NULL) {\r
-        FreePool(PackageVersionName);\r
-      }\r
-\r
-      TempFmpImageInfo = FmpImageInfoBuf;\r
-      for (Index2 = 0; Index2 < FmpImageInfoCount; Index2++) {\r
-        //\r
-        // Check all the payload entry in capsule payload list\r
-        //\r
-        for (Index = FmpCapsuleHeader->EmbeddedDriverCount; Index < ItemNum; Index++) {\r
-          ImageHeader  = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);\r
-          if (CompareGuid(&ImageHeader->UpdateImageTypeId, &TempFmpImageInfo->ImageTypeId) &&\r
-              ImageHeader->UpdateImageIndex == TempFmpImageInfo->ImageIndex) {\r
-            AbortReason = NULL;\r
-            if (ImageHeader->UpdateVendorCodeSize == 0) {\r
-              Status = Fmp->SetImage(\r
-                              Fmp,\r
-                              TempFmpImageInfo->ImageIndex,           // ImageIndex\r
-                              (UINT8 *)(ImageHeader + 1),             // Image\r
-                              ImageHeader->UpdateImageSize,           // ImageSize\r
-                              NULL,                                   // VendorCode\r
-                              Update_Image_Progress,                  // Progress\r
-                              &AbortReason                            // AbortReason\r
-                              );\r
-            } else {\r
-              Status = Fmp->SetImage(\r
-                              Fmp,\r
-                              TempFmpImageInfo->ImageIndex,                                          // ImageIndex\r
-                              (UINT8 *)(ImageHeader + 1),                                            // Image\r
-                              ImageHeader->UpdateImageSize,                                          // ImageSize\r
-                              (UINT8 *)((UINT8 *) (ImageHeader + 1) + ImageHeader->UpdateImageSize), // VendorCode\r
-                              Update_Image_Progress,                                                 // Progress\r
-                              &AbortReason                                                           // AbortReason\r
-                              );\r
-            }\r
-            if (AbortReason != NULL) {\r
-              DEBUG ((EFI_D_ERROR, "%s\n", AbortReason));\r
-              FreePool(AbortReason);\r
-            }\r
-          }\r
-        }\r
-        //\r
-        // Use DescriptorSize to move ImageInfo Pointer to stay compatible with different ImageInfo version\r
-        //\r
-        TempFmpImageInfo = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)((UINT8 *)TempFmpImageInfo + DescriptorSize);\r
-      }\r
-      FreePool(FmpImageInfoBuf);\r
-    }\r
-  }\r
-\r
-EXIT:\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool(HandleBuffer);\r
-  }\r
-\r
-  if (DriverDevicePath != NULL) {\r
-    FreePool(DriverDevicePath);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Those capsules supported by the firmwares.\r
-\r
-  @param  CapsuleHeader    Points to a capsule header.\r
-\r
-  @retval EFI_SUCESS       Input capsule is supported by firmware.\r
-  @retval EFI_UNSUPPORTED  Input capsule is not supported by the firmware.\r
-  @retval EFI_INVALID_PARAMETER Input capsule layout is not correct\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SupportCapsuleImage (\r
-  IN EFI_CAPSULE_HEADER *CapsuleHeader\r
-  )\r
-{\r
-  if (CompareGuid (&gEfiCapsuleGuid, &CapsuleHeader->CapsuleGuid)) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (CompareGuid (&gEfiFmpCapsuleGuid, &CapsuleHeader->CapsuleGuid)) {\r
-    //\r
-    // Check layout of FMP capsule\r
-    //\r
-    return ValidateFmpCapsule(CapsuleHeader);\r
-  }\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  The firmware implements to process the capsule image.\r
-\r
-  @param  CapsuleHeader         Points to a capsule header.\r
-\r
-  @retval EFI_SUCESS            Process Capsule Image successfully.\r
-  @retval EFI_UNSUPPORTED       Capsule image is not supported by the firmware.\r
-  @retval EFI_VOLUME_CORRUPTED  FV volume in the capsule is corrupted.\r
-  @retval EFI_OUT_OF_RESOURCES  Not enough memory.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ProcessCapsuleImage (\r
-  IN EFI_CAPSULE_HEADER *CapsuleHeader\r
-  )\r
-{\r
-  UINT32                       Length;\r
-  EFI_FIRMWARE_VOLUME_HEADER   *FvImage;\r
-  EFI_FIRMWARE_VOLUME_HEADER   *ProcessedFvImage;\r
-  EFI_STATUS                   Status;\r
-  EFI_HANDLE                   FvProtocolHandle;\r
-  UINT32                       FvAlignment;\r
-\r
-  FvImage = NULL;\r
-  ProcessedFvImage = NULL;\r
-  Status  = EFI_SUCCESS;\r
-\r
-  if (SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Check FMP capsule layout\r
-  //\r
-  if (CompareGuid (&gEfiFmpCapsuleGuid, &CapsuleHeader->CapsuleGuid)){\r
-    Status = ValidateFmpCapsule(CapsuleHeader);\r
-    if (EFI_ERROR(Status)) {\r
-      return Status;\r
-    }\r
-\r
-    //\r
-    // Press EFI FMP Capsule\r
-    //\r
-    return ProcessFmpCapsuleImage(CapsuleHeader);\r
-  }\r
-\r
-  //\r
-  // Skip the capsule header, move to the Firware Volume\r
-  //\r
-  FvImage = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);\r
-  Length  = CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize;\r
-\r
-  while (Length != 0) {\r
-    //\r
-    // Point to the next firmware volume header, and then\r
-    // call the DXE service to process it.\r
-    //\r
-    if (FvImage->FvLength > (UINTN) Length) {\r
-      //\r
-      // Notes: need to stuff this status somewhere so that the\r
-      // error can be detected at OS runtime\r
-      //\r
-      Status = EFI_VOLUME_CORRUPTED;\r
-      break;\r
-    }\r
-\r
-    FvAlignment = 1 << ((FvImage->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
-    //\r
-    // FvAlignment must be more than 8 bytes required by FvHeader structure.\r
-    //\r
-    if (FvAlignment < 8) {\r
-      FvAlignment = 8;\r
-    }\r
-    //\r
-    // Check FvImage Align is required.\r
-    //\r
-    if (((UINTN) FvImage % FvAlignment) == 0) {\r
-      ProcessedFvImage = FvImage;\r
-    } else {\r
-      //\r
-      // Allocate new aligned buffer to store FvImage.\r
-      //\r
-      ProcessedFvImage = (EFI_FIRMWARE_VOLUME_HEADER *) AllocateAlignedPages ((UINTN) EFI_SIZE_TO_PAGES ((UINTN) FvImage->FvLength), (UINTN) FvAlignment);\r
-      if (ProcessedFvImage == NULL) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        break;\r
-      }\r
-      CopyMem (ProcessedFvImage, FvImage, (UINTN) FvImage->FvLength);\r
-    }\r
-\r
-    Status = gDS->ProcessFirmwareVolume (\r
-                  (VOID *) ProcessedFvImage,\r
-                  (UINTN) ProcessedFvImage->FvLength,\r
-                  &FvProtocolHandle\r
-                  );\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    //\r
-    // Call the dispatcher to dispatch any drivers from the produced firmware volume\r
-    //\r
-    gDS->Dispatch ();\r
-    //\r
-    // On to the next FV in the capsule\r
-    //\r
-    Length -= (UINT32) FvImage->FvLength;\r
-    FvImage = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINT8 *) FvImage + FvImage->FvLength);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-\r
-  This routine is called to process capsules.\r
-\r
-  Caution: This function may receive untrusted input.\r
-\r
-  The capsules reported in EFI_HOB_UEFI_CAPSULE are processed.\r
-  If there is no EFI_HOB_UEFI_CAPSULE, this routine does nothing.\r
-\r
-  This routine should be called twice in BDS.\r
-  1) The first call must be before EndOfDxe. The system capsules is processed.\r
-     If device capsule FMP protocols are exposted at this time and device FMP\r
-     capsule has zero EmbeddedDriverCount, the device capsules are processed.\r
-     Each individual capsule result is recorded in capsule record variable.\r
-     System may reset in this function, if reset is required by capsule and\r
-     all capsules are processed.\r
-     If not all capsules are processed, reset will be defered to second call.\r
-\r
-  2) The second call must be after EndOfDxe and after ConnectAll, so that all\r
-     device capsule FMP protocols are exposed.\r
-     The system capsules are skipped. If the device capsules are NOT processed\r
-     in first call, they are processed here.\r
-     Each individual capsule result is recorded in capsule record variable.\r
-     System may reset in this function, if reset is required by capsule\r
-     processed in first call and second call.\r
-\r
-  @retval EFI_SUCCESS             There is no error when processing capsules.\r
-  @retval EFI_OUT_OF_RESOURCES    No enough resource to process capsules.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ProcessCapsules (\r
-  VOID\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.inf b/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.inf
deleted file mode 100644 (file)
index ed39f74..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-## @file\r
-# Capsule library instance for DXE_DRIVER, DXE_RUNTIME_DRIVER.\r
-#\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DxeCapsuleLib\r
-  MODULE_UNI_FILE                = DxeCapsuleLib.uni\r
-  FILE_GUID                      = 654950df-1ede-4b04-b144-6b77845736ad\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = CapsuleLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION\r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  DxeCapsuleLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseMemoryLib\r
-  DebugLib\r
-  MemoryAllocationLib\r
-  DxeServicesTableLib\r
-  GenericBdsLib\r
-  UefiBootServicesTableLib\r
-  DevicePathLib\r
-\r
-[Protocols]\r
-  gEfiFirmwareManagementProtocolGuid      ## SOMETIMES_CONSUMES\r
-\r
-[Guids]\r
-  gEfiCapsuleGuid                         ## SOMETIMES_CONSUMES ## GUID # Capsule Image Header Guid\r
-  gEfiFmpCapsuleGuid                      ## SOMETIMES_CONSUMES ## GUID\r
diff --git a/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.uni b/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.uni
deleted file mode 100644 (file)
index 4309467..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// Capsule library instance for DXE_DRIVER, DXE_RUNTIME_DRIVER.\r
-//\r
-// Capsule library instance for DXE_DRIVER and DXE_RUNTIME_DRIVER module types.\r
-//\r
-// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Capsule Support Library"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Capsule library instance for DXE_DRIVER and DXE_RUNTIME_DRIVER module types."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf b/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
deleted file mode 100644 (file)
index 3e484ca..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-## @file\r
-#  Framework DXE report status code library to support EFI1.1 and UEFI2.0 system.\r
-#\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DxeReportStatusCodeLib\r
-  MODULE_UNI_FILE                = DxeReportStatusCodeLib.uni\r
-  FILE_GUID                      = 3ddc3b12-99ea-4364-b315-6310a2050be5\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = ReportStatusCodeLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  ReportStatusCodeLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  BaseMemoryLib\r
-  MemoryAllocationLib\r
-  UefiBootServicesTableLib\r
-  DebugLib\r
-  UefiRuntimeServicesTableLib\r
-  DevicePathLib\r
-\r
-[Guids]\r
-  gEfiStatusCodeSpecificDataGuid                ## SOMETIMES_CONSUMES ## UNDEFINED\r
-  gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_CONSUMES ## UNDEFINED\r
-\r
-[Protocols]\r
-  gEfiStatusCodeRuntimeProtocolGuid             ## SOMETIMES_CONSUMES # Used if revision of the EFI Specification is not less than 0x20000\r
-\r
-[Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask  ## CONSUMES\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.uni b/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.uni
deleted file mode 100644 (file)
index deb7344..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// Framework DXE report status code library to support EFI1.1 and UEFI2.0 system.\r
-//\r
-// Framework DXE report status code library to support EFI1.1 and UEFI2.0 systems.\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Framework DXE report status code library to support EFI1.1 and UEFI2.0 systems"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Framework DXE report status code library to support EFI1.1 and UEFI2.0 systems."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/ReportStatusCodeLib.c b/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/ReportStatusCodeLib.c
deleted file mode 100644 (file)
index 6fc916b..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-/** @file\r
-  Report Status Code Library for DXE Phase.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Protocol/StatusCode.h>\r
-\r
-//\r
-// Define the maximum extended data size that is supported when a status code is\r
-// reported at TPL_HIGH_LEVEL.\r
-//\r
-#define MAX_EXTENDED_DATA_SIZE  0x200\r
-\r
-EFI_REPORT_STATUS_CODE  mReportStatusCode = NULL;\r
-\r
-/**\r
-  Locate the report status code service.\r
-\r
-  @return   Function pointer to the report status code service.\r
-            NULL is returned if no status code service is available.\r
-\r
-**/\r
-EFI_REPORT_STATUS_CODE\r
-InternalGetReportStatusCode (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS_CODE_PROTOCOL  *StatusCodeProtocol;\r
-  EFI_STATUS                Status;\r
-\r
-  if (gRT != NULL && gRT->Hdr.Revision < 0x20000) {\r
-    return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)gRT)->ReportStatusCode;\r
-  } else if (gBS != NULL && gBS->LocateProtocol != NULL) {\r
-    Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);\r
-    if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {\r
-      return StatusCodeProtocol->ReportStatusCode;\r
-    }\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-/**\r
-  Internal worker function that reports a status code through the status code service.\r
-\r
-  If status code service is not cached, then this function checks if status code service is\r
-  available in system.  If status code service is not available, then EFI_UNSUPPORTED is\r
-  returned.  If status code service is present, then it is cached in mReportStatusCode.\r
-  Finally this function reports status code through the status code service.\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  This is an optional parameter that may be\r
-                            NULL.\r
-  @param  Data              Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-\r
-  @retval EFI_SUCCESS       The status code was reported.\r
-  @retval EFI_UNSUPPORTED   Status code service is not available.\r
-  @retval EFI_UNSUPPORTED   Status code type is not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalReportStatusCode (\r
-  IN EFI_STATUS_CODE_TYPE     Type,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN CONST EFI_GUID           *CallerId OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL\r
-  )\r
-{\r
-  if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
-      (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||\r
-      (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {\r
-    //\r
-    // If mReportStatusCode is NULL, then check if status code service is available in system.\r
-    //\r
-    if (mReportStatusCode == NULL) {\r
-      mReportStatusCode = InternalGetReportStatusCode ();\r
-      if (mReportStatusCode == NULL) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-    }\r
-\r
-    //\r
-    // A status code service is present in system, so pass in all the parameters to the service.\r
-    //\r
-    return (*mReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
-  }\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-/**\r
-  Converts a status code to an 8-bit POST code value.\r
-\r
-  Converts the status code specified by CodeType and Value to an 8-bit POST code\r
-  and returns the 8-bit POST code in PostCode.  If CodeType is an\r
-  EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode\r
-  are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits\r
-  24..26 of Value., and TRUE is returned.  Otherwise, FALSE is returned.\r
-\r
-  If PostCode is NULL, then ASSERT().\r
-\r
-  @param  CodeType  The type of status code being converted.\r
-  @param  Value     The status code value being converted.\r
-  @param  PostCode  A pointer to the 8-bit POST code value to return.\r
-\r
-  @retval  TRUE   The status code specified by CodeType and Value was converted\r
-                  to an 8-bit POST code and returned in  PostCode.\r
-  @retval  FALSE  The status code specified by CodeType and Value could not be\r
-                  converted to an 8-bit POST code value.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-CodeTypeToPostCode (\r
-  IN  EFI_STATUS_CODE_TYPE   CodeType,\r
-  IN  EFI_STATUS_CODE_VALUE  Value,\r
-  OUT UINT8                  *PostCode\r
-  )\r
-{\r
-  //\r
-  // If PostCode is NULL, then ASSERT()\r
-  //\r
-  ASSERT (PostCode != NULL);\r
-\r
-  //\r
-  // Convert Value to an 8 bit post code\r
-  //\r
-  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
-      ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)       ) {\r
-    *PostCode  = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r
-                          (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r
-    return TRUE;\r
-  }\r
-  return FALSE;\r
-}\r
-\r
-\r
-/**\r
-  Extracts ASSERT() information from a status code structure.\r
-\r
-  Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r
-  arguments specified by Filename, Description, and LineNumber.  If CodeType is\r
-  an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and\r
-  Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract\r
-  Filename, Description, and LineNumber from the optional data area of the\r
-  status code buffer specified by Data.  The optional data area of Data contains\r
-  a Null-terminated ASCII string for the FileName, followed by a Null-terminated\r
-  ASCII string for the Description, followed by a 32-bit LineNumber.  If the\r
-  ASSERT() information could be extracted from Data, then return TRUE.\r
-  Otherwise, FALSE is returned.\r
-\r
-  If Data is NULL, then ASSERT().\r
-  If Filename is NULL, then ASSERT().\r
-  If Description is NULL, then ASSERT().\r
-  If LineNumber is NULL, then ASSERT().\r
-\r
-  @param  CodeType     The type of status code being converted.\r
-  @param  Value        The status code value being converted.\r
-  @param  Data         Pointer to status code data buffer.\r
-  @param  Filename     Pointer to the source file name that generated the ASSERT().\r
-  @param  Description  Pointer to the description of the ASSERT().\r
-  @param  LineNumber   Pointer to source line number that generated the ASSERT().\r
-\r
-  @retval  TRUE   The status code specified by CodeType, Value, and Data was\r
-                  converted ASSERT() arguments specified by Filename, Description,\r
-                  and LineNumber.\r
-  @retval  FALSE  The status code specified by CodeType, Value, and Data could\r
-                  not be converted to ASSERT() arguments.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportStatusCodeExtractAssertInfo (\r
-  IN EFI_STATUS_CODE_TYPE        CodeType,\r
-  IN EFI_STATUS_CODE_VALUE       Value,\r
-  IN CONST EFI_STATUS_CODE_DATA  *Data,\r
-  OUT CHAR8                      **Filename,\r
-  OUT CHAR8                      **Description,\r
-  OUT UINT32                     *LineNumber\r
-  )\r
-{\r
-  EFI_DEBUG_ASSERT_DATA  *AssertData;\r
-\r
-  ASSERT (Data        != NULL);\r
-  ASSERT (Filename    != NULL);\r
-  ASSERT (Description != NULL);\r
-  ASSERT (LineNumber  != NULL);\r
-\r
-  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK)      == EFI_ERROR_CODE) &&\r
-      ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK)  == EFI_ERROR_UNRECOVERED) &&\r
-      ((Value    & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {\r
-    AssertData   = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r
-    *Filename    = (CHAR8 *)(AssertData + 1);\r
-    *Description = *Filename + AsciiStrLen (*Filename) + 1;\r
-    *LineNumber  = AssertData->LineNumber;\r
-    return TRUE;\r
-  }\r
-  return FALSE;\r
-}\r
-\r
-\r
-/**\r
-  Extracts DEBUG() information from a status code structure.\r
-\r
-  Converts the status code specified by Data to the DEBUG() arguments specified\r
-  by ErrorLevel, Marker, and Format.  If type GUID in Data is\r
-  EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and\r
-  Format from the optional data area of the status code buffer specified by Data.\r
-  The optional data area of Data contains a 32-bit ErrorLevel followed by Marker\r
-  which is 12 UINTN parameters, followed by a Null-terminated ASCII string for\r
-  the Format.  If the DEBUG() information could be extracted from Data, then\r
-  return TRUE.  Otherwise, FALSE is returned.\r
-\r
-  If Data is NULL, then ASSERT().\r
-  If ErrorLevel is NULL, then ASSERT().\r
-  If Marker is NULL, then ASSERT().\r
-  If Format is NULL, then ASSERT().\r
-\r
-  @param  Data        Pointer to status code data buffer.\r
-  @param  ErrorLevel  Pointer to error level mask for a debug message.\r
-  @param  Marker      Pointer to the variable argument list associated with Format.\r
-  @param  Format      Pointer to a Null-terminated ASCII format string of a\r
-                      debug message.\r
-\r
-  @retval  TRUE   The status code specified by Data was converted DEBUG() arguments\r
-                  specified by ErrorLevel, Marker, and Format.\r
-  @retval  FALSE  The status code specified by Data could not be converted to\r
-                  DEBUG() arguments.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportStatusCodeExtractDebugInfo (\r
-  IN CONST EFI_STATUS_CODE_DATA  *Data,\r
-  OUT UINT32                     *ErrorLevel,\r
-  OUT BASE_LIST                  *Marker,\r
-  OUT CHAR8                      **Format\r
-  )\r
-{\r
-  EFI_DEBUG_INFO  *DebugInfo;\r
-\r
-  ASSERT (Data       != NULL);\r
-  ASSERT (ErrorLevel != NULL);\r
-  ASSERT (Marker     != NULL);\r
-  ASSERT (Format     != NULL);\r
-\r
-  //\r
-  // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE\r
-  //\r
-  if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Retrieve the debug information from the status code record\r
-  //\r
-  DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r
-\r
-  *ErrorLevel = DebugInfo->ErrorLevel;\r
-\r
-  //\r
-  // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments\r
-  // of format in DEBUG string. Its address is returned in Marker and has to be 64-bit aligned.\r
-  // It must be noticed that EFI_DEBUG_INFO follows EFI_STATUS_CODE_DATA, whose size is\r
-  // 20 bytes. The size of EFI_DEBUG_INFO is 4 bytes, so we can ensure that Marker\r
-  // returned is 64-bit aligned.\r
-  // 64-bit aligned is a must, otherwise retrieving 64-bit parameter from BASE_LIST will\r
-  // cause unalignment exception.\r
-  //\r
-  *Marker = (BASE_LIST) (DebugInfo + 1);\r
-  *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code.\r
-\r
-  Reports the status code specified by the parameters Type and Value.  Status\r
-  code also require an instance, caller ID, and extended data.  This function\r
-  passed in a zero instance, NULL extended data, and a caller ID of\r
-  gEfiCallerIdGuid, which is the GUID for the module.\r
-\r
-  ReportStatusCode()must actively prevent recusrsion.  If ReportStatusCode()\r
-  is called while processing another any other Report Status Code Library function,\r
-  then ReportStatusCode() must return immediately.\r
-\r
-  @param  Type   Status code type.\r
-  @param  Value  Status code value.\r
-\r
-  @retval  EFI_SUCCESS       The status code was reported.\r
-  @retval  EFI_DEVICE_ERROR  There status code could not be reported due to a\r
-                             device error.\r
-  @retval  EFI_UNSUPPORTED   Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCode (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value\r
-  )\r
-{\r
-  return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code with a Device Path Protocol as the extended data.\r
-\r
-  Allocates and fills in the extended data section of a status code with the\r
-  Device Path Protocol specified by DevicePath.  This function is responsible\r
-  for allocating a buffer large enough for the standard header and the device\r
-  path.  The standard header is filled in with a GUID of\r
-  gEfiStatusCodeSpecificDataGuid.  The status code is reported with a zero\r
-  instance and a caller ID of gEfiCallerIdGuid.\r
-\r
-  ReportStatusCodeWithDevicePath()must actively prevent recursion.  If\r
-  ReportStatusCodeWithDevicePath() is called while processing another any other\r
-  Report Status Code Library function, then ReportStatusCodeWithDevicePath()\r
-  must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If DevicePath is NULL, then ASSERT().\r
-\r
-  @param  Type        Status code type.\r
-  @param  Value       Status code value.\r
-  @param  DevicePath  Pointer to the Device Path Protocol to be reported.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported with the extended\r
-                                 data specified by DevicePath.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the\r
-                                 extended data section.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeWithDevicePath (\r
-  IN EFI_STATUS_CODE_TYPE            Type,\r
-  IN EFI_STATUS_CODE_VALUE           Value,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  )\r
-{\r
-  ASSERT (DevicePath != NULL);\r
-  return ReportStatusCodeWithExtendedData (\r
-           Type,\r
-           Value,\r
-           (VOID *)DevicePath,\r
-           GetDevicePathSize (DevicePath)\r
-           );\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code with an extended data buffer.\r
-\r
-  Allocates and fills in the extended data section of a status code with the\r
-  extended data specified by ExtendedData and ExtendedDataSize.  ExtendedData\r
-  is assumed to be one of the data structures specified in Related Definitions.\r
-  These data structure do not have the standard header, so this function is\r
-  responsible for allocating a buffer large enough for the standard header and\r
-  the extended data passed into this function.  The standard header is filled\r
-  in with a GUID of  gEfiStatusCodeSpecificDataGuid.  The status code is reported\r
-  with a zero instance and a caller ID of gEfiCallerIdGuid.\r
-\r
-  ReportStatusCodeWithExtendedData()must actively prevent recursion.  If\r
-  ReportStatusCodeWithExtendedData() is called while processing another any other\r
-  Report Status Code Library function, then ReportStatusCodeWithExtendedData()\r
-  must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If ExtendedData is NULL, then ASSERT().\r
-  If ExtendedDataSize is 0, then ASSERT().\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  ExtendedData      Pointer to the extended data buffer to be reported.\r
-  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer to\r
-                            be reported.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported with the extended\r
-                                 data specified by ExtendedData and ExtendedDataSize.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the\r
-                                 extended data section.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeWithExtendedData (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value,\r
-  IN CONST VOID             *ExtendedData,\r
-  IN UINTN                  ExtendedDataSize\r
-  )\r
-{\r
-  ASSERT (ExtendedData     != NULL);\r
-  ASSERT (ExtendedDataSize != 0);\r
-  return ReportStatusCodeEx (\r
-           Type,\r
-           Value,\r
-           0,\r
-           NULL,\r
-           NULL,\r
-           ExtendedData,\r
-           ExtendedDataSize\r
-           );\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code with full parameters.\r
-\r
-  The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize\r
-  is 0, then an extended data buffer is not reported.  If ExtendedData is not\r
-  NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r
-  ExtendedData is assumed not have the standard status code header, so this function\r
-  is responsible for allocating a buffer large enough for the standard header and\r
-  the extended data passed into this function.  The standard header is filled in\r
-  with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a\r
-  GUID of gEfiStatusCodeSpecificDataGuid is used.  The status code is reported with\r
-  an instance specified by Instance and a caller ID specified by CallerId.  If\r
-  CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
-\r
-  ReportStatusCodeEx()must actively prevent recursion. If\r
-  ReportStatusCodeEx() is called while processing another any\r
-  other Report Status Code Library function, then\r
-  ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
-  If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  If this parameter is NULL, then a caller\r
-                            ID of gEfiCallerIdGuid is used.\r
-  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.\r
-                            If this parameter is NULL, then a the status code\r
-                            standard header is filled in with\r
-                            gEfiStatusCodeSpecificDataGuid.\r
-  @param  ExtendedData      Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate\r
-                                 the extended data section if it was specified.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeEx (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value,\r
-  IN UINT32                 Instance,\r
-  IN CONST EFI_GUID         *CallerId          OPTIONAL,\r
-  IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,\r
-  IN CONST VOID             *ExtendedData      OPTIONAL,\r
-  IN UINTN                  ExtendedDataSize\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_STATUS_CODE_DATA  *StatusCodeData;\r
-  EFI_TPL               Tpl;\r
-  UINT64                Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1];\r
-\r
-  ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
-  ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
-\r
-  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Retrieve the current TPL\r
-  //\r
-  Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-  gBS->RestoreTPL (Tpl);\r
-\r
-  StatusCodeData = NULL;\r
-  if (Tpl <= TPL_NOTIFY) {\r
-    //\r
-    // Allocate space for the Status Code Header and its buffer\r
-    //\r
-    gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
-  }\r
-\r
-  if (StatusCodeData == NULL) {\r
-    //\r
-    // If a buffer could not be allocated, then see if the local variable Buffer can be used\r
-    //\r
-    if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {\r
-      //\r
-      // The local variable Buffer not large enough to hold the extended data associated\r
-      // with the status code being reported.\r
-      //\r
-      DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be reported!\n"));\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    StatusCodeData = (EFI_STATUS_CODE_DATA  *)Buffer;\r
-  }\r
-\r
-  //\r
-  // Fill in the extended data header\r
-  //\r
-  StatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);\r
-  StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
-  if (ExtendedDataGuid == NULL) {\r
-    ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
-  }\r
-  CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
-\r
-  //\r
-  // Fill in the extended data buffer\r
-  //\r
-  if (ExtendedData != NULL) {\r
-    CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
-  }\r
-\r
-  //\r
-  // Report the status code\r
-  //\r
-  if (CallerId == NULL) {\r
-    CallerId = &gEfiCallerIdGuid;\r
-  }\r
-  Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r
-\r
-  //\r
-  // Free the allocated buffer\r
-  //\r
-  if (StatusCodeData != (EFI_STATUS_CODE_DATA  *)Buffer) {\r
-    gBS->FreePool (StatusCodeData);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r
-\r
-  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED\r
-  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is set.\r
-  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportProgressCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r
-\r
-  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED\r
-  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is set.\r
-  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportErrorCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r
-\r
-  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED\r
-  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is set.\r
-  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportDebugCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
deleted file mode 100644 (file)
index 3b22736..0000000
+++ /dev/null
@@ -1,4373 +0,0 @@
-/** @file\r
-  BDS Lib functions which relate with create or process the boot option.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalBdsLib.h"\r
-#include "String.h"\r
-\r
-BOOLEAN mEnumBootDevice = FALSE;\r
-EFI_HII_HANDLE gBdsLibStringPackHandle = NULL;\r
-\r
-/**\r
-\r
-  End Perf entry of BDS\r
-\r
-  @param  Event                 The triggered event.\r
-  @param  Context               Context for this event.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BmEndOfBdsPerfCode (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-{\r
-  //\r
-  // Record the performance data for End of BDS\r
-  //\r
-  PERF_END(NULL, "BDS", NULL, 0);\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  The constructor function register UNI strings into imageHandle.\r
-\r
-  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS   The constructor successfully added string package.\r
-  @retval Other value   The constructor can't add string package.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GenericBdsLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-\r
-  gBdsLibStringPackHandle = HiiAddPackages (\r
-                              &gBdsLibStringPackageGuid,\r
-                              ImageHandle,\r
-                              GenericBdsLibStrings,\r
-                              NULL\r
-                              );\r
-\r
-  ASSERT (gBdsLibStringPackHandle != NULL);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Deletete the Boot Option from EFI Variable. The Boot Order Arrray\r
-  is also updated.\r
-\r
-  @param OptionNumber    The number of Boot option want to be deleted.\r
-  @param BootOrder       The Boot Order array.\r
-  @param BootOrderSize   The size of the Boot Order Array.\r
-\r
-  @retval  EFI_SUCCESS           The Boot Option Variable was found and removed\r
-  @retval  EFI_UNSUPPORTED       The Boot Option Variable store was inaccessible\r
-  @retval  EFI_NOT_FOUND         The Boot Option Variable was not found\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsDeleteBootOption (\r
-  IN UINTN                       OptionNumber,\r
-  IN OUT UINT16                  *BootOrder,\r
-  IN OUT UINTN                   *BootOrderSize\r
-  )\r
-{\r
-  CHAR16      BootOption[9];\r
-  UINTN       Index;\r
-  EFI_STATUS  Status;\r
-\r
-  UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", OptionNumber);\r
-  Status = gRT->SetVariable (\r
-                  BootOption,\r
-                  &gEfiGlobalVariableGuid,\r
-                  0,\r
-                  0,\r
-                  NULL\r
-                  );\r
-  //\r
-  // Deleting variable with existing variable implementation shouldn't fail.\r
-  //\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // adjust boot order array\r
-  //\r
-  for (Index = 0; Index < *BootOrderSize / sizeof (UINT16); Index++) {\r
-    if (BootOrder[Index] == OptionNumber) {\r
-      CopyMem (&BootOrder[Index], &BootOrder[Index+1], *BootOrderSize - (Index+1) * sizeof (UINT16));\r
-      *BootOrderSize -= sizeof (UINT16);\r
-      break;\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-/**\r
-\r
-  Translate the first n characters of an Ascii string to\r
-  Unicode characters. The count n is indicated by parameter\r
-  Size. If Size is greater than the length of string, then\r
-  the entire string is translated.\r
-\r
-\r
-  @param AStr               Pointer to input Ascii string.\r
-  @param Size               The number of characters to translate.\r
-  @param UStr               Pointer to output Unicode string buffer.\r
-\r
-**/\r
-VOID\r
-AsciiToUnicodeSize (\r
-  IN UINT8              *AStr,\r
-  IN UINTN              Size,\r
-  OUT UINT16            *UStr\r
-  )\r
-{\r
-  UINTN Idx;\r
-\r
-  Idx = 0;\r
-  while (AStr[Idx] != 0) {\r
-    UStr[Idx] = (CHAR16) AStr[Idx];\r
-    if (Idx == Size) {\r
-      break;\r
-    }\r
-\r
-    Idx++;\r
-  }\r
-  UStr[Idx] = 0;\r
-}\r
-\r
-/**\r
-  Build Legacy Device Name String according.\r
-\r
-  @param CurBBSEntry     BBS Table.\r
-  @param Index           Index.\r
-  @param BufSize         The buffer size.\r
-  @param BootString      The output string.\r
-\r
-**/\r
-VOID\r
-BdsBuildLegacyDevNameString (\r
-  IN  BBS_TABLE                 *CurBBSEntry,\r
-  IN  UINTN                     Index,\r
-  IN  UINTN                     BufSize,\r
-  OUT CHAR16                    *BootString\r
-  )\r
-{\r
-  CHAR16  *Fmt;\r
-  CHAR16  *Type;\r
-  UINT8   *StringDesc;\r
-  CHAR16  Temp[80];\r
-\r
-  switch (Index) {\r
-  //\r
-  // Primary Master\r
-  //\r
-  case 1:\r
-    Fmt = L"Primary Master %s";\r
-    break;\r
-\r
- //\r
- // Primary Slave\r
- //\r
-  case 2:\r
-    Fmt = L"Primary Slave %s";\r
-    break;\r
-\r
-  //\r
-  // Secondary Master\r
-  //\r
-  case 3:\r
-    Fmt = L"Secondary Master %s";\r
-    break;\r
-\r
-  //\r
-  // Secondary Slave\r
-  //\r
-  case 4:\r
-    Fmt = L"Secondary Slave %s";\r
-    break;\r
-\r
-  default:\r
-    Fmt = L"%s";\r
-    break;\r
-  }\r
-\r
-  switch (CurBBSEntry->DeviceType) {\r
-  case BBS_FLOPPY:\r
-    Type = L"Floppy";\r
-    break;\r
-\r
-  case BBS_HARDDISK:\r
-    Type = L"Harddisk";\r
-    break;\r
-\r
-  case BBS_CDROM:\r
-    Type = L"CDROM";\r
-    break;\r
-\r
-  case BBS_PCMCIA:\r
-    Type = L"PCMCIAe";\r
-    break;\r
-\r
-  case BBS_USB:\r
-    Type = L"USB";\r
-    break;\r
-\r
-  case BBS_EMBED_NETWORK:\r
-    Type = L"Network";\r
-    break;\r
-\r
-  case BBS_BEV_DEVICE:\r
-    Type = L"BEVe";\r
-    break;\r
-\r
-  case BBS_UNKNOWN:\r
-  default:\r
-    Type = L"Unknown";\r
-    break;\r
-  }\r
-  //\r
-  // If current BBS entry has its description then use it.\r
-  //\r
-  StringDesc = (UINT8 *) (((UINTN) CurBBSEntry->DescStringSegment << 4) + CurBBSEntry->DescStringOffset);\r
-  if (NULL != StringDesc) {\r
-    //\r
-    // Only get fisrt 32 characters, this is suggested by BBS spec\r
-    //\r
-    AsciiToUnicodeSize (StringDesc, 32, Temp);\r
-    Fmt   = L"%s";\r
-    Type  = Temp;\r
-  }\r
-\r
-  //\r
-  // BbsTable 16 entries are for onboard IDE.\r
-  // Set description string for SATA harddisks, Harddisk 0 ~ Harddisk 11\r
-  //\r
-  if (Index >= 5 && Index <= 16 && (CurBBSEntry->DeviceType == BBS_HARDDISK || CurBBSEntry->DeviceType == BBS_CDROM)) {\r
-    Fmt = L"%s %d";\r
-    UnicodeSPrint (BootString, BufSize, Fmt, Type, Index - 5);\r
-  } else {\r
-    UnicodeSPrint (BootString, BufSize, Fmt, Type);\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Create a legacy boot option for the specified entry of\r
-  BBS table, save it as variable, and append it to the boot\r
-  order list.\r
-\r
-\r
-  @param CurrentBbsEntry    Pointer to current BBS table.\r
-  @param CurrentBbsDevPath  Pointer to the Device Path Protocol instance of BBS\r
-  @param Index              Index of the specified entry in BBS table.\r
-  @param BootOrderList      On input, the original boot order list.\r
-                            On output, the new boot order list attached with the\r
-                            created node.\r
-  @param BootOrderListSize  On input, the original size of boot order list.\r
-                            On output, the size of new boot order list.\r
-\r
-  @retval  EFI_SUCCESS             Boot Option successfully created.\r
-  @retval  EFI_OUT_OF_RESOURCES    Fail to allocate necessary memory.\r
-  @retval  Other                   Error occurs while setting variable.\r
-\r
-**/\r
-EFI_STATUS\r
-BdsCreateLegacyBootOption (\r
-  IN BBS_TABLE                        *CurrentBbsEntry,\r
-  IN EFI_DEVICE_PATH_PROTOCOL         *CurrentBbsDevPath,\r
-  IN UINTN                            Index,\r
-  IN OUT UINT16                       **BootOrderList,\r
-  IN OUT UINTN                        *BootOrderListSize\r
-  )\r
-{\r
-  EFI_STATUS           Status;\r
-  UINT16               CurrentBootOptionNo;\r
-  UINT16               BootString[10];\r
-  CHAR16               BootDesc[100];\r
-  CHAR8                HelpString[100];\r
-  UINT16               *NewBootOrderList;\r
-  UINTN                BufferSize;\r
-  UINTN                StringLen;\r
-  VOID                 *Buffer;\r
-  UINT8                *Ptr;\r
-  UINT16               CurrentBbsDevPathSize;\r
-  UINTN                BootOrderIndex;\r
-  UINTN                BootOrderLastIndex;\r
-  UINTN                ArrayIndex;\r
-  BOOLEAN              IndexNotFound;\r
-  BBS_BBS_DEVICE_PATH  *NewBbsDevPathNode;\r
-\r
-  if ((*BootOrderList) == NULL) {\r
-    CurrentBootOptionNo = 0;\r
-  } else {\r
-    for (ArrayIndex = 0; ArrayIndex < (UINTN) (*BootOrderListSize / sizeof (UINT16)); ArrayIndex++) {\r
-      IndexNotFound = TRUE;\r
-      for (BootOrderIndex = 0; BootOrderIndex < (UINTN) (*BootOrderListSize / sizeof (UINT16)); BootOrderIndex++) {\r
-        if ((*BootOrderList)[BootOrderIndex] == ArrayIndex) {\r
-          IndexNotFound = FALSE;\r
-          break;\r
-        }\r
-      }\r
-\r
-      if (!IndexNotFound) {\r
-        continue;\r
-      } else {\r
-        break;\r
-      }\r
-    }\r
-\r
-    CurrentBootOptionNo = (UINT16) ArrayIndex;\r
-  }\r
-\r
-  UnicodeSPrint (\r
-    BootString,\r
-    sizeof (BootString),\r
-    L"Boot%04x",\r
-    CurrentBootOptionNo\r
-    );\r
-\r
-  BdsBuildLegacyDevNameString (CurrentBbsEntry, Index, sizeof (BootDesc), BootDesc);\r
-\r
-  //\r
-  // Create new BBS device path node with description string\r
-  //\r
-  UnicodeStrToAsciiStrS (BootDesc, HelpString, sizeof (HelpString));\r
-\r
-  StringLen = AsciiStrLen (HelpString);\r
-  NewBbsDevPathNode = AllocateZeroPool (sizeof (BBS_BBS_DEVICE_PATH) + StringLen);\r
-  if (NewBbsDevPathNode == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (NewBbsDevPathNode, CurrentBbsDevPath, sizeof (BBS_BBS_DEVICE_PATH));\r
-  CopyMem (NewBbsDevPathNode->String, HelpString, StringLen + 1);\r
-  SetDevicePathNodeLength (&(NewBbsDevPathNode->Header), sizeof (BBS_BBS_DEVICE_PATH) + StringLen);\r
-\r
-  //\r
-  // Create entire new CurrentBbsDevPath with end node\r
-  //\r
-  CurrentBbsDevPath = AppendDevicePathNode (\r
-                        NULL,\r
-                        (EFI_DEVICE_PATH_PROTOCOL *) NewBbsDevPathNode\r
-                        );\r
-   if (CurrentBbsDevPath == NULL) {\r
-    FreePool (NewBbsDevPathNode);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  CurrentBbsDevPathSize = (UINT16) (GetDevicePathSize (CurrentBbsDevPath));\r
-\r
-  BufferSize = sizeof (UINT32) +\r
-    sizeof (UINT16) +\r
-    StrSize (BootDesc) +\r
-    CurrentBbsDevPathSize +\r
-    sizeof (BBS_TABLE) +\r
-    sizeof (UINT16);\r
-\r
-  Buffer = AllocateZeroPool (BufferSize);\r
-  if (Buffer == NULL) {\r
-    FreePool (NewBbsDevPathNode);\r
-    FreePool (CurrentBbsDevPath);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Ptr               = (UINT8 *) Buffer;\r
-\r
-  *((UINT32 *) Ptr) = LOAD_OPTION_ACTIVE;\r
-  Ptr += sizeof (UINT32);\r
-\r
-  *((UINT16 *) Ptr) = CurrentBbsDevPathSize;\r
-  Ptr += sizeof (UINT16);\r
-\r
-  CopyMem (\r
-    Ptr,\r
-    BootDesc,\r
-    StrSize (BootDesc)\r
-    );\r
-  Ptr += StrSize (BootDesc);\r
-\r
-  CopyMem (\r
-    Ptr,\r
-    CurrentBbsDevPath,\r
-    CurrentBbsDevPathSize\r
-    );\r
-  Ptr += CurrentBbsDevPathSize;\r
-\r
-  CopyMem (\r
-    Ptr,\r
-    CurrentBbsEntry,\r
-    sizeof (BBS_TABLE)\r
-    );\r
-\r
-  Ptr += sizeof (BBS_TABLE);\r
-  *((UINT16 *) Ptr) = (UINT16) Index;\r
-\r
-  Status = gRT->SetVariable (\r
-                  BootString,\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  BufferSize,\r
-                  Buffer\r
-                  );\r
-\r
-  FreePool (Buffer);\r
-\r
-  Buffer = NULL;\r
-\r
-  NewBootOrderList = AllocateZeroPool (*BootOrderListSize + sizeof (UINT16));\r
-  if (NULL == NewBootOrderList) {\r
-    FreePool (NewBbsDevPathNode);\r
-    FreePool (CurrentBbsDevPath);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  if (*BootOrderList != NULL) {\r
-    CopyMem (NewBootOrderList, *BootOrderList, *BootOrderListSize);\r
-    FreePool (*BootOrderList);\r
-  }\r
-\r
-  BootOrderLastIndex                    = (UINTN) (*BootOrderListSize / sizeof (UINT16));\r
-  NewBootOrderList[BootOrderLastIndex]  = CurrentBootOptionNo;\r
-  *BootOrderListSize += sizeof (UINT16);\r
-  *BootOrderList = NewBootOrderList;\r
-\r
-  FreePool (NewBbsDevPathNode);\r
-  FreePool (CurrentBbsDevPath);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Check if the boot option is a legacy one.\r
-\r
-  @param BootOptionVar   The boot option data payload.\r
-  @param BbsEntry        The BBS Table.\r
-  @param BbsIndex        The table index.\r
-\r
-  @retval TRUE           It is a legacy boot option.\r
-  @retval FALSE          It is not a legacy boot option.\r
-\r
-**/\r
-BOOLEAN\r
-BdsIsLegacyBootOption (\r
-  IN UINT8                 *BootOptionVar,\r
-  OUT BBS_TABLE            **BbsEntry,\r
-  OUT UINT16               *BbsIndex\r
-  )\r
-{\r
-  UINT8                     *Ptr;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  BOOLEAN                   Ret;\r
-  UINT16                    DevPathLen;\r
-\r
-  Ptr = BootOptionVar;\r
-  Ptr += sizeof (UINT32);\r
-  DevPathLen = *(UINT16 *) Ptr;\r
-  Ptr += sizeof (UINT16);\r
-  Ptr += StrSize ((UINT16 *) Ptr);\r
-  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
-  if ((BBS_DEVICE_PATH == DevicePath->Type) && (BBS_BBS_DP == DevicePath->SubType)) {\r
-    Ptr += DevPathLen;\r
-    *BbsEntry = (BBS_TABLE *) Ptr;\r
-    Ptr += sizeof (BBS_TABLE);\r
-    *BbsIndex = *(UINT16 *) Ptr;\r
-    Ret       = TRUE;\r
-  } else {\r
-    *BbsEntry = NULL;\r
-    Ret       = FALSE;\r
-  }\r
-\r
-  return Ret;\r
-}\r
-\r
-/**\r
-  Delete all the invalid legacy boot options.\r
-\r
-  @retval EFI_SUCCESS             All invalide legacy boot options are deleted.\r
-  @retval EFI_OUT_OF_RESOURCES    Fail to allocate necessary memory.\r
-  @retval EFI_NOT_FOUND           Fail to retrive variable of boot order.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsDeleteAllInvalidLegacyBootOptions (\r
-  VOID\r
-  )\r
-{\r
-  UINT16                    *BootOrder;\r
-  UINT8                     *BootOptionVar;\r
-  UINTN                     BootOrderSize;\r
-  UINTN                     BootOptionSize;\r
-  EFI_STATUS                Status;\r
-  UINT16                    HddCount;\r
-  UINT16                    BbsCount;\r
-  HDD_INFO                  *LocalHddInfo;\r
-  BBS_TABLE                 *LocalBbsTable;\r
-  BBS_TABLE                 *BbsEntry;\r
-  UINT16                    BbsIndex;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  UINTN                     Index;\r
-  UINT16                    BootOption[10];\r
-  UINT16                    BootDesc[100];\r
-  BOOLEAN                   DescStringMatch;\r
-\r
-  Status        = EFI_SUCCESS;\r
-  BootOrder     = NULL;\r
-  BootOrderSize = 0;\r
-  HddCount      = 0;\r
-  BbsCount      = 0;\r
-  LocalHddInfo  = NULL;\r
-  LocalBbsTable = NULL;\r
-  BbsEntry      = NULL;\r
-\r
-  Status        = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  BootOrder = BdsLibGetVariableAndSize (\r
-                L"BootOrder",\r
-                &gEfiGlobalVariableGuid,\r
-                &BootOrderSize\r
-                );\r
-  if (BootOrder == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  LegacyBios->GetBbsInfo (\r
-                LegacyBios,\r
-                &HddCount,\r
-                &LocalHddInfo,\r
-                &BbsCount,\r
-                &LocalBbsTable\r
-                );\r
-\r
-  Index = 0;\r
-  while (Index < BootOrderSize / sizeof (UINT16)) {\r
-    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
-    BootOptionVar = BdsLibGetVariableAndSize (\r
-                      BootOption,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &BootOptionSize\r
-                      );\r
-    if (NULL == BootOptionVar) {\r
-      BootOptionSize = 0;\r
-      Status = gRT->GetVariable (\r
-                      BootOption,\r
-                      &gEfiGlobalVariableGuid,\r
-                      NULL,\r
-                      &BootOptionSize,\r
-                      BootOptionVar\r
-                      );\r
-      if (Status == EFI_NOT_FOUND) {\r
-        //\r
-        // Update BootOrder\r
-        //\r
-        BdsDeleteBootOption (\r
-          BootOrder[Index],\r
-          BootOrder,\r
-          &BootOrderSize\r
-          );\r
-        continue;\r
-      } else {\r
-        FreePool (BootOrder);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Skip Non-Legacy boot option\r
-    //\r
-    if (!BdsIsLegacyBootOption (BootOptionVar, &BbsEntry, &BbsIndex)) {\r
-      if (BootOptionVar!= NULL) {\r
-        FreePool (BootOptionVar);\r
-      }\r
-      Index++;\r
-      continue;\r
-    }\r
-\r
-    if (BbsIndex < BbsCount) {\r
-      //\r
-      // Check if BBS Description String is changed\r
-      //\r
-      DescStringMatch = FALSE;\r
-      BdsBuildLegacyDevNameString (\r
-        &LocalBbsTable[BbsIndex],\r
-        BbsIndex,\r
-        sizeof (BootDesc),\r
-        BootDesc\r
-        );\r
-\r
-      if (StrCmp (BootDesc, (UINT16*)(BootOptionVar + sizeof (UINT32) + sizeof (UINT16))) == 0) {\r
-        DescStringMatch = TRUE;\r
-      }\r
-\r
-      if (!((LocalBbsTable[BbsIndex].BootPriority == BBS_IGNORE_ENTRY) ||\r
-            (LocalBbsTable[BbsIndex].BootPriority == BBS_DO_NOT_BOOT_FROM)) &&\r
-          (LocalBbsTable[BbsIndex].DeviceType == BbsEntry->DeviceType) &&\r
-          DescStringMatch) {\r
-        Index++;\r
-        continue;\r
-      }\r
-    }\r
-\r
-    if (BootOptionVar != NULL) {\r
-      FreePool (BootOptionVar);\r
-    }\r
-    //\r
-    // should delete\r
-    //\r
-    BdsDeleteBootOption (\r
-      BootOrder[Index],\r
-      BootOrder,\r
-      &BootOrderSize\r
-      );\r
-  }\r
-\r
-  //\r
-  // Adjust the number of boot options.\r
-  //\r
-  Status = gRT->SetVariable (\r
-                  L"BootOrder",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  BootOrderSize,\r
-                  BootOrder\r
-                  );\r
-  //\r
-  // Shrinking variable with existing variable implementation shouldn't fail.\r
-  //\r
-  ASSERT_EFI_ERROR (Status);\r
-  FreePool (BootOrder);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Find all legacy boot option by device type.\r
-\r
-  @param BootOrder       The boot order array.\r
-  @param BootOptionNum   The number of boot option.\r
-  @param DevType         Device type.\r
-  @param DevName         Device name.\r
-  @param Attribute       The boot option attribute.\r
-  @param BbsIndex        The BBS table index.\r
-  @param OptionNumber    The boot option index.\r
-\r
-  @retval TRUE           The Legacy boot option is found.\r
-  @retval FALSE          The legacy boot option is not found.\r
-\r
-**/\r
-BOOLEAN\r
-BdsFindLegacyBootOptionByDevTypeAndName (\r
-  IN UINT16                 *BootOrder,\r
-  IN UINTN                  BootOptionNum,\r
-  IN UINT16                 DevType,\r
-  IN CHAR16                 *DevName,\r
-  OUT UINT32                *Attribute,\r
-  OUT UINT16                *BbsIndex,\r
-  OUT UINT16                *OptionNumber\r
-  )\r
-{\r
-  UINTN     Index;\r
-  CHAR16    BootOption[9];\r
-  UINTN     BootOptionSize;\r
-  UINT8     *BootOptionVar;\r
-  BBS_TABLE *BbsEntry;\r
-  BOOLEAN   Found;\r
-\r
-  BbsEntry  = NULL;\r
-  Found     = FALSE;\r
-\r
-  if (NULL == BootOrder) {\r
-    return Found;\r
-  }\r
-\r
-  //\r
-  // Loop all boot option from variable\r
-  //\r
-  for (Index = 0; Index < BootOptionNum; Index++) {\r
-    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", (UINTN) BootOrder[Index]);\r
-    BootOptionVar = BdsLibGetVariableAndSize (\r
-                      BootOption,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &BootOptionSize\r
-                      );\r
-    if (NULL == BootOptionVar) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Skip Non-legacy boot option\r
-    //\r
-    if (!BdsIsLegacyBootOption (BootOptionVar, &BbsEntry, BbsIndex)) {\r
-      FreePool (BootOptionVar);\r
-      continue;\r
-    }\r
-\r
-    if (\r
-        (BbsEntry->DeviceType != DevType) ||\r
-        (StrCmp (DevName, (CHAR16*)(BootOptionVar + sizeof (UINT32) + sizeof (UINT16))) != 0)\r
-       ) {\r
-      FreePool (BootOptionVar);\r
-      continue;\r
-    }\r
-\r
-    *Attribute    = *(UINT32 *) BootOptionVar;\r
-    *OptionNumber = BootOrder[Index];\r
-    Found         = TRUE;\r
-    FreePool (BootOptionVar);\r
-    break;\r
-  }\r
-\r
-  return Found;\r
-}\r
-\r
-/**\r
-  Create a legacy boot option.\r
-\r
-  @param BbsItem         The BBS Table entry.\r
-  @param Index           Index of the specified entry in BBS table.\r
-  @param BootOrderList   The boot order list.\r
-  @param BootOrderListSize The size of boot order list.\r
-\r
-  @retval EFI_OUT_OF_RESOURCE  No enough memory.\r
-  @retval EFI_SUCCESS          The function complete successfully.\r
-  @return Other value if the legacy boot option is not created.\r
-\r
-**/\r
-EFI_STATUS\r
-BdsCreateOneLegacyBootOption (\r
-  IN BBS_TABLE              *BbsItem,\r
-  IN UINTN                  Index,\r
-  IN OUT UINT16             **BootOrderList,\r
-  IN OUT UINTN              *BootOrderListSize\r
-  )\r
-{\r
-  BBS_BBS_DEVICE_PATH       BbsDevPathNode;\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
-\r
-  DevPath                       = NULL;\r
-\r
-  //\r
-  // Create device path node.\r
-  //\r
-  BbsDevPathNode.Header.Type    = BBS_DEVICE_PATH;\r
-  BbsDevPathNode.Header.SubType = BBS_BBS_DP;\r
-  SetDevicePathNodeLength (&BbsDevPathNode.Header, sizeof (BBS_BBS_DEVICE_PATH));\r
-  BbsDevPathNode.DeviceType = BbsItem->DeviceType;\r
-  CopyMem (&BbsDevPathNode.StatusFlag, &BbsItem->StatusFlags, sizeof (UINT16));\r
-\r
-  DevPath = AppendDevicePathNode (\r
-              NULL,\r
-              (EFI_DEVICE_PATH_PROTOCOL *) &BbsDevPathNode\r
-              );\r
-  if (NULL == DevPath) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Status = BdsCreateLegacyBootOption (\r
-            BbsItem,\r
-            DevPath,\r
-            Index,\r
-            BootOrderList,\r
-            BootOrderListSize\r
-            );\r
-  BbsItem->BootPriority = 0x00;\r
-\r
-  FreePool (DevPath);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Add the legacy boot options from BBS table if they do not exist.\r
-\r
-  @retval EFI_SUCCESS          The boot options are added successfully\r
-                               or they are already in boot options.\r
-  @retval EFI_NOT_FOUND        No legacy boot options is found.\r
-  @retval EFI_OUT_OF_RESOURCE  No enough memory.\r
-  @return Other value          LegacyBoot options are not added.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsAddNonExistingLegacyBootOptions (\r
-  VOID\r
-  )\r
-{\r
-  UINT16                    *BootOrder;\r
-  UINTN                     BootOrderSize;\r
-  EFI_STATUS                Status;\r
-  CHAR16                    Desc[100];\r
-  UINT16                    HddCount;\r
-  UINT16                    BbsCount;\r
-  HDD_INFO                  *LocalHddInfo;\r
-  BBS_TABLE                 *LocalBbsTable;\r
-  UINT16                    BbsIndex;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  UINT16                    Index;\r
-  UINT32                    Attribute;\r
-  UINT16                    OptionNumber;\r
-  BOOLEAN                   Exist;\r
-\r
-  HddCount      = 0;\r
-  BbsCount      = 0;\r
-  LocalHddInfo  = NULL;\r
-  LocalBbsTable = NULL;\r
-\r
-  Status        = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  LegacyBios->GetBbsInfo (\r
-                LegacyBios,\r
-                &HddCount,\r
-                &LocalHddInfo,\r
-                &BbsCount,\r
-                &LocalBbsTable\r
-                );\r
-\r
-  BootOrder = BdsLibGetVariableAndSize (\r
-                L"BootOrder",\r
-                &gEfiGlobalVariableGuid,\r
-                &BootOrderSize\r
-                );\r
-  if (BootOrder == NULL) {\r
-    BootOrderSize = 0;\r
-  }\r
-\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if ((LocalBbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) ||\r
-        (LocalBbsTable[Index].BootPriority == BBS_DO_NOT_BOOT_FROM)\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    BdsBuildLegacyDevNameString (&LocalBbsTable[Index], Index, sizeof (Desc), Desc);\r
-\r
-    Exist = BdsFindLegacyBootOptionByDevTypeAndName (\r
-              BootOrder,\r
-              BootOrderSize / sizeof (UINT16),\r
-              LocalBbsTable[Index].DeviceType,\r
-              Desc,\r
-              &Attribute,\r
-              &BbsIndex,\r
-              &OptionNumber\r
-              );\r
-    if (!Exist) {\r
-      //\r
-      // Not found such type of legacy device in boot options or we found but it's disabled\r
-      // so we have to create one and put it to the tail of boot order list\r
-      //\r
-      Status = BdsCreateOneLegacyBootOption (\r
-                &LocalBbsTable[Index],\r
-                Index,\r
-                &BootOrder,\r
-                &BootOrderSize\r
-                );\r
-      if (!EFI_ERROR (Status)) {\r
-        ASSERT (BootOrder != NULL);\r
-        BbsIndex     = Index;\r
-        OptionNumber = BootOrder[BootOrderSize / sizeof (UINT16) - 1];\r
-      }\r
-    }\r
-\r
-    ASSERT (BbsIndex == Index);\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  L"BootOrder",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  BootOrderSize,\r
-                  BootOrder\r
-                  );\r
-  if (BootOrder != NULL) {\r
-    FreePool (BootOrder);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Fill the device order buffer.\r
-\r
-  @param BbsTable        The BBS table.\r
-  @param BbsType         The BBS Type.\r
-  @param BbsCount        The BBS Count.\r
-  @param Buf             device order buffer.\r
-\r
-  @return The device order buffer.\r
-\r
-**/\r
-UINT16 *\r
-BdsFillDevOrderBuf (\r
-  IN BBS_TABLE                    *BbsTable,\r
-  IN BBS_TYPE                     BbsType,\r
-  IN UINTN                        BbsCount,\r
-  OUT UINT16                      *Buf\r
-  )\r
-{\r
-  UINTN Index;\r
-\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (BbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) {\r
-      continue;\r
-    }\r
-\r
-    if (BbsTable[Index].DeviceType != BbsType) {\r
-      continue;\r
-    }\r
-\r
-    *Buf = (UINT16) (Index & 0xFF);\r
-    Buf++;\r
-  }\r
-\r
-  return Buf;\r
-}\r
-\r
-/**\r
-  Create the device order buffer.\r
-\r
-  @param BbsTable        The BBS table.\r
-  @param BbsCount        The BBS Count.\r
-\r
-  @retval EFI_SUCCES             The buffer is created and the EFI variable named\r
-                                 VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid is\r
-                                 set correctly.\r
-  @retval EFI_OUT_OF_RESOURCES   Memmory or storage is not enough.\r
-  @retval EFI_DEVICE_ERROR       Fail to add the device order into EFI variable fail\r
-                                 because of hardware error.\r
-**/\r
-EFI_STATUS\r
-BdsCreateDevOrder (\r
-  IN BBS_TABLE                  *BbsTable,\r
-  IN UINT16                     BbsCount\r
-  )\r
-{\r
-  UINTN                       Index;\r
-  UINTN                       FDCount;\r
-  UINTN                       HDCount;\r
-  UINTN                       CDCount;\r
-  UINTN                       NETCount;\r
-  UINTN                       BEVCount;\r
-  UINTN                       TotalSize;\r
-  UINTN                       HeaderSize;\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrderPtr;\r
-  EFI_STATUS                  Status;\r
-\r
-  FDCount     = 0;\r
-  HDCount     = 0;\r
-  CDCount     = 0;\r
-  NETCount    = 0;\r
-  BEVCount    = 0;\r
-  TotalSize   = 0;\r
-  HeaderSize  = sizeof (BBS_TYPE) + sizeof (UINT16);\r
-  DevOrder    = NULL;\r
-  Status      = EFI_SUCCESS;\r
-\r
-  //\r
-  // Count all boot devices\r
-  //\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (BbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) {\r
-      continue;\r
-    }\r
-\r
-    switch (BbsTable[Index].DeviceType) {\r
-    case BBS_FLOPPY:\r
-      FDCount++;\r
-      break;\r
-\r
-    case BBS_HARDDISK:\r
-      HDCount++;\r
-      break;\r
-\r
-    case BBS_CDROM:\r
-      CDCount++;\r
-      break;\r
-\r
-    case BBS_EMBED_NETWORK:\r
-      NETCount++;\r
-      break;\r
-\r
-    case BBS_BEV_DEVICE:\r
-      BEVCount++;\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-  }\r
-\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * FDCount);\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * HDCount);\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * CDCount);\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * NETCount);\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * BEVCount);\r
-\r
-  //\r
-  // Create buffer to hold all boot device order\r
-  //\r
-  DevOrder = AllocateZeroPool (TotalSize);\r
-  if (NULL == DevOrder) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  DevOrderPtr          = DevOrder;\r
-\r
-  DevOrderPtr->BbsType = BBS_FLOPPY;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (DevOrderPtr->Length) + FDCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_FLOPPY, BbsCount, DevOrderPtr->Data);\r
-\r
-  DevOrderPtr->BbsType = BBS_HARDDISK;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + HDCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_HARDDISK, BbsCount, DevOrderPtr->Data);\r
-\r
-  DevOrderPtr->BbsType = BBS_CDROM;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + CDCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_CDROM, BbsCount, DevOrderPtr->Data);\r
-\r
-  DevOrderPtr->BbsType = BBS_EMBED_NETWORK;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + NETCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_EMBED_NETWORK, BbsCount, DevOrderPtr->Data);\r
-\r
-  DevOrderPtr->BbsType = BBS_BEV_DEVICE;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + BEVCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_BEV_DEVICE, BbsCount, DevOrderPtr->Data);\r
-\r
-  ASSERT (TotalSize == ((UINTN) DevOrderPtr - (UINTN) DevOrder));\r
-\r
-  //\r
-  // Save device order for legacy boot device to variable.\r
-  //\r
-  Status = gRT->SetVariable (\r
-                  VAR_LEGACY_DEV_ORDER,\r
-                  &gEfiLegacyDevOrderVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  TotalSize,\r
-                  DevOrder\r
-                  );\r
-  FreePool (DevOrder);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Add the legacy boot devices from BBS table into\r
-  the legacy device boot order.\r
-\r
-  @retval EFI_SUCCESS           The boot devices are added successfully.\r
-  @retval EFI_NOT_FOUND         The legacy boot devices are not found.\r
-  @retval EFI_OUT_OF_RESOURCES  Memmory or storage is not enough.\r
-  @retval EFI_DEVICE_ERROR      Fail to add the legacy device boot order into EFI variable\r
-                                because of hardware error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsUpdateLegacyDevOrder (\r
-  VOID\r
-  )\r
-{\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  LEGACY_DEV_ORDER_ENTRY      *NewDevOrder;\r
-  LEGACY_DEV_ORDER_ENTRY      *Ptr;\r
-  LEGACY_DEV_ORDER_ENTRY      *NewPtr;\r
-  UINTN                       DevOrderSize;\r
-  EFI_LEGACY_BIOS_PROTOCOL    *LegacyBios;\r
-  EFI_STATUS                  Status;\r
-  UINT16                      HddCount;\r
-  UINT16                      BbsCount;\r
-  HDD_INFO                    *LocalHddInfo;\r
-  BBS_TABLE                   *LocalBbsTable;\r
-  UINTN                       Index;\r
-  UINTN                       Index2;\r
-  UINTN                       *Idx;\r
-  UINTN                       FDCount;\r
-  UINTN                       HDCount;\r
-  UINTN                       CDCount;\r
-  UINTN                       NETCount;\r
-  UINTN                       BEVCount;\r
-  UINTN                       TotalSize;\r
-  UINTN                       HeaderSize;\r
-  UINT16                      *NewFDPtr;\r
-  UINT16                      *NewHDPtr;\r
-  UINT16                      *NewCDPtr;\r
-  UINT16                      *NewNETPtr;\r
-  UINT16                      *NewBEVPtr;\r
-  UINT16                      *NewDevPtr;\r
-  UINTN                       FDIndex;\r
-  UINTN                       HDIndex;\r
-  UINTN                       CDIndex;\r
-  UINTN                       NETIndex;\r
-  UINTN                       BEVIndex;\r
-\r
-  Idx           = NULL;\r
-  FDCount       = 0;\r
-  HDCount       = 0;\r
-  CDCount       = 0;\r
-  NETCount      = 0;\r
-  BEVCount      = 0;\r
-  TotalSize     = 0;\r
-  HeaderSize    = sizeof (BBS_TYPE) + sizeof (UINT16);\r
-  FDIndex       = 0;\r
-  HDIndex       = 0;\r
-  CDIndex       = 0;\r
-  NETIndex      = 0;\r
-  BEVIndex      = 0;\r
-  NewDevPtr     = NULL;\r
-\r
-  Status        = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = LegacyBios->GetBbsInfo (\r
-                         LegacyBios,\r
-                         &HddCount,\r
-                         &LocalHddInfo,\r
-                         &BbsCount,\r
-                         &LocalBbsTable\r
-                         );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  DevOrder = BdsLibGetVariableAndSize (\r
-               VAR_LEGACY_DEV_ORDER,\r
-               &gEfiLegacyDevOrderVariableGuid,\r
-               &DevOrderSize\r
-               );\r
-  if (NULL == DevOrder) {\r
-    return BdsCreateDevOrder (LocalBbsTable, BbsCount);\r
-  }\r
-  //\r
-  // First we figure out how many boot devices with same device type respectively\r
-  //\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if ((LocalBbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) ||\r
-        (LocalBbsTable[Index].BootPriority == BBS_DO_NOT_BOOT_FROM)\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    switch (LocalBbsTable[Index].DeviceType) {\r
-    case BBS_FLOPPY:\r
-      FDCount++;\r
-      break;\r
-\r
-    case BBS_HARDDISK:\r
-      HDCount++;\r
-      break;\r
-\r
-    case BBS_CDROM:\r
-      CDCount++;\r
-      break;\r
-\r
-    case BBS_EMBED_NETWORK:\r
-      NETCount++;\r
-      break;\r
-\r
-    case BBS_BEV_DEVICE:\r
-      BEVCount++;\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-  }\r
-\r
-  TotalSize += (HeaderSize + FDCount * sizeof (UINT16));\r
-  TotalSize += (HeaderSize + HDCount * sizeof (UINT16));\r
-  TotalSize += (HeaderSize + CDCount * sizeof (UINT16));\r
-  TotalSize += (HeaderSize + NETCount * sizeof (UINT16));\r
-  TotalSize += (HeaderSize + BEVCount * sizeof (UINT16));\r
-\r
-  NewDevOrder = AllocateZeroPool (TotalSize);\r
-  if (NULL == NewDevOrder) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-\r
-\r
-  //\r
-  // copy FD\r
-  //\r
-  Ptr             = DevOrder;\r
-  NewPtr          = NewDevOrder;\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + FDCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_IGNORE_ENTRY ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_FLOPPY\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[FDIndex] = Ptr->Data[Index];\r
-    FDIndex++;\r
-  }\r
-  NewFDPtr = NewPtr->Data;\r
-\r
-  //\r
-  // copy HD\r
-  //\r
-  Ptr             = (LEGACY_DEV_ORDER_ENTRY *) (&Ptr->Data[Ptr->Length / sizeof (UINT16) - 1]);\r
-  NewPtr          = (LEGACY_DEV_ORDER_ENTRY *) (&NewPtr->Data[NewPtr->Length / sizeof (UINT16) -1]);\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + HDCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_IGNORE_ENTRY ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_LOWEST_PRIORITY ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_HARDDISK\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[HDIndex] = Ptr->Data[Index];\r
-    HDIndex++;\r
-  }\r
-  NewHDPtr = NewPtr->Data;\r
-\r
-  //\r
-  // copy CD\r
-  //\r
-  Ptr    = (LEGACY_DEV_ORDER_ENTRY *) (&Ptr->Data[Ptr->Length / sizeof (UINT16) - 1]);\r
-  NewPtr = (LEGACY_DEV_ORDER_ENTRY *) (&NewPtr->Data[NewPtr->Length / sizeof (UINT16) -1]);\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + CDCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_IGNORE_ENTRY ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_LOWEST_PRIORITY ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_CDROM\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[CDIndex] = Ptr->Data[Index];\r
-    CDIndex++;\r
-  }\r
-  NewCDPtr = NewPtr->Data;\r
-\r
-  //\r
-  // copy NET\r
-  //\r
-  Ptr    = (LEGACY_DEV_ORDER_ENTRY *) (&Ptr->Data[Ptr->Length / sizeof (UINT16) - 1]);\r
-  NewPtr = (LEGACY_DEV_ORDER_ENTRY *) (&NewPtr->Data[NewPtr->Length / sizeof (UINT16) -1]);\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + NETCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_IGNORE_ENTRY ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_LOWEST_PRIORITY ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_EMBED_NETWORK\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[NETIndex] = Ptr->Data[Index];\r
-    NETIndex++;\r
-  }\r
-  NewNETPtr = NewPtr->Data;\r
-\r
-  //\r
-  // copy BEV\r
-  //\r
-  Ptr    = (LEGACY_DEV_ORDER_ENTRY *) (&Ptr->Data[Ptr->Length / sizeof (UINT16) - 1]);\r
-  NewPtr = (LEGACY_DEV_ORDER_ENTRY *) (&NewPtr->Data[NewPtr->Length / sizeof (UINT16) -1]);\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + BEVCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_IGNORE_ENTRY ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].BootPriority == BBS_LOWEST_PRIORITY ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_BEV_DEVICE\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[BEVIndex] = Ptr->Data[Index];\r
-    BEVIndex++;\r
-  }\r
-  NewBEVPtr = NewPtr->Data;\r
-\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if ((LocalBbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) ||\r
-        (LocalBbsTable[Index].BootPriority == BBS_DO_NOT_BOOT_FROM)\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    switch (LocalBbsTable[Index].DeviceType) {\r
-    case BBS_FLOPPY:\r
-      Idx       = &FDIndex;\r
-      NewDevPtr = NewFDPtr;\r
-      break;\r
-\r
-    case BBS_HARDDISK:\r
-      Idx       = &HDIndex;\r
-      NewDevPtr = NewHDPtr;\r
-      break;\r
-\r
-    case BBS_CDROM:\r
-      Idx       = &CDIndex;\r
-      NewDevPtr = NewCDPtr;\r
-      break;\r
-\r
-    case BBS_EMBED_NETWORK:\r
-      Idx       = &NETIndex;\r
-      NewDevPtr = NewNETPtr;\r
-      break;\r
-\r
-    case BBS_BEV_DEVICE:\r
-      Idx       = &BEVIndex;\r
-      NewDevPtr = NewBEVPtr;\r
-      break;\r
-\r
-    default:\r
-      Idx = NULL;\r
-      break;\r
-    }\r
-    //\r
-    // at this point we have copied those valid indexes to new buffer\r
-    // and we should check if there is any new appeared boot device\r
-    //\r
-    if (Idx != NULL) {\r
-      for (Index2 = 0; Index2 < *Idx; Index2++) {\r
-        if ((NewDevPtr[Index2] & 0xFF) == (UINT16) Index) {\r
-          break;\r
-        }\r
-      }\r
-\r
-      if (Index2 == *Idx) {\r
-        //\r
-        // Index2 == *Idx means we didn't find Index\r
-        // so Index is a new appeared device's index in BBS table\r
-        // insert it before disabled indexes.\r
-        //\r
-        for (Index2 = 0; Index2 < *Idx; Index2++) {\r
-          if ((NewDevPtr[Index2] & 0xFF00) == 0xFF00) {\r
-            break;\r
-          }\r
-        }\r
-        CopyMem (&NewDevPtr[Index2 + 1], &NewDevPtr[Index2], (*Idx - Index2) * sizeof (UINT16));\r
-        NewDevPtr[Index2] = (UINT16) (Index & 0xFF);\r
-        (*Idx)++;\r
-      }\r
-    }\r
-  }\r
-\r
-  FreePool (DevOrder);\r
-\r
-  Status = gRT->SetVariable (\r
-                  VAR_LEGACY_DEV_ORDER,\r
-                  &gEfiLegacyDevOrderVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  TotalSize,\r
-                  NewDevOrder\r
-                  );\r
-  FreePool (NewDevOrder);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Set Boot Priority for specified device type.\r
-\r
-  @param DeviceType      The device type.\r
-  @param BbsIndex        The BBS index to set the highest priority. Ignore when -1.\r
-  @param LocalBbsTable   The BBS table.\r
-  @param Priority        The prority table.\r
-\r
-  @retval EFI_SUCCESS           The function completes successfully.\r
-  @retval EFI_NOT_FOUND         Failed to find device.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to get the efi variable of device order.\r
-\r
-**/\r
-EFI_STATUS\r
-BdsSetBootPriority4SameTypeDev (\r
-  IN UINT16                                              DeviceType,\r
-  IN UINTN                                               BbsIndex,\r
-  IN OUT BBS_TABLE                                       *LocalBbsTable,\r
-  IN OUT UINT16                                          *Priority\r
-  )\r
-{\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrderPtr;\r
-  UINTN                       DevOrderSize;\r
-  UINTN                       Index;\r
-\r
-  DevOrder = BdsLibGetVariableAndSize (\r
-               VAR_LEGACY_DEV_ORDER,\r
-               &gEfiLegacyDevOrderVariableGuid,\r
-               &DevOrderSize\r
-               );\r
-  if (NULL == DevOrder) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  DevOrderPtr = DevOrder;\r
-  while ((UINT8 *) DevOrderPtr < (UINT8 *) DevOrder + DevOrderSize) {\r
-    if (DevOrderPtr->BbsType == DeviceType) {\r
-      break;\r
-    }\r
-\r
-    DevOrderPtr = (LEGACY_DEV_ORDER_ENTRY *) ((UINTN) DevOrderPtr + sizeof (BBS_TYPE) + DevOrderPtr->Length);\r
-  }\r
-\r
-  if ((UINT8 *) DevOrderPtr >= (UINT8 *) DevOrder + DevOrderSize) {\r
-    FreePool (DevOrder);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if (BbsIndex != (UINTN) -1) {\r
-    LocalBbsTable[BbsIndex].BootPriority = *Priority;\r
-    (*Priority)++;\r
-  }\r
-  //\r
-  // If the high byte of the DevIndex is 0xFF, it indicates that this device has been disabled.\r
-  //\r
-  for (Index = 0; Index < DevOrderPtr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if ((DevOrderPtr->Data[Index] & 0xFF00) == 0xFF00) {\r
-      //\r
-      // LocalBbsTable[DevIndex[Index] & 0xFF].BootPriority = BBS_DISABLED_ENTRY;\r
-      //\r
-    } else if (DevOrderPtr->Data[Index] != BbsIndex) {\r
-      LocalBbsTable[DevOrderPtr->Data[Index]].BootPriority = *Priority;\r
-      (*Priority)++;\r
-    }\r
-  }\r
-\r
-  FreePool (DevOrder);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Print the BBS Table.\r
-\r
-  @param LocalBbsTable   The BBS table.\r
-  @param BbsCount        The count of entry in BBS table.\r
-**/\r
-VOID\r
-PrintBbsTable (\r
-  IN BBS_TABLE  *LocalBbsTable,\r
-  IN UINT16     BbsCount\r
-  )\r
-{\r
-  UINT16  Idx;\r
-\r
-  DEBUG ((DEBUG_ERROR, "\n"));\r
-  DEBUG ((DEBUG_ERROR, " NO  Prio bb/dd/ff cl/sc Type Stat segm:offs\n"));\r
-  DEBUG ((DEBUG_ERROR, "=============================================\n"));\r
-  for (Idx = 0; Idx < BbsCount; Idx++) {\r
-    if ((LocalBbsTable[Idx].BootPriority == BBS_IGNORE_ENTRY) ||\r
-        (LocalBbsTable[Idx].BootPriority == BBS_DO_NOT_BOOT_FROM) ||\r
-        (LocalBbsTable[Idx].BootPriority == BBS_LOWEST_PRIORITY)\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    DEBUG (\r
-      (DEBUG_ERROR,\r
-      " %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x %04x:%04x\n",\r
-      (UINTN) Idx,\r
-      (UINTN) LocalBbsTable[Idx].BootPriority,\r
-      (UINTN) LocalBbsTable[Idx].Bus,\r
-      (UINTN) LocalBbsTable[Idx].Device,\r
-      (UINTN) LocalBbsTable[Idx].Function,\r
-      (UINTN) LocalBbsTable[Idx].Class,\r
-      (UINTN) LocalBbsTable[Idx].SubClass,\r
-      (UINTN) LocalBbsTable[Idx].DeviceType,\r
-      (UINTN) * (UINT16 *) &LocalBbsTable[Idx].StatusFlags,\r
-      (UINTN) LocalBbsTable[Idx].BootHandlerSegment,\r
-      (UINTN) LocalBbsTable[Idx].BootHandlerOffset,\r
-      (UINTN) ((LocalBbsTable[Idx].MfgStringSegment << 4) + LocalBbsTable[Idx].MfgStringOffset),\r
-      (UINTN) ((LocalBbsTable[Idx].DescStringSegment << 4) + LocalBbsTable[Idx].DescStringOffset))\r
-      );\r
-  }\r
-\r
-  DEBUG ((DEBUG_ERROR, "\n"));\r
-}\r
-\r
-/**\r
-  Set the boot priority for BBS entries based on boot option entry and boot order.\r
-\r
-  @param  Entry             The boot option is to be checked for refresh BBS table.\r
-\r
-  @retval EFI_SUCCESS           The boot priority for BBS entries is refreshed successfully.\r
-  @retval EFI_NOT_FOUND         BBS entries can't be found.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to get the legacy device boot order.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsRefreshBbsTableForBoot (\r
-  IN BDS_COMMON_OPTION        *Entry\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  UINT16                    BbsIndex;\r
-  UINT16                    HddCount;\r
-  UINT16                    BbsCount;\r
-  HDD_INFO                  *LocalHddInfo;\r
-  BBS_TABLE                 *LocalBbsTable;\r
-  UINT16                    DevType;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  UINTN                     Index;\r
-  UINT16                    Priority;\r
-  UINT16                    *BootOrder;\r
-  UINTN                     BootOrderSize;\r
-  UINT8                     *BootOptionVar;\r
-  UINTN                     BootOptionSize;\r
-  CHAR16                    BootOption[9];\r
-  UINT8                     *Ptr;\r
-  UINT16                    DevPathLen;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
-  UINT16                    *DeviceType;\r
-  UINTN                     DeviceTypeCount;\r
-  UINTN                     DeviceTypeIndex;\r
-\r
-  HddCount      = 0;\r
-  BbsCount      = 0;\r
-  LocalHddInfo  = NULL;\r
-  LocalBbsTable = NULL;\r
-  DevType       = BBS_UNKNOWN;\r
-\r
-  Status        = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  LegacyBios->GetBbsInfo (\r
-                LegacyBios,\r
-                &HddCount,\r
-                &LocalHddInfo,\r
-                &BbsCount,\r
-                &LocalBbsTable\r
-                );\r
-  //\r
-  // First, set all the present devices' boot priority to BBS_UNPRIORITIZED_ENTRY\r
-  // We will set them according to the settings setup by user\r
-  //\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (!((BBS_IGNORE_ENTRY == LocalBbsTable[Index].BootPriority) ||\r
-        (BBS_DO_NOT_BOOT_FROM == LocalBbsTable[Index].BootPriority) ||\r
-         (BBS_LOWEST_PRIORITY == LocalBbsTable[Index].BootPriority))) {\r
-      LocalBbsTable[Index].BootPriority = BBS_UNPRIORITIZED_ENTRY;\r
-    }\r
-  }\r
-  //\r
-  // boot priority always starts at 0\r
-  //\r
-  Priority = 0;\r
-  if (Entry->LoadOptionsSize == sizeof (BBS_TABLE) + sizeof (UINT16)) {\r
-    //\r
-    // If Entry stands for a legacy boot option, we prioritize the devices with the same type first.\r
-    //\r
-    DevType  = ((BBS_TABLE *) Entry->LoadOptions)->DeviceType;\r
-    BbsIndex = *(UINT16 *) ((BBS_TABLE *) Entry->LoadOptions + 1);\r
-    Status = BdsSetBootPriority4SameTypeDev (\r
-              DevType,\r
-              BbsIndex,\r
-              LocalBbsTable,\r
-              &Priority\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-  //\r
-  // we have to set the boot priority for other BBS entries with different device types\r
-  //\r
-  BootOrder = BdsLibGetVariableAndSize (\r
-                L"BootOrder",\r
-                &gEfiGlobalVariableGuid,\r
-                &BootOrderSize\r
-                );\r
-  DeviceType = AllocatePool (BootOrderSize + sizeof (UINT16));\r
-  ASSERT (DeviceType != NULL);\r
-\r
-  DeviceType[0]   = DevType;\r
-  DeviceTypeCount = 1;\r
-  for (Index = 0; ((BootOrder != NULL) && (Index < BootOrderSize / sizeof (UINT16))); Index++) {\r
-    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
-    BootOptionVar = BdsLibGetVariableAndSize (\r
-                      BootOption,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &BootOptionSize\r
-                      );\r
-    if (NULL == BootOptionVar) {\r
-      continue;\r
-    }\r
-\r
-    Ptr = BootOptionVar;\r
-\r
-    Ptr += sizeof (UINT32);\r
-    DevPathLen = *(UINT16 *) Ptr;\r
-    Ptr += sizeof (UINT16);\r
-    Ptr += StrSize ((UINT16 *) Ptr);\r
-    DevPath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
-    if (BBS_DEVICE_PATH != DevPath->Type || BBS_BBS_DP != DevPath->SubType) {\r
-      FreePool (BootOptionVar);\r
-      continue;\r
-    }\r
-\r
-    Ptr += DevPathLen;\r
-    DevType = ((BBS_TABLE *) Ptr)->DeviceType;\r
-    for (DeviceTypeIndex = 0; DeviceTypeIndex < DeviceTypeCount; DeviceTypeIndex++) {\r
-      if (DeviceType[DeviceTypeIndex] == DevType) {\r
-        break;\r
-      }\r
-    }\r
-    if (DeviceTypeIndex < DeviceTypeCount) {\r
-      //\r
-      // We don't want to process twice for a device type\r
-      //\r
-      FreePool (BootOptionVar);\r
-      continue;\r
-    }\r
-\r
-    DeviceType[DeviceTypeCount] = DevType;\r
-    DeviceTypeCount++;\r
-\r
-    Status = BdsSetBootPriority4SameTypeDev (\r
-              DevType,\r
-              (UINTN) -1,\r
-              LocalBbsTable,\r
-              &Priority\r
-              );\r
-    FreePool (BootOptionVar);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  FreePool (DeviceType);\r
-\r
-  if (BootOrder != NULL) {\r
-    FreePool (BootOrder);\r
-  }\r
-\r
-  DEBUG_CODE_BEGIN();\r
-    PrintBbsTable (LocalBbsTable, BbsCount);\r
-  DEBUG_CODE_END();\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Boot the legacy system with the boot option\r
-\r
-  @param  Option                 The legacy boot option which have BBS device path\r
-\r
-  @retval EFI_UNSUPPORTED        There is no legacybios protocol, do not support\r
-                                 legacy boot.\r
-  @retval EFI_STATUS             Return the status of LegacyBios->LegacyBoot ().\r
-\r
-**/\r
-EFI_STATUS\r
-BdsLibDoLegacyBoot (\r
-  IN  BDS_COMMON_OPTION           *Option\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  EFI_EVENT                 LegacyBootEvent;\r
-\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // If no LegacyBios protocol we do not support legacy boot\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Notes: if we separate the int 19, then we don't need to refresh BBS\r
-  //\r
-  BdsRefreshBbsTableForBoot (Option);\r
-\r
-  //\r
-  // Write boot to OS performance data for legacy boot.\r
-  //\r
-  PERF_CODE (\r
-    //\r
-    // Create an event to be signalled when Legacy Boot occurs to write performance data.\r
-    //\r
-    Status = EfiCreateEventLegacyBootEx(\r
-               TPL_NOTIFY,\r
-               BmEndOfBdsPerfCode,\r
-               NULL,\r
-               &LegacyBootEvent\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-  );\r
-\r
-  DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Legacy Boot: %S\n", Option->Description));\r
-  return LegacyBios->LegacyBoot (\r
-                      LegacyBios,\r
-                      (BBS_BBS_DEVICE_PATH *) Option->DevicePath,\r
-                      Option->LoadOptionsSize,\r
-                      Option->LoadOptions\r
-                      );\r
-}\r
-\r
-/**\r
-  Internal function to check if the input boot option is a valid EFI NV Boot####.\r
-\r
-  @param OptionToCheck  Boot option to be checked.\r
-\r
-  @retval TRUE      This boot option matches a valid EFI NV Boot####.\r
-  @retval FALSE     If not.\r
-\r
-**/\r
-BOOLEAN\r
-IsBootOptionValidNVVarialbe (\r
-  IN  BDS_COMMON_OPTION             *OptionToCheck\r
-  )\r
-{\r
-  LIST_ENTRY        TempList;\r
-  BDS_COMMON_OPTION *BootOption;\r
-  BOOLEAN           Valid;\r
-  CHAR16            OptionName[20];\r
-\r
-  Valid = FALSE;\r
-\r
-  InitializeListHead (&TempList);\r
-  UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", OptionToCheck->BootCurrent);\r
-\r
-  BootOption = BdsLibVariableToOption (&TempList, OptionName);\r
-  if (BootOption == NULL) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // If the Boot Option Number and Device Path matches, OptionToCheck matches a\r
-  // valid EFI NV Boot####.\r
-  //\r
-  if ((OptionToCheck->BootCurrent == BootOption->BootCurrent) &&\r
-      (CompareMem (OptionToCheck->DevicePath, BootOption->DevicePath, GetDevicePathSize (OptionToCheck->DevicePath)) == 0))\r
-      {\r
-    Valid = TRUE;\r
-  }\r
-\r
-  FreePool (BootOption);\r
-\r
-  return Valid;\r
-}\r
-\r
-/**\r
-  Check whether a USB device match the specified USB Class device path. This\r
-  function follows "Load Option Processing" behavior in UEFI specification.\r
-\r
-  @param UsbIo       USB I/O protocol associated with the USB device.\r
-  @param UsbClass    The USB Class device path to match.\r
-\r
-  @retval TRUE       The USB device match the USB Class device path.\r
-  @retval FALSE      The USB device does not match the USB Class device path.\r
-\r
-**/\r
-BOOLEAN\r
-BdsMatchUsbClass (\r
-  IN EFI_USB_IO_PROTOCOL        *UsbIo,\r
-  IN USB_CLASS_DEVICE_PATH      *UsbClass\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_USB_DEVICE_DESCRIPTOR     DevDesc;\r
-  EFI_USB_INTERFACE_DESCRIPTOR  IfDesc;\r
-  UINT8                         DeviceClass;\r
-  UINT8                         DeviceSubClass;\r
-  UINT8                         DeviceProtocol;\r
-\r
-  if ((DevicePathType (UsbClass) != MESSAGING_DEVICE_PATH) ||\r
-      (DevicePathSubType (UsbClass) != MSG_USB_CLASS_DP)){\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Check Vendor Id and Product Id.\r
-  //\r
-  Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if ((UsbClass->VendorId != 0xffff) &&\r
-      (UsbClass->VendorId != DevDesc.IdVendor)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if ((UsbClass->ProductId != 0xffff) &&\r
-      (UsbClass->ProductId != DevDesc.IdProduct)) {\r
-    return FALSE;\r
-  }\r
-\r
-  DeviceClass    = DevDesc.DeviceClass;\r
-  DeviceSubClass = DevDesc.DeviceSubClass;\r
-  DeviceProtocol = DevDesc.DeviceProtocol;\r
-  if (DeviceClass == 0) {\r
-    //\r
-    // If Class in Device Descriptor is set to 0, use the Class, SubClass and\r
-    // Protocol in Interface Descriptor instead.\r
-    //\r
-    Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &IfDesc);\r
-    if (EFI_ERROR (Status)) {\r
-      return FALSE;\r
-    }\r
-\r
-    DeviceClass    = IfDesc.InterfaceClass;\r
-    DeviceSubClass = IfDesc.InterfaceSubClass;\r
-    DeviceProtocol = IfDesc.InterfaceProtocol;\r
-  }\r
-\r
-  //\r
-  // Check Class, SubClass and Protocol.\r
-  //\r
-  if ((UsbClass->DeviceClass != 0xff) &&\r
-      (UsbClass->DeviceClass != DeviceClass)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if ((UsbClass->DeviceSubClass != 0xff) &&\r
-      (UsbClass->DeviceSubClass != DeviceSubClass)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if ((UsbClass->DeviceProtocol != 0xff) &&\r
-      (UsbClass->DeviceProtocol != DeviceProtocol)) {\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Check whether a USB device match the specified USB WWID device path. This\r
-  function follows "Load Option Processing" behavior in UEFI specification.\r
-\r
-  @param UsbIo       USB I/O protocol associated with the USB device.\r
-  @param UsbWwid     The USB WWID device path to match.\r
-\r
-  @retval TRUE       The USB device match the USB WWID device path.\r
-  @retval FALSE      The USB device does not match the USB WWID device path.\r
-\r
-**/\r
-BOOLEAN\r
-BdsMatchUsbWwid (\r
-  IN EFI_USB_IO_PROTOCOL        *UsbIo,\r
-  IN USB_WWID_DEVICE_PATH       *UsbWwid\r
-  )\r
-{\r
-  EFI_STATUS                   Status;\r
-  EFI_USB_DEVICE_DESCRIPTOR    DevDesc;\r
-  EFI_USB_INTERFACE_DESCRIPTOR IfDesc;\r
-  UINT16                       *LangIdTable;\r
-  UINT16                       TableSize;\r
-  UINT16                       Index;\r
-  CHAR16                       *CompareStr;\r
-  UINTN                        CompareLen;\r
-  CHAR16                       *SerialNumberStr;\r
-  UINTN                        Length;\r
-\r
-  if ((DevicePathType (UsbWwid) != MESSAGING_DEVICE_PATH) ||\r
-      (DevicePathSubType (UsbWwid) != MSG_USB_WWID_DP )){\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Check Vendor Id and Product Id.\r
-  //\r
-  Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-  if ((DevDesc.IdVendor != UsbWwid->VendorId) ||\r
-      (DevDesc.IdProduct != UsbWwid->ProductId)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Check Interface Number.\r
-  //\r
-  Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &IfDesc);\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-  if (IfDesc.InterfaceNumber != UsbWwid->InterfaceNumber) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Check Serial Number.\r
-  //\r
-  if (DevDesc.StrSerialNumber == 0) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Get all supported languages.\r
-  //\r
-  TableSize = 0;\r
-  LangIdTable = NULL;\r
-  Status = UsbIo->UsbGetSupportedLanguages (UsbIo, &LangIdTable, &TableSize);\r
-  if (EFI_ERROR (Status) || (TableSize == 0) || (LangIdTable == NULL)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Serial number in USB WWID device path is the last 64-or-less UTF-16 characters.\r
-  //\r
-  CompareStr = (CHAR16 *) (UINTN) (UsbWwid + 1);\r
-  CompareLen = (DevicePathNodeLength (UsbWwid) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16);\r
-  if (CompareStr[CompareLen - 1] == L'\0') {\r
-    CompareLen--;\r
-  }\r
-\r
-  //\r
-  // Compare serial number in each supported language.\r
-  //\r
-  for (Index = 0; Index < TableSize / sizeof (UINT16); Index++) {\r
-    SerialNumberStr = NULL;\r
-    Status = UsbIo->UsbGetStringDescriptor (\r
-                      UsbIo,\r
-                      LangIdTable[Index],\r
-                      DevDesc.StrSerialNumber,\r
-                      &SerialNumberStr\r
-                      );\r
-    if (EFI_ERROR (Status) || (SerialNumberStr == NULL)) {\r
-      continue;\r
-    }\r
-\r
-    Length = StrLen (SerialNumberStr);\r
-    if ((Length >= CompareLen) &&\r
-        (CompareMem (SerialNumberStr + Length - CompareLen, CompareStr, CompareLen * sizeof (CHAR16)) == 0)) {\r
-      FreePool (SerialNumberStr);\r
-      return TRUE;\r
-    }\r
-\r
-    FreePool (SerialNumberStr);\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Find a USB device path which match the specified short-form device path start\r
-  with USB Class or USB WWID device path and load the boot file then return the\r
-  image handle. If ParentDevicePath is NULL, this function will search in all USB\r
-  devices of the platform. If ParentDevicePath is not NULL,this function will only\r
-  search in its child devices.\r
-\r
-  @param ParentDevicePath      The device path of the parent.\r
-  @param ShortFormDevicePath   The USB Class or USB WWID device path to match.\r
-\r
-  @return  The image Handle if find load file from specified short-form device path\r
-           or NULL if not found.\r
-\r
-**/\r
-EFI_HANDLE *\r
-BdsFindUsbDevice (\r
-  IN EFI_DEVICE_PATH_PROTOCOL   *ParentDevicePath,\r
-  IN EFI_DEVICE_PATH_PROTOCOL   *ShortFormDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  UINTN                     UsbIoHandleCount;\r
-  EFI_HANDLE                *UsbIoHandleBuffer;\r
-  EFI_DEVICE_PATH_PROTOCOL  *UsbIoDevicePath;\r
-  EFI_USB_IO_PROTOCOL       *UsbIo;\r
-  UINTN                     Index;\r
-  UINTN                     ParentSize;\r
-  UINTN                     Size;\r
-  EFI_HANDLE                ImageHandle;\r
-  EFI_HANDLE                Handle;\r
-  EFI_DEVICE_PATH_PROTOCOL  *FullDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NextDevicePath;\r
-\r
-  FullDevicePath = NULL;\r
-  ImageHandle    = NULL;\r
-\r
-  //\r
-  // Get all UsbIo Handles.\r
-  //\r
-  UsbIoHandleCount = 0;\r
-  UsbIoHandleBuffer = NULL;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiUsbIoProtocolGuid,\r
-                  NULL,\r
-                  &UsbIoHandleCount,\r
-                  &UsbIoHandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status) || (UsbIoHandleCount == 0) || (UsbIoHandleBuffer == NULL)) {\r
-    return NULL;\r
-  }\r
-\r
-  ParentSize = (ParentDevicePath == NULL) ? 0 : GetDevicePathSize (ParentDevicePath);\r
-  for (Index = 0; Index < UsbIoHandleCount; Index++) {\r
-    //\r
-    // Get the Usb IO interface.\r
-    //\r
-    Status = gBS->HandleProtocol(\r
-                    UsbIoHandleBuffer[Index],\r
-                    &gEfiUsbIoProtocolGuid,\r
-                    (VOID **) &UsbIo\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    UsbIoDevicePath = DevicePathFromHandle (UsbIoHandleBuffer[Index]);\r
-    if (UsbIoDevicePath == NULL) {\r
-      continue;\r
-    }\r
-\r
-    if (ParentDevicePath != NULL) {\r
-      //\r
-      // Compare starting part of UsbIoHandle's device path with ParentDevicePath.\r
-      //\r
-      Size = GetDevicePathSize (UsbIoDevicePath);\r
-      if ((Size < ParentSize) ||\r
-          (CompareMem (UsbIoDevicePath, ParentDevicePath, ParentSize - END_DEVICE_PATH_LENGTH) != 0)) {\r
-        continue;\r
-      }\r
-    }\r
-\r
-    if (BdsMatchUsbClass (UsbIo, (USB_CLASS_DEVICE_PATH *) ShortFormDevicePath) ||\r
-        BdsMatchUsbWwid (UsbIo, (USB_WWID_DEVICE_PATH *) ShortFormDevicePath)) {\r
-      //\r
-      // Try to find if there is the boot file in this DevicePath\r
-      //\r
-      NextDevicePath = NextDevicePathNode (ShortFormDevicePath);\r
-      if (!IsDevicePathEnd (NextDevicePath)) {\r
-        FullDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePath);\r
-        //\r
-        // Connect the full device path, so that Simple File System protocol\r
-        // could be installed for this USB device.\r
-        //\r
-        BdsLibConnectDevicePath (FullDevicePath);\r
-        REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderLoad));\r
-        Status = gBS->LoadImage (\r
-                       TRUE,\r
-                       gImageHandle,\r
-                       FullDevicePath,\r
-                       NULL,\r
-                       0,\r
-                       &ImageHandle\r
-                       );\r
-        FreePool (FullDevicePath);\r
-      } else {\r
-        FullDevicePath = UsbIoDevicePath;\r
-        Status = EFI_NOT_FOUND;\r
-      }\r
-\r
-      //\r
-      // If we didn't find an image directly, we need to try as if it is a removable device boot option\r
-      // and load the image according to the default boot behavior for removable device.\r
-      //\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // check if there is a bootable removable media could be found in this device path ,\r
-        // and get the bootable media handle\r
-        //\r
-        Handle = BdsLibGetBootableHandle(UsbIoDevicePath);\r
-        if (Handle == NULL) {\r
-          continue;\r
-        }\r
-        //\r
-        // Load the default boot file \EFI\BOOT\boot{machinename}.EFI from removable Media\r
-        //  machinename is ia32, ia64, x64, ...\r
-        //\r
-        FullDevicePath = FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
-        if (FullDevicePath != NULL) {\r
-          REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderLoad));\r
-          Status = gBS->LoadImage (\r
-                          TRUE,\r
-                          gImageHandle,\r
-                          FullDevicePath,\r
-                          NULL,\r
-                          0,\r
-                          &ImageHandle\r
-                          );\r
-          if (EFI_ERROR (Status)) {\r
-            //\r
-            // The DevicePath failed, and it's not a valid\r
-            // removable media device.\r
-            //\r
-            continue;\r
-          }\r
-        } else {\r
-          continue;\r
-        }\r
-      }\r
-      break;\r
-    }\r
-  }\r
-\r
-  FreePool (UsbIoHandleBuffer);\r
-  return ImageHandle;\r
-}\r
-\r
-/**\r
-  Expand USB Class or USB WWID device path node to be full device path of a USB\r
-  device in platform then load the boot file on this full device path and return the\r
-  image handle.\r
-\r
-  This function support following 4 cases:\r
-  1) Boot Option device path starts with a USB Class or USB WWID device path,\r
-     and there is no Media FilePath device path in the end.\r
-     In this case, it will follow Removable Media Boot Behavior.\r
-  2) Boot Option device path starts with a USB Class or USB WWID device path,\r
-     and ended with Media FilePath device path.\r
-  3) Boot Option device path starts with a full device path to a USB Host Controller,\r
-     contains a USB Class or USB WWID device path node, while not ended with Media\r
-     FilePath device path. In this case, it will follow Removable Media Boot Behavior.\r
-  4) Boot Option device path starts with a full device path to a USB Host Controller,\r
-     contains a USB Class or USB WWID device path node, and ended with Media\r
-     FilePath device path.\r
-\r
-  @param  DevicePath    The Boot Option device path.\r
-\r
-  @return  The image handle of boot file, or NULL if there is no boot file found in\r
-           the specified USB Class or USB WWID device path.\r
-\r
-**/\r
-EFI_HANDLE *\r
-BdsExpandUsbShortFormDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *DevicePath\r
-  )\r
-{\r
-  EFI_HANDLE                *ImageHandle;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ShortFormDevicePath;\r
-\r
-  //\r
-  // Search for USB Class or USB WWID device path node.\r
-  //\r
-  ShortFormDevicePath = NULL;\r
-  ImageHandle         = NULL;\r
-  TempDevicePath      = DevicePath;\r
-  while (!IsDevicePathEnd (TempDevicePath)) {\r
-    if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) &&\r
-        ((DevicePathSubType (TempDevicePath) == MSG_USB_CLASS_DP) ||\r
-         (DevicePathSubType (TempDevicePath) == MSG_USB_WWID_DP))) {\r
-      ShortFormDevicePath = TempDevicePath;\r
-      break;\r
-    }\r
-    TempDevicePath = NextDevicePathNode (TempDevicePath);\r
-  }\r
-\r
-  if (ShortFormDevicePath == NULL) {\r
-    //\r
-    // No USB Class or USB WWID device path node found, do nothing.\r
-    //\r
-    return NULL;\r
-  }\r
-\r
-  if (ShortFormDevicePath == DevicePath) {\r
-    //\r
-    // Boot Option device path starts with USB Class or USB WWID device path.\r
-    //\r
-    ImageHandle = BdsFindUsbDevice (NULL, ShortFormDevicePath);\r
-    if (ImageHandle == NULL) {\r
-      //\r
-      // Failed to find a match in existing devices, connect the short form USB\r
-      // device path and try again.\r
-      //\r
-      BdsLibConnectUsbDevByShortFormDP (0xff, ShortFormDevicePath);\r
-      ImageHandle = BdsFindUsbDevice (NULL, ShortFormDevicePath);\r
-    }\r
-  } else {\r
-    //\r
-    // Boot Option device path contains USB Class or USB WWID device path node.\r
-    //\r
-\r
-    //\r
-    // Prepare the parent device path for search.\r
-    //\r
-    TempDevicePath = DuplicateDevicePath (DevicePath);\r
-    ASSERT (TempDevicePath != NULL);\r
-    SetDevicePathEndNode (((UINT8 *) TempDevicePath) + ((UINTN) ShortFormDevicePath - (UINTN) DevicePath));\r
-\r
-    //\r
-    // The USB Host Controller device path is already in Boot Option device path\r
-    // and USB Bus driver already support RemainingDevicePath starts with USB\r
-    // Class or USB WWID device path, so just search in existing USB devices and\r
-    // doesn't perform ConnectController here.\r
-    //\r
-    ImageHandle = BdsFindUsbDevice (TempDevicePath, ShortFormDevicePath);\r
-    FreePool (TempDevicePath);\r
-  }\r
-\r
-  return ImageHandle;\r
-}\r
-\r
-/**\r
-  Process the boot option follow the UEFI specification and\r
-  special treat the legacy boot option with BBS_DEVICE_PATH.\r
-\r
-  @param  Option                 The boot option need to be processed\r
-  @param  DevicePath             The device path which describe where to load the\r
-                                 boot image or the legacy BBS device path to boot\r
-                                 the legacy OS\r
-  @param  ExitDataSize           The size of exit data.\r
-  @param  ExitData               Data returned when Boot image failed.\r
-\r
-  @retval EFI_SUCCESS            Boot from the input boot option successfully.\r
-  @retval EFI_NOT_FOUND          If the Device Path is not found in the system\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibBootViaBootOption (\r
-  IN  BDS_COMMON_OPTION             *Option,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL      *DevicePath,\r
-  OUT UINTN                         *ExitDataSize,\r
-  OUT CHAR16                        **ExitData OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_STATUS                StatusLogo;\r
-  EFI_HANDLE                Handle;\r
-  EFI_HANDLE                ImageHandle;\r
-  EFI_DEVICE_PATH_PROTOCOL  *FilePath;\r
-  EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
-  EFI_DEVICE_PATH_PROTOCOL  *WorkingDevicePath;\r
-  LIST_ENTRY                TempBootLists;\r
-  EFI_BOOT_LOGO_PROTOCOL    *BootLogo;\r
-\r
-  Status        = EFI_SUCCESS;\r
-  *ExitDataSize = 0;\r
-  *ExitData     = NULL;\r
-\r
-  //\r
-  // If it's Device Path that starts with a hard drive path, append it with the front part to compose a\r
-  // full device path\r
-  //\r
-  WorkingDevicePath = NULL;\r
-  if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) &&\r
-      (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)) {\r
-    WorkingDevicePath = BdsExpandPartitionPartialDevicePathToFull (\r
-                          (HARDDRIVE_DEVICE_PATH *)DevicePath\r
-                          );\r
-    if (WorkingDevicePath != NULL) {\r
-      DevicePath = WorkingDevicePath;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Set Boot Current\r
-  //\r
-  if (IsBootOptionValidNVVarialbe (Option)) {\r
-    //\r
-    // For a temporary boot (i.e. a boot by selected a EFI Shell using "Boot From File"), Boot Current is actually not valid.\r
-    // In this case, "BootCurrent" is not created.\r
-    // Only create the BootCurrent variable when it points to a valid Boot#### variable.\r
-    //\r
-    SetVariableAndReportStatusCodeOnError (\r
-          L"BootCurrent",\r
-          &gEfiGlobalVariableGuid,\r
-          EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-          sizeof (UINT16),\r
-          &Option->BootCurrent\r
-          );\r
-  }\r
-\r
-  //\r
-  // Signal the EVT_SIGNAL_READY_TO_BOOT event\r
-  //\r
-  EfiSignalEventReadyToBoot();\r
-\r
-  //\r
-  // Report Status Code to indicate ReadyToBoot event was signalled\r
-  //\r
-  REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT));\r
-\r
-  //\r
-  // Expand USB Class or USB WWID device path node to be full device path of a USB\r
-  // device in platform then load the boot file on this full device path and get the\r
-  // image handle.\r
-  //\r
-  ImageHandle = BdsExpandUsbShortFormDevicePath (DevicePath);\r
-\r
-  //\r
-  // Adjust the different type memory page number just before booting\r
-  // and save the updated info into the variable for next boot to use\r
-  //\r
-  BdsSetMemoryTypeInformationVariable ();\r
-\r
-  //\r
-  // By expanding the USB Class or WWID device path, the ImageHandle has returnned.\r
-  // Here get the ImageHandle for the non USB class or WWID device path.\r
-  //\r
-  if (ImageHandle == NULL) {\r
-    ASSERT (Option->DevicePath != NULL);\r
-    if ((DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) &&\r
-        (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP)\r
-       ) {\r
-      //\r
-      // Check to see if we should legacy BOOT. If yes then do the legacy boot\r
-      //\r
-      return BdsLibDoLegacyBoot (Option);\r
-    }\r
-\r
-    //\r
-    // If the boot option point to Internal FV shell, make sure it is valid\r
-    //\r
-    Status = BdsLibUpdateFvFileDevicePath (&DevicePath, PcdGetPtr(PcdShellFile));\r
-    if (!EFI_ERROR(Status)) {\r
-      if (Option->DevicePath != NULL) {\r
-        FreePool(Option->DevicePath);\r
-      }\r
-      Option->DevicePath  = AllocateZeroPool (GetDevicePathSize (DevicePath));\r
-      ASSERT(Option->DevicePath != NULL);\r
-      CopyMem (Option->DevicePath, DevicePath, GetDevicePathSize (DevicePath));\r
-      //\r
-      // Update the shell boot option\r
-      //\r
-      InitializeListHead (&TempBootLists);\r
-      BdsLibRegisterNewOption (&TempBootLists, DevicePath, L"EFI Internal Shell", L"BootOrder");\r
-\r
-      //\r
-      // free the temporary device path created by BdsLibUpdateFvFileDevicePath()\r
-      //\r
-      FreePool (DevicePath);\r
-      DevicePath = Option->DevicePath;\r
-    }\r
-\r
-    DEBUG_CODE_BEGIN();\r
-\r
-    if (Option->Description == NULL) {\r
-      DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Booting from unknown device path\n"));\r
-    } else {\r
-      DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Booting %S\n", Option->Description));\r
-    }\r
-\r
-    DEBUG_CODE_END();\r
-\r
-    //\r
-    // Report status code for OS Loader LoadImage.\r
-    //\r
-    REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderLoad));\r
-    Status = gBS->LoadImage (\r
-                    TRUE,\r
-                    gImageHandle,\r
-                    DevicePath,\r
-                    NULL,\r
-                    0,\r
-                    &ImageHandle\r
-                    );\r
-\r
-    //\r
-    // If we didn't find an image directly, we need to try as if it is a removable device boot option\r
-    // and load the image according to the default boot behavior for removable device.\r
-    //\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // check if there is a bootable removable media could be found in this device path ,\r
-      // and get the bootable media handle\r
-      //\r
-      Handle = BdsLibGetBootableHandle(DevicePath);\r
-      if (Handle != NULL) {\r
-        //\r
-        // Load the default boot file \EFI\BOOT\boot{machinename}.EFI from removable Media\r
-        //  machinename is ia32, ia64, x64, ...\r
-        //\r
-        FilePath = FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
-        if (FilePath != NULL) {\r
-          REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderLoad));\r
-          Status = gBS->LoadImage (\r
-                          TRUE,\r
-                          gImageHandle,\r
-                          FilePath,\r
-                          NULL,\r
-                          0,\r
-                          &ImageHandle\r
-                          );\r
-        }\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Provide the image with it's load options\r
-  //\r
-  if ((ImageHandle == NULL) || (EFI_ERROR(Status))) {\r
-    //\r
-    // Report Status Code to indicate that the failure to load boot option\r
-    //\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR)\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &ImageInfo);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  if (Option->LoadOptionsSize != 0) {\r
-    ImageInfo->LoadOptionsSize  = Option->LoadOptionsSize;\r
-    ImageInfo->LoadOptions      = Option->LoadOptions;\r
-  }\r
-\r
-  //\r
-  // Clean to NULL because the image is loaded directly from the firmwares boot manager.\r
-  //\r
-  ImageInfo->ParentHandle = NULL;\r
-\r
-  //\r
-  // Before calling the image, enable the Watchdog Timer for\r
-  // the 5 Minute period\r
-  //\r
-  gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
-\r
-  //\r
-  // Write boot to OS performance data for UEFI boot\r
-  //\r
-  PERF_CODE (\r
-    BmEndOfBdsPerfCode (NULL, NULL);\r
-  );\r
-\r
-  //\r
-  // Report status code for OS Loader StartImage.\r
-  //\r
-  REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderStart));\r
-\r
-  Status = gBS->StartImage (ImageHandle, ExitDataSize, ExitData);\r
-  DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Image Return Status = %r\n", Status));\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Report Status Code to indicate that boot failure\r
-    //\r
-    REPORT_STATUS_CODE (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED)\r
-      );\r
-  }\r
-\r
-  //\r
-  // Clear the Watchdog Timer after the image returns\r
-  //\r
-  gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
-\r
-Done:\r
-  //\r
-  // Set Logo status invalid after trying one boot option\r
-  //\r
-  BootLogo = NULL;\r
-  StatusLogo = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);\r
-  if (!EFI_ERROR (StatusLogo) && (BootLogo != NULL)) {\r
-    BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);\r
-  }\r
-\r
-  //\r
-  // Clear Boot Current\r
-  // Deleting variable with current implementation shouldn't fail.\r
-  //\r
-  gRT->SetVariable (\r
-        L"BootCurrent",\r
-        &gEfiGlobalVariableGuid,\r
-        EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-        0,\r
-        NULL\r
-        );\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Expand a device path that starts with a hard drive media device path node to be a\r
-  full device path that includes the full hardware path to the device. We need\r
-  to do this so it can be booted. As an optimization the front match (the part point\r
-  to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ) is saved in a variable\r
-  so a connect all is not required on every boot. All successful history device path\r
-  which point to partition node (the front part) will be saved.\r
-\r
-  @param  HardDriveDevicePath    EFI Device Path to boot, if it starts with a hard\r
-                                 drive media device path.\r
-  @return A Pointer to the full device path or NULL if a valid Hard Drive devic path\r
-          cannot be found.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-BdsExpandPartitionPartialDevicePathToFull (\r
-  IN  HARDDRIVE_DEVICE_PATH      *HardDriveDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  UINTN                     BlockIoHandleCount;\r
-  EFI_HANDLE                *BlockIoBuffer;\r
-  EFI_DEVICE_PATH_PROTOCOL  *FullDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *BlockIoDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  UINTN                     Index;\r
-  UINTN                     InstanceNum;\r
-  EFI_DEVICE_PATH_PROTOCOL  *CachedDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempNewDevicePath;\r
-  UINTN                     CachedDevicePathSize;\r
-  BOOLEAN                   DeviceExist;\r
-  BOOLEAN                   NeedAdjust;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
-  UINTN                     Size;\r
-\r
-  FullDevicePath = NULL;\r
-  //\r
-  // Check if there is prestore HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable.\r
-  // If exist, search the front path which point to partition node in the variable instants.\r
-  // If fail to find or HD_BOOT_DEVICE_PATH_VARIABLE_NAME not exist, reconnect all and search in all system\r
-  //\r
-  GetVariable2 (\r
-    HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
-    &gHdBootDevicePathVariablGuid,\r
-    (VOID **) &CachedDevicePath,\r
-    &CachedDevicePathSize\r
-    );\r
-\r
-  //\r
-  // Delete the invalid HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable.\r
-  //\r
-  if ((CachedDevicePath != NULL) && !IsDevicePathValid (CachedDevicePath, CachedDevicePathSize)) {\r
-    FreePool (CachedDevicePath);\r
-    CachedDevicePath = NULL;\r
-    Status = gRT->SetVariable (\r
-                    HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
-                    &gHdBootDevicePathVariablGuid,\r
-                    0,\r
-                    0,\r
-                    NULL\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  if (CachedDevicePath != NULL) {\r
-    TempNewDevicePath = CachedDevicePath;\r
-    DeviceExist = FALSE;\r
-    NeedAdjust = FALSE;\r
-    do {\r
-      //\r
-      // Check every instance of the variable\r
-      // First, check whether the instance contain the partition node, which is needed for distinguishing  multi\r
-      // partial partition boot option. Second, check whether the instance could be connected.\r
-      //\r
-      Instance  = GetNextDevicePathInstance (&TempNewDevicePath, &Size);\r
-      if (MatchPartitionDevicePathNode (Instance, HardDriveDevicePath)) {\r
-        //\r
-        // Connect the device path instance, the device path point to hard drive media device path node\r
-        // e.g. ACPI() /PCI()/ATA()/Partition()\r
-        //\r
-        Status = BdsLibConnectDevicePath (Instance);\r
-        if (!EFI_ERROR (Status)) {\r
-          DeviceExist = TRUE;\r
-          break;\r
-        }\r
-      }\r
-      //\r
-      // Come here means the first instance is not matched\r
-      //\r
-      NeedAdjust = TRUE;\r
-      FreePool(Instance);\r
-    } while (TempNewDevicePath != NULL);\r
-\r
-    if (DeviceExist) {\r
-      //\r
-      // Find the matched device path.\r
-      // Append the file path information from the boot option and return the fully expanded device path.\r
-      //\r
-      DevicePath     = NextDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
-      FullDevicePath = AppendDevicePath (Instance, DevicePath);\r
-\r
-      //\r
-      // Adjust the HD_BOOT_DEVICE_PATH_VARIABLE_NAME instances sequence if the matched one is not first one.\r
-      //\r
-      if (NeedAdjust) {\r
-        //\r
-        // First delete the matched instance.\r
-        //\r
-        TempNewDevicePath = CachedDevicePath;\r
-        CachedDevicePath  = BdsLibDelPartMatchInstance (CachedDevicePath, Instance );\r
-        FreePool (TempNewDevicePath);\r
-\r
-        //\r
-        // Second, append the remaining path after the matched instance\r
-        //\r
-        TempNewDevicePath = CachedDevicePath;\r
-        CachedDevicePath = AppendDevicePathInstance (Instance, CachedDevicePath );\r
-        FreePool (TempNewDevicePath);\r
-        //\r
-        // Save the matching Device Path so we don't need to do a connect all next time\r
-        // Failure to set the variable only impacts the performance when next time expanding the short-form device path.\r
-        //\r
-        Status = gRT->SetVariable (\r
-                        HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
-                        &gHdBootDevicePathVariablGuid,\r
-                        EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                        GetDevicePathSize (CachedDevicePath),\r
-                        CachedDevicePath\r
-                        );\r
-      }\r
-\r
-      FreePool (Instance);\r
-      FreePool (CachedDevicePath);\r
-      return FullDevicePath;\r
-    }\r
-  }\r
-\r
-  //\r
-  // If we get here we fail to find or HD_BOOT_DEVICE_PATH_VARIABLE_NAME not exist, and now we need\r
-  // to search all devices in the system for a matched partition\r
-  //\r
-  BdsLibConnectAllDriversToAllControllers ();\r
-  Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlockIoHandleCount, &BlockIoBuffer);\r
-  if (EFI_ERROR (Status) || BlockIoHandleCount == 0 || BlockIoBuffer == NULL) {\r
-    //\r
-    // If there was an error or there are no device handles that support\r
-    // the BLOCK_IO Protocol, then return.\r
-    //\r
-    return NULL;\r
-  }\r
-  //\r
-  // Loop through all the device handles that support the BLOCK_IO Protocol\r
-  //\r
-  for (Index = 0; Index < BlockIoHandleCount; Index++) {\r
-\r
-    Status = gBS->HandleProtocol (BlockIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *) &BlockIoDevicePath);\r
-    if (EFI_ERROR (Status) || BlockIoDevicePath == NULL) {\r
-      continue;\r
-    }\r
-\r
-    if (MatchPartitionDevicePathNode (BlockIoDevicePath, HardDriveDevicePath)) {\r
-      //\r
-      // Find the matched partition device path\r
-      //\r
-      DevicePath    = NextDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
-      FullDevicePath = AppendDevicePath (BlockIoDevicePath, DevicePath);\r
-\r
-      //\r
-      // Save the matched partition device path in HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable\r
-      //\r
-      if (CachedDevicePath != NULL) {\r
-        //\r
-        // Save the matched partition device path as first instance of HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable\r
-        //\r
-        if (BdsLibMatchDevicePaths (CachedDevicePath, BlockIoDevicePath)) {\r
-          TempNewDevicePath = CachedDevicePath;\r
-          CachedDevicePath = BdsLibDelPartMatchInstance (CachedDevicePath, BlockIoDevicePath);\r
-          FreePool(TempNewDevicePath);\r
-        }\r
-\r
-        if (CachedDevicePath != NULL) {\r
-          TempNewDevicePath = CachedDevicePath;\r
-          CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath);\r
-          FreePool(TempNewDevicePath);\r
-        } else {\r
-          CachedDevicePath = DuplicateDevicePath (BlockIoDevicePath);\r
-        }\r
-\r
-        //\r
-        // Here limit the device path instance number to 12, which is max number for a system support 3 IDE controller\r
-        // If the user try to boot many OS in different HDs or partitions, in theory,\r
-        // the HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable maybe become larger and larger.\r
-        //\r
-        InstanceNum = 0;\r
-        ASSERT (CachedDevicePath != NULL);\r
-        TempNewDevicePath = CachedDevicePath;\r
-        while (!IsDevicePathEnd (TempNewDevicePath)) {\r
-          TempNewDevicePath = NextDevicePathNode (TempNewDevicePath);\r
-          //\r
-          // Parse one instance\r
-          //\r
-          while (!IsDevicePathEndType (TempNewDevicePath)) {\r
-            TempNewDevicePath = NextDevicePathNode (TempNewDevicePath);\r
-          }\r
-          InstanceNum++;\r
-          //\r
-          // If the CachedDevicePath variable contain too much instance, only remain 12 instances.\r
-          //\r
-          if (InstanceNum >= 12) {\r
-            SetDevicePathEndNode (TempNewDevicePath);\r
-            break;\r
-          }\r
-        }\r
-      } else {\r
-        CachedDevicePath = DuplicateDevicePath (BlockIoDevicePath);\r
-      }\r
-\r
-      //\r
-      // Save the matching Device Path so we don't need to do a connect all next time\r
-      // Failure to set the variable only impacts the performance when next time expanding the short-form device path.\r
-      //\r
-      Status = gRT->SetVariable (\r
-                      HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
-                      &gHdBootDevicePathVariablGuid,\r
-                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                      GetDevicePathSize (CachedDevicePath),\r
-                      CachedDevicePath\r
-                      );\r
-\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (CachedDevicePath != NULL) {\r
-    FreePool (CachedDevicePath);\r
-  }\r
-  if (BlockIoBuffer != NULL) {\r
-    FreePool (BlockIoBuffer);\r
-  }\r
-  return FullDevicePath;\r
-}\r
-\r
-/**\r
-  Check whether there is a instance in BlockIoDevicePath, which contain multi device path\r
-  instances, has the same partition node with HardDriveDevicePath device path\r
-\r
-  @param  BlockIoDevicePath      Multi device path instances which need to check\r
-  @param  HardDriveDevicePath    A device path which starts with a hard drive media\r
-                                 device path.\r
-\r
-  @retval TRUE                   There is a matched device path instance.\r
-  @retval FALSE                  There is no matched device path instance.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-MatchPartitionDevicePathNode (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL   *BlockIoDevicePath,\r
-  IN  HARDDRIVE_DEVICE_PATH      *HardDriveDevicePath\r
-  )\r
-{\r
-  HARDDRIVE_DEVICE_PATH     *TmpHdPath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  BOOLEAN                   Match;\r
-  EFI_DEVICE_PATH_PROTOCOL  *BlockIoHdDevicePathNode;\r
-\r
-  if ((BlockIoDevicePath == NULL) || (HardDriveDevicePath == NULL)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Make PreviousDevicePath == the device path node before the end node\r
-  //\r
-  DevicePath              = BlockIoDevicePath;\r
-  BlockIoHdDevicePathNode = NULL;\r
-\r
-  //\r
-  // find the partition device path node\r
-  //\r
-  while (!IsDevicePathEnd (DevicePath)) {\r
-    if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) &&\r
-        (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)\r
-        ) {\r
-      BlockIoHdDevicePathNode = DevicePath;\r
-      break;\r
-    }\r
-\r
-    DevicePath = NextDevicePathNode (DevicePath);\r
-  }\r
-\r
-  if (BlockIoHdDevicePathNode == NULL) {\r
-    return FALSE;\r
-  }\r
-  //\r
-  // See if the harddrive device path in blockio matches the orig Hard Drive Node\r
-  //\r
-  TmpHdPath = (HARDDRIVE_DEVICE_PATH *) BlockIoHdDevicePathNode;\r
-  Match = FALSE;\r
-\r
-  //\r
-  // Check for the match\r
-  //\r
-  if ((TmpHdPath->MBRType == HardDriveDevicePath->MBRType) &&\r
-      (TmpHdPath->SignatureType == HardDriveDevicePath->SignatureType)) {\r
-    switch (TmpHdPath->SignatureType) {\r
-    case SIGNATURE_TYPE_GUID:\r
-      Match = CompareGuid ((EFI_GUID *)TmpHdPath->Signature, (EFI_GUID *)HardDriveDevicePath->Signature);\r
-      break;\r
-    case SIGNATURE_TYPE_MBR:\r
-      Match = (BOOLEAN)(*((UINT32 *)(&(TmpHdPath->Signature[0]))) == ReadUnaligned32((UINT32 *)(&(HardDriveDevicePath->Signature[0]))));\r
-      break;\r
-    default:\r
-      Match = FALSE;\r
-      break;\r
-    }\r
-  }\r
-\r
-  return Match;\r
-}\r
-\r
-/**\r
-  Delete the boot option associated with the handle passed in.\r
-\r
-  @param  Handle                 The handle which present the device path to create\r
-                                 boot option\r
-\r
-  @retval EFI_SUCCESS            Delete the boot option success\r
-  @retval EFI_NOT_FOUND          If the Device Path is not found in the system\r
-  @retval EFI_OUT_OF_RESOURCES   Lack of memory resource\r
-  @retval Other                  Error return value from SetVariable()\r
-\r
-**/\r
-EFI_STATUS\r
-BdsLibDeleteOptionFromHandle (\r
-  IN  EFI_HANDLE                 Handle\r
-  )\r
-{\r
-  UINT16                    *BootOrder;\r
-  UINT8                     *BootOptionVar;\r
-  UINTN                     BootOrderSize;\r
-  UINTN                     BootOptionSize;\r
-  EFI_STATUS                Status;\r
-  UINTN                     Index;\r
-  UINT16                    BootOption[BOOT_OPTION_MAX_CHAR];\r
-  UINTN                     DevicePathSize;\r
-  UINTN                     OptionDevicePathSize;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *OptionDevicePath;\r
-  UINT8                     *TempPtr;\r
-\r
-  Status        = EFI_SUCCESS;\r
-  BootOrder     = NULL;\r
-  BootOrderSize = 0;\r
-\r
-  //\r
-  // Check "BootOrder" variable, if no, means there is no any boot order.\r
-  //\r
-  BootOrder = BdsLibGetVariableAndSize (\r
-                L"BootOrder",\r
-                &gEfiGlobalVariableGuid,\r
-                &BootOrderSize\r
-                );\r
-  if (BootOrder == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Convert device handle to device path protocol instance\r
-  //\r
-  DevicePath = DevicePathFromHandle (Handle);\r
-  if (DevicePath == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  DevicePathSize = GetDevicePathSize (DevicePath);\r
-\r
-  //\r
-  // Loop all boot order variable and find the matching device path\r
-  //\r
-  Index = 0;\r
-  while (Index < BootOrderSize / sizeof (UINT16)) {\r
-    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
-    BootOptionVar = BdsLibGetVariableAndSize (\r
-                      BootOption,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &BootOptionSize\r
-                      );\r
-\r
-    if (BootOptionVar == NULL) {\r
-      FreePool (BootOrder);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    if (!ValidateOption(BootOptionVar, BootOptionSize)) {\r
-      BdsDeleteBootOption (BootOrder[Index], BootOrder, &BootOrderSize);\r
-      FreePool (BootOptionVar);\r
-      Index++;\r
-      continue;\r
-    }\r
-\r
-    TempPtr = BootOptionVar;\r
-    TempPtr += sizeof (UINT32) + sizeof (UINT16);\r
-    TempPtr += StrSize ((CHAR16 *) TempPtr);\r
-    OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
-    OptionDevicePathSize = GetDevicePathSize (OptionDevicePath);\r
-\r
-    //\r
-    // Check whether the device path match\r
-    //\r
-    if ((OptionDevicePathSize == DevicePathSize) &&\r
-        (CompareMem (DevicePath, OptionDevicePath, DevicePathSize) == 0)) {\r
-      BdsDeleteBootOption (BootOrder[Index], BootOrder, &BootOrderSize);\r
-      FreePool (BootOptionVar);\r
-      break;\r
-    }\r
-\r
-    FreePool (BootOptionVar);\r
-    Index++;\r
-  }\r
-\r
-  //\r
-  // Adjust number of boot option for "BootOrder" variable.\r
-  //\r
-  Status = gRT->SetVariable (\r
-                  L"BootOrder",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  BootOrderSize,\r
-                  BootOrder\r
-                  );\r
-  //\r
-  // Shrinking variable with existing variable implementation shouldn't fail.\r
-  //\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  FreePool (BootOrder);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Delete all invalid EFI boot options.\r
-\r
-  @retval EFI_SUCCESS            Delete all invalid boot option success\r
-  @retval EFI_NOT_FOUND          Variable "BootOrder" is not found\r
-  @retval EFI_OUT_OF_RESOURCES   Lack of memory resource\r
-  @retval Other                  Error return value from SetVariable()\r
-\r
-**/\r
-EFI_STATUS\r
-BdsDeleteAllInvalidEfiBootOption (\r
-  VOID\r
-  )\r
-{\r
-  UINT16                    *BootOrder;\r
-  UINT8                     *BootOptionVar;\r
-  UINTN                     BootOrderSize;\r
-  UINTN                     BootOptionSize;\r
-  EFI_STATUS                Status;\r
-  UINTN                     Index;\r
-  UINTN                     Index2;\r
-  UINT16                    BootOption[BOOT_OPTION_MAX_CHAR];\r
-  EFI_DEVICE_PATH_PROTOCOL  *OptionDevicePath;\r
-  UINT8                     *TempPtr;\r
-  CHAR16                    *Description;\r
-  BOOLEAN                   Corrupted;\r
-\r
-  Status           = EFI_SUCCESS;\r
-  BootOrder        = NULL;\r
-  Description      = NULL;\r
-  OptionDevicePath = NULL;\r
-  BootOrderSize    = 0;\r
-  Corrupted        = FALSE;\r
-\r
-  //\r
-  // Check "BootOrder" variable firstly, this variable hold the number of boot options\r
-  //\r
-  BootOrder = BdsLibGetVariableAndSize (\r
-                L"BootOrder",\r
-                &gEfiGlobalVariableGuid,\r
-                &BootOrderSize\r
-                );\r
-  if (NULL == BootOrder) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  Index = 0;\r
-  while (Index < BootOrderSize / sizeof (UINT16)) {\r
-    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
-    BootOptionVar = BdsLibGetVariableAndSize (\r
-                      BootOption,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &BootOptionSize\r
-                      );\r
-    if (NULL == BootOptionVar) {\r
-      FreePool (BootOrder);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    if (!ValidateOption(BootOptionVar, BootOptionSize)) {\r
-      Corrupted = TRUE;\r
-    } else {\r
-      TempPtr = BootOptionVar;\r
-      TempPtr += sizeof (UINT32) + sizeof (UINT16);\r
-      Description = (CHAR16 *) TempPtr;\r
-      TempPtr += StrSize ((CHAR16 *) TempPtr);\r
-      OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
-\r
-      //\r
-      // Skip legacy boot option (BBS boot device)\r
-      //\r
-      if ((DevicePathType (OptionDevicePath) == BBS_DEVICE_PATH) &&\r
-          (DevicePathSubType (OptionDevicePath) == BBS_BBS_DP)) {\r
-        FreePool (BootOptionVar);\r
-        Index++;\r
-        continue;\r
-      }\r
-    }\r
-\r
-    if (Corrupted || !BdsLibIsValidEFIBootOptDevicePathExt (OptionDevicePath, FALSE, Description)) {\r
-      //\r
-      // Delete this invalid boot option "Boot####"\r
-      //\r
-      Status = gRT->SetVariable (\r
-                      BootOption,\r
-                      &gEfiGlobalVariableGuid,\r
-                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                      0,\r
-                      NULL\r
-                      );\r
-      //\r
-      // Deleting variable with current variable implementation shouldn't fail.\r
-      //\r
-      ASSERT_EFI_ERROR (Status);\r
-      //\r
-      // Mark this boot option in boot order as deleted\r
-      //\r
-      BootOrder[Index] = 0xffff;\r
-      Corrupted        = FALSE;\r
-    }\r
-\r
-    FreePool (BootOptionVar);\r
-    Index++;\r
-  }\r
-\r
-  //\r
-  // Adjust boot order array\r
-  //\r
-  Index2 = 0;\r
-  for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
-    if (BootOrder[Index] != 0xffff) {\r
-      BootOrder[Index2] = BootOrder[Index];\r
-      Index2 ++;\r
-    }\r
-  }\r
-  Status = gRT->SetVariable (\r
-                  L"BootOrder",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  Index2 * sizeof (UINT16),\r
-                  BootOrder\r
-                  );\r
-  //\r
-  // Shrinking variable with current variable implementation shouldn't fail.\r
-  //\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  FreePool (BootOrder);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  For EFI boot option, BDS separate them as six types:\r
-  1. Network - The boot option points to the SimpleNetworkProtocol device.\r
-               Bds will try to automatically create this type boot option when enumerate.\r
-  2. Shell   - The boot option points to internal flash shell.\r
-               Bds will try to automatically create this type boot option when enumerate.\r
-  3. Removable BlockIo      - The boot option only points to the removable media\r
-                              device, like USB flash disk, DVD, Floppy etc.\r
-                              These device should contain a *removable* blockIo\r
-                              protocol in their device handle.\r
-                              Bds will try to automatically create this type boot option\r
-                              when enumerate.\r
-  4. Fixed BlockIo          - The boot option only points to a Fixed blockIo device,\r
-                              like HardDisk.\r
-                              These device should contain a *fixed* blockIo\r
-                              protocol in their device handle.\r
-                              BDS will skip fixed blockIo devices, and NOT\r
-                              automatically create boot option for them. But BDS\r
-                              will help to delete those fixed blockIo boot option,\r
-                              whose description rule conflict with other auto-created\r
-                              boot options.\r
-  5. Non-BlockIo Simplefile - The boot option points to a device whose handle\r
-                              has SimpleFileSystem Protocol, but has no blockio\r
-                              protocol. These devices do not offer blockIo\r
-                              protocol, but BDS still can get the\r
-                              \EFI\BOOT\boot{machinename}.EFI by SimpleFileSystem\r
-                              Protocol.\r
-  6. File    - The boot option points to a file. These boot options are usually\r
-               created by user manually or OS loader. BDS will not delete or modify\r
-               these boot options.\r
-\r
-  This function will enumerate all possible boot device in the system, and\r
-  automatically create boot options for Network, Shell, Removable BlockIo,\r
-  and Non-BlockIo Simplefile devices.\r
-  It will only execute once of every boot.\r
-\r
-  @param  BdsBootOptionList      The header of the link list which indexed all\r
-                                 current boot options\r
-\r
-  @retval EFI_SUCCESS            Finished all the boot device enumerate and create\r
-                                 the boot option base on that boot device\r
-\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to enumerate the boot device and create the boot option list\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibEnumerateAllBootOption (\r
-  IN OUT LIST_ENTRY          *BdsBootOptionList\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  UINT16                        FloppyNumber;\r
-  UINT16                        HarddriveNumber;\r
-  UINT16                        CdromNumber;\r
-  UINT16                        UsbNumber;\r
-  UINT16                        MiscNumber;\r
-  UINT16                        ScsiNumber;\r
-  UINT16                        NonBlockNumber;\r
-  UINTN                         NumberBlockIoHandles;\r
-  EFI_HANDLE                    *BlockIoHandles;\r
-  EFI_BLOCK_IO_PROTOCOL         *BlkIo;\r
-  BOOLEAN                       Removable[2];\r
-  UINTN                         RemovableIndex;\r
-  UINTN                         Index;\r
-  UINTN                         NumOfLoadFileHandles;\r
-  EFI_HANDLE                    *LoadFileHandles;\r
-  UINTN                         FvHandleCount;\r
-  EFI_HANDLE                    *FvHandleBuffer;\r
-  EFI_FV_FILETYPE               Type;\r
-  UINTN                         Size;\r
-  EFI_FV_FILE_ATTRIBUTES        Attributes;\r
-  UINT32                        AuthenticationStatus;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
-  EFI_DEVICE_PATH_PROTOCOL      *DevicePath;\r
-  UINTN                         DevicePathType;\r
-  CHAR16                        Buffer[40];\r
-  EFI_HANDLE                    *FileSystemHandles;\r
-  UINTN                         NumberFileSystemHandles;\r
-  BOOLEAN                       NeedDelete;\r
-  EFI_IMAGE_DOS_HEADER          DosHeader;\r
-  CHAR8                         *PlatLang;\r
-  CHAR8                         *LastLang;\r
-  EFI_IMAGE_OPTIONAL_HEADER_UNION       HdrData;\r
-  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
-\r
-  FloppyNumber    = 0;\r
-  HarddriveNumber = 0;\r
-  CdromNumber     = 0;\r
-  UsbNumber       = 0;\r
-  MiscNumber      = 0;\r
-  ScsiNumber      = 0;\r
-  PlatLang        = NULL;\r
-  LastLang        = NULL;\r
-  ZeroMem (Buffer, sizeof (Buffer));\r
-\r
-  //\r
-  // If the boot device enumerate happened, just get the boot\r
-  // device from the boot order variable\r
-  //\r
-  if (mEnumBootDevice) {\r
-    GetVariable2 (LAST_ENUM_LANGUAGE_VARIABLE_NAME, &gLastEnumLangGuid, (VOID**)&LastLang, NULL);\r
-    GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&PlatLang, NULL);\r
-    ASSERT (PlatLang != NULL);\r
-    if ((LastLang != NULL) && (AsciiStrCmp (LastLang, PlatLang) == 0)) {\r
-      Status = BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
-      FreePool (LastLang);\r
-      FreePool (PlatLang);\r
-      return Status;\r
-    } else {\r
-      Status = gRT->SetVariable (\r
-        LAST_ENUM_LANGUAGE_VARIABLE_NAME,\r
-        &gLastEnumLangGuid,\r
-        EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-        AsciiStrSize (PlatLang),\r
-        PlatLang\r
-        );\r
-      //\r
-      // Failure to set the variable only impacts the performance next time enumerating the boot options.\r
-      //\r
-\r
-      if (LastLang != NULL) {\r
-        FreePool (LastLang);\r
-      }\r
-      FreePool (PlatLang);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Notes: this dirty code is to get the legacy boot option from the\r
-  // BBS table and create to variable as the EFI boot option, it should\r
-  // be removed after the CSM can provide legacy boot option directly\r
-  //\r
-  REFRESH_LEGACY_BOOT_OPTIONS;\r
-\r
-  //\r
-  // Delete invalid boot option\r
-  //\r
-  BdsDeleteAllInvalidEfiBootOption ();\r
-\r
-  //\r
-  // Parse removable media followed by fixed media.\r
-  // The Removable[] array is used by the for-loop below to create removable media boot options\r
-  // at first, and then to create fixed media boot options.\r
-  //\r
-  Removable[0]  = FALSE;\r
-  Removable[1]  = TRUE;\r
-\r
-  gBS->LocateHandleBuffer (\r
-        ByProtocol,\r
-        &gEfiBlockIoProtocolGuid,\r
-        NULL,\r
-        &NumberBlockIoHandles,\r
-        &BlockIoHandles\r
-        );\r
-\r
-  for (RemovableIndex = 0; RemovableIndex < 2; RemovableIndex++) {\r
-    for (Index = 0; Index < NumberBlockIoHandles; Index++) {\r
-      Status = gBS->HandleProtocol (\r
-                      BlockIoHandles[Index],\r
-                      &gEfiBlockIoProtocolGuid,\r
-                      (VOID **) &BlkIo\r
-                      );\r
-      //\r
-      // skip the logical partition\r
-      //\r
-      if (EFI_ERROR (Status) || BlkIo->Media->LogicalPartition) {\r
-        continue;\r
-      }\r
-\r
-      //\r
-      // firstly fixed block io then the removable block io\r
-      //\r
-      if (BlkIo->Media->RemovableMedia == Removable[RemovableIndex]) {\r
-        continue;\r
-      }\r
-      DevicePath  = DevicePathFromHandle (BlockIoHandles[Index]);\r
-      DevicePathType = BdsGetBootTypeFromDevicePath (DevicePath);\r
-\r
-      switch (DevicePathType) {\r
-      case BDS_EFI_ACPI_FLOPPY_BOOT:\r
-        if (FloppyNumber != 0) {\r
-          UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)), FloppyNumber);\r
-        } else {\r
-          UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)));\r
-        }\r
-        BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
-        FloppyNumber++;\r
-        break;\r
-\r
-      //\r
-      // Assume a removable SATA device should be the DVD/CD device, a fixed SATA device should be the Hard Drive device.\r
-      //\r
-      case BDS_EFI_MESSAGE_ATAPI_BOOT:\r
-      case BDS_EFI_MESSAGE_SATA_BOOT:\r
-        if (BlkIo->Media->RemovableMedia) {\r
-          if (CdromNumber != 0) {\r
-            UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)), CdromNumber);\r
-          } else {\r
-            UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)));\r
-          }\r
-          CdromNumber++;\r
-        } else {\r
-          if (HarddriveNumber != 0) {\r
-            UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)), HarddriveNumber);\r
-          } else {\r
-            UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)));\r
-          }\r
-          HarddriveNumber++;\r
-        }\r
-        DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Buffer: %S\n", Buffer));\r
-        BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
-        break;\r
-\r
-      case BDS_EFI_MESSAGE_USB_DEVICE_BOOT:\r
-        if (UsbNumber != 0) {\r
-          UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)), UsbNumber);\r
-        } else {\r
-          UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)));\r
-        }\r
-        BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
-        UsbNumber++;\r
-        break;\r
-\r
-      case BDS_EFI_MESSAGE_SCSI_BOOT:\r
-        if (ScsiNumber != 0) {\r
-          UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)), ScsiNumber);\r
-        } else {\r
-          UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)));\r
-        }\r
-        BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
-        ScsiNumber++;\r
-        break;\r
-\r
-      case BDS_EFI_MESSAGE_MISC_BOOT:\r
-      default:\r
-        if (MiscNumber != 0) {\r
-          UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC)), MiscNumber);\r
-        } else {\r
-          UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC)));\r
-        }\r
-        BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
-        MiscNumber++;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  if (NumberBlockIoHandles != 0) {\r
-    FreePool (BlockIoHandles);\r
-  }\r
-\r
-  //\r
-  // If there is simple file protocol which does not consume block Io protocol, create a boot option for it here.\r
-  //\r
-  NonBlockNumber = 0;\r
-  gBS->LocateHandleBuffer (\r
-        ByProtocol,\r
-        &gEfiSimpleFileSystemProtocolGuid,\r
-        NULL,\r
-        &NumberFileSystemHandles,\r
-        &FileSystemHandles\r
-        );\r
-  for (Index = 0; Index < NumberFileSystemHandles; Index++) {\r
-    Status = gBS->HandleProtocol (\r
-                    FileSystemHandles[Index],\r
-                    &gEfiBlockIoProtocolGuid,\r
-                    (VOID **) &BlkIo\r
-                    );\r
-     if (!EFI_ERROR (Status)) {\r
-      //\r
-      //  Skip if the file system handle supports a BlkIo protocol,\r
-      //\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Do the removable Media thing. \EFI\BOOT\boot{machinename}.EFI\r
-    //  machinename is ia32, ia64, x64, ...\r
-    //\r
-    Hdr.Union  = &HdrData;\r
-    NeedDelete = TRUE;\r
-    Status     = BdsLibGetImageHeader (\r
-                   FileSystemHandles[Index],\r
-                   EFI_REMOVABLE_MEDIA_FILE_NAME,\r
-                   &DosHeader,\r
-                   Hdr\r
-                   );\r
-    if (!EFI_ERROR (Status) &&\r
-        EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Hdr.Pe32->FileHeader.Machine) &&\r
-        Hdr.Pe32->OptionalHeader.Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {\r
-      NeedDelete = FALSE;\r
-    }\r
-\r
-    if (NeedDelete) {\r
-      //\r
-      // No such file or the file is not a EFI application, delete this boot option\r
-      //\r
-      BdsLibDeleteOptionFromHandle (FileSystemHandles[Index]);\r
-    } else {\r
-      if (NonBlockNumber != 0) {\r
-        UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)), NonBlockNumber);\r
-      } else {\r
-        UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)));\r
-      }\r
-      BdsLibBuildOptionFromHandle (FileSystemHandles[Index], BdsBootOptionList, Buffer);\r
-      NonBlockNumber++;\r
-    }\r
-  }\r
-\r
-  if (NumberFileSystemHandles != 0) {\r
-    FreePool (FileSystemHandles);\r
-  }\r
-\r
-  //\r
-  // Parse Network Boot Device\r
-  //\r
-  NumOfLoadFileHandles = 0;\r
-  //\r
-  // Search Load File protocol for PXE boot option.\r
-  //\r
-  gBS->LocateHandleBuffer (\r
-        ByProtocol,\r
-        &gEfiLoadFileProtocolGuid,\r
-        NULL,\r
-        &NumOfLoadFileHandles,\r
-        &LoadFileHandles\r
-        );\r
-\r
-  for (Index = 0; Index < NumOfLoadFileHandles; Index++) {\r
-    if (Index != 0) {\r
-      UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK)), Index);\r
-    } else {\r
-      UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK)));\r
-    }\r
-    BdsLibBuildOptionFromHandle (LoadFileHandles[Index], BdsBootOptionList, Buffer);\r
-  }\r
-\r
-  if (NumOfLoadFileHandles != 0) {\r
-    FreePool (LoadFileHandles);\r
-  }\r
-\r
-  //\r
-  // Check if we have on flash shell\r
-  //\r
-  gBS->LocateHandleBuffer (\r
-        ByProtocol,\r
-        &gEfiFirmwareVolume2ProtocolGuid,\r
-        NULL,\r
-        &FvHandleCount,\r
-        &FvHandleBuffer\r
-        );\r
-  for (Index = 0; Index < FvHandleCount; Index++) {\r
-    gBS->HandleProtocol (\r
-          FvHandleBuffer[Index],\r
-          &gEfiFirmwareVolume2ProtocolGuid,\r
-          (VOID **) &Fv\r
-          );\r
-\r
-    Status = Fv->ReadFile (\r
-                  Fv,\r
-                  PcdGetPtr(PcdShellFile),\r
-                  NULL,\r
-                  &Size,\r
-                  &Type,\r
-                  &Attributes,\r
-                  &AuthenticationStatus\r
-                  );\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Skip if no shell file in the FV\r
-      //\r
-      continue;\r
-    }\r
-    //\r
-    // Build the shell boot option\r
-    //\r
-    BdsLibBuildOptionFromShell (FvHandleBuffer[Index], BdsBootOptionList);\r
-  }\r
-\r
-  if (FvHandleCount != 0) {\r
-    FreePool (FvHandleBuffer);\r
-  }\r
-  //\r
-  // Make sure every boot only have one time\r
-  // boot device enumerate\r
-  //\r
-  Status = BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
-  mEnumBootDevice = TRUE;\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Build the boot option with the handle parsed in\r
-\r
-  @param  Handle                 The handle which present the device path to create\r
-                                 boot option\r
-  @param  BdsBootOptionList      The header of the link list which indexed all\r
-                                 current boot options\r
-  @param  String                 The description of the boot option.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibBuildOptionFromHandle (\r
-  IN  EFI_HANDLE                 Handle,\r
-  IN  LIST_ENTRY                 *BdsBootOptionList,\r
-  IN  CHAR16                     *String\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-\r
-  DevicePath = DevicePathFromHandle (Handle);\r
-\r
-  //\r
-  // Create and register new boot option\r
-  //\r
-  BdsLibRegisterNewOption (BdsBootOptionList, DevicePath, String, L"BootOrder");\r
-}\r
-\r
-\r
-/**\r
-  Build the on flash shell boot option with the handle parsed in.\r
-\r
-  @param  Handle                 The handle which present the device path to create\r
-                                 on flash shell boot option\r
-  @param  BdsBootOptionList      The header of the link list which indexed all\r
-                                 current boot options\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibBuildOptionFromShell (\r
-  IN EFI_HANDLE                  Handle,\r
-  IN OUT LIST_ENTRY              *BdsBootOptionList\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;\r
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH ShellNode;\r
-\r
-  DevicePath = DevicePathFromHandle (Handle);\r
-\r
-  //\r
-  // Build the shell device path\r
-  //\r
-  EfiInitializeFwVolDevicepathNode (&ShellNode, PcdGetPtr(PcdShellFile));\r
-\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &ShellNode);\r
-\r
-  //\r
-  // Create and register the shell boot option\r
-  //\r
-  BdsLibRegisterNewOption (BdsBootOptionList, DevicePath, L"EFI Internal Shell", L"BootOrder");\r
-\r
-}\r
-\r
-/**\r
-  Boot from the UEFI spec defined "BootNext" variable.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibBootNext (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  UINT16            *BootNext;\r
-  UINTN             BootNextSize;\r
-  CHAR16            Buffer[20];\r
-  BDS_COMMON_OPTION *BootOption;\r
-  LIST_ENTRY        TempList;\r
-  UINTN             ExitDataSize;\r
-  CHAR16            *ExitData;\r
-\r
-  //\r
-  // Init the boot option name buffer and temp link list\r
-  //\r
-  InitializeListHead (&TempList);\r
-  ZeroMem (Buffer, sizeof (Buffer));\r
-\r
-  BootNext = BdsLibGetVariableAndSize (\r
-              L"BootNext",\r
-              &gEfiGlobalVariableGuid,\r
-              &BootNextSize\r
-              );\r
-\r
-  //\r
-  // Clear the boot next variable first\r
-  //\r
-  if (BootNext != NULL) {\r
-    Status = gRT->SetVariable (\r
-                    L"BootNext",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    0,\r
-                    NULL\r
-                    );\r
-    //\r
-    // Deleting variable with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Start to build the boot option and try to boot\r
-    //\r
-    UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *BootNext);\r
-    BootOption = BdsLibVariableToOption (&TempList, Buffer);\r
-    ASSERT (BootOption != NULL);\r
-    BdsLibConnectDevicePath (BootOption->DevicePath);\r
-    BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
-    FreePool(BootOption);\r
-    FreePool(BootNext);\r
-  }\r
-\r
-}\r
-\r
-/**\r
-  Return the bootable media handle.\r
-  First, check the device is connected\r
-  Second, check whether the device path point to a device which support SimpleFileSystemProtocol,\r
-  Third, detect the the default boot file in the Media, and return the removable Media handle.\r
-\r
-  @param  DevicePath  Device Path to a  bootable device\r
-\r
-  @return  The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.\r
-\r
-**/\r
-EFI_HANDLE\r
-EFIAPI\r
-BdsLibGetBootableHandle (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_TPL                         OldTpl;\r
-  EFI_DEVICE_PATH_PROTOCOL        *UpdatedDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL        *DupDevicePath;\r
-  EFI_HANDLE                      Handle;\r
-  EFI_BLOCK_IO_PROTOCOL           *BlockIo;\r
-  VOID                            *Buffer;\r
-  EFI_DEVICE_PATH_PROTOCOL        *TempDevicePath;\r
-  UINTN                           Size;\r
-  UINTN                           TempSize;\r
-  EFI_HANDLE                      ReturnHandle;\r
-  EFI_HANDLE                      *SimpleFileSystemHandles;\r
-\r
-  UINTN                           NumberSimpleFileSystemHandles;\r
-  UINTN                           Index;\r
-  EFI_IMAGE_DOS_HEADER            DosHeader;\r
-  EFI_IMAGE_OPTIONAL_HEADER_UNION       HdrData;\r
-  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
-\r
-  UpdatedDevicePath = DevicePath;\r
-\r
-  //\r
-  // Enter to critical section to protect the acquired BlockIo instance\r
-  // from getting released due to the USB mass storage hotplug event\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  //\r
-  // Check whether the device is connected\r
-  //\r
-  Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &UpdatedDevicePath, &Handle);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Skip the case that the boot option point to a simple file protocol which does not consume block Io protocol,\r
-    //\r
-    Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &UpdatedDevicePath, &Handle);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Fail to find the proper BlockIo and simple file protocol, maybe because device not present,  we need to connect it firstly\r
-      //\r
-      UpdatedDevicePath = DevicePath;\r
-      Status            = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &UpdatedDevicePath, &Handle);\r
-      gBS->ConnectController (Handle, NULL, NULL, TRUE);\r
-    }\r
-  } else {\r
-    //\r
-    // For removable device boot option, its contained device path only point to the removable device handle,\r
-    // should make sure all its children handles (its child partion or media handles) are created and connected.\r
-    //\r
-    gBS->ConnectController (Handle, NULL, NULL, TRUE);\r
-    //\r
-    // Get BlockIo protocol and check removable attribute\r
-    //\r
-    Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Issue a dummy read to the device to check for media change.\r
-    // When the removable media is changed, any Block IO read/write will\r
-    // cause the BlockIo protocol be reinstalled and EFI_MEDIA_CHANGED is\r
-    // returned. After the Block IO protocol is reinstalled, subsequent\r
-    // Block IO read/write will success.\r
-    //\r
-    Buffer = AllocatePool (BlockIo->Media->BlockSize);\r
-    if (Buffer != NULL) {\r
-      BlockIo->ReadBlocks (\r
-               BlockIo,\r
-               BlockIo->Media->MediaId,\r
-               0,\r
-               BlockIo->Media->BlockSize,\r
-               Buffer\r
-               );\r
-      FreePool(Buffer);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Detect the the default boot file from removable Media\r
-  //\r
-\r
-  //\r
-  // If fail to get bootable handle specified by a USB boot option, the BDS should try to find other bootable device in the same USB bus\r
-  // Try to locate the USB node device path first, if fail then use its previous PCI node to search\r
-  //\r
-  DupDevicePath = DuplicateDevicePath (DevicePath);\r
-  ASSERT (DupDevicePath != NULL);\r
-\r
-  UpdatedDevicePath = DupDevicePath;\r
-  Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &UpdatedDevicePath, &Handle);\r
-  //\r
-  // if the resulting device path point to a usb node, and the usb node is a dummy node, should only let device path only point to the previous Pci node\r
-  // Acpi()/Pci()/Usb() --> Acpi()/Pci()\r
-  //\r
-  if ((DevicePathType (UpdatedDevicePath) == MESSAGING_DEVICE_PATH) &&\r
-      (DevicePathSubType (UpdatedDevicePath) == MSG_USB_DP)) {\r
-    //\r
-    // Remove the usb node, let the device path only point to PCI node\r
-    //\r
-    SetDevicePathEndNode (UpdatedDevicePath);\r
-    UpdatedDevicePath = DupDevicePath;\r
-  } else {\r
-    UpdatedDevicePath = DevicePath;\r
-  }\r
-\r
-  //\r
-  // Get the device path size of boot option\r
-  //\r
-  Size = GetDevicePathSize(UpdatedDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL); // minus the end node\r
-  ReturnHandle = NULL;\r
-  gBS->LocateHandleBuffer (\r
-      ByProtocol,\r
-      &gEfiSimpleFileSystemProtocolGuid,\r
-      NULL,\r
-      &NumberSimpleFileSystemHandles,\r
-      &SimpleFileSystemHandles\r
-      );\r
-  for (Index = 0; Index < NumberSimpleFileSystemHandles; Index++) {\r
-    //\r
-    // Get the device path size of SimpleFileSystem handle\r
-    //\r
-    TempDevicePath = DevicePathFromHandle (SimpleFileSystemHandles[Index]);\r
-    TempSize = GetDevicePathSize (TempDevicePath)- sizeof (EFI_DEVICE_PATH_PROTOCOL); // minus the end node\r
-    //\r
-    // Check whether the device path of boot option is part of the  SimpleFileSystem handle's device path\r
-    //\r
-    if (Size <= TempSize && CompareMem (TempDevicePath, UpdatedDevicePath, Size)==0) {\r
-      //\r
-      // Load the default boot file \EFI\BOOT\boot{machinename}.EFI from removable Media\r
-      //  machinename is ia32, ia64, x64, ...\r
-      //\r
-      Hdr.Union = &HdrData;\r
-      Status = BdsLibGetImageHeader (\r
-                 SimpleFileSystemHandles[Index],\r
-                 EFI_REMOVABLE_MEDIA_FILE_NAME,\r
-                 &DosHeader,\r
-                 Hdr\r
-                 );\r
-      if (!EFI_ERROR (Status) &&\r
-        EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Hdr.Pe32->FileHeader.Machine) &&\r
-        Hdr.Pe32->OptionalHeader.Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {\r
-        ReturnHandle = SimpleFileSystemHandles[Index];\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  FreePool(DupDevicePath);\r
-\r
-  if (SimpleFileSystemHandles != NULL) {\r
-    FreePool(SimpleFileSystemHandles);\r
-  }\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return ReturnHandle;\r
-}\r
-\r
-/**\r
-  Check to see if the network cable is plugged in. If the DevicePath is not\r
-  connected it will be connected.\r
-\r
-  @param  DevicePath             Device Path to check\r
-\r
-  @retval TRUE                   DevicePath points to an Network that is connected\r
-  @retval FALSE                  DevicePath does not point to a bootable network\r
-\r
-**/\r
-BOOLEAN\r
-BdsLibNetworkBootWithMediaPresent (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_DEVICE_PATH_PROTOCOL        *UpdatedDevicePath;\r
-  EFI_HANDLE                      Handle;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL     *Snp;\r
-  BOOLEAN                         MediaPresent;\r
-  UINT32                          InterruptStatus;\r
-\r
-  MediaPresent = FALSE;\r
-\r
-  UpdatedDevicePath = DevicePath;\r
-  //\r
-  // Locate Load File Protocol for PXE boot option first\r
-  //\r
-  Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &UpdatedDevicePath, &Handle);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Device not present so see if we need to connect it\r
-    //\r
-    Status = BdsLibConnectDevicePath (DevicePath);\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // This one should work after we did the connect\r
-      //\r
-      Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &UpdatedDevicePath, &Handle);\r
-    }\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = gBS->HandleProtocol (Handle, &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Failed to open SNP from this handle, try to get SNP from parent handle\r
-      //\r
-      UpdatedDevicePath = DevicePathFromHandle (Handle);\r
-      if (UpdatedDevicePath != NULL) {\r
-        Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &UpdatedDevicePath, &Handle);\r
-        if (!EFI_ERROR (Status)) {\r
-          //\r
-          // SNP handle found, get SNP from it\r
-          //\r
-          Status = gBS->HandleProtocol (Handle, &gEfiSimpleNetworkProtocolGuid, (VOID **) &Snp);\r
-        }\r
-      }\r
-    }\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      if (Snp->Mode->MediaPresentSupported) {\r
-        if (Snp->Mode->State == EfiSimpleNetworkInitialized) {\r
-          //\r
-          // Invoke Snp->GetStatus() to refresh the media status\r
-          //\r
-          Snp->GetStatus (Snp, &InterruptStatus, NULL);\r
-\r
-          //\r
-          // In case some one else is using the SNP check to see if it's connected\r
-          //\r
-          MediaPresent = Snp->Mode->MediaPresent;\r
-        } else {\r
-          //\r
-          // No one is using SNP so we need to Start and Initialize so\r
-          // MediaPresent will be valid.\r
-          //\r
-          Status = Snp->Start (Snp);\r
-          if (!EFI_ERROR (Status)) {\r
-            Status = Snp->Initialize (Snp, 0, 0);\r
-            if (!EFI_ERROR (Status)) {\r
-              MediaPresent = Snp->Mode->MediaPresent;\r
-              Snp->Shutdown (Snp);\r
-            }\r
-            Snp->Stop (Snp);\r
-          }\r
-        }\r
-      } else {\r
-        MediaPresent = TRUE;\r
-      }\r
-    }\r
-  }\r
-\r
-  return MediaPresent;\r
-}\r
-\r
-/**\r
-  For a bootable Device path, return its boot type.\r
-\r
-  @param  DevicePath                      The bootable device Path to check\r
-\r
-  @retval BDS_EFI_MEDIA_HD_BOOT           If given device path contains MEDIA_DEVICE_PATH type device path node\r
-                                          which subtype is MEDIA_HARDDRIVE_DP\r
-  @retval BDS_EFI_MEDIA_CDROM_BOOT        If given device path contains MEDIA_DEVICE_PATH type device path node\r
-                                          which subtype is MEDIA_CDROM_DP\r
-  @retval BDS_EFI_ACPI_FLOPPY_BOOT        If given device path contains ACPI_DEVICE_PATH type device path node\r
-                                          which HID is floppy device.\r
-  @retval BDS_EFI_MESSAGE_ATAPI_BOOT      If given device path contains MESSAGING_DEVICE_PATH type device path node\r
-                                          and its last device path node's subtype is MSG_ATAPI_DP.\r
-  @retval BDS_EFI_MESSAGE_SCSI_BOOT       If given device path contains MESSAGING_DEVICE_PATH type device path node\r
-                                          and its last device path node's subtype is MSG_SCSI_DP.\r
-  @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT If given device path contains MESSAGING_DEVICE_PATH type device path node\r
-                                          and its last device path node's subtype is MSG_USB_DP.\r
-  @retval BDS_EFI_MESSAGE_MISC_BOOT       If the device path not contains any media device path node,  and\r
-                                          its last device path node point to a message device path node.\r
-  @retval BDS_LEGACY_BBS_BOOT             If given device path contains BBS_DEVICE_PATH type device path node.\r
-  @retval BDS_EFI_UNSUPPORT               An EFI Removable BlockIO device path not point to a media and message device,\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-BdsGetBootTypeFromDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
-  )\r
-{\r
-  ACPI_HID_DEVICE_PATH          *Acpi;\r
-  EFI_DEVICE_PATH_PROTOCOL      *TempDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL      *LastDeviceNode;\r
-  UINT32                        BootType;\r
-\r
-  if (NULL == DevicePath) {\r
-    return BDS_EFI_UNSUPPORT;\r
-  }\r
-\r
-  TempDevicePath = DevicePath;\r
-\r
-  while (!IsDevicePathEndType (TempDevicePath)) {\r
-    switch (DevicePathType (TempDevicePath)) {\r
-      case BBS_DEVICE_PATH:\r
-         return BDS_LEGACY_BBS_BOOT;\r
-      case MEDIA_DEVICE_PATH:\r
-        if (DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP) {\r
-          return BDS_EFI_MEDIA_HD_BOOT;\r
-        } else if (DevicePathSubType (TempDevicePath) == MEDIA_CDROM_DP) {\r
-          return BDS_EFI_MEDIA_CDROM_BOOT;\r
-        }\r
-        break;\r
-      case ACPI_DEVICE_PATH:\r
-        Acpi = (ACPI_HID_DEVICE_PATH *) TempDevicePath;\r
-        if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {\r
-          return BDS_EFI_ACPI_FLOPPY_BOOT;\r
-        }\r
-        break;\r
-      case MESSAGING_DEVICE_PATH:\r
-        //\r
-        // Get the last device path node\r
-        //\r
-        LastDeviceNode = NextDevicePathNode (TempDevicePath);\r
-        if (DevicePathSubType(LastDeviceNode) == MSG_DEVICE_LOGICAL_UNIT_DP) {\r
-          //\r
-          // if the next node type is Device Logical Unit, which specify the Logical Unit Number (LUN),\r
-          // skip it\r
-          //\r
-          LastDeviceNode = NextDevicePathNode (LastDeviceNode);\r
-        }\r
-        //\r
-        // if the device path not only point to driver device, it is not a messaging device path,\r
-        //\r
-        if (!IsDevicePathEndType (LastDeviceNode)) {\r
-          break;\r
-        }\r
-\r
-        switch (DevicePathSubType (TempDevicePath)) {\r
-        case MSG_ATAPI_DP:\r
-          BootType = BDS_EFI_MESSAGE_ATAPI_BOOT;\r
-          break;\r
-\r
-        case MSG_USB_DP:\r
-          BootType = BDS_EFI_MESSAGE_USB_DEVICE_BOOT;\r
-          break;\r
-\r
-        case MSG_SCSI_DP:\r
-          BootType = BDS_EFI_MESSAGE_SCSI_BOOT;\r
-          break;\r
-\r
-        case MSG_SATA_DP:\r
-          BootType = BDS_EFI_MESSAGE_SATA_BOOT;\r
-          break;\r
-\r
-        case MSG_MAC_ADDR_DP:\r
-        case MSG_VLAN_DP:\r
-        case MSG_IPv4_DP:\r
-        case MSG_IPv6_DP:\r
-          BootType = BDS_EFI_MESSAGE_MAC_BOOT;\r
-          break;\r
-\r
-        default:\r
-          BootType = BDS_EFI_MESSAGE_MISC_BOOT;\r
-          break;\r
-        }\r
-        return BootType;\r
-\r
-      default:\r
-        break;\r
-    }\r
-    TempDevicePath = NextDevicePathNode (TempDevicePath);\r
-  }\r
-\r
-  return BDS_EFI_UNSUPPORT;\r
-}\r
-\r
-/**\r
-  Check whether the Device path in a boot option point to a valid bootable device,\r
-  And if CheckMedia is true, check the device is ready to boot now.\r
-\r
-  @param  DevPath     the Device path in a boot option\r
-  @param  CheckMedia  if true, check the device is ready to boot now.\r
-\r
-  @retval TRUE        the Device path  is valid\r
-  @retval FALSE       the Device path  is invalid .\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-BdsLibIsValidEFIBootOptDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath,\r
-  IN BOOLEAN                      CheckMedia\r
-  )\r
-{\r
-  return BdsLibIsValidEFIBootOptDevicePathExt (DevPath, CheckMedia, NULL);\r
-}\r
-\r
-/**\r
-  Check whether the Device path in a boot option point to a valid bootable device,\r
-  And if CheckMedia is true, check the device is ready to boot now.\r
-  If Description is not NULL and the device path point to a fixed BlockIo\r
-  device, check the description whether conflict with other auto-created\r
-  boot options.\r
-\r
-  @param  DevPath     the Device path in a boot option\r
-  @param  CheckMedia  if true, check the device is ready to boot now.\r
-  @param  Description the description in a boot option\r
-\r
-  @retval TRUE        the Device path  is valid\r
-  @retval FALSE       the Device path  is invalid .\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-BdsLibIsValidEFIBootOptDevicePathExt (\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath,\r
-  IN BOOLEAN                      CheckMedia,\r
-  IN CHAR16                       *Description\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_HANDLE                Handle;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *LastDeviceNode;\r
-  EFI_BLOCK_IO_PROTOCOL     *BlockIo;\r
-\r
-  TempDevicePath = DevPath;\r
-  LastDeviceNode = DevPath;\r
-\r
-  //\r
-  // Check if it's a valid boot option for network boot device.\r
-  // Check if there is EfiLoadFileProtocol installed.\r
-  // If yes, that means there is a boot option for network.\r
-  //\r
-  Status = gBS->LocateDevicePath (\r
-                  &gEfiLoadFileProtocolGuid,\r
-                  &TempDevicePath,\r
-                  &Handle\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Device not present so see if we need to connect it\r
-    //\r
-    TempDevicePath = DevPath;\r
-    BdsLibConnectDevicePath (TempDevicePath);\r
-    Status = gBS->LocateDevicePath (\r
-                    &gEfiLoadFileProtocolGuid,\r
-                    &TempDevicePath,\r
-                    &Handle\r
-                    );\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    if (!IsDevicePathEnd (TempDevicePath)) {\r
-      //\r
-      // LoadFile protocol is not installed on handle with exactly the same DevPath\r
-      //\r
-      return FALSE;\r
-    }\r
-\r
-    if (CheckMedia) {\r
-      //\r
-      // Test if it is ready to boot now\r
-      //\r
-      if (BdsLibNetworkBootWithMediaPresent(DevPath)) {\r
-        return TRUE;\r
-      }\r
-    } else {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // If the boot option point to a file, it is a valid EFI boot option,\r
-  // and assume it is ready to boot now\r
-  //\r
-  while (!IsDevicePathEnd (TempDevicePath)) {\r
-    //\r
-    // If there is USB Class or USB WWID device path node, treat it as valid EFI\r
-    // Boot Option. BdsExpandUsbShortFormDevicePath () will be used to expand it\r
-    // to full device path.\r
-    //\r
-    if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) &&\r
-        ((DevicePathSubType (TempDevicePath) == MSG_USB_CLASS_DP) ||\r
-         (DevicePathSubType (TempDevicePath) == MSG_USB_WWID_DP))) {\r
-      return TRUE;\r
-    }\r
-\r
-    LastDeviceNode = TempDevicePath;\r
-    TempDevicePath = NextDevicePathNode (TempDevicePath);\r
-  }\r
-  if ((DevicePathType (LastDeviceNode) == MEDIA_DEVICE_PATH) &&\r
-    (DevicePathSubType (LastDeviceNode) == MEDIA_FILEPATH_DP)) {\r
-    return TRUE;\r
-  }\r
-\r
-  //\r
-  // Check if it's a valid boot option for internal FV application\r
-  //\r
-  if (EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode) != NULL) {\r
-    //\r
-    // If the boot option point to internal FV application, make sure it is valid\r
-    //\r
-    TempDevicePath = DevPath;\r
-    Status = BdsLibUpdateFvFileDevicePath (\r
-               &TempDevicePath,\r
-               EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode)\r
-               );\r
-    if (Status == EFI_ALREADY_STARTED) {\r
-      return TRUE;\r
-    } else {\r
-      if (Status == EFI_SUCCESS) {\r
-        FreePool (TempDevicePath);\r
-      }\r
-      return FALSE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // If the boot option point to a blockIO device:\r
-  //    if it is a removable blockIo device, it is valid.\r
-  //    if it is a fixed blockIo device, check its description confliction.\r
-  //\r
-  TempDevicePath = DevPath;\r
-  Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath, &Handle);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Device not present so see if we need to connect it\r
-    //\r
-    Status = BdsLibConnectDevicePath (DevPath);\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Try again to get the Block Io protocol after we did the connect\r
-      //\r
-      TempDevicePath = DevPath;\r
-      Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath, &Handle);\r
-    }\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);\r
-    if (!EFI_ERROR (Status)) {\r
-      if (CheckMedia) {\r
-        //\r
-        // Test if it is ready to boot now\r
-        //\r
-        if (BdsLibGetBootableHandle (DevPath) != NULL) {\r
-          return TRUE;\r
-        }\r
-      } else {\r
-        return TRUE;\r
-      }\r
-    }\r
-  } else {\r
-    //\r
-    // if the boot option point to a simple file protocol which does not consume block Io protocol, it is also a valid EFI boot option,\r
-    //\r
-    Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &TempDevicePath, &Handle);\r
-    if (!EFI_ERROR (Status)) {\r
-      if (CheckMedia) {\r
-        //\r
-        // Test if it is ready to boot now\r
-        //\r
-        if (BdsLibGetBootableHandle (DevPath) != NULL) {\r
-          return TRUE;\r
-        }\r
-      } else {\r
-        return TRUE;\r
-      }\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-\r
-/**\r
-  According to a file guild, check a Fv file device path is valid. If it is invalid,\r
-  try to return the valid device path.\r
-  FV address maybe changes for memory layout adjust from time to time, use this function\r
-  could promise the Fv file device path is right.\r
-\r
-  @param  DevicePath             on input, the Fv file device path need to check on\r
-                                 output, the updated valid Fv file device path\r
-  @param  FileGuid               the Fv file guild\r
-\r
-  @retval EFI_INVALID_PARAMETER  the input DevicePath or FileGuid is invalid\r
-                                 parameter\r
-  @retval EFI_UNSUPPORTED        the input DevicePath does not contain Fv file\r
-                                 guild at all\r
-  @retval EFI_ALREADY_STARTED    the input DevicePath has pointed to Fv file, it is\r
-                                 valid\r
-  @retval EFI_SUCCESS            has successfully updated the invalid DevicePath,\r
-                                 and return the updated device path in DevicePath\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibUpdateFvFileDevicePath (\r
-  IN  OUT EFI_DEVICE_PATH_PROTOCOL      ** DevicePath,\r
-  IN  EFI_GUID                          *FileGuid\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL      *TempDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL      *LastDeviceNode;\r
-  EFI_STATUS                    Status;\r
-  EFI_GUID                      *GuidPoint;\r
-  UINTN                         Index;\r
-  UINTN                         FvHandleCount;\r
-  EFI_HANDLE                    *FvHandleBuffer;\r
-  EFI_FV_FILETYPE               Type;\r
-  UINTN                         Size;\r
-  EFI_FV_FILE_ATTRIBUTES        Attributes;\r
-  UINT32                        AuthenticationStatus;\r
-  BOOLEAN                       FindFvFile;\r
-  EFI_LOADED_IMAGE_PROTOCOL     *LoadedImage;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FvFileNode;\r
-  EFI_HANDLE                    FoundFvHandle;\r
-  EFI_DEVICE_PATH_PROTOCOL      *NewDevicePath;\r
-\r
-  if ((DevicePath == NULL) || (*DevicePath == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  if (FileGuid == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Check whether the device path point to the default the input Fv file\r
-  //\r
-  TempDevicePath = *DevicePath;\r
-  LastDeviceNode = TempDevicePath;\r
-  while (!IsDevicePathEnd (TempDevicePath)) {\r
-     LastDeviceNode = TempDevicePath;\r
-     TempDevicePath = NextDevicePathNode (TempDevicePath);\r
-  }\r
-  GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (\r
-                (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode\r
-                );\r
-  if (GuidPoint == NULL) {\r
-    //\r
-    // if this option does not points to a Fv file, just return EFI_UNSUPPORTED\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  if (!CompareGuid (GuidPoint, FileGuid)) {\r
-    //\r
-    // If the Fv file is not the input file guid, just return EFI_UNSUPPORTED\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Check whether the input Fv file device path is valid\r
-  //\r
-  TempDevicePath = *DevicePath;\r
-  FoundFvHandle = NULL;\r
-  Status = gBS->LocateDevicePath (\r
-                  &gEfiFirmwareVolume2ProtocolGuid,\r
-                  &TempDevicePath,\r
-                  &FoundFvHandle\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = gBS->HandleProtocol (\r
-                    FoundFvHandle,\r
-                    &gEfiFirmwareVolume2ProtocolGuid,\r
-                    (VOID **) &Fv\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Set FV ReadFile Buffer as NULL, only need to check whether input Fv file exist there\r
-      //\r
-      Status = Fv->ReadFile (\r
-                    Fv,\r
-                    FileGuid,\r
-                    NULL,\r
-                    &Size,\r
-                    &Type,\r
-                    &Attributes,\r
-                    &AuthenticationStatus\r
-                    );\r
-      if (!EFI_ERROR (Status)) {\r
-        return EFI_ALREADY_STARTED;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Look for the input wanted FV file in current FV\r
-  // First, try to look for in Bds own FV. Bds and input wanted FV file usually are in the same FV\r
-  //\r
-  FindFvFile = FALSE;\r
-  FoundFvHandle = NULL;\r
-  Status = gBS->HandleProtocol (\r
-             gImageHandle,\r
-             &gEfiLoadedImageProtocolGuid,\r
-             (VOID **) &LoadedImage\r
-             );\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = gBS->HandleProtocol (\r
-                    LoadedImage->DeviceHandle,\r
-                    &gEfiFirmwareVolume2ProtocolGuid,\r
-                    (VOID **) &Fv\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = Fv->ReadFile (\r
-                    Fv,\r
-                    FileGuid,\r
-                    NULL,\r
-                    &Size,\r
-                    &Type,\r
-                    &Attributes,\r
-                    &AuthenticationStatus\r
-                    );\r
-      if (!EFI_ERROR (Status)) {\r
-        FindFvFile = TRUE;\r
-        FoundFvHandle = LoadedImage->DeviceHandle;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Second, if fail to find, try to enumerate all FV\r
-  //\r
-  if (!FindFvFile) {\r
-    FvHandleBuffer = NULL;\r
-    gBS->LocateHandleBuffer (\r
-          ByProtocol,\r
-          &gEfiFirmwareVolume2ProtocolGuid,\r
-          NULL,\r
-          &FvHandleCount,\r
-          &FvHandleBuffer\r
-          );\r
-    for (Index = 0; Index < FvHandleCount; Index++) {\r
-      gBS->HandleProtocol (\r
-            FvHandleBuffer[Index],\r
-            &gEfiFirmwareVolume2ProtocolGuid,\r
-            (VOID **) &Fv\r
-            );\r
-\r
-      Status = Fv->ReadFile (\r
-                    Fv,\r
-                    FileGuid,\r
-                    NULL,\r
-                    &Size,\r
-                    &Type,\r
-                    &Attributes,\r
-                    &AuthenticationStatus\r
-                    );\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // Skip if input Fv file not in the FV\r
-        //\r
-        continue;\r
-      }\r
-      FindFvFile = TRUE;\r
-      FoundFvHandle = FvHandleBuffer[Index];\r
-      break;\r
-    }\r
-\r
-    if (FvHandleBuffer != NULL) {\r
-      FreePool (FvHandleBuffer);\r
-    }\r
-  }\r
-\r
-  if (FindFvFile) {\r
-    //\r
-    // Build the shell device path\r
-    //\r
-    NewDevicePath = DevicePathFromHandle (FoundFvHandle);\r
-    EfiInitializeFwVolDevicepathNode (&FvFileNode, FileGuid);\r
-    NewDevicePath = AppendDevicePathNode (NewDevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &FvFileNode);\r
-    ASSERT (NewDevicePath != NULL);\r
-    *DevicePath = NewDevicePath;\r
-    return EFI_SUCCESS;\r
-  }\r
-  return EFI_NOT_FOUND;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConnect.c
deleted file mode 100644 (file)
index 5ca5bb5..0000000
+++ /dev/null
@@ -1,429 +0,0 @@
-/** @file\r
-  BDS Lib functions which relate with connect the device\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalBdsLib.h"\r
-\r
-\r
-/**\r
-  This function will connect all the system driver to controller\r
-  first, and then special connect the default console, this make\r
-  sure all the system controller available and the platform default\r
-  console connected.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibConnectAll (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Connect the platform console first\r
-  //\r
-  BdsLibConnectAllDefaultConsoles ();\r
-\r
-  //\r
-  // Generic way to connect all the drivers\r
-  //\r
-  BdsLibConnectAllDriversToAllControllers ();\r
-\r
-  //\r
-  // Here we have the assumption that we have already had\r
-  // platform default console\r
-  //\r
-  BdsLibConnectAllDefaultConsoles ();\r
-}\r
-\r
-\r
-/**\r
-  This function will connect all the system drivers to all controllers\r
-  first, and then connect all the console devices the system current\r
-  have. After this we should get all the device work and console available\r
-  if the system have console device.\r
-\r
-**/\r
-VOID\r
-BdsLibGenericConnectAll (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Most generic way to connect all the drivers\r
-  //\r
-  BdsLibConnectAllDriversToAllControllers ();\r
-  BdsLibConnectAllConsoles ();\r
-}\r
-\r
-/**\r
-  This function will create all handles associate with every device\r
-  path node. If the handle associate with one device path node can not\r
-  be created successfully, then still give chance to do the dispatch,\r
-  which load the missing drivers if possible.\r
-\r
-  @param  DevicePathToConnect   The device path which will be connected, it can be\r
-                                a multi-instance device path\r
-\r
-  @retval EFI_SUCCESS           All handles associate with every device path  node\r
-                                have been created\r
-  @retval EFI_OUT_OF_RESOURCES  There is no resource to create new handles\r
-  @retval EFI_NOT_FOUND         Create the handle associate with one device  path\r
-                                node failed\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
-  EFI_DEVICE_PATH_PROTOCOL  *RemainingDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Next;\r
-  EFI_HANDLE                Handle;\r
-  EFI_HANDLE                PreviousHandle;\r
-  UINTN                     Size;\r
-  EFI_TPL                   CurrentTpl;\r
-\r
-  if (DevicePathToConnect == NULL) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  CurrentTpl  = EfiGetCurrentTpl ();\r
-\r
-  DevicePath        = DuplicateDevicePath (DevicePathToConnect);\r
-  if (DevicePath == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyOfDevicePath  = DevicePath;\r
-\r
-  do {\r
-    //\r
-    // The outer loop handles multi instance device paths.\r
-    // Only console variables contain multiple instance device paths.\r
-    //\r
-    // After this call DevicePath points to the next Instance\r
-    //\r
-    Instance  = GetNextDevicePathInstance (&DevicePath, &Size);\r
-    if (Instance == NULL) {\r
-      FreePool (CopyOfDevicePath);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    Next      = Instance;\r
-    while (!IsDevicePathEndType (Next)) {\r
-      Next = NextDevicePathNode (Next);\r
-    }\r
-\r
-    SetDevicePathEndNode (Next);\r
-\r
-    //\r
-    // Start the real work of connect with RemainingDevicePath\r
-    //\r
-    PreviousHandle = NULL;\r
-    do {\r
-      //\r
-      // Find the handle that best matches the Device Path. If it is only a\r
-      // partial match the remaining part of the device path is returned in\r
-      // RemainingDevicePath.\r
-      //\r
-      RemainingDevicePath = Instance;\r
-      Status              = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);\r
-\r
-      if (!EFI_ERROR (Status)) {\r
-        if (Handle == PreviousHandle) {\r
-          //\r
-          // If no forward progress is made try invoking the Dispatcher.\r
-          // A new FV may have been added to the system an new drivers\r
-          // may now be found.\r
-          // Status == EFI_SUCCESS means a driver was dispatched\r
-          // Status == EFI_NOT_FOUND means no new drivers were dispatched\r
-          //\r
-          if (CurrentTpl == TPL_APPLICATION) {\r
-            //\r
-            // Dispatch calls LoadImage/StartImage which cannot run at TPL > TPL_APPLICATION\r
-            //\r
-            Status = gDS->Dispatch ();\r
-          } else {\r
-            //\r
-            // Always return EFI_NOT_FOUND here\r
-            // to prevent dead loop when control handle is found but connection failded case\r
-            //\r
-            Status = EFI_NOT_FOUND;\r
-          }\r
-        }\r
-\r
-        if (!EFI_ERROR (Status)) {\r
-          PreviousHandle = Handle;\r
-          //\r
-          // Connect all drivers that apply to Handle and RemainingDevicePath,\r
-          // the Recursive flag is FALSE so only one level will be expanded.\r
-          //\r
-          // Do not check the connect status here, if the connect controller fail,\r
-          // then still give the chance to do dispatch, because partial\r
-          // RemainingDevicepath may be in the new FV\r
-          //\r
-          // 1. If the connect fail, RemainingDevicepath and handle will not\r
-          //    change, so next time will do the dispatch, then dispatch's status\r
-          //    will take effect\r
-          // 2. If the connect success, the RemainingDevicepath and handle will\r
-          //    change, then avoid the dispatch, we have chance to continue the\r
-          //    next connection\r
-          //\r
-          gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);\r
-        }\r
-      }\r
-      //\r
-      // Loop until RemainingDevicePath is an empty device path\r
-      //\r
-    } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));\r
-\r
-  } while (DevicePath != NULL);\r
-\r
-  if (CopyOfDevicePath != NULL) {\r
-    FreePool (CopyOfDevicePath);\r
-  }\r
-  //\r
-  // All handle with DevicePath exists in the handle database\r
-  //\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function will connect all current system handles recursively.\r
-\r
-  gBS->ConnectController() service is invoked for each handle exist in system handler buffer.\r
-  If the handle is bus type handler, all childrens also will be connected recursively\r
-  by gBS->ConnectController().\r
-\r
-  @retval EFI_SUCCESS           All handles and it's child handle have been connected\r
-  @retval EFI_STATUS            Error status returned by of gBS->LocateHandleBuffer().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectAllEfi (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       HandleCount;\r
-  EFI_HANDLE  *HandleBuffer;\r
-  UINTN       Index;\r
-\r
-  Status = gBS->LocateHandleBuffer (\r
-                  AllHandles,\r
-                  NULL,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
-  }\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool (HandleBuffer);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function will disconnect all current system handles.\r
-\r
-  gBS->DisconnectController() is invoked for each handle exists in system handle buffer.\r
-  If handle is a bus type handle, all childrens also are disconnected recursively by\r
-  gBS->DisconnectController().\r
-\r
-  @retval EFI_SUCCESS           All handles have been disconnected\r
-  @retval EFI_STATUS            Error status returned by of gBS->LocateHandleBuffer().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibDisconnectAllEfi (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       HandleCount;\r
-  EFI_HANDLE  *HandleBuffer;\r
-  UINTN       Index;\r
-\r
-  //\r
-  // Disconnect all\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  AllHandles,\r
-                  NULL,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
-  }\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool (HandleBuffer);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Connects all drivers to all controllers.\r
-  This function make sure all the current system driver will manage\r
-  the correspoinding controllers if have. And at the same time, make\r
-  sure all the system controllers have driver to manage it if have.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibConnectAllDriversToAllControllers (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  do {\r
-    //\r
-    // Connect All EFI 1.10 drivers following EFI 1.10 algorithm\r
-    //\r
-    BdsLibConnectAllEfi ();\r
-\r
-    //\r
-    // Check to see if it's possible to dispatch an more DXE drivers.\r
-    // The BdsLibConnectAllEfi () may have made new DXE drivers show up.\r
-    // If anything is Dispatched Status == EFI_SUCCESS and we will try\r
-    // the connect again.\r
-    //\r
-    Status = gDS->Dispatch ();\r
-\r
-  } while (!EFI_ERROR (Status));\r
-\r
-}\r
-\r
-\r
-/**\r
-  Connect the specific Usb device which match the short form device path,\r
-  and whose bus is determined by Host Controller (Uhci or Ehci).\r
-\r
-  @param  HostControllerPI      Uhci (0x00) or Ehci (0x20) or Both uhci and ehci\r
-                                (0xFF)\r
-  @param  RemainingDevicePath   a short-form device path that starts with the first\r
-                                element  being a USB WWID or a USB Class device\r
-                                path\r
-\r
-  @return EFI_INVALID_PARAMETER  RemainingDevicePath is NULL pointer.\r
-                                 RemainingDevicePath is not a USB device path.\r
-                                 Invalid HostControllerPI type.\r
-  @return EFI_SUCCESS            Success to connect USB device\r
-  @return EFI_NOT_FOUND          Fail to find handle for USB controller to connect.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectUsbDevByShortFormDP(\r
-  IN UINT8                      HostControllerPI,\r
-  IN EFI_DEVICE_PATH_PROTOCOL   *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_HANDLE                            *HandleArray;\r
-  UINTN                                 HandleArrayCount;\r
-  UINTN                                 Index;\r
-  EFI_PCI_IO_PROTOCOL                   *PciIo;\r
-  UINT8                                 Class[3];\r
-  BOOLEAN                               AtLeastOneConnected;\r
-\r
-  //\r
-  // Check the passed in parameters\r
-  //\r
-  if (RemainingDevicePath == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((DevicePathType (RemainingDevicePath) != MESSAGING_DEVICE_PATH) ||\r
-      ((DevicePathSubType (RemainingDevicePath) != MSG_USB_CLASS_DP)\r
-      && (DevicePathSubType (RemainingDevicePath) != MSG_USB_WWID_DP)\r
-      )) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (HostControllerPI != 0xFF &&\r
-      HostControllerPI != 0x00 &&\r
-      HostControllerPI != 0x20) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Find the usb host controller firstly, then connect with the remaining device path\r
-  //\r
-  AtLeastOneConnected = FALSE;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  NULL,\r
-                  &HandleArrayCount,\r
-                  &HandleArray\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    for (Index = 0; Index < HandleArrayCount; Index++) {\r
-      Status = gBS->HandleProtocol (\r
-                      HandleArray[Index],\r
-                      &gEfiPciIoProtocolGuid,\r
-                      (VOID **)&PciIo\r
-                      );\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Check whether the Pci device is the wanted usb host controller\r
-        //\r
-        Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);\r
-        if (!EFI_ERROR (Status)) {\r
-          if ((PCI_CLASS_SERIAL == Class[2]) &&\r
-              (PCI_CLASS_SERIAL_USB == Class[1])) {\r
-            if (HostControllerPI == Class[0] || HostControllerPI == 0xFF) {\r
-              Status = gBS->ConnectController (\r
-                              HandleArray[Index],\r
-                              NULL,\r
-                              RemainingDevicePath,\r
-                              FALSE\r
-                              );\r
-              if (!EFI_ERROR(Status)) {\r
-                AtLeastOneConnected = TRUE;\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-\r
-    if (HandleArray != NULL) {\r
-      FreePool (HandleArray);\r
-    }\r
-\r
-    if (AtLeastOneConnected) {\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
deleted file mode 100644 (file)
index aebf69a..0000000
+++ /dev/null
@@ -1,1050 +0,0 @@
-/** @file\r
-  BDS Lib functions which contain all the code to connect console device\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalBdsLib.h"\r
-\r
-\r
-/**\r
-  Check if we need to save the EFI variable with "ConVarName" as name\r
-  as NV type\r
-  If ConVarName is NULL, then ASSERT().\r
-\r
-  @param ConVarName The name of the EFI variable.\r
-\r
-  @retval TRUE    Set the EFI variable as NV type.\r
-  @retval FALSE   EFI variable as NV type can be set NonNV.\r
-**/\r
-BOOLEAN\r
-IsNvNeed (\r
-  IN CHAR16 *ConVarName\r
-  )\r
-{\r
-  CHAR16 *Ptr;\r
-\r
-  ASSERT (ConVarName != NULL);\r
-\r
-  Ptr = ConVarName;\r
-\r
-  //\r
-  // If the variable includes "Dev" at last, we consider\r
-  // it does not support NV attribute.\r
-  //\r
-  while (*Ptr != L'\0') {\r
-    Ptr++;\r
-  }\r
-\r
-  if (((INTN)((UINTN)Ptr - (UINTN)ConVarName) / sizeof (CHAR16)) <= 3) {\r
-    return TRUE;\r
-  }\r
-\r
-  if ((*(Ptr - 3) == 'D') && (*(Ptr - 2) == 'e') && (*(Ptr - 1) == 'v')) {\r
-    return FALSE;\r
-  } else {\r
-    return TRUE;\r
-  }\r
-}\r
-\r
-/**\r
-  Fill console handle in System Table if there are no valid console handle in.\r
-\r
-  Firstly, check the validation of console handle in System Table. If it is invalid,\r
-  update it by the first console device handle from EFI console variable.\r
-\r
-  @param  VarName            The name of the EFI console variable.\r
-  @param  ConsoleGuid        Specified Console protocol GUID.\r
-  @param  ConsoleHandle      On IN,  console handle in System Table to be checked.\r
-                             On OUT, new console handle in system table.\r
-  @param  ProtocolInterface  On IN,  console protocol on console handle in System Table to be checked.\r
-                             On OUT, new console protocol on new console handle in system table.\r
-\r
-  @retval TRUE               System Table has been updated.\r
-  @retval FALSE              System Table hasn't been updated.\r
-\r
-**/\r
-BOOLEAN\r
-UpdateSystemTableConsole (\r
-  IN     CHAR16                          *VarName,\r
-  IN     EFI_GUID                        *ConsoleGuid,\r
-  IN OUT EFI_HANDLE                      *ConsoleHandle,\r
-  IN OUT VOID                            **ProtocolInterface\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  UINTN                     DevicePathSize;\r
-  EFI_DEVICE_PATH_PROTOCOL  *FullDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *VarConsole;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
-  VOID                      *Interface;\r
-  EFI_HANDLE                NewHandle;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
-\r
-  ASSERT (VarName != NULL);\r
-  ASSERT (ConsoleHandle != NULL);\r
-  ASSERT (ConsoleGuid != NULL);\r
-  ASSERT (ProtocolInterface != NULL);\r
-\r
-  if (*ConsoleHandle != NULL) {\r
-    Status = gBS->HandleProtocol (\r
-                   *ConsoleHandle,\r
-                   ConsoleGuid,\r
-                   &Interface\r
-                   );\r
-    if (Status == EFI_SUCCESS && Interface == *ProtocolInterface) {\r
-      //\r
-      // If ConsoleHandle is valid and console protocol on this handle also\r
-      // also matched, just return.\r
-      //\r
-      return FALSE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Get all possible consoles device path from EFI variable\r
-  //\r
-  VarConsole = BdsLibGetVariableAndSize (\r
-                VarName,\r
-                &gEfiGlobalVariableGuid,\r
-                &DevicePathSize\r
-                );\r
-  if (VarConsole == NULL) {\r
-    //\r
-    // If there is no any console device, just return.\r
-    //\r
-    return FALSE;\r
-  }\r
-\r
-  FullDevicePath = VarConsole;\r
-\r
-  do {\r
-    //\r
-    // Check every instance of the console variable\r
-    //\r
-    Instance  = GetNextDevicePathInstance (&VarConsole, &DevicePathSize);\r
-    if (Instance == NULL) {\r
-      FreePool (FullDevicePath);\r
-      ASSERT (FALSE);\r
-    }\r
-\r
-    //\r
-    // Find console device handle by device path instance\r
-    //\r
-    Status = gBS->LocateDevicePath (\r
-                   ConsoleGuid,\r
-                   &Instance,\r
-                   &NewHandle\r
-                   );\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Get the console protocol on this console device handle\r
-      //\r
-      Status = gBS->HandleProtocol (\r
-                     NewHandle,\r
-                     ConsoleGuid,\r
-                     &Interface\r
-                     );\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Update new console handle in System Table.\r
-        //\r
-        *ConsoleHandle     = NewHandle;\r
-        *ProtocolInterface = Interface;\r
-        if (CompareGuid (ConsoleGuid, &gEfiSimpleTextOutProtocolGuid)) {\r
-          //\r
-          // If it is console out device, set console mode 80x25 if current mode is invalid.\r
-          //\r
-          TextOut = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *) Interface;\r
-          if (TextOut->Mode->Mode == -1) {\r
-            TextOut->SetMode (TextOut, 0);\r
-          }\r
-        }\r
-        return TRUE;\r
-      }\r
-    }\r
-\r
-  } while (Instance != NULL);\r
-\r
-  //\r
-  // No any available console devcie found.\r
-  //\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  This function update console variable based on ConVarName, it can\r
-  add or remove one specific console device path from the variable\r
-\r
-  @param  ConVarName               Console related variable name, ConIn, ConOut,\r
-                                   ErrOut.\r
-  @param  CustomizedConDevicePath  The console device path which will be added to\r
-                                   the console variable ConVarName, this parameter\r
-                                   can not be multi-instance.\r
-  @param  ExclusiveDevicePath      The console device path which will be removed\r
-                                   from the console variable ConVarName, this\r
-                                   parameter can not be multi-instance.\r
-\r
-  @retval EFI_UNSUPPORTED          The added device path is same to the removed one.\r
-  @retval EFI_SUCCESS              Success add or remove the device path from  the\r
-                                   console variable.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibUpdateConsoleVariable (\r
-  IN  CHAR16                    *ConVarName,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *CustomizedConDevicePath,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *ExclusiveDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *VarConsole;\r
-  UINTN                     DevicePathSize;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempNewDevicePath;\r
-  UINT32                    Attributes;\r
-\r
-  VarConsole      = NULL;\r
-  DevicePathSize  = 0;\r
-\r
-  //\r
-  // Notes: check the device path point, here should check\r
-  // with compare memory\r
-  //\r
-  if (CustomizedConDevicePath == ExclusiveDevicePath) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Delete the ExclusiveDevicePath from current default console\r
-  //\r
-  VarConsole = BdsLibGetVariableAndSize (\r
-                ConVarName,\r
-                &gEfiGlobalVariableGuid,\r
-                &DevicePathSize\r
-                );\r
-\r
-  //\r
-  // Initialize NewDevicePath\r
-  //\r
-  NewDevicePath  = VarConsole;\r
-\r
-  //\r
-  // If ExclusiveDevicePath is even the part of the instance in VarConsole, delete it.\r
-  // In the end, NewDevicePath is the final device path.\r
-  //\r
-  if (ExclusiveDevicePath != NULL && VarConsole != NULL) {\r
-      NewDevicePath = BdsLibDelPartMatchInstance (VarConsole, ExclusiveDevicePath);\r
-  }\r
-  //\r
-  // Try to append customized device path to NewDevicePath.\r
-  //\r
-  if (CustomizedConDevicePath != NULL) {\r
-    if (!BdsLibMatchDevicePaths (NewDevicePath, CustomizedConDevicePath)) {\r
-      //\r
-      // Check if there is part of CustomizedConDevicePath in NewDevicePath, delete it.\r
-      //\r
-      NewDevicePath = BdsLibDelPartMatchInstance (NewDevicePath, CustomizedConDevicePath);\r
-      //\r
-      // In the first check, the default console variable will be _ModuleEntryPoint,\r
-      // just append current customized device path\r
-      //\r
-      TempNewDevicePath = NewDevicePath;\r
-      NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);\r
-      if (TempNewDevicePath != NULL) {\r
-        FreePool(TempNewDevicePath);\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // The attribute for ConInDev, ConOutDev and ErrOutDev does not include NV.\r
-  //\r
-  if (IsNvNeed(ConVarName)) {\r
-    //\r
-    // ConVarName has NV attribute.\r
-    //\r
-    Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE;\r
-  } else {\r
-    //\r
-    // ConVarName does not have NV attribute.\r
-    //\r
-    Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;\r
-  }\r
-\r
-  //\r
-  // Finally, Update the variable of the default console by NewDevicePath\r
-  //\r
-  DevicePathSize = GetDevicePathSize (NewDevicePath);\r
-  Status = SetVariableAndReportStatusCodeOnError (\r
-             ConVarName,\r
-             &gEfiGlobalVariableGuid,\r
-             Attributes,\r
-             DevicePathSize,\r
-             NewDevicePath\r
-             );\r
-  if ((DevicePathSize == 0) && (Status == EFI_NOT_FOUND)) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-\r
-  if (VarConsole == NewDevicePath) {\r
-    if (VarConsole != NULL) {\r
-      FreePool(VarConsole);\r
-    }\r
-  } else {\r
-    if (VarConsole != NULL) {\r
-      FreePool(VarConsole);\r
-    }\r
-    if (NewDevicePath != NULL) {\r
-      FreePool(NewDevicePath);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-\r
-}\r
-\r
-\r
-/**\r
-  Connect the console device base on the variable ConVarName, if\r
-  device path of the ConVarName is multi-instance device path and\r
-  anyone of the instances is connected success, then this function\r
-  will return success.\r
-  If the handle associate with one device path node can not\r
-  be created successfully, then still give chance to do the dispatch,\r
-  which load the missing drivers if possible..\r
-\r
-  @param  ConVarName               Console related variable name, ConIn, ConOut,\r
-                                   ErrOut.\r
-\r
-  @retval EFI_NOT_FOUND            There is not any console devices connected\r
-                                   success\r
-  @retval EFI_SUCCESS              Success connect any one instance of the console\r
-                                   device path base on the variable ConVarName.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectConsoleVariable (\r
-  IN  CHAR16                 *ConVarName\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *StartDevicePath;\r
-  UINTN                     VariableSize;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Next;\r
-  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;\r
-  UINTN                     Size;\r
-  BOOLEAN                   DeviceExist;\r
-\r
-  Status      = EFI_SUCCESS;\r
-  DeviceExist = FALSE;\r
-\r
-  //\r
-  // Check if the console variable exist\r
-  //\r
-  StartDevicePath = BdsLibGetVariableAndSize (\r
-                      ConVarName,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &VariableSize\r
-                      );\r
-  if (StartDevicePath == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  CopyOfDevicePath = StartDevicePath;\r
-  do {\r
-    //\r
-    // Check every instance of the console variable\r
-    //\r
-    Instance  = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);\r
-    if (Instance == NULL) {\r
-      FreePool (StartDevicePath);\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    Next      = Instance;\r
-    while (!IsDevicePathEndType (Next)) {\r
-      Next = NextDevicePathNode (Next);\r
-    }\r
-\r
-    SetDevicePathEndNode (Next);\r
-    //\r
-    // Connect the USB console\r
-    // USB console device path is a short-form device path that\r
-    //  starts with the first element being a USB WWID\r
-    //  or a USB Class device path\r
-    //\r
-    if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&\r
-       ((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)\r
-       || (DevicePathSubType (Instance) == MSG_USB_WWID_DP)\r
-       )) {\r
-      Status = BdsLibConnectUsbDevByShortFormDP (0xFF, Instance);\r
-      if (!EFI_ERROR (Status)) {\r
-        DeviceExist = TRUE;\r
-      }\r
-    } else {\r
-      //\r
-      // Connect the instance device path\r
-      //\r
-      Status = BdsLibConnectDevicePath (Instance);\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // Delete the instance from the console varialbe\r
-        //\r
-        BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);\r
-      } else {\r
-        DeviceExist = TRUE;\r
-      }\r
-    }\r
-    FreePool(Instance);\r
-  } while (CopyOfDevicePath != NULL);\r
-\r
-  FreePool (StartDevicePath);\r
-\r
-  if (!DeviceExist) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function will search every simpletext device in current system,\r
-  and make every simpletext device as pertantial console device.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibConnectAllConsoles (\r
-  VOID\r
-  )\r
-{\r
-  UINTN                     Index;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ConDevicePath;\r
-  UINTN                     HandleCount;\r
-  EFI_HANDLE                *HandleBuffer;\r
-\r
-  Index         = 0;\r
-  HandleCount   = 0;\r
-  HandleBuffer  = NULL;\r
-  ConDevicePath = NULL;\r
-\r
-  //\r
-  // Update all the console variables\r
-  //\r
-  gBS->LocateHandleBuffer (\r
-          ByProtocol,\r
-          &gEfiSimpleTextInProtocolGuid,\r
-          NULL,\r
-          &HandleCount,\r
-          &HandleBuffer\r
-          );\r
-\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    gBS->HandleProtocol (\r
-            HandleBuffer[Index],\r
-            &gEfiDevicePathProtocolGuid,\r
-            (VOID **) &ConDevicePath\r
-            );\r
-    BdsLibUpdateConsoleVariable (L"ConIn", ConDevicePath, NULL);\r
-  }\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool(HandleBuffer);\r
-    HandleBuffer = NULL;\r
-  }\r
-\r
-  gBS->LocateHandleBuffer (\r
-          ByProtocol,\r
-          &gEfiSimpleTextOutProtocolGuid,\r
-          NULL,\r
-          &HandleCount,\r
-          &HandleBuffer\r
-          );\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    gBS->HandleProtocol (\r
-            HandleBuffer[Index],\r
-            &gEfiDevicePathProtocolGuid,\r
-            (VOID **) &ConDevicePath\r
-            );\r
-    BdsLibUpdateConsoleVariable (L"ConOut", ConDevicePath, NULL);\r
-    BdsLibUpdateConsoleVariable (L"ErrOut", ConDevicePath, NULL);\r
-  }\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool(HandleBuffer);\r
-  }\r
-\r
-  //\r
-  // Connect all console variables\r
-  //\r
-  BdsLibConnectAllDefaultConsoles ();\r
-\r
-}\r
-\r
-/**\r
-  This function will connect console device base on the console\r
-  device variable ConIn, ConOut and ErrOut.\r
-\r
-  @retval EFI_SUCCESS              At least one of the ConIn and ConOut device have\r
-                                   been connected success.\r
-  @retval EFI_STATUS               Return the status of BdsLibConnectConsoleVariable ().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectAllDefaultConsoles (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  BOOLEAN                   SystemTableUpdated;\r
-\r
-  //\r
-  // Connect all default console variables\r
-  //\r
-\r
-  //\r
-  // It seems impossible not to have any ConOut device on platform,\r
-  // so we check the status here.\r
-  //\r
-  Status = BdsLibConnectConsoleVariable (L"ConOut");\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Insert the performance probe for Console Out\r
-  //\r
-  PERF_START (NULL, "ConOut", "BDS", 1);\r
-  PERF_END (NULL, "ConOut", "BDS", 0);\r
-\r
-  //\r
-  // Because possibly the platform is legacy free, in such case,\r
-  // ConIn devices (Serial Port and PS2 Keyboard ) does not exist,\r
-  // so we need not check the status.\r
-  //\r
-  BdsLibConnectConsoleVariable (L"ConIn");\r
-\r
-  //\r
-  // The _ModuleEntryPoint err out var is legal.\r
-  //\r
-  BdsLibConnectConsoleVariable (L"ErrOut");\r
-\r
-  SystemTableUpdated = FALSE;\r
-  //\r
-  // Fill console handles in System Table if no console device assignd.\r
-  //\r
-  if (UpdateSystemTableConsole (L"ConIn", &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **) &gST->ConIn)) {\r
-    SystemTableUpdated = TRUE;\r
-  }\r
-  if (UpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **) &gST->ConOut)) {\r
-    SystemTableUpdated = TRUE;\r
-  }\r
-  if (UpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **) &gST->StdErr)) {\r
-    SystemTableUpdated = TRUE;\r
-  }\r
-\r
-  if (SystemTableUpdated) {\r
-    //\r
-    // Update the CRC32 in the EFI System Table header\r
-    //\r
-    gST->Hdr.CRC32 = 0;\r
-    gBS->CalculateCrc32 (\r
-          (UINT8 *) &gST->Hdr,\r
-          gST->Hdr.HeaderSize,\r
-          &gST->Hdr.CRC32\r
-          );\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-/**\r
-  This function will connect console device except ConIn base on the console\r
-  device variable  ConOut and ErrOut.\r
-\r
-  @retval EFI_SUCCESS              At least one of the ConOut device have\r
-                                   been connected success.\r
-  @retval EFI_STATUS               Return the status of BdsLibConnectConsoleVariable ().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectAllDefaultConsolesWithOutConIn (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  BOOLEAN                   SystemTableUpdated;\r
-\r
-  //\r
-  // Connect all default console variables except ConIn\r
-  //\r
-\r
-  //\r
-  // It seems impossible not to have any ConOut device on platform,\r
-  // so we check the status here.\r
-  //\r
-  Status = BdsLibConnectConsoleVariable (L"ConOut");\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Insert the performance probe for Console Out\r
-  //\r
-  PERF_START (NULL, "ConOut", "BDS", 1);\r
-  PERF_END (NULL, "ConOut", "BDS", 0);\r
-\r
-  //\r
-  // The _ModuleEntryPoint err out var is legal.\r
-  //\r
-  BdsLibConnectConsoleVariable (L"ErrOut");\r
-\r
-  SystemTableUpdated = FALSE;\r
-  //\r
-  // Fill console handles in System Table if no console device assignd.\r
-  //\r
-  if (UpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **) &gST->ConOut)) {\r
-    SystemTableUpdated = TRUE;\r
-  }\r
-  if (UpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **) &gST->StdErr)) {\r
-    SystemTableUpdated = TRUE;\r
-  }\r
-\r
-  if (SystemTableUpdated) {\r
-    //\r
-    // Update the CRC32 in the EFI System Table header\r
-    //\r
-    gST->Hdr.CRC32 = 0;\r
-    gBS->CalculateCrc32 (\r
-          (UINT8 *) &gST->Hdr,\r
-          gST->Hdr.HeaderSize,\r
-          &gST->Hdr.CRC32\r
-          );\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-/**\r
-  Use SystemTable Conout to stop video based Simple Text Out consoles from going\r
-  to the video device. Put up LogoFile on every video device that is a console.\r
-\r
-  @param[in]  LogoFile   File name of logo to display on the center of the screen.\r
-\r
-  @retval EFI_SUCCESS     ConsoleControl has been flipped to graphics and logo displayed.\r
-  @retval EFI_UNSUPPORTED Logo not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EnableQuietBoot (\r
-  IN  EFI_GUID  *LogoFile\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_OEM_BADGING_PROTOCOL      *Badging;\r
-  UINT32                        SizeOfX;\r
-  UINT32                        SizeOfY;\r
-  INTN                          DestX;\r
-  INTN                          DestY;\r
-  UINT8                         *ImageData;\r
-  UINTN                         ImageSize;\r
-  UINTN                         BltSize;\r
-  UINT32                        Instance;\r
-  EFI_BADGING_FORMAT            Format;\r
-  EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;\r
-  UINTN                         CoordinateX;\r
-  UINTN                         CoordinateY;\r
-  UINTN                         Height;\r
-  UINTN                         Width;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
-  EFI_UGA_DRAW_PROTOCOL         *UgaDraw;\r
-  UINT32                        ColorDepth;\r
-  UINT32                        RefreshRate;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
-  EFI_BOOT_LOGO_PROTOCOL        *BootLogo;\r
-  UINTN                         NumberOfLogos;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LogoBlt;\r
-  UINTN                         LogoDestX;\r
-  UINTN                         LogoDestY;\r
-  UINTN                         LogoHeight;\r
-  UINTN                         LogoWidth;\r
-  UINTN                         NewDestX;\r
-  UINTN                         NewDestY;\r
-  UINTN                         NewHeight;\r
-  UINTN                         NewWidth;\r
-  UINT64                        BufferSize;\r
-\r
-  UgaDraw = NULL;\r
-  //\r
-  // Try to open GOP first\r
-  //\r
-  Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);\r
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-    GraphicsOutput = NULL;\r
-    //\r
-    // Open GOP failed, try to open UGA\r
-    //\r
-    Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Try to open Boot Logo Protocol.\r
-  //\r
-  BootLogo = NULL;\r
-  gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);\r
-\r
-  //\r
-  // Erase Cursor from screen\r
-  //\r
-  gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r
-\r
-  Badging = NULL;\r
-  Status  = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID **) &Badging);\r
-\r
-  if (GraphicsOutput != NULL) {\r
-    SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
-    SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
-\r
-  } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-    Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Blt = NULL;\r
-  NumberOfLogos = 0;\r
-  LogoDestX = 0;\r
-  LogoDestY = 0;\r
-  LogoHeight = 0;\r
-  LogoWidth = 0;\r
-  NewDestX = 0;\r
-  NewDestY = 0;\r
-  NewHeight = 0;\r
-  NewWidth = 0;\r
-  Instance = 0;\r
-  while (1) {\r
-    ImageData = NULL;\r
-    ImageSize = 0;\r
-\r
-    if (Badging != NULL) {\r
-      //\r
-      // Get image from OEMBadging protocol.\r
-      //\r
-      Status = Badging->GetImage (\r
-                          Badging,\r
-                          &Instance,\r
-                          &Format,\r
-                          &ImageData,\r
-                          &ImageSize,\r
-                          &Attribute,\r
-                          &CoordinateX,\r
-                          &CoordinateY\r
-                          );\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-\r
-      //\r
-      // Currently only support BMP format.\r
-      //\r
-      if (Format != EfiBadgingFormatBMP) {\r
-        if (ImageData != NULL) {\r
-          FreePool (ImageData);\r
-        }\r
-        continue;\r
-      }\r
-    } else {\r
-      //\r
-      // Get the specified image from FV.\r
-      //\r
-      Status = GetSectionFromAnyFv (LogoFile, EFI_SECTION_RAW, 0, (VOID **) &ImageData, &ImageSize);\r
-      if (EFI_ERROR (Status)) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-\r
-      CoordinateX = 0;\r
-      CoordinateY = 0;\r
-      if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
-        Attribute   = EfiBadgingDisplayAttributeCenter;\r
-      } else {\r
-        Attribute   = EfiBadgingDisplayAttributeCustomized;\r
-      }\r
-    }\r
-\r
-    if (Blt != NULL) {\r
-      FreePool (Blt);\r
-    }\r
-    Blt = NULL;\r
-    Status = TranslateBmpToGopBlt (\r
-              ImageData,\r
-              ImageSize,\r
-              &Blt,\r
-              &BltSize,\r
-              &Height,\r
-              &Width\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (ImageData);\r
-\r
-      if (Badging == NULL) {\r
-        return Status;\r
-      } else {\r
-        continue;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Calculate the display position according to Attribute.\r
-    //\r
-    switch (Attribute) {\r
-    case EfiBadgingDisplayAttributeLeftTop:\r
-      DestX = CoordinateX;\r
-      DestY = CoordinateY;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenterTop:\r
-      DestX = (SizeOfX - Width) / 2;\r
-      DestY = CoordinateY;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeRightTop:\r
-      DestX = (SizeOfX - Width - CoordinateX);\r
-      DestY = CoordinateY;;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenterRight:\r
-      DestX = (SizeOfX - Width - CoordinateX);\r
-      DestY = (SizeOfY - Height) / 2;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeRightBottom:\r
-      DestX = (SizeOfX - Width - CoordinateX);\r
-      DestY = (SizeOfY - Height - CoordinateY);\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenterBottom:\r
-      DestX = (SizeOfX - Width) / 2;\r
-      DestY = (SizeOfY - Height - CoordinateY);\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeLeftBottom:\r
-      DestX = CoordinateX;\r
-      DestY = (SizeOfY - Height - CoordinateY);\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenterLeft:\r
-      DestX = CoordinateX;\r
-      DestY = (SizeOfY - Height) / 2;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenter:\r
-      DestX = (SizeOfX - Width) / 2;\r
-      DestY = (SizeOfY - Height) / 2;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCustomized:\r
-      DestX = (SizeOfX - Width) / 2;\r
-      DestY = ((SizeOfY * 382) / 1000) - Height / 2;\r
-      break;\r
-\r
-    default:\r
-      DestX = CoordinateX;\r
-      DestY = CoordinateY;\r
-      break;\r
-    }\r
-\r
-    if ((DestX >= 0) && (DestY >= 0)) {\r
-      if (GraphicsOutput != NULL) {\r
-        Status = GraphicsOutput->Blt (\r
-                            GraphicsOutput,\r
-                            Blt,\r
-                            EfiBltBufferToVideo,\r
-                            0,\r
-                            0,\r
-                            (UINTN) DestX,\r
-                            (UINTN) DestY,\r
-                            Width,\r
-                            Height,\r
-                            Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-                            );\r
-      } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-        Status = UgaDraw->Blt (\r
-                            UgaDraw,\r
-                            (EFI_UGA_PIXEL *) Blt,\r
-                            EfiUgaBltBufferToVideo,\r
-                            0,\r
-                            0,\r
-                            (UINTN) DestX,\r
-                            (UINTN) DestY,\r
-                            Width,\r
-                            Height,\r
-                            Width * sizeof (EFI_UGA_PIXEL)\r
-                            );\r
-      } else {\r
-        Status = EFI_UNSUPPORTED;\r
-      }\r
-\r
-      //\r
-      // Report displayed Logo information.\r
-      //\r
-      if (!EFI_ERROR (Status)) {\r
-        NumberOfLogos++;\r
-\r
-        if (LogoWidth == 0) {\r
-          //\r
-          // The first Logo.\r
-          //\r
-          LogoDestX = (UINTN) DestX;\r
-          LogoDestY = (UINTN) DestY;\r
-          LogoWidth = Width;\r
-          LogoHeight = Height;\r
-        } else {\r
-          //\r
-          // Merge new logo with old one.\r
-          //\r
-          NewDestX = MIN ((UINTN) DestX, LogoDestX);\r
-          NewDestY = MIN ((UINTN) DestY, LogoDestY);\r
-          NewWidth = MAX ((UINTN) DestX + Width, LogoDestX + LogoWidth) - NewDestX;\r
-          NewHeight = MAX ((UINTN) DestY + Height, LogoDestY + LogoHeight) - NewDestY;\r
-\r
-          LogoDestX = NewDestX;\r
-          LogoDestY = NewDestY;\r
-          LogoWidth = NewWidth;\r
-          LogoHeight = NewHeight;\r
-        }\r
-      }\r
-    }\r
-\r
-    FreePool (ImageData);\r
-\r
-    if (Badging == NULL) {\r
-      break;\r
-    }\r
-  }\r
-\r
-Done:\r
-  if (BootLogo == NULL || NumberOfLogos == 0) {\r
-    //\r
-    // No logo displayed.\r
-    //\r
-    if (Blt != NULL) {\r
-      FreePool (Blt);\r
-    }\r
-\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Advertise displayed Logo information.\r
-  //\r
-  if (NumberOfLogos == 1) {\r
-    //\r
-    // Only one logo displayed, use its Blt buffer directly for BootLogo protocol.\r
-    //\r
-    LogoBlt = Blt;\r
-    Status = EFI_SUCCESS;\r
-  } else {\r
-    //\r
-    // More than one Logo displayed, get merged BltBuffer using VideoToBuffer operation.\r
-    //\r
-    if (Blt != NULL) {\r
-      FreePool (Blt);\r
-    }\r
-\r
-    //\r
-    // Ensure the LogoHeight * LogoWidth doesn't overflow\r
-    //\r
-    if (LogoHeight > DivU64x64Remainder ((UINTN) ~0, LogoWidth, NULL)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    BufferSize = MultU64x64 (LogoWidth, LogoHeight);\r
-\r
-    //\r
-    // Ensure the BufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow\r
-    //\r
-    if (BufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    LogoBlt = AllocateZeroPool ((UINTN)BufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-    if (LogoBlt == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    if (GraphicsOutput != NULL) {\r
-      Status = GraphicsOutput->Blt (\r
-                          GraphicsOutput,\r
-                          LogoBlt,\r
-                          EfiBltVideoToBltBuffer,\r
-                          LogoDestX,\r
-                          LogoDestY,\r
-                          0,\r
-                          0,\r
-                          LogoWidth,\r
-                          LogoHeight,\r
-                          LogoWidth * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-                          );\r
-    } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-      Status = UgaDraw->Blt (\r
-                          UgaDraw,\r
-                          (EFI_UGA_PIXEL *) LogoBlt,\r
-                          EfiUgaVideoToBltBuffer,\r
-                          LogoDestX,\r
-                          LogoDestY,\r
-                          0,\r
-                          0,\r
-                          LogoWidth,\r
-                          LogoHeight,\r
-                          LogoWidth * sizeof (EFI_UGA_PIXEL)\r
-                          );\r
-    } else {\r
-      Status = EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    BootLogo->SetBootLogo (BootLogo, LogoBlt, LogoDestX, LogoDestY, LogoWidth, LogoHeight);\r
-  }\r
-  FreePool (LogoBlt);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Use SystemTable Conout to turn on video based Simple Text Out consoles. The\r
-  Simple Text Out screens will now be synced up with all non video output devices\r
-\r
-  @retval EFI_SUCCESS     UGA devices are back in text mode and synced up.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DisableQuietBoot (\r
-  VOID\r
-  )\r
-{\r
-\r
-  //\r
-  // Enable Cursor on Screen\r
-  //\r
-  gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
deleted file mode 100644 (file)
index e034f59..0000000
+++ /dev/null
@@ -1,1583 +0,0 @@
-/** @file\r
-  Misc BDS library function\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalBdsLib.h"\r
-\r
-\r
-#define MAX_STRING_LEN        200\r
-\r
-BOOLEAN   mFeaturerSwitch = TRUE;\r
-BOOLEAN   mResetRequired  = FALSE;\r
-\r
-extern UINT16 gPlatformBootTimeOutDefault;\r
-\r
-/**\r
-  The function will go through the driver option link list, load and start\r
-  every driver the driver option device path point to.\r
-\r
-  @param  BdsDriverLists        The header of the current driver option link list\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibLoadDrivers (\r
-  IN LIST_ENTRY                   *BdsDriverLists\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  LIST_ENTRY                *Link;\r
-  BDS_COMMON_OPTION         *Option;\r
-  EFI_HANDLE                ImageHandle;\r
-  EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
-  UINTN                     ExitDataSize;\r
-  CHAR16                    *ExitData;\r
-  BOOLEAN                   ReconnectAll;\r
-\r
-  ReconnectAll = FALSE;\r
-\r
-  //\r
-  // Process the driver option\r
-  //\r
-  for (Link = BdsDriverLists->ForwardLink; Link != BdsDriverLists; Link = Link->ForwardLink) {\r
-    Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
-\r
-    //\r
-    // If a load option is not marked as LOAD_OPTION_ACTIVE,\r
-    // the boot manager will not automatically load the option.\r
-    //\r
-    if (!IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_ACTIVE)) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // If a driver load option is marked as LOAD_OPTION_FORCE_RECONNECT,\r
-    // then all of the EFI drivers in the system will be disconnected and\r
-    // reconnected after the last driver load option is processed.\r
-    //\r
-    if (IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_FORCE_RECONNECT)) {\r
-      ReconnectAll = TRUE;\r
-    }\r
-\r
-    //\r
-    // Make sure the driver path is connected.\r
-    //\r
-    BdsLibConnectDevicePath (Option->DevicePath);\r
-\r
-    //\r
-    // Load and start the image that Driver#### describes\r
-    //\r
-    Status = gBS->LoadImage (\r
-                    FALSE,\r
-                    gImageHandle,\r
-                    Option->DevicePath,\r
-                    NULL,\r
-                    0,\r
-                    &ImageHandle\r
-                    );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &ImageInfo);\r
-\r
-      //\r
-      // Verify whether this image is a driver, if not,\r
-      // exit it and continue to parse next load option\r
-      //\r
-      if (ImageInfo->ImageCodeType != EfiBootServicesCode && ImageInfo->ImageCodeType != EfiRuntimeServicesCode) {\r
-        gBS->Exit (ImageHandle, EFI_INVALID_PARAMETER, 0, NULL);\r
-        continue;\r
-      }\r
-\r
-      if (Option->LoadOptionsSize != 0) {\r
-        ImageInfo->LoadOptionsSize  = Option->LoadOptionsSize;\r
-        ImageInfo->LoadOptions      = Option->LoadOptions;\r
-      }\r
-      //\r
-      // Before calling the image, enable the Watchdog Timer for\r
-      // the 5 Minute period\r
-      //\r
-      gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
-\r
-      Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);\r
-      DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Driver Return Status = %r\n", Status));\r
-\r
-      //\r
-      // Clear the Watchdog Timer after the image returns\r
-      //\r
-      gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Process the LOAD_OPTION_FORCE_RECONNECT driver option\r
-  //\r
-  if (ReconnectAll) {\r
-    BdsLibDisconnectAllEfi ();\r
-    BdsLibConnectAll ();\r
-  }\r
-\r
-}\r
-\r
-/**\r
-  Get the Option Number that does not used.\r
-  Try to locate the specific option variable one by one utile find a free number.\r
-\r
-  @param  VariableName          Indicate if the boot#### or driver#### option\r
-\r
-  @return The Minimal Free Option Number\r
-\r
-**/\r
-UINT16\r
-BdsLibGetFreeOptionNumber (\r
-  IN  CHAR16    *VariableName\r
-  )\r
-{\r
-  UINTN         Index;\r
-  CHAR16        StrTemp[10];\r
-  UINT16        *OptionBuffer;\r
-  UINTN         OptionSize;\r
-\r
-  //\r
-  // Try to find the minimum free number from 0, 1, 2, 3....\r
-  //\r
-  Index = 0;\r
-  do {\r
-    if (*VariableName == 'B') {\r
-      UnicodeSPrint (StrTemp, sizeof (StrTemp), L"Boot%04x", Index);\r
-    } else {\r
-      UnicodeSPrint (StrTemp, sizeof (StrTemp), L"Driver%04x", Index);\r
-    }\r
-    //\r
-    // try if the option number is used\r
-    //\r
-    OptionBuffer = BdsLibGetVariableAndSize (\r
-                     StrTemp,\r
-                     &gEfiGlobalVariableGuid,\r
-                     &OptionSize\r
-                     );\r
-    if (OptionBuffer == NULL) {\r
-      break;\r
-    }\r
-    FreePool(OptionBuffer);\r
-    Index++;\r
-  } while (TRUE);\r
-\r
-  return ((UINT16) Index);\r
-}\r
-\r
-\r
-/**\r
-  This function will register the new boot#### or driver#### option base on\r
-  the VariableName. The new registered boot#### or driver#### will be linked\r
-  to BdsOptionList and also update to the VariableName. After the boot#### or\r
-  driver#### updated, the BootOrder or DriverOrder will also be updated.\r
-\r
-  @param  BdsOptionList         The header of the boot#### or driver#### link list\r
-  @param  DevicePath            The device path which the boot#### or driver####\r
-                                option present\r
-  @param  String                The description of the boot#### or driver####\r
-  @param  VariableName          Indicate if the boot#### or driver#### option\r
-\r
-  @retval EFI_SUCCESS           The boot#### or driver#### have been success\r
-                                registered\r
-  @retval EFI_STATUS            Return the status of gRT->SetVariable ().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibRegisterNewOption (\r
-  IN  LIST_ENTRY                     *BdsOptionList,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL       *DevicePath,\r
-  IN  CHAR16                         *String,\r
-  IN  CHAR16                         *VariableName\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  UINTN                     Index;\r
-  UINT16                    RegisterOptionNumber;\r
-  UINT16                    *TempOptionPtr;\r
-  UINTN                     TempOptionSize;\r
-  UINT16                    *OptionOrderPtr;\r
-  VOID                      *OptionPtr;\r
-  UINTN                     OptionSize;\r
-  UINT8                     *TempPtr;\r
-  EFI_DEVICE_PATH_PROTOCOL  *OptionDevicePath;\r
-  CHAR16                    *Description;\r
-  CHAR16                    OptionName[10];\r
-  BOOLEAN                   UpdateDescription;\r
-  UINT16                    BootOrderEntry;\r
-  UINTN                     OrderItemNum;\r
-\r
-  if (DevicePath == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OptionPtr             = NULL;\r
-  OptionSize            = 0;\r
-  TempPtr               = NULL;\r
-  OptionDevicePath      = NULL;\r
-  Description           = NULL;\r
-  OptionOrderPtr        = NULL;\r
-  UpdateDescription     = FALSE;\r
-  Status                = EFI_SUCCESS;\r
-  ZeroMem (OptionName, sizeof (OptionName));\r
-\r
-  TempOptionSize = 0;\r
-  TempOptionPtr = BdsLibGetVariableAndSize (\r
-                    VariableName,\r
-                    &gEfiGlobalVariableGuid,\r
-                    &TempOptionSize\r
-                    );\r
-  //\r
-  // Compare with current option variable if the previous option is set in global variable.\r
-  //\r
-  for (Index = 0; Index < TempOptionSize / sizeof (UINT16); Index++) {\r
-    //\r
-    // TempOptionPtr must not be NULL if we have non-zero TempOptionSize.\r
-    //\r
-    ASSERT (TempOptionPtr != NULL);\r
-\r
-    if (*VariableName == 'B') {\r
-      UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", TempOptionPtr[Index]);\r
-    } else {\r
-      UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", TempOptionPtr[Index]);\r
-    }\r
-\r
-    OptionPtr = BdsLibGetVariableAndSize (\r
-                  OptionName,\r
-                  &gEfiGlobalVariableGuid,\r
-                  &OptionSize\r
-                  );\r
-    if (OptionPtr == NULL) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Validate the variable.\r
-    //\r
-    if (!ValidateOption(OptionPtr, OptionSize)) {\r
-      FreePool(OptionPtr);\r
-      continue;\r
-    }\r
-\r
-    TempPtr         =   OptionPtr;\r
-    TempPtr         +=  sizeof (UINT32) + sizeof (UINT16);\r
-    Description     =   (CHAR16 *) TempPtr;\r
-    TempPtr         +=  StrSize ((CHAR16 *) TempPtr);\r
-    OptionDevicePath =  (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
-\r
-    //\r
-    // Notes: the description may will change base on the GetStringToken\r
-    //\r
-    if (CompareMem (OptionDevicePath, DevicePath, GetDevicePathSize (OptionDevicePath)) == 0) {\r
-      if (CompareMem (Description, String, StrSize (Description)) == 0) {\r
-        //\r
-        // Got the option, so just return\r
-        //\r
-        FreePool (OptionPtr);\r
-        FreePool (TempOptionPtr);\r
-        return EFI_SUCCESS;\r
-      } else {\r
-        //\r
-        // Option description changed, need update.\r
-        //\r
-        UpdateDescription = TRUE;\r
-        FreePool (OptionPtr);\r
-        break;\r
-      }\r
-    }\r
-\r
-    FreePool (OptionPtr);\r
-  }\r
-\r
-  OptionSize          = sizeof (UINT32) + sizeof (UINT16) + StrSize (String);\r
-  OptionSize          += GetDevicePathSize (DevicePath);\r
-  OptionPtr           = AllocateZeroPool (OptionSize);\r
-  ASSERT (OptionPtr != NULL);\r
-\r
-  TempPtr             = OptionPtr;\r
-  *(UINT32 *) TempPtr = LOAD_OPTION_ACTIVE;\r
-  TempPtr             += sizeof (UINT32);\r
-  *(UINT16 *) TempPtr = (UINT16) GetDevicePathSize (DevicePath);\r
-  TempPtr             += sizeof (UINT16);\r
-  CopyMem (TempPtr, String, StrSize (String));\r
-  TempPtr             += StrSize (String);\r
-  CopyMem (TempPtr, DevicePath, GetDevicePathSize (DevicePath));\r
-\r
-  if (UpdateDescription) {\r
-    //\r
-    // The number in option#### to be updated.\r
-    // In this case, we must have non-NULL TempOptionPtr.\r
-    //\r
-    ASSERT (TempOptionPtr != NULL);\r
-    RegisterOptionNumber = TempOptionPtr[Index];\r
-  } else {\r
-    //\r
-    // The new option#### number\r
-    //\r
-    RegisterOptionNumber = BdsLibGetFreeOptionNumber(VariableName);\r
-  }\r
-\r
-  if (*VariableName == 'B') {\r
-    UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", RegisterOptionNumber);\r
-  } else {\r
-    UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", RegisterOptionNumber);\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  OptionName,\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  OptionSize,\r
-                  OptionPtr\r
-                  );\r
-  //\r
-  // Return if only need to update a changed description or fail to set option.\r
-  //\r
-  if (EFI_ERROR (Status) || UpdateDescription) {\r
-    FreePool (OptionPtr);\r
-    if (TempOptionPtr != NULL) {\r
-      FreePool (TempOptionPtr);\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  FreePool (OptionPtr);\r
-\r
-  //\r
-  // Update the option order variable\r
-  //\r
-\r
-  //\r
-  // If no option order\r
-  //\r
-  if (TempOptionSize == 0) {\r
-    BootOrderEntry = 0;\r
-    Status = gRT->SetVariable (\r
-                    VariableName,\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    sizeof (UINT16),\r
-                    &BootOrderEntry\r
-                    );\r
-    if (TempOptionPtr != NULL) {\r
-      FreePool (TempOptionPtr);\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // TempOptionPtr must not be NULL if TempOptionSize is not zero.\r
-  //\r
-  ASSERT (TempOptionPtr != NULL);\r
-  //\r
-  // Append the new option number to the original option order\r
-  //\r
-  OrderItemNum = (TempOptionSize / sizeof (UINT16)) + 1 ;\r
-  OptionOrderPtr = AllocateZeroPool ( OrderItemNum * sizeof (UINT16));\r
-  ASSERT (OptionOrderPtr!= NULL);\r
-  CopyMem (OptionOrderPtr, TempOptionPtr, (OrderItemNum - 1) * sizeof (UINT16));\r
-\r
-  OptionOrderPtr[Index] = RegisterOptionNumber;\r
-\r
-  Status = gRT->SetVariable (\r
-                  VariableName,\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  OrderItemNum * sizeof (UINT16),\r
-                  OptionOrderPtr\r
-                  );\r
-  FreePool (TempOptionPtr);\r
-  FreePool (OptionOrderPtr);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Returns the size of a device path in bytes.\r
-\r
-  This function returns the size, in bytes, of the device path data structure\r
-  specified by DevicePath including the end of device path node. If DevicePath\r
-  is NULL, then 0 is returned. If the length of the device path is bigger than\r
-  MaxSize, also return 0 to indicate this is an invalidate device path.\r
-\r
-  @param  DevicePath         A pointer to a device path data structure.\r
-  @param  MaxSize            Max valid device path size. If big than this size,\r
-                             return error.\r
-\r
-  @retval 0                  An invalid device path.\r
-  @retval Others             The size of a device path in bytes.\r
-\r
-**/\r
-UINTN\r
-GetDevicePathSizeEx (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
-  IN UINTN                           MaxSize\r
-  )\r
-{\r
-  UINTN  Size;\r
-  UINTN  NodeSize;\r
-\r
-  if (DevicePath == NULL) {\r
-    return 0;\r
-  }\r
-\r
-  //\r
-  // Search for the end of the device path structure\r
-  //\r
-  Size = 0;\r
-  while (!IsDevicePathEnd (DevicePath)) {\r
-    NodeSize = DevicePathNodeLength (DevicePath);\r
-    if (NodeSize < END_DEVICE_PATH_LENGTH) {\r
-      return 0;\r
-    }\r
-    Size += NodeSize;\r
-    if (Size > MaxSize) {\r
-      return 0;\r
-    }\r
-    DevicePath = NextDevicePathNode (DevicePath);\r
-  }\r
-  Size += DevicePathNodeLength (DevicePath);\r
-  if (Size > MaxSize) {\r
-    return 0;\r
-  }\r
-\r
-  return Size;\r
-}\r
-\r
-/**\r
-  Returns the length of a Null-terminated Unicode string. If the length is\r
-  bigger than MaxStringLen, return length 0 to indicate that this is an\r
-  invalidate string.\r
-\r
-  This function returns the byte length of Unicode characters in the Null-terminated\r
-  Unicode string specified by String.\r
-\r
-  If String is NULL, then ASSERT().\r
-  If String is not aligned on a 16-bit boundary, then ASSERT().\r
-\r
-  @param  String           A pointer to a Null-terminated Unicode string.\r
-  @param  MaxStringLen     Max string len in this string.\r
-\r
-  @retval 0                An invalid string.\r
-  @retval Others           The length of String.\r
-\r
-**/\r
-UINTN\r
-StrSizeEx (\r
-  IN      CONST CHAR16              *String,\r
-  IN      UINTN                     MaxStringLen\r
-  )\r
-{\r
-  UINTN                             Length;\r
-\r
-  ASSERT (String != NULL && MaxStringLen != 0);\r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
-\r
-  for (Length = 0; *String != L'\0' && MaxStringLen != Length; String++, Length+=2);\r
-\r
-  if (*String != L'\0' && MaxStringLen == Length) {\r
-    return 0;\r
-  }\r
-\r
-  return Length + 2;\r
-}\r
-\r
-/**\r
-  Validate the EFI Boot#### variable (VendorGuid/Name)\r
-\r
-  @param  Variable              Boot#### variable data.\r
-  @param  VariableSize          Returns the size of the EFI variable that was read\r
-\r
-  @retval TRUE                  The variable data is correct.\r
-  @retval FALSE                 The variable data is corrupted.\r
-\r
-**/\r
-BOOLEAN\r
-ValidateOption (\r
-  UINT8                     *Variable,\r
-  UINTN                     VariableSize\r
-  )\r
-{\r
-  UINT16                    FilePathSize;\r
-  UINT8                     *TempPtr;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  UINTN                     TempSize;\r
-\r
-  if (VariableSize <= sizeof (UINT16) + sizeof (UINT32)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Skip the option attribute\r
-  //\r
-  TempPtr    = Variable;\r
-  TempPtr   += sizeof (UINT32);\r
-\r
-  //\r
-  // Get the option's device path size\r
-  //\r
-  FilePathSize  = *(UINT16 *) TempPtr;\r
-  TempPtr      += sizeof (UINT16);\r
-\r
-  //\r
-  // Get the option's description string size\r
-  //\r
-  TempSize = StrSizeEx ((CHAR16 *) TempPtr, VariableSize - sizeof (UINT16) - sizeof (UINT32));\r
-  TempPtr += TempSize;\r
-\r
-  //\r
-  // Get the option's device path\r
-  //\r
-  DevicePath =  (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
-  TempPtr   += FilePathSize;\r
-\r
-  //\r
-  // Validation boot option variable.\r
-  //\r
-  if ((FilePathSize == 0) || (TempSize == 0)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if (TempSize + FilePathSize + sizeof (UINT16) + sizeof (UINT32) > VariableSize) {\r
-    return FALSE;\r
-  }\r
-\r
-  return (BOOLEAN) (GetDevicePathSizeEx (DevicePath, FilePathSize) != 0);\r
-}\r
-\r
-/**\r
-  Convert a single character to number.\r
-  It assumes the input Char is in the scope of L'0' ~ L'9' and L'A' ~ L'F'\r
-\r
-  @param Char    The input char which need to change to a hex number.\r
-\r
-**/\r
-UINTN\r
-CharToUint (\r
-  IN CHAR16                           Char\r
-  )\r
-{\r
-  if ((Char >= L'0') && (Char <= L'9')) {\r
-    return (Char - L'0');\r
-  }\r
-\r
-  if ((Char >= L'A') && (Char <= L'F')) {\r
-    return (Char - L'A' + 0xA);\r
-  }\r
-\r
-  ASSERT (FALSE);\r
-  return 0;\r
-}\r
-\r
-/**\r
-  Build the boot#### or driver#### option from the VariableName, the\r
-  build boot#### or driver#### will also be linked to BdsCommonOptionList.\r
-\r
-  @param  BdsCommonOptionList   The header of the boot#### or driver#### option\r
-                                link list\r
-  @param  VariableName          EFI Variable name indicate if it is boot#### or\r
-                                driver####\r
-\r
-  @retval BDS_COMMON_OPTION     Get the option just been created\r
-  @retval NULL                  Failed to get the new option\r
-\r
-**/\r
-BDS_COMMON_OPTION *\r
-EFIAPI\r
-BdsLibVariableToOption (\r
-  IN OUT LIST_ENTRY                   *BdsCommonOptionList,\r
-  IN  CHAR16                          *VariableName\r
-  )\r
-{\r
-  UINT32                    Attribute;\r
-  UINT16                    FilePathSize;\r
-  UINT8                     *Variable;\r
-  UINT8                     *TempPtr;\r
-  UINTN                     VariableSize;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  BDS_COMMON_OPTION         *Option;\r
-  VOID                      *LoadOptions;\r
-  UINT32                    LoadOptionsSize;\r
-  CHAR16                    *Description;\r
-  UINT8                     NumOff;\r
-\r
-  //\r
-  // Read the variable. We will never free this data.\r
-  //\r
-  Variable = BdsLibGetVariableAndSize (\r
-              VariableName,\r
-              &gEfiGlobalVariableGuid,\r
-              &VariableSize\r
-              );\r
-  if (Variable == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Validate Boot#### variable data.\r
-  //\r
-  if (!ValidateOption(Variable, VariableSize)) {\r
-    FreePool (Variable);\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Notes: careful defined the variable of Boot#### or\r
-  // Driver####, consider use some macro to abstract the code\r
-  //\r
-  //\r
-  // Get the option attribute\r
-  //\r
-  TempPtr   =  Variable;\r
-  Attribute =  *(UINT32 *) Variable;\r
-  TempPtr   += sizeof (UINT32);\r
-\r
-  //\r
-  // Get the option's device path size\r
-  //\r
-  FilePathSize =  *(UINT16 *) TempPtr;\r
-  TempPtr      += sizeof (UINT16);\r
-\r
-  //\r
-  // Get the option's description string\r
-  //\r
-  Description = (CHAR16 *) TempPtr;\r
-\r
-  //\r
-  // Get the option's description string size\r
-  //\r
-  TempPtr += StrSize((CHAR16 *) TempPtr);\r
-\r
-  //\r
-  // Get the option's device path\r
-  //\r
-  DevicePath =  (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
-  TempPtr    += FilePathSize;\r
-\r
-  //\r
-  // Get load opion data.\r
-  //\r
-  LoadOptions     = TempPtr;\r
-  LoadOptionsSize = (UINT32) (VariableSize - ((UINTN)TempPtr - (UINTN)Variable));\r
-\r
-  //\r
-  // The Console variables may have multiple device paths, so make\r
-  // an Entry for each one.\r
-  //\r
-  Option = AllocateZeroPool (sizeof (BDS_COMMON_OPTION));\r
-  if (Option == NULL) {\r
-    FreePool (Variable);\r
-    return NULL;\r
-  }\r
-\r
-  Option->Signature   = BDS_LOAD_OPTION_SIGNATURE;\r
-  Option->DevicePath  = AllocateZeroPool (GetDevicePathSize (DevicePath));\r
-  ASSERT(Option->DevicePath != NULL);\r
-  CopyMem (Option->DevicePath, DevicePath, GetDevicePathSize (DevicePath));\r
-\r
-  Option->Attribute   = Attribute;\r
-  Option->Description = AllocateZeroPool (StrSize (Description));\r
-  ASSERT(Option->Description != NULL);\r
-  CopyMem (Option->Description, Description, StrSize (Description));\r
-\r
-  Option->LoadOptions = AllocateZeroPool (LoadOptionsSize);\r
-  ASSERT(Option->LoadOptions != NULL);\r
-  CopyMem (Option->LoadOptions, LoadOptions, LoadOptionsSize);\r
-  Option->LoadOptionsSize = LoadOptionsSize;\r
-\r
-  //\r
-  // Get the value from VariableName Unicode string\r
-  // since the ISO standard assumes ASCII equivalent abbreviations, we can be safe in converting this\r
-  // Unicode stream to ASCII without any loss in meaning.\r
-  //\r
-  if (*VariableName == 'B') {\r
-    NumOff = (UINT8) (sizeof (L"Boot") / sizeof (CHAR16) - 1);\r
-    Option->BootCurrent = (UINT16) (CharToUint (VariableName[NumOff+0]) * 0x1000)\r
-               + (UINT16) (CharToUint (VariableName[NumOff+1]) * 0x100)\r
-               + (UINT16) (CharToUint (VariableName[NumOff+2]) * 0x10)\r
-               + (UINT16) (CharToUint (VariableName[NumOff+3]) * 0x1);\r
-  }\r
-  InsertTailList (BdsCommonOptionList, &Option->Link);\r
-  FreePool (Variable);\r
-  return Option;\r
-}\r
-\r
-/**\r
-  Process BootOrder, or DriverOrder variables, by calling\r
-  BdsLibVariableToOption () for each UINT16 in the variables.\r
-\r
-  @param  BdsCommonOptionList   The header of the option list base on variable\r
-                                VariableName\r
-  @param  VariableName          EFI Variable name indicate the BootOrder or\r
-                                DriverOrder\r
-\r
-  @retval EFI_SUCCESS           Success create the boot option or driver option\r
-                                list\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to get the boot option or driver option list\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibBuildOptionFromVar (\r
-  IN  LIST_ENTRY                      *BdsCommonOptionList,\r
-  IN  CHAR16                          *VariableName\r
-  )\r
-{\r
-  UINT16            *OptionOrder;\r
-  UINTN             OptionOrderSize;\r
-  UINTN             Index;\r
-  BDS_COMMON_OPTION *Option;\r
-  CHAR16            OptionName[20];\r
-\r
-  //\r
-  // Zero Buffer in order to get all BOOT#### variables\r
-  //\r
-  ZeroMem (OptionName, sizeof (OptionName));\r
-\r
-  //\r
-  // Read the BootOrder, or DriverOrder variable.\r
-  //\r
-  OptionOrder = BdsLibGetVariableAndSize (\r
-                  VariableName,\r
-                  &gEfiGlobalVariableGuid,\r
-                  &OptionOrderSize\r
-                  );\r
-  if (OptionOrder == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  for (Index = 0; Index < OptionOrderSize / sizeof (UINT16); Index++) {\r
-    if (*VariableName == 'B') {\r
-      UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", OptionOrder[Index]);\r
-    } else {\r
-      UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", OptionOrder[Index]);\r
-    }\r
-\r
-    Option              = BdsLibVariableToOption (BdsCommonOptionList, OptionName);\r
-    if (Option != NULL) {\r
-      Option->BootCurrent = OptionOrder[Index];\r
-    }\r
-  }\r
-\r
-  FreePool (OptionOrder);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Get boot mode by looking up configuration table and parsing HOB list\r
-\r
-  @param  BootMode              Boot mode from PEI handoff HOB.\r
-\r
-  @retval EFI_SUCCESS           Successfully get boot mode\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibGetBootMode (\r
-  OUT EFI_BOOT_MODE       *BootMode\r
-  )\r
-{\r
-  *BootMode = GetBootModeHob ();\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r
-  buffer, and the size of the buffer. If failure return NULL.\r
-\r
-  @param  Name                  String part of EFI variable name\r
-  @param  VendorGuid            GUID part of EFI variable name\r
-  @param  VariableSize          Returns the size of the EFI variable that was read\r
-\r
-  @return                       Dynamically allocated memory that contains a copy of the EFI variable\r
-                                Caller is responsible freeing the buffer.\r
-  @retval NULL                  Variable was not read\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-BdsLibGetVariableAndSize (\r
-  IN  CHAR16              *Name,\r
-  IN  EFI_GUID            *VendorGuid,\r
-  OUT UINTN               *VariableSize\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       BufferSize;\r
-  VOID        *Buffer;\r
-\r
-  Buffer = NULL;\r
-\r
-  //\r
-  // Pass in a zero size buffer to find the required buffer size.\r
-  //\r
-  BufferSize  = 0;\r
-  Status      = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
-  if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    //\r
-    // Allocate the buffer to return\r
-    //\r
-    Buffer = AllocateZeroPool (BufferSize);\r
-    if (Buffer == NULL) {\r
-      *VariableSize = 0;\r
-      return NULL;\r
-    }\r
-    //\r
-    // Read variable into the allocated buffer.\r
-    //\r
-    Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (Buffer);\r
-      BufferSize = 0;\r
-      Buffer     = NULL;\r
-    }\r
-  }\r
-\r
-  ASSERT (((Buffer == NULL) && (BufferSize == 0)) ||\r
-          ((Buffer != NULL) && (BufferSize != 0))\r
-          );\r
-  *VariableSize = BufferSize;\r
-  return Buffer;\r
-}\r
-\r
-/**\r
-  Delete the instance in Multi which matches partly with Single instance\r
-\r
-  @param  Multi                 A pointer to a multi-instance device path data\r
-                                structure.\r
-  @param  Single                A pointer to a single-instance device path data\r
-                                structure.\r
-\r
-  @return This function will remove the device path instances in Multi which partly\r
-          match with the Single, and return the result device path. If there is no\r
-          remaining device path as a result, this function will return NULL.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-BdsLibDelPartMatchInstance (\r
-  IN     EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
-  IN     EFI_DEVICE_PATH_PROTOCOL  *Single\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempNewDevicePath;\r
-  UINTN                     InstanceSize;\r
-  UINTN                     SingleDpSize;\r
-  UINTN                     Size;\r
-\r
-  NewDevicePath     = NULL;\r
-  TempNewDevicePath = NULL;\r
-\r
-  if (Multi == NULL || Single == NULL) {\r
-    return Multi;\r
-  }\r
-\r
-  Instance        =  GetNextDevicePathInstance (&Multi, &InstanceSize);\r
-  SingleDpSize    =  GetDevicePathSize (Single) - END_DEVICE_PATH_LENGTH;\r
-  InstanceSize    -= END_DEVICE_PATH_LENGTH;\r
-\r
-  while (Instance != NULL) {\r
-\r
-    Size = (SingleDpSize < InstanceSize) ? SingleDpSize : InstanceSize;\r
-\r
-    if ((CompareMem (Instance, Single, Size) != 0)) {\r
-      //\r
-      // Append the device path instance which does not match with Single\r
-      //\r
-      TempNewDevicePath = NewDevicePath;\r
-      NewDevicePath = AppendDevicePathInstance (NewDevicePath, Instance);\r
-      if (TempNewDevicePath != NULL) {\r
-        FreePool(TempNewDevicePath);\r
-      }\r
-    }\r
-    FreePool(Instance);\r
-    Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);\r
-    InstanceSize  -= END_DEVICE_PATH_LENGTH;\r
-  }\r
-\r
-  return NewDevicePath;\r
-}\r
-\r
-/**\r
-  Function compares a device path data structure to that of all the nodes of a\r
-  second device path instance.\r
-\r
-  @param  Multi                 A pointer to a multi-instance device path data\r
-                                structure.\r
-  @param  Single                A pointer to a single-instance device path data\r
-                                structure.\r
-\r
-  @retval TRUE                  If the Single device path is contained within Multi device path.\r
-  @retval FALSE                 The Single device path is not match within Multi device path.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-BdsLibMatchDevicePaths (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *Single\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
-  UINTN                     Size;\r
-\r
-  if (Multi == NULL || Single  == NULL) {\r
-    return FALSE;\r
-  }\r
-\r
-  DevicePath      = Multi;\r
-  DevicePathInst  = GetNextDevicePathInstance (&DevicePath, &Size);\r
-\r
-  //\r
-  // Search for the match of 'Single' in 'Multi'\r
-  //\r
-  while (DevicePathInst != NULL) {\r
-    //\r
-    // If the single device path is found in multiple device paths,\r
-    // return success\r
-    //\r
-    if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
-      FreePool (DevicePathInst);\r
-      return TRUE;\r
-    }\r
-\r
-    FreePool (DevicePathInst);\r
-    DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  This function prints a series of strings.\r
-\r
-  @param  ConOut                Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL\r
-  @param  ...                   A variable argument list containing series of\r
-                                strings, the last string must be NULL.\r
-\r
-  @retval EFI_SUCCESS           Success print out the string using ConOut.\r
-  @retval EFI_STATUS            Return the status of the ConOut->OutputString ().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibOutputStrings (\r
-  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *ConOut,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST     Args;\r
-  EFI_STATUS  Status;\r
-  CHAR16      *String;\r
-\r
-  Status = EFI_SUCCESS;\r
-  VA_START (Args, ConOut);\r
-\r
-  while (!EFI_ERROR (Status)) {\r
-    //\r
-    // If String is NULL, then it's the end of the list\r
-    //\r
-    String = VA_ARG (Args, CHAR16 *);\r
-    if (String == NULL) {\r
-      break;\r
-    }\r
-\r
-    Status = ConOut->OutputString (ConOut, String);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  VA_END(Args);\r
-  return Status;\r
-}\r
-\r
-//\r
-//  Following are BDS Lib functions which contain all the code about setup browser reset reminder feature.\r
-//  Setup Browser reset reminder feature is that an reset reminder will be given before user leaves the setup browser  if\r
-//  user change any option setting which needs a reset to be effective, and  the reset will be applied according to  the user selection.\r
-//\r
-\r
-\r
-/**\r
-  Enable the setup browser reset reminder feature.\r
-  This routine is used in platform tip. If the platform policy need the feature, use the routine to enable it.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-EnableResetReminderFeature (\r
-  VOID\r
-  )\r
-{\r
-  mFeaturerSwitch = TRUE;\r
-}\r
-\r
-\r
-/**\r
-  Disable the setup browser reset reminder feature.\r
-  This routine is used in platform tip. If the platform policy do not want the feature, use the routine to disable it.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-DisableResetReminderFeature (\r
-  VOID\r
-  )\r
-{\r
-  mFeaturerSwitch = FALSE;\r
-}\r
-\r
-\r
-/**\r
-  Record the info that  a reset is required.\r
-  A  module boolean variable is used to record whether a reset is required.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-EnableResetRequired (\r
-  VOID\r
-  )\r
-{\r
-  mResetRequired = TRUE;\r
-}\r
-\r
-\r
-/**\r
-  Record the info that  no reset is required.\r
-  A  module boolean variable is used to record whether a reset is required.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-DisableResetRequired (\r
-  VOID\r
-  )\r
-{\r
-  mResetRequired = FALSE;\r
-}\r
-\r
-\r
-/**\r
-  Check whether platform policy enable the reset reminder feature. The default is enabled.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsResetReminderFeatureEnable (\r
-  VOID\r
-  )\r
-{\r
-  return mFeaturerSwitch;\r
-}\r
-\r
-\r
-/**\r
-  Check if  user changed any option setting which needs a system reset to be effective.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsResetRequired (\r
-  VOID\r
-  )\r
-{\r
-  return mResetRequired;\r
-}\r
-\r
-\r
-/**\r
-  Check whether a reset is needed, and finish the reset reminder feature.\r
-  If a reset is needed, Popup a menu to notice user, and finish the feature\r
-  according to the user selection.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SetupResetReminder (\r
-  VOID\r
-  )\r
-{\r
-  EFI_INPUT_KEY                 Key;\r
-  CHAR16                        *StringBuffer1;\r
-  CHAR16                        *StringBuffer2;\r
-\r
-\r
-  //\r
-  //check any reset required change is applied? if yes, reset system\r
-  //\r
-  if (IsResetReminderFeatureEnable ()) {\r
-    if (IsResetRequired ()) {\r
-\r
-      StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
-      ASSERT (StringBuffer1 != NULL);\r
-      StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
-      ASSERT (StringBuffer2 != NULL);\r
-      StrCpyS (\r
-        StringBuffer1,\r
-        MAX_STRING_LEN,\r
-        L"Configuration changed. Reset to apply it Now."\r
-        );\r
-      StrCpyS (\r
-        StringBuffer2,\r
-        MAX_STRING_LEN,\r
-        L"Press ENTER to reset"\r
-        );\r
-      //\r
-      // Popup a menu to notice user\r
-      //\r
-      do {\r
-        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);\r
-      } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
-\r
-      FreePool (StringBuffer1);\r
-      FreePool (StringBuffer2);\r
-\r
-      gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Get the headers (dos, image, optional header) from an image\r
-\r
-  @param  Device                SimpleFileSystem device handle\r
-  @param  FileName              File name for the image\r
-  @param  DosHeader             Pointer to dos header\r
-  @param  Hdr                   The buffer in which to return the PE32, PE32+, or TE header.\r
-\r
-  @retval EFI_SUCCESS           Successfully get the machine type.\r
-  @retval EFI_NOT_FOUND         The file is not found.\r
-  @retval EFI_LOAD_ERROR        File is not a valid image file.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibGetImageHeader (\r
-  IN  EFI_HANDLE                  Device,\r
-  IN  CHAR16                      *FileName,\r
-  OUT EFI_IMAGE_DOS_HEADER        *DosHeader,\r
-  OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr\r
-  )\r
-{\r
-  EFI_STATUS                       Status;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL  *Volume;\r
-  EFI_FILE_HANDLE                  Root;\r
-  EFI_FILE_HANDLE                  ThisFile;\r
-  UINTN                            BufferSize;\r
-  UINT64                           FileSize;\r
-  EFI_FILE_INFO                    *Info;\r
-\r
-  Root     = NULL;\r
-  ThisFile = NULL;\r
-  //\r
-  // Handle the file system interface to the device\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  Device,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  (VOID *) &Volume\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = Volume->OpenVolume (\r
-                     Volume,\r
-                     &Root\r
-                     );\r
-  if (EFI_ERROR (Status)) {\r
-    Root = NULL;\r
-    goto Done;\r
-  }\r
-  ASSERT (Root != NULL);\r
-  Status = Root->Open (Root, &ThisFile, FileName, EFI_FILE_MODE_READ, 0);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  ASSERT (ThisFile != NULL);\r
-\r
-  //\r
-  // Get file size\r
-  //\r
-  BufferSize  = SIZE_OF_EFI_FILE_INFO + 200;\r
-  do {\r
-    Info   = NULL;\r
-    Status = gBS->AllocatePool (EfiBootServicesData, BufferSize, (VOID **) &Info);\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-    Status = ThisFile->GetInfo (\r
-                         ThisFile,\r
-                         &gEfiFileInfoGuid,\r
-                         &BufferSize,\r
-                         Info\r
-                         );\r
-    if (!EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    if (Status != EFI_BUFFER_TOO_SMALL) {\r
-      FreePool (Info);\r
-      goto Done;\r
-    }\r
-    FreePool (Info);\r
-  } while (TRUE);\r
-\r
-  FileSize = Info->FileSize;\r
-  FreePool (Info);\r
-\r
-  //\r
-  // Read dos header\r
-  //\r
-  BufferSize = sizeof (EFI_IMAGE_DOS_HEADER);\r
-  Status = ThisFile->Read (ThisFile, &BufferSize, DosHeader);\r
-  if (EFI_ERROR (Status) ||\r
-      BufferSize < sizeof (EFI_IMAGE_DOS_HEADER) ||\r
-      FileSize <= DosHeader->e_lfanew ||\r
-      DosHeader->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
-    Status = EFI_LOAD_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Move to PE signature\r
-  //\r
-  Status = ThisFile->SetPosition (ThisFile, DosHeader->e_lfanew);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_LOAD_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Read and check PE signature\r
-  //\r
-  BufferSize = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);\r
-  Status = ThisFile->Read (ThisFile, &BufferSize, Hdr.Pe32);\r
-  if (EFI_ERROR (Status) ||\r
-      BufferSize < sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION) ||\r
-      Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
-    Status = EFI_LOAD_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Check PE32 or PE32+ magic\r
-  //\r
-  if (Hdr.Pe32->OptionalHeader.Magic != EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC &&\r
-      Hdr.Pe32->OptionalHeader.Magic != EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
-    Status = EFI_LOAD_ERROR;\r
-    goto Done;\r
-  }\r
-\r
- Done:\r
-  if (ThisFile != NULL) {\r
-    ThisFile->Close (ThisFile);\r
-  }\r
-  if (Root != NULL) {\r
-    Root->Close (Root);\r
-  }\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This routine adjust the memory information for different memory type and\r
-  save them into the variables for next boot.\r
-**/\r
-VOID\r
-BdsSetMemoryTypeInformationVariable (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                   Status;\r
-  EFI_MEMORY_TYPE_INFORMATION  *PreviousMemoryTypeInformation;\r
-  EFI_MEMORY_TYPE_INFORMATION  *CurrentMemoryTypeInformation;\r
-  UINTN                        VariableSize;\r
-  UINTN                        Index;\r
-  UINTN                        Index1;\r
-  UINT32                       Previous;\r
-  UINT32                       Current;\r
-  UINT32                       Next;\r
-  EFI_HOB_GUID_TYPE            *GuidHob;\r
-  BOOLEAN                      MemoryTypeInformationModified;\r
-  BOOLEAN                      MemoryTypeInformationVariableExists;\r
-  EFI_BOOT_MODE                BootMode;\r
-\r
-  MemoryTypeInformationModified       = FALSE;\r
-  MemoryTypeInformationVariableExists = FALSE;\r
-\r
-\r
-  BootMode = GetBootModeHob ();\r
-  //\r
-  // In BOOT_IN_RECOVERY_MODE, Variable region is not reliable.\r
-  //\r
-  if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Only check the the Memory Type Information variable in the boot mode\r
-  // other than BOOT_WITH_DEFAULT_SETTINGS because the Memory Type\r
-  // Information is not valid in this boot mode.\r
-  //\r
-  if (BootMode != BOOT_WITH_DEFAULT_SETTINGS) {\r
-    VariableSize = 0;\r
-    Status = gRT->GetVariable (\r
-                    EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,\r
-                    &gEfiMemoryTypeInformationGuid,\r
-                    NULL,\r
-                    &VariableSize,\r
-                    NULL\r
-                    );\r
-    if (Status == EFI_BUFFER_TOO_SMALL) {\r
-      MemoryTypeInformationVariableExists = TRUE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Retrieve the current memory usage statistics.  If they are not found, then\r
-  // no adjustments can be made to the Memory Type Information variable.\r
-  //\r
-  Status = EfiGetSystemConfigurationTable (\r
-             &gEfiMemoryTypeInformationGuid,\r
-             (VOID **) &CurrentMemoryTypeInformation\r
-             );\r
-  if (EFI_ERROR (Status) || CurrentMemoryTypeInformation == NULL) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Get the Memory Type Information settings from Hob if they exist,\r
-  // PEI is responsible for getting them from variable and build a Hob to save them.\r
-  // If the previous Memory Type Information is not available, then set defaults\r
-  //\r
-  GuidHob = GetFirstGuidHob (&gEfiMemoryTypeInformationGuid);\r
-  if (GuidHob == NULL) {\r
-    //\r
-    // If Platform has not built Memory Type Info into the Hob, just return.\r
-    //\r
-    return;\r
-  }\r
-  PreviousMemoryTypeInformation = GET_GUID_HOB_DATA (GuidHob);\r
-  VariableSize = GET_GUID_HOB_DATA_SIZE (GuidHob);\r
-\r
-  //\r
-  // Use a heuristic to adjust the Memory Type Information for the next boot\r
-  //\r
-  DEBUG ((EFI_D_INFO, "Memory  Previous  Current    Next   \n"));\r
-  DEBUG ((EFI_D_INFO, " Type    Pages     Pages     Pages  \n"));\r
-  DEBUG ((EFI_D_INFO, "======  ========  ========  ========\n"));\r
-\r
-  for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {\r
-\r
-    for (Index1 = 0; CurrentMemoryTypeInformation[Index1].Type != EfiMaxMemoryType; Index1++) {\r
-      if (PreviousMemoryTypeInformation[Index].Type == CurrentMemoryTypeInformation[Index1].Type) {\r
-        break;\r
-      }\r
-    }\r
-    if (CurrentMemoryTypeInformation[Index1].Type == EfiMaxMemoryType) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Previous is the number of pages pre-allocated\r
-    // Current is the number of pages actually needed\r
-    //\r
-    Previous = PreviousMemoryTypeInformation[Index].NumberOfPages;\r
-    Current  = CurrentMemoryTypeInformation[Index1].NumberOfPages;\r
-    Next     = Previous;\r
-\r
-    //\r
-    // Inconsistent Memory Reserved across bootings may lead to S4 fail\r
-    // Write next varible to 125% * current when the pre-allocated memory is:\r
-    //  1. More than 150% of needed memory and boot mode is BOOT_WITH_DEFAULT_SETTING\r
-    //  2. Less than the needed memory\r
-    //\r
-    if ((Current + (Current >> 1)) < Previous) {\r
-      if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) {\r
-        Next = Current + (Current >> 2);\r
-      }\r
-    } else if (Current > Previous) {\r
-      Next = Current + (Current >> 2);\r
-    }\r
-    if (Next > 0 && Next < 4) {\r
-      Next = 4;\r
-    }\r
-\r
-    if (Next != Previous) {\r
-      PreviousMemoryTypeInformation[Index].NumberOfPages = Next;\r
-      MemoryTypeInformationModified = TRUE;\r
-    }\r
-\r
-    DEBUG ((EFI_D_INFO, "  %02x    %08x  %08x  %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next));\r
-  }\r
-\r
-  //\r
-  // If any changes were made to the Memory Type Information settings, then set the new variable value;\r
-  // Or create the variable in first boot.\r
-  //\r
-  if (MemoryTypeInformationModified || !MemoryTypeInformationVariableExists) {\r
-    Status = SetVariableAndReportStatusCodeOnError (\r
-               EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,\r
-               &gEfiMemoryTypeInformationGuid,\r
-               EFI_VARIABLE_NON_VOLATILE  | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-               VariableSize,\r
-               PreviousMemoryTypeInformation\r
-               );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // If the Memory Type Information settings have been modified, then reset the platform\r
-      // so the new Memory Type Information setting will be used to guarantee that an S4\r
-      // entry/resume cycle will not fail.\r
-      //\r
-      if (MemoryTypeInformationModified && PcdGetBool (PcdResetOnMemoryTypeInformationChange)) {\r
-        DEBUG ((EFI_D_INFO, "Memory Type Information settings change. Warm Reset!!!\n"));\r
-        gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
-      }\r
-    } else {\r
-      DEBUG ((EFI_D_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n"));\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  This routine is kept for backward compatibility.\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibSaveMemoryTypeInformation (\r
-  VOID\r
-  )\r
-{\r
-}\r
-\r
-\r
-/**\r
-  Identify a user and, if authenticated, returns the current user profile handle.\r
-\r
-  @param[out]  User           Point to user profile handle.\r
-\r
-  @retval EFI_SUCCESS         User is successfully identified, or user identification\r
-                              is not supported.\r
-  @retval EFI_ACCESS_DENIED   User is not successfully identified\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibUserIdentify (\r
-  OUT EFI_USER_PROFILE_HANDLE         *User\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_USER_MANAGER_PROTOCOL           *Manager;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiUserManagerProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &Manager\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return Manager->Identify (Manager, User);\r
-}\r
-\r
-/**\r
-  Set the variable and report the error through status code upon failure.\r
-\r
-  @param  VariableName           A Null-terminated string that is the name of the vendor's variable.\r
-                                 Each VariableName is unique for each VendorGuid. VariableName must\r
-                                 contain 1 or more characters. If VariableName is an empty string,\r
-                                 then EFI_INVALID_PARAMETER is returned.\r
-  @param  VendorGuid             A unique identifier for the vendor.\r
-  @param  Attributes             Attributes bitmask to set for the variable.\r
-  @param  DataSize               The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,\r
-                                 EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or\r
-                                 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero\r
-                                 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is\r
-                                 set, then a SetVariable() call with a DataSize of zero will not cause any change to\r
-                                 the variable value (the timestamp associated with the variable may be updated however\r
-                                 even if no new data value is provided,see the description of the\r
-                                 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not\r
-                                 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).\r
-  @param  Data                   The contents for the variable.\r
-\r
-  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r
-                                 defined by the Attributes.\r
-  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits, name, and GUID was supplied, or the\r
-                                 DataSize exceeds the maximum allowed.\r
-  @retval EFI_INVALID_PARAMETER  VariableName is an empty string.\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
-  @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question is read-only.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.\r
-  @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\r
-                                 or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo\r
-                                 does NOT pass the validation check carried out by the firmware.\r
-\r
-  @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.\r
-**/\r
-EFI_STATUS\r
-SetVariableAndReportStatusCodeOnError (\r
-  IN CHAR16     *VariableName,\r
-  IN EFI_GUID   *VendorGuid,\r
-  IN UINT32     Attributes,\r
-  IN UINTN      DataSize,\r
-  IN VOID       *Data\r
-  )\r
-{\r
-  EFI_STATUS                 Status;\r
-  EDKII_SET_VARIABLE_STATUS  *SetVariableStatus;\r
-  UINTN                      NameSize;\r
-\r
-  Status = gRT->SetVariable (\r
-                  VariableName,\r
-                  VendorGuid,\r
-                  Attributes,\r
-                  DataSize,\r
-                  Data\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    NameSize = StrSize (VariableName);\r
-    SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize);\r
-    if (SetVariableStatus != NULL) {\r
-      CopyGuid (&SetVariableStatus->Guid, VendorGuid);\r
-      SetVariableStatus->NameSize   = NameSize;\r
-      SetVariableStatus->DataSize   = DataSize;\r
-      SetVariableStatus->SetStatus  = Status;\r
-      SetVariableStatus->Attributes = Attributes;\r
-      CopyMem (SetVariableStatus + 1,                          VariableName, NameSize);\r
-      if ((Data != NULL) && (DataSize != 0)) {\r
-        CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data,         DataSize);\r
-      }\r
-\r
-      REPORT_STATUS_CODE_EX (\r
-        EFI_ERROR_CODE,\r
-        PcdGet32 (PcdErrorCodeSetVariable),\r
-        0,\r
-        NULL,\r
-        &gEdkiiStatusCodeDataTypeVariableGuid,\r
-        SetVariableStatus,\r
-        sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize\r
-        );\r
-\r
-      FreePool (SetVariableStatus);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/DevicePath.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/DevicePath.c
deleted file mode 100644 (file)
index a0b9da8..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/** @file\r
-  BDS internal function define the default device path string, it can be\r
-  replaced by platform device path.\r
-\r
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalBdsLib.h"\r
-\r
-/**\r
-  This function converts an input device structure to a Unicode string.\r
-\r
-  @param DevPath                  A pointer to the device path structure.\r
-\r
-  @return A new allocated Unicode string that represents the device path.\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-DevicePathToStr (\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
-  )\r
-{\r
-  return ConvertDevicePathToText (DevPath, TRUE, TRUE);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
deleted file mode 100644 (file)
index 1de48cd..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-## @file\r
-#  General BDS library.\r
-#\r
-#  General BDS defines and produce general interfaces for platform BDS driver including:\r
-#  1) BDS boot policy interface;\r
-#  2) BDS boot device connect interface;\r
-#  3) BDS Misc interfaces for mainting boot variable, ouput string, etc.\r
-#\r
-#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = GenericBdsLib\r
-  MODULE_UNI_FILE                = GenericBdsLib.uni\r
-  FILE_GUID                      = e405ec31-ccaa-4dd4-83e8-0aec01703f7e\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = GenericBdsLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION\r
-  CONSTRUCTOR                    = GenericBdsLibConstructor\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  DevicePath.c\r
-  BdsConnect.c\r
-  BdsMisc.c\r
-  BdsConsole.c\r
-  BdsBoot.c\r
-  InternalBdsLib.h\r
-  String.h\r
-  String.c\r
-  GenericBdsStrings.uni\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  DevicePathLib\r
-  PeCoffGetEntryPointLib\r
-  BaseLib\r
-  HobLib\r
-  UefiRuntimeServicesTableLib\r
-  DxeServicesTableLib\r
-  MemoryAllocationLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  PrintLib\r
-  PcdLib\r
-  PerformanceLib\r
-  TimerLib\r
-  DxeServicesLib\r
-  HiiLib\r
-  ReportStatusCodeLib\r
-  BmpSupportLib\r
-\r
-[Guids]\r
-  ## SOMETIMES_CONSUMES ## HOB         # The hob holding memory type information\r
-  ## SOMETIMES_CONSUMES ## SystemTable # The identifier of memory type information type in system table\r
-  ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation"\r
-  ## SOMETIMES_PRODUCES ## Variable:L"MemoryTypeInformation"\r
-  gEfiMemoryTypeInformationGuid\r
-  ## SOMETIMES_CONSUMES ## Variable:L"BootXXXX"    # Boot option variable\r
-  ## SOMETIMES_PRODUCES ## Variable:L"BootXXXX"    # Boot option variable\r
-  ## SOMETIMES_CONSUMES ## Variable:L"DriverXXXX"  # Driver load option.\r
-  ## SOMETIMES_PRODUCES ## Variable:L"DriverXXXX"  # Driver load option.\r
-  ## SOMETIMES_CONSUMES ## Variable:L"BootNext"    # Next Boot Option\r
-  ## SOMETIMES_PRODUCES ## Variable:L"BootNext"    # Next Boot Option\r
-  ## SOMETIMES_CONSUMES ## Variable:L"BootOrder"   # The boot option array\r
-  ## SOMETIMES_PRODUCES ## Variable:L"BootOrder"   # The boot option array\r
-  ## SOMETIMES_CONSUMES ## Variable:L"DriverOrder" # The driver order list\r
-  ## SOMETIMES_CONSUMES ## Variable:L"ConIn"       # The device path of console in device\r
-  ## SOMETIMES_PRODUCES ## Variable:L"ConIn"       # The device path of console in device\r
-  ## SOMETIMES_CONSUMES ## Variable:L"ConOut"      # The device path of console out device\r
-  ## SOMETIMES_PRODUCES ## Variable:L"ConOut"      # The device path of console out device\r
-  ## SOMETIMES_CONSUMES ## Variable:L"ErrOut"      # The device path of error out device\r
-  ## SOMETIMES_PRODUCES ## Variable:L"ErrOut"      # The device path of error out device\r
-  ## SOMETIMES_PRODUCES ## Variable:L"BootCurrent" # The boot option of current boot\r
-  ## SOMETIMES_PRODUCES ## Variable:L"BootNext"    # The number of next boot option\r
-  gEfiGlobalVariableGuid\r
-  gEfiFileInfoGuid                              ## SOMETIMES_CONSUMES ## GUID\r
-  gLastEnumLangGuid                             ## SOMETIMES_PRODUCES ## Variable:L"LastEnumLang" # Platform language at last time enumeration.\r
-  gHdBootDevicePathVariablGuid                  ## SOMETIMES_PRODUCES ## Variable:L"HDDP" # The device path of Boot file on Hard device.\r
-  gBdsLibStringPackageGuid                      ## CONSUMES ## HII # HII String PackageList Guid\r
-  ## SOMETIMES_PRODUCES ## Variable:L"LegacyDevOrder"\r
-  ## SOMETIMES_CONSUMES ## Variable:L"LegacyDevOrder"\r
-  gEfiLegacyDevOrderVariableGuid\r
-  gEdkiiStatusCodeDataTypeVariableGuid          ## SOMETIMES_CONSUMES ## GUID\r
-\r
-[Protocols]\r
-  gEfiSimpleFileSystemProtocolGuid              ## SOMETIMES_CONSUMES\r
-  gEfiLoadFileProtocolGuid                      ## SOMETIMES_CONSUMES\r
-  gEfiSimpleTextOutProtocolGuid                 ## CONSUMES\r
-  gEfiPciIoProtocolGuid                         ## SOMETIMES_CONSUMES\r
-  gEfiLoadedImageProtocolGuid                   ## SOMETIMES_CONSUMES\r
-  gEfiSimpleNetworkProtocolGuid                 ## SOMETIMES_CONSUMES\r
-  gEfiDebugPortProtocolGuid                     ## SOMETIMES_CONSUMES\r
-  gEfiSimpleTextInProtocolGuid                  ## CONSUMES\r
-  gEfiBlockIoProtocolGuid                       ## SOMETIMES_CONSUMES\r
-  gEfiFirmwareVolume2ProtocolGuid               ## SOMETIMES_CONSUMES\r
-  gEfiLegacyBiosProtocolGuid                    ## SOMETIMES_CONSUMES\r
-  gEfiCpuArchProtocolGuid                       ## CONSUMES\r
-  gEfiDevicePathProtocolGuid                    ## CONSUMES\r
-  gEfiGraphicsOutputProtocolGuid                ## SOMETIMES_CONSUMES\r
-  gEfiUgaDrawProtocolGuid |gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## SOMETIMES_CONSUMES\r
-  gEfiOEMBadgingProtocolGuid                    ## SOMETIMES_CONSUMES\r
-  gEfiHiiFontProtocolGuid                       ## CONSUMES\r
-  gEfiUserManagerProtocolGuid                   ## SOMETIMES_CONSUMES\r
-  gEfiUsbIoProtocolGuid                         ## SOMETIMES_CONSUMES\r
-  gEfiBootLogoProtocolGuid                      ## SOMETIMES_CONSUMES\r
-\r
-[FeaturePcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport                   ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootlogoOnlyEnable ## CONSUMES\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange ## SOMETIMES_CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad  ## SOMETIMES_CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderStart ## SOMETIMES_CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable      ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile      ## CONSUMES\r
-\r
-#\r
-# [BootMode]\r
-#   RECOVERY_FULL    ## SOMETIMES_CONSUMES # Memory Type Information variable\r
-#\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.uni b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.uni
deleted file mode 100644 (file)
index b747978..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// /** @file\r
-// General BDS library.\r
-//\r
-// General BDS defines and produce general interfaces for platform BDS driver including:\r
-// 1) BDS boot policy interface;\r
-// 2) BDS boot device connect interface;\r
-// 3) BDS Misc interfaces for mainting boot variable, ouput string, etc.\r
-//\r
-// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "General BDS library"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "General BDS defines and produces general interfaces for a platform BDS driver including: 1) BDS boot policy interface; 2) BDS boot device connect interface; 3) BDS Misc interfaces for maintaining boot variable, output string, etc."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsStrings.uni b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsStrings.uni
deleted file mode 100644 (file)
index 67e96d2..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-///** @file\r
-//\r
-//  String definitions for Boot Option description.\r
-//\r
-//  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-//**/\r
-\r
-/=#\r
-\r
-#langdef   en-US "English"\r
-#langdef   fr-FR "Français"\r
-\r
-#string STR_DESCRIPTION_FLOPPY         #language en-US  "EFI Floppy"\r
-                                       #language fr-FR  "fr-FR: EFI Floppy"\r
-#string STR_DESCRIPTION_CD_DVD         #language en-US  "EFI DVD/CDROM"\r
-                                       #language fr-FR  "fr-FR: EFI DVD/CDROM"\r
-#string STR_DESCRIPTION_HARDDRIVE      #language en-US  "EFI Hard Drive"\r
-                                       #language fr-FR  "fr-FR: EFI Hard Drive"\r
-#string STR_DESCRIPTION_USB            #language en-US  "EFI USB Device"\r
-                                       #language fr-FR  "fr-FR: EFI USB Device"\r
-#string STR_DESCRIPTION_SCSI           #language en-US  "EFI SCSI Device"\r
-                                       #language fr-FR  "fr-FR: EFI SCSI Device"\r
-#string STR_DESCRIPTION_MISC           #language en-US  "EFI Misc Device"\r
-                                       #language fr-FR  "fr-FR: EFI Misc Device"\r
-#string STR_DESCRIPTION_NETWORK        #language en-US  "EFI Network"\r
-                                       #language fr-FR  "fr-FR: EFI Network"\r
-#string STR_DESCRIPTION_NON_BLOCK      #language en-US  "EFI Non-Block Boot Device"\r
-                                       #language fr-FR  "fr-FR: EFI Non-Block Boot Device"\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h
deleted file mode 100644 (file)
index 131b4fa..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/** @file\r
-  BDS library definition, include the file and data structure\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _INTERNAL_BDS_LIB_H_\r
-#define _INTERNAL_BDS_LIB_H_\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-#include <IndustryStandard/PeImage.h>\r
-\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/LoadedImage.h>\r
-#include <Protocol/Cpu.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/LoadFile.h>\r
-#include <Protocol/DebugPort.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/SimpleTextIn.h>\r
-#include <Protocol/LegacyBios.h>\r
-#include <Protocol/SimpleTextOut.h>\r
-#include <Protocol/SimpleNetwork.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/OEMBadging.h>\r
-#include <Protocol/GraphicsOutput.h>\r
-#include <Protocol/UgaDraw.h>\r
-#include <Protocol/HiiFont.h>\r
-#include <Protocol/HiiImage.h>\r
-#include <Protocol/UsbIo.h>\r
-#include <Protocol/BootLogo.h>\r
-\r
-#include <Guid/MemoryTypeInformation.h>\r
-#include <Guid/FileInfo.h>\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/PcAnsi.h>\r
-#include <Guid/BdsLibHii.h>\r
-#include <Guid/HdBootVariable.h>\r
-#include <Guid/LastEnumLang.h>\r
-#include <Guid/LegacyDevOrder.h>\r
-#include <Guid/StatusCodeDataTypeVariable.h>\r
-\r
-#include <Library/PrintLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/PerformanceLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/PeCoffGetEntryPointLib.h>\r
-#include <Library/GenericBdsLib.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/DxeServicesLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/BmpSupportLib.h>\r
-\r
-#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)\r
-    #if defined (MDE_CPU_EBC)\r
-        //\r
-        // Uefi specification only defines the default boot file name for IA32, X64\r
-        // and IPF processor, so need define boot file name for EBC architecture here.\r
-        //\r
-        #define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"\r
-    #else\r
-        #error "Can not determine the default boot file name for unknown processor type!"\r
-    #endif\r
-#endif\r
-\r
-/**\r
-  Get the headers (dos, image, optional header) from an image\r
-\r
-  @param  Device                SimpleFileSystem device handle\r
-  @param  FileName              File name for the image\r
-  @param  DosHeader             Pointer to dos header\r
-  @param  Hdr                   The buffer in which to return the PE32, PE32+, or TE header.\r
-\r
-  @retval EFI_SUCCESS           Successfully get the machine type.\r
-  @retval EFI_NOT_FOUND         The file is not found.\r
-  @retval EFI_LOAD_ERROR        File is not a valid image file.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibGetImageHeader (\r
-  IN  EFI_HANDLE                  Device,\r
-  IN  CHAR16                      *FileName,\r
-  OUT EFI_IMAGE_DOS_HEADER        *DosHeader,\r
-  OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr\r
-  );\r
-\r
-/**\r
-  This routine adjust the memory information for different memory type and\r
-  save them into the variables for next boot.\r
-**/\r
-VOID\r
-BdsSetMemoryTypeInformationVariable (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Validate the EFI Boot#### or Driver#### variable (VendorGuid/Name)\r
-\r
-  @param  Variable              Boot#### variable data.\r
-  @param  VariableSize          Returns the size of the EFI variable that was read\r
-\r
-  @retval TRUE                  The variable data is correct.\r
-  @retval FALSE                 The variable data is corrupted.\r
-\r
-**/\r
-BOOLEAN\r
-ValidateOption (\r
-  UINT8                     *Variable,\r
-  UINTN                     VariableSize\r
-  );\r
-\r
-/**\r
-  Set the variable and report the error through status code upon failure.\r
-\r
-  @param  VariableName           A Null-terminated string that is the name of the vendor's variable.\r
-                                 Each VariableName is unique for each VendorGuid. VariableName must\r
-                                 contain 1 or more characters. If VariableName is an empty string,\r
-                                 then EFI_INVALID_PARAMETER is returned.\r
-  @param  VendorGuid             A unique identifier for the vendor.\r
-  @param  Attributes             Attributes bitmask to set for the variable.\r
-  @param  DataSize               The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,\r
-                                 EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or\r
-                                 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero\r
-                                 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is\r
-                                 set, then a SetVariable() call with a DataSize of zero will not cause any change to\r
-                                 the variable value (the timestamp associated with the variable may be updated however\r
-                                 even if no new data value is provided,see the description of the\r
-                                 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not\r
-                                 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).\r
-  @param  Data                   The contents for the variable.\r
-\r
-  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r
-                                 defined by the Attributes.\r
-  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits, name, and GUID was supplied, or the\r
-                                 DataSize exceeds the maximum allowed.\r
-  @retval EFI_INVALID_PARAMETER  VariableName is an empty string.\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
-  @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question is read-only.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.\r
-  @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\r
-                                 or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo\r
-                                 does NOT pass the validation check carried out by the firmware.\r
-\r
-  @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.\r
-**/\r
-EFI_STATUS\r
-SetVariableAndReportStatusCodeOnError (\r
-  IN CHAR16     *VariableName,\r
-  IN EFI_GUID   *VendorGuid,\r
-  IN UINT32     Attributes,\r
-  IN UINTN      DataSize,\r
-  IN VOID       *Data\r
-  );\r
-\r
-#endif // _BDS_LIB_H_\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/String.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/String.c
deleted file mode 100644 (file)
index f36860d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/** @file\r
-  String support\r
-\r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-#include "String.h"\r
-\r
-/**\r
-  Get string by string id from HII Interface\r
-\r
-\r
-  @param Id              String ID.\r
-\r
-  @retval  CHAR16 *  String from ID.\r
-  @retval  NULL      If error occurs.\r
-\r
-**/\r
-CHAR16 *\r
-BdsLibGetStringById (\r
-  IN  EFI_STRING_ID   Id\r
-  )\r
-{\r
-  return HiiGetString (gBdsLibStringPackHandle, Id, NULL);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/String.h b/IntelFrameworkModulePkg/Library/GenericBdsLib/String.h
deleted file mode 100644 (file)
index 53cabe6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/** @file\r
-  String support\r
-\r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _STRING_H_\r
-#define _STRING_H_\r
-\r
-#include <Library/HiiLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-extern EFI_HII_HANDLE gBdsLibStringPackHandle;\r
-\r
-//\r
-// This is the VFR compiler generated header file which defines the\r
-// string identifiers.\r
-//\r
-\r
-extern UINT8  GenericBdsLibStrings[];\r
-\r
-/**\r
-  Get string by string id from HII Interface\r
-\r
-\r
-  @param Id              String ID.\r
-\r
-  @retval  CHAR16 *  String from ID.\r
-  @retval  NULL      If error occurs.\r
-\r
-**/\r
-CHAR16 *\r
-BdsLibGetStringById (\r
-  IN  EFI_STRING_ID   Id\r
-  );\r
-\r
-#endif // _STRING_H_\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c
deleted file mode 100644 (file)
index af7d80e..0000000
+++ /dev/null
@@ -1,1505 +0,0 @@
-/** @file\r
-  Legacy Boot Maintainence UI implementation.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#include "LegacyBootMaintUi.h"\r
-\r
-LEGACY_BOOT_OPTION_CALLBACK_DATA  *mLegacyBootOptionPrivate = NULL;\r
-EFI_GUID  mLegacyBootOptionGuid     = LEGACY_BOOT_OPTION_FORMSET_GUID;\r
-CHAR16    mLegacyBootStorageName[]  = L"LegacyBootData";\r
-BBS_TYPE  mBbsType[] = {BBS_FLOPPY, BBS_HARDDISK, BBS_CDROM, BBS_EMBED_NETWORK, BBS_BEV_DEVICE, BBS_UNKNOWN};\r
-BOOLEAN   mFirstEnterLegacyForm = FALSE;\r
-\r
-\r
-///\r
-/// Legacy FD Info from LegacyBios.GetBbsInfo()\r
-///\r
-LEGACY_MENU_OPTION      LegacyFDMenu = {\r
-  LEGACY_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Legacy HD Info from LegacyBios.GetBbsInfo()\r
-///\r
-LEGACY_MENU_OPTION      LegacyHDMenu = {\r
-  LEGACY_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Legacy CD Info from LegacyBios.GetBbsInfo()\r
-///\r
-LEGACY_MENU_OPTION      LegacyCDMenu = {\r
-  LEGACY_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Legacy NET Info from LegacyBios.GetBbsInfo()\r
-///\r
-LEGACY_MENU_OPTION      LegacyNETMenu = {\r
-  LEGACY_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Legacy NET Info from LegacyBios.GetBbsInfo()\r
-///\r
-LEGACY_MENU_OPTION      LegacyBEVMenu = {\r
-  LEGACY_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-\r
-VOID                *mLegacyStartOpCodeHandle = NULL;\r
-VOID                *mLegacyEndOpCodeHandle = NULL;\r
-EFI_IFR_GUID_LABEL  *mLegacyStartLabel = NULL;\r
-EFI_IFR_GUID_LABEL  *mLegacyEndLabel = NULL;\r
-\r
-\r
-HII_VENDOR_DEVICE_PATH  mLegacyBootOptionHiiVendorDevicePath = {\r
-  {\r
-    {\r
-      HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,\r
-      {\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    { 0x6bc75598, 0x89b4, 0x483d, { 0x91, 0x60, 0x7f, 0x46, 0x9a, 0x96, 0x35, 0x31 } }\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      (UINT8) (END_DEVICE_PATH_LENGTH),\r
-      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
-    }\r
-  }\r
-};\r
-\r
-/**\r
-\r
-  Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().\r
-\r
-**/\r
-VOID\r
-GetLegacyOptions (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-\r
-  Base on the L"LegacyDevOrder" variable to build the current order data.\r
-\r
-**/\r
-VOID\r
-GetLegacyOptionsOrder (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Re-order the Boot Option according to the DevOrder.\r
-\r
-  The routine re-orders the Boot Option in BootOption array according to\r
-  the order specified by DevOrder.\r
-\r
-  @param DevOrder           Pointer to buffer containing the BBS Index,\r
-                            high 8-bit value 0xFF indicating a disabled boot option\r
-  @param DevOrderCount      Count of the BBS Index\r
-  @param EnBootOption       Callee allocated buffer containing the enabled Boot Option Numbers\r
-  @param EnBootOptionCount  Count of the enabled Boot Option Numbers\r
-  @param DisBootOption      Callee allocated buffer containing the disabled Boot Option Numbers\r
-  @param DisBootOptionCount Count of the disabled Boot Option Numbers\r
-\r
-  @return EFI_SUCCESS       The function completed successfully.\r
-  @retval other             Contain some error, details see  the status return by gRT->SetVariable.\r
-**/\r
-EFI_STATUS\r
-OrderLegacyBootOption4SameType (\r
-  UINT16                   *DevOrder,\r
-  UINTN                    DevOrderCount,\r
-  UINT16                   **EnBootOption,\r
-  UINTN                    *EnBootOptionCount,\r
-  UINT16                   **DisBootOption,\r
-  UINTN                    *DisBootOptionCount\r
-  )\r
-{\r
-  EFI_STATUS               Status;\r
-  UINT16                   *NewBootOption;\r
-  UINT16                   *BootOrder;\r
-  UINTN                    BootOrderSize;\r
-  UINTN                    Index;\r
-  UINTN                    StartPosition;\r
-\r
-  EFI_BOOT_MANAGER_LOAD_OPTION    BootOption;\r
-\r
-  CHAR16                           OptionName[sizeof ("Boot####")];\r
-  UINT16                   *BbsIndexArray;\r
-  UINT16                   *DeviceTypeArray;\r
-\r
-  GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrder, &BootOrderSize);\r
-  ASSERT (BootOrder != NULL);\r
-\r
-  BbsIndexArray       = AllocatePool (BootOrderSize);\r
-  DeviceTypeArray     = AllocatePool (BootOrderSize);\r
-  *EnBootOption       = AllocatePool (BootOrderSize);\r
-  *DisBootOption      = AllocatePool (BootOrderSize);\r
-  *DisBootOptionCount = 0;\r
-  *EnBootOptionCount  = 0;\r
-  Index               = 0;\r
-  Status              = EFI_SUCCESS;\r
-\r
-  ASSERT (BbsIndexArray != NULL);\r
-  ASSERT (DeviceTypeArray != NULL);\r
-  ASSERT (*EnBootOption != NULL);\r
-  ASSERT (*DisBootOption != NULL);\r
-\r
-  for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
-\r
-    UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);\r
-    Status = EfiBootManagerVariableToLoadOption (OptionName, &BootOption);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    if ((DevicePathType (BootOption.FilePath) == BBS_DEVICE_PATH) &&\r
-        (DevicePathSubType (BootOption.FilePath) == BBS_BBS_DP)) {\r
-      //\r
-      // Legacy Boot Option\r
-      //\r
-      ASSERT (BootOption.OptionalDataSize == sizeof (LEGACY_BOOT_OPTION_BBS_DATA));\r
-\r
-      DeviceTypeArray[Index] = ((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType;\r
-      BbsIndexArray  [Index] = ((LEGACY_BOOT_OPTION_BBS_DATA *) BootOption.OptionalData)->BbsIndex;\r
-    } else {\r
-      DeviceTypeArray[Index] = BBS_TYPE_UNKNOWN;\r
-      BbsIndexArray  [Index] = 0xFFFF;\r
-    }\r
-    EfiBootManagerFreeLoadOption (&BootOption);\r
-  }\r
-\r
-  //\r
-  // Record the corresponding Boot Option Numbers according to the DevOrder\r
-  // Record the EnBootOption and DisBootOption according to the DevOrder\r
-  //\r
-  StartPosition = BootOrderSize / sizeof (UINT16);\r
-  NewBootOption = AllocatePool (DevOrderCount * sizeof (UINT16));\r
-  ASSERT (NewBootOption != NULL);\r
-  while (DevOrderCount-- != 0) {\r
-    for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
-      if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) {\r
-        StartPosition = MIN (StartPosition, Index);\r
-        NewBootOption[DevOrderCount] = BootOrder[Index];\r
-\r
-        if ((DevOrder[DevOrderCount] & 0xFF00) == 0xFF00) {\r
-          (*DisBootOption)[*DisBootOptionCount] = BootOrder[Index];\r
-          (*DisBootOptionCount)++;\r
-        } else {\r
-          (*EnBootOption)[*EnBootOptionCount] = BootOrder[Index];\r
-          (*EnBootOptionCount)++;\r
-        }\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Overwrite the old BootOption\r
-  //\r
-  CopyMem (&BootOrder[StartPosition], NewBootOption, (*DisBootOptionCount + *EnBootOptionCount) * sizeof (UINT16));\r
-  Status = gRT->SetVariable (\r
-                  L"BootOrder",\r
-                  &gEfiGlobalVariableGuid,\r
-                  VAR_FLAG,\r
-                  BootOrderSize,\r
-                  BootOrder\r
-                  );\r
-\r
-  FreePool (NewBootOption);\r
-  FreePool (DeviceTypeArray);\r
-  FreePool (BbsIndexArray);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Update the legacy BBS boot option. L"LegacyDevOrder" and gEfiLegacyDevOrderVariableGuid EFI Variable\r
-  is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid\r
-  is also updated.\r
-\r
-  @param NVMapData   The data for egacy BBS boot.\r
-\r
-  @return EFI_SUCCESS           The function completed successfully.\r
-  @retval EFI_NOT_FOUND         If L"LegacyDevOrder" and gEfiLegacyDevOrderVariableGuid EFI Variable can not be found.\r
-  @retval EFI_OUT_OF_RESOURCES  Fail to allocate memory resource\r
-  @retval other                 Contain some error, details see  the status return by gRT->SetVariable.\r
-**/\r
-EFI_STATUS\r
-UpdateBBSOption (\r
-  IN LEGACY_BOOT_NV_DATA            *NVMapData\r
-  )\r
-{\r
-  UINTN                       Index;\r
-  UINTN                       Index2;\r
-  UINTN                       CurrentType;\r
-  VOID                        *BootOptionVar;\r
-  CHAR16                      VarName[100];\r
-  UINTN                       OptionSize;\r
-  EFI_STATUS                  Status;\r
-  UINT32                      *Attribute;\r
-  LEGACY_MENU_OPTION          *OptionMenu;\r
-  UINT16                      *LegacyDev;\r
-  UINT16                      *InitialLegacyDev;\r
-  UINT8                       *VarData;\r
-  UINTN                       VarSize;\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  UINT8                       *OriginalPtr;\r
-  UINT8                       *DisMap;\r
-  UINTN                       Pos;\r
-  UINTN                       Bit;\r
-  UINT16                      *NewOrder;\r
-  UINT16                      Tmp;\r
-  UINT16                      *EnBootOption;\r
-  UINTN                       EnBootOptionCount;\r
-  UINT16                      *DisBootOption;\r
-  UINTN                       DisBootOptionCount;\r
-  UINTN                       BufferSize;\r
-\r
-\r
-  DisMap              = NULL;\r
-  NewOrder            = NULL;\r
-  CurrentType         = 0;\r
-  EnBootOption        = NULL;\r
-  DisBootOption       = NULL;\r
-\r
-\r
-  DisMap  = mLegacyBootOptionPrivate->MaintainMapData->DisableMap;\r
-  Status  = EFI_SUCCESS;\r
-\r
-  //\r
-  // Update the Variable "LegacyDevOrder"\r
-  //\r
-  GetVariable2 (VAR_LEGACY_DEV_ORDER, &gEfiLegacyDevOrderVariableGuid, (VOID **) &VarData, &VarSize);\r
-  if (VarData == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  OriginalPtr = VarData;\r
-\r
-  while (mBbsType[CurrentType] != BBS_UNKNOWN) {\r
-    switch (mBbsType[CurrentType]) {\r
-    case BBS_FLOPPY:\r
-      OptionMenu            = (LEGACY_MENU_OPTION *) &LegacyFDMenu;\r
-      LegacyDev             = NVMapData->LegacyFD;\r
-      InitialLegacyDev     = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyFD;\r
-      BufferSize            = sizeof (NVMapData->LegacyFD);\r
-      break;\r
-\r
-    case BBS_HARDDISK:\r
-      OptionMenu            = (LEGACY_MENU_OPTION *) &LegacyHDMenu;\r
-      LegacyDev             = NVMapData->LegacyHD;\r
-      InitialLegacyDev     = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyHD;\r
-\r
-      BufferSize            = sizeof (NVMapData->LegacyHD);\r
-      break;\r
-\r
-    case BBS_CDROM:\r
-      OptionMenu            = (LEGACY_MENU_OPTION *) &LegacyCDMenu;\r
-      LegacyDev             = NVMapData->LegacyCD;\r
-      InitialLegacyDev     = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyCD;\r
-      BufferSize            = sizeof (NVMapData->LegacyCD);\r
-      break;\r
-\r
-    case BBS_EMBED_NETWORK:\r
-      OptionMenu            = (LEGACY_MENU_OPTION *) &LegacyNETMenu;\r
-      LegacyDev             = NVMapData->LegacyNET;\r
-      InitialLegacyDev     = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyNET;\r
-      BufferSize            = sizeof (NVMapData->LegacyNET);\r
-      break;\r
-\r
-    default:\r
-      ASSERT (mBbsType[CurrentType] == BBS_BEV_DEVICE);\r
-      OptionMenu            = (LEGACY_MENU_OPTION *) &LegacyBEVMenu;\r
-      LegacyDev             = NVMapData->LegacyBEV;\r
-      InitialLegacyDev     = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyBEV;\r
-      BufferSize            = sizeof (NVMapData->LegacyBEV);\r
-      break;\r
-    }\r
-\r
-    //\r
-    // Check whether has value changed.\r
-    //\r
-    if (CompareMem (LegacyDev, InitialLegacyDev, BufferSize) == 0) {\r
-      CurrentType++;\r
-      continue;\r
-    }\r
-\r
-    DevOrder    = (LEGACY_DEV_ORDER_ENTRY *) OriginalPtr;\r
-    while (VarData < OriginalPtr + VarSize) {\r
-      if (DevOrder->BbsType == mBbsType[CurrentType]) {\r
-        break;\r
-      }\r
-\r
-      VarData += sizeof (BBS_TYPE) + DevOrder->Length;\r
-      DevOrder = (LEGACY_DEV_ORDER_ENTRY *) VarData;\r
-    }\r
-\r
-    if (VarData >= OriginalPtr + VarSize) {\r
-      FreePool (OriginalPtr);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    NewOrder = AllocateZeroPool (DevOrder->Length - sizeof (DevOrder->Length));\r
-    if (NewOrder == NULL) {\r
-      FreePool (OriginalPtr);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
-      if (0xFF == LegacyDev[Index]) {\r
-        break;\r
-      }\r
-\r
-      NewOrder[Index] = LegacyDev[Index];\r
-    }\r
-\r
-    //\r
-    // Only the enable/disable state of each boot device with same device type can be changed,\r
-    // so we can count on the index information in DevOrder.\r
-    // DisMap bit array is the only reliable source to check a device's en/dis state,\r
-    // so we use DisMap to set en/dis state of each item in NewOrder array\r
-    //\r
-    for (Index2 = 0; Index2 < OptionMenu->MenuNumber; Index2++) {\r
-      Tmp = (UINT16) (DevOrder->Data[Index2] & 0xFF);\r
-      Pos = Tmp / 8;\r
-      Bit = 7 - (Tmp % 8);\r
-      if ((DisMap[Pos] & (1 << Bit)) != 0) {\r
-        NewOrder[Index] = (UINT16) (0xFF00 | Tmp);\r
-        Index++;\r
-      }\r
-    }\r
-\r
-    CopyMem (\r
-      DevOrder->Data,\r
-      NewOrder,\r
-      DevOrder->Length - sizeof (DevOrder->Length)\r
-      );\r
-    FreePool (NewOrder);\r
-\r
-    //\r
-    // Update BootOrder and Boot####.Attribute\r
-    //\r
-    // 1. Re-order the Option Number in BootOrder according to Legacy Dev Order\r
-    //\r
-    ASSERT (OptionMenu->MenuNumber == DevOrder->Length / sizeof (UINT16) - 1);\r
-\r
-    Status = OrderLegacyBootOption4SameType (\r
-      DevOrder->Data,\r
-      DevOrder->Length / sizeof (UINT16) - 1,\r
-      &EnBootOption,\r
-      &EnBootOptionCount,\r
-      &DisBootOption,\r
-      &DisBootOptionCount\r
-      );\r
-     if (EFI_ERROR(Status)) {\r
-       goto Fail;\r
-     }\r
-\r
-    //\r
-    // 2. Deactivate the DisBootOption and activate the EnBootOption\r
-    //\r
-    for (Index = 0; Index < DisBootOptionCount; Index++) {\r
-      UnicodeSPrint (VarName, sizeof (VarName), L"Boot%04x", DisBootOption[Index]);\r
-      GetEfiGlobalVariable2 (VarName, (VOID **) &BootOptionVar, &OptionSize);\r
-      if (BootOptionVar != NULL) {\r
-        Attribute   = (UINT32 *) BootOptionVar;\r
-        *Attribute &= ~LOAD_OPTION_ACTIVE;\r
-\r
-        Status = gRT->SetVariable (\r
-                        VarName,\r
-                        &gEfiGlobalVariableGuid,\r
-                        VAR_FLAG,\r
-                        OptionSize,\r
-                        BootOptionVar\r
-                        );\r
-\r
-        FreePool (BootOptionVar);\r
-      }\r
-    }\r
-\r
-    for (Index = 0; Index < EnBootOptionCount; Index++) {\r
-      UnicodeSPrint (VarName, sizeof (VarName), L"Boot%04x", EnBootOption[Index]);\r
-      GetEfiGlobalVariable2 (VarName, (VOID **) &BootOptionVar, &OptionSize);\r
-      if (BootOptionVar != NULL) {\r
-        Attribute   = (UINT32 *) BootOptionVar;\r
-        *Attribute |= LOAD_OPTION_ACTIVE;\r
-\r
-        Status = gRT->SetVariable (\r
-                        VarName,\r
-                        &gEfiGlobalVariableGuid,\r
-                        VAR_FLAG,\r
-                        OptionSize,\r
-                        BootOptionVar\r
-                        );\r
-\r
-        FreePool (BootOptionVar);\r
-      }\r
-    }\r
-\r
-\r
-    FreePool (EnBootOption);\r
-    FreePool (DisBootOption);\r
-\r
-    CurrentType++;\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  VAR_LEGACY_DEV_ORDER,\r
-                  &gEfiLegacyDevOrderVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  VarSize,\r
-                  OriginalPtr\r
-                  );\r
-\r
-Fail:\r
-  if (EnBootOption != NULL) {\r
-    FreePool (EnBootOption);\r
-  }\r
-\r
-  if (DisBootOption != NULL) {\r
-    FreePool (DisBootOption);\r
-  }\r
-\r
-  FreePool (OriginalPtr);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function allows a caller to extract the current configuration for one\r
-  or more named elements from the target driver.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Request         A null-terminated Unicode string in <ConfigRequest> format.\r
-  @param Progress        On return, points to a character in the Request string.\r
-                         Points to the string's null terminator if request was successful.\r
-                         Points to the most recent '&' before the first failing name/value\r
-                         pair (or the beginning of the string if the failure is in the\r
-                         first name/value pair) if the request was not successful.\r
-  @param Results         A null-terminated Unicode string in <ConfigAltResp> format which\r
-                         has all values filled in for the names in the Request string.\r
-                         String to be allocated by the called function.\r
-\r
-  @retval  EFI_SUCCESS            The Results is filled with the requested values.\r
-  @retval  EFI_OUT_OF_RESOURCES   Not enough memory to store the results.\r
-  @retval  EFI_INVALID_PARAMETER  Request is illegal syntax, or unknown name.\r
-  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBootOptionExtractConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Request,\r
-  OUT EFI_STRING                             *Progress,\r
-  OUT EFI_STRING                             *Results\r
-  )\r
-{\r
-  if (Progress == NULL || Results == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  *Progress = Request;\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Configuration   A null-terminated Unicode string in <ConfigResp> format.\r
-  @param Progress        A pointer to a string filled in with the offset of the most\r
-                         recent '&' before the first failing name/value pair (or the\r
-                         beginning of the string if the failure is in the first\r
-                         name/value pair) or the terminating NULL if all was successful.\r
-\r
-  @retval  EFI_SUCCESS            The Results is processed successfully.\r
-  @retval  EFI_INVALID_PARAMETER  Configuration is NULL.\r
-  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBootOptionRouteConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Configuration,\r
-  OUT       EFI_STRING                       *Progress\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;\r
-  LEGACY_BOOT_NV_DATA             *CurrentNVMapData;\r
-  UINTN                           BufferSize;\r
-\r
-\r
-  if (Configuration == NULL || Progress == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *Progress = Configuration;\r
-\r
-  //\r
-  // Check routing data in <ConfigHdr>.\r
-  // Note: there is no name for Name/Value storage, only GUID will be checked\r
-  //\r
-  if (!HiiIsConfigHdrMatch (Configuration, &mLegacyBootOptionGuid, mLegacyBootStorageName)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiHiiConfigRoutingProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &ConfigRouting\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()\r
-  //\r
-  CurrentNVMapData = &mLegacyBootOptionPrivate->MaintainMapData->CurrentNvData;\r
-  Status = ConfigRouting->ConfigToBlock (\r
-                            ConfigRouting,\r
-                            Configuration,\r
-                            (UINT8 *) CurrentNVMapData,\r
-                            &BufferSize,\r
-                            Progress\r
-                            );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = UpdateBBSOption (CurrentNVMapData);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Refresh the global UpdateData structure.\r
-\r
-**/\r
-VOID\r
-RefreshLegacyUpdateData (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Free current updated date\r
-  //\r
-  if (mLegacyStartOpCodeHandle != NULL) {\r
-    HiiFreeOpCodeHandle (mLegacyStartOpCodeHandle);\r
-  }\r
-  if (mLegacyEndOpCodeHandle != NULL) {\r
-    HiiFreeOpCodeHandle (mLegacyEndOpCodeHandle);\r
-  }\r
-\r
-  //\r
-  // Create new OpCode Handle\r
-  //\r
-  mLegacyStartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  mLegacyEndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  mLegacyStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
-                                         mLegacyStartOpCodeHandle,\r
-                                         &gEfiIfrTianoGuid,\r
-                                         NULL,\r
-                                         sizeof (EFI_IFR_GUID_LABEL)\r
-                                         );\r
-  mLegacyStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-\r
-  mLegacyStartLabel->Number = FORM_BOOT_LEGACY_DEVICE_ID;\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  mLegacyEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
-                                         mLegacyEndOpCodeHandle,\r
-                                         &gEfiIfrTianoGuid,\r
-                                         NULL,\r
-                                         sizeof (EFI_IFR_GUID_LABEL)\r
-                                         );\r
-  mLegacyEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-\r
-  mLegacyEndLabel->Number = FORM_BOOT_LEGACY_LABEL_END;\r
-\r
-}\r
-\r
-/**\r
-  Get the Menu Entry from the list in Menu Entry List.\r
-\r
-  If MenuNumber is great or equal to the number of Menu\r
-  Entry in the list, then ASSERT.\r
-\r
-  @param MenuOption      The Menu Entry List to read the menu entry.\r
-  @param MenuNumber      The index of Menu Entry.\r
-\r
-  @return The Menu Entry.\r
-\r
-**/\r
-LEGACY_MENU_ENTRY *\r
-GetMenuEntry (\r
-  LEGACY_MENU_OPTION      *MenuOption,\r
-  UINTN                   MenuNumber\r
-  )\r
-{\r
-  LEGACY_MENU_ENTRY   *NewMenuEntry;\r
-  UINTN               Index;\r
-  LIST_ENTRY          *List;\r
-\r
-  ASSERT (MenuNumber < MenuOption->MenuNumber);\r
-\r
-  List = MenuOption->Head.ForwardLink;\r
-  for (Index = 0; Index < MenuNumber; Index++) {\r
-    List = List->ForwardLink;\r
-  }\r
-\r
-  NewMenuEntry = CR (List, LEGACY_MENU_ENTRY, Link, LEGACY_MENU_ENTRY_SIGNATURE);\r
-\r
-  return NewMenuEntry;\r
-}\r
-\r
-/**\r
-  Create string tokens for a menu from its help strings and display strings\r
-\r
-  @param HiiHandle          Hii Handle of the package to be updated.\r
-  @param MenuOption         The Menu whose string tokens need to be created\r
-\r
-**/\r
-VOID\r
-CreateLegacyMenuStringToken (\r
-  IN EFI_HII_HANDLE                   HiiHandle,\r
-  IN LEGACY_MENU_OPTION               *MenuOption\r
-  )\r
-{\r
-  LEGACY_MENU_ENTRY *NewMenuEntry;\r
-  UINTN             Index;\r
-\r
-  for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r
-    NewMenuEntry = GetMenuEntry (MenuOption, Index);\r
-\r
-    NewMenuEntry->DisplayStringToken = HiiSetString (\r
-                                         HiiHandle,\r
-                                         0,\r
-                                         NewMenuEntry->DisplayString,\r
-                                         NULL\r
-                                         );\r
-\r
-    if (NULL == NewMenuEntry->HelpString) {\r
-      NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;\r
-    } else {\r
-      NewMenuEntry->HelpStringToken = HiiSetString (\r
-                                        HiiHandle,\r
-                                        0,\r
-                                        NewMenuEntry->HelpString,\r
-                                        NULL\r
-                                        );\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Create a dynamic page so that Legacy Device boot order\r
-  can be set for specified device type.\r
-\r
-  @param UpdatePageId    The form ID. It also spefies the legacy device type.\r
-\r
-\r
-**/\r
-VOID\r
-UpdateLegacyDeviceOrderPage (\r
-  IN UINT16                           UpdatePageId\r
-  )\r
-{\r
-  LEGACY_MENU_OPTION          *OptionMenu;\r
-  LEGACY_MENU_ENTRY           *NewMenuEntry;\r
-  EFI_STRING_ID               StrRef;\r
-  EFI_STRING_ID               StrRefHelp;\r
-  UINT16                      *Default;\r
-  UINT16                      Index;\r
-  UINT16                      Key;\r
-  CHAR16                      String[100];\r
-  CHAR16                      *TypeStr;\r
-  CHAR16                      *TypeStrHelp;\r
-  CHAR16                      *FormTitle;\r
-  VOID                        *OptionsOpCodeHandle;\r
-  VOID                        *DefaultOpCodeHandle;\r
-\r
-  Key         = 0;\r
-  StrRef      = 0;\r
-  StrRefHelp  = 0;\r
-  OptionMenu  = NULL;\r
-  TypeStr     = NULL;\r
-  TypeStrHelp = NULL;\r
-  Default     = NULL;\r
-\r
-  RefreshLegacyUpdateData();\r
-\r
-  //\r
-  // Create oneof option list\r
-  //\r
-  switch (UpdatePageId) {\r
-  case FORM_FLOPPY_BOOT_ID:\r
-    OptionMenu  = (LEGACY_MENU_OPTION *) &LegacyFDMenu;\r
-    Key         = (UINT16) LEGACY_FD_QUESTION_ID;\r
-    TypeStr     = STR_FLOPPY;\r
-    TypeStrHelp = STR_FLOPPY_HELP;\r
-    FormTitle   = STR_FLOPPY_TITLE;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->CurrentNvData.LegacyFD;\r
-    break;\r
-\r
-  case FORM_HARDDISK_BOOT_ID:\r
-    OptionMenu  = (LEGACY_MENU_OPTION *) &LegacyHDMenu;\r
-    Key         = (UINT16) LEGACY_HD_QUESTION_ID;\r
-    TypeStr     = STR_HARDDISK;\r
-    TypeStrHelp = STR_HARDDISK_HELP;\r
-    FormTitle   = STR_HARDDISK_TITLE;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->CurrentNvData.LegacyHD;\r
-    break;\r
-\r
-  case FORM_CDROM_BOOT_ID:\r
-    OptionMenu  = (LEGACY_MENU_OPTION *) &LegacyCDMenu;\r
-    Key         = (UINT16) LEGACY_CD_QUESTION_ID;\r
-    TypeStr     = STR_CDROM;\r
-    TypeStrHelp = STR_CDROM_HELP;\r
-    FormTitle   = STR_CDROM_TITLE;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->CurrentNvData.LegacyCD;\r
-    break;\r
-\r
-  case FORM_NET_BOOT_ID:\r
-    OptionMenu  = (LEGACY_MENU_OPTION *) &LegacyNETMenu;\r
-    Key         = (UINT16) LEGACY_NET_QUESTION_ID;\r
-    TypeStr     = STR_NET;\r
-    TypeStrHelp = STR_NET_HELP;\r
-    FormTitle   = STR_NET_TITLE;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->CurrentNvData.LegacyNET;\r
-    break;\r
-\r
-  case FORM_BEV_BOOT_ID:\r
-    OptionMenu  = (LEGACY_MENU_OPTION *) &LegacyBEVMenu;\r
-    Key         = (UINT16) LEGACY_BEV_QUESTION_ID;\r
-    TypeStr     = STR_BEV;\r
-    TypeStrHelp = STR_BEV_HELP;\r
-    FormTitle   = STR_BEV_TITLE;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->CurrentNvData.LegacyBEV;\r
-    break;\r
-\r
-  default:\r
-    DEBUG ((EFI_D_ERROR, "Invalid command ID for updating page!\n"));\r
-    return;\r
-  }\r
-\r
-  HiiSetString (mLegacyBootOptionPrivate->HiiHandle, STRING_TOKEN(STR_ORDER_CHANGE_PROMPT), FormTitle, NULL);\r
-\r
-  CreateLegacyMenuStringToken (mLegacyBootOptionPrivate->HiiHandle, OptionMenu);\r
-\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-\r
-  for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
-    NewMenuEntry = GetMenuEntry (OptionMenu, Index);\r
-    //\r
-    // Create OneOf for each legacy device\r
-    //\r
-    HiiCreateOneOfOptionOpCode (\r
-      OptionsOpCodeHandle,\r
-      NewMenuEntry->DisplayStringToken,\r
-      0,\r
-      EFI_IFR_TYPE_NUM_SIZE_16,\r
-      ((LEGACY_DEVICE_CONTEXT *) NewMenuEntry->VariableContext)->BbsIndex\r
-      );\r
-  }\r
-\r
-  //\r
-  // Create OneOf for item "Disabled"\r
-  //\r
-  HiiCreateOneOfOptionOpCode (\r
-    OptionsOpCodeHandle,\r
-    STRING_TOKEN (STR_DISABLE_LEGACY_DEVICE),\r
-    0,\r
-    EFI_IFR_TYPE_NUM_SIZE_16,\r
-    0xFF\r
-    );\r
-\r
-  //\r
-  // Create oneof tag here for FD/HD/CD #1 #2\r
-  //\r
-  for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
-    DefaultOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-    ASSERT (DefaultOpCodeHandle != NULL);\r
-\r
-    HiiCreateDefaultOpCode (\r
-      DefaultOpCodeHandle,\r
-      EFI_HII_DEFAULT_CLASS_STANDARD,\r
-      EFI_IFR_TYPE_NUM_SIZE_16,\r
-      *Default++\r
-      );\r
-\r
-    //\r
-    // Create the string for oneof tag\r
-    //\r
-    UnicodeSPrint (String, sizeof (String), TypeStr, Index);\r
-    StrRef = HiiSetString (mLegacyBootOptionPrivate->HiiHandle, 0, String, NULL);\r
-\r
-    UnicodeSPrint (String, sizeof (String), TypeStrHelp, Index);\r
-    StrRefHelp = HiiSetString (mLegacyBootOptionPrivate->HiiHandle, 0, String, NULL);\r
-\r
-    HiiCreateOneOfOpCode (\r
-      mLegacyStartOpCodeHandle,\r
-      (EFI_QUESTION_ID) (Key + Index),\r
-      VARSTORE_ID_LEGACY_BOOT,\r
-      (UINT16) (Key + Index * 2 - CONFIG_OPTION_OFFSET),\r
-      StrRef,\r
-      StrRefHelp,\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      EFI_IFR_NUMERIC_SIZE_2,\r
-      OptionsOpCodeHandle,\r
-      DefaultOpCodeHandle //NULL //\r
-      );\r
-\r
-    HiiFreeOpCodeHandle (DefaultOpCodeHandle);\r
-  }\r
-\r
-  HiiUpdateForm (\r
-    mLegacyBootOptionPrivate->HiiHandle,\r
-    &mLegacyBootOptionGuid,\r
-    LEGACY_ORDER_CHANGE_FORM_ID,\r
-    mLegacyStartOpCodeHandle,\r
-    mLegacyEndOpCodeHandle\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-}\r
-\r
-\r
-/**\r
-  Adjust question value when one question value has been changed.\r
-\r
-  @param QuestionId    The question id for the value changed question.\r
-  @param Value         The value for the changed question.\r
-\r
-**/\r
-VOID\r
-AdjustOptionValue (\r
-  IN  UINT16                                 QuestionId,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value\r
-  )\r
-{\r
-  UINTN                       Number;\r
-  UINT16                      *Default;\r
-  LEGACY_BOOT_NV_DATA         *CurrentNVMap;\r
-  UINT16                      *CurrentVal;\r
-  UINTN                       Index;\r
-  UINTN                       Index2;\r
-  UINTN                       Index3;\r
-  UINTN                       NewValuePos;\r
-  UINTN                       OldValue;\r
-  UINTN                       NewValue;\r
-  UINT8                       *DisMap;\r
-  UINTN                       Pos;\r
-  UINTN                       Bit;\r
-\r
-  Number = 0;\r
-  CurrentVal = 0;\r
-  Default = NULL;\r
-  NewValue = 0;\r
-  NewValuePos = 0;\r
-  OldValue = 0;\r
-\r
-  //\r
-  // Update Select FD/HD/CD/NET/BEV Order Form\r
-  //\r
-  ASSERT ((QuestionId >= LEGACY_FD_QUESTION_ID) && (QuestionId < LEGACY_BEV_QUESTION_ID + MAX_MENU_NUMBER));\r
-\r
-  CurrentNVMap = &mLegacyBootOptionPrivate->MaintainMapData->CurrentNvData;\r
-  HiiGetBrowserData (&mLegacyBootOptionGuid, mLegacyBootStorageName, sizeof (LEGACY_BOOT_NV_DATA), (UINT8 *) CurrentNVMap);\r
-  DisMap  = mLegacyBootOptionPrivate->MaintainMapData->DisableMap;\r
-\r
-  if (QuestionId >= LEGACY_FD_QUESTION_ID && QuestionId < LEGACY_FD_QUESTION_ID + MAX_MENU_NUMBER) {\r
-    Number      = (UINT16) LegacyFDMenu.MenuNumber;\r
-    CurrentVal  = CurrentNVMap->LegacyFD;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyFD;\r
-  } else if (QuestionId >= LEGACY_HD_QUESTION_ID && QuestionId < LEGACY_HD_QUESTION_ID + MAX_MENU_NUMBER) {\r
-    Number      = (UINT16) LegacyHDMenu.MenuNumber;\r
-    CurrentVal  = CurrentNVMap->LegacyHD;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyHD;\r
-  } else if (QuestionId >= LEGACY_CD_QUESTION_ID && QuestionId < LEGACY_CD_QUESTION_ID + MAX_MENU_NUMBER) {\r
-    Number      = (UINT16) LegacyCDMenu.MenuNumber;\r
-    CurrentVal  = CurrentNVMap->LegacyCD;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyCD;\r
-  } else if (QuestionId >= LEGACY_NET_QUESTION_ID && QuestionId < LEGACY_NET_QUESTION_ID + MAX_MENU_NUMBER) {\r
-    Number      = (UINT16) LegacyNETMenu.MenuNumber;\r
-    CurrentVal  = CurrentNVMap->LegacyNET;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyNET;\r
-  } else if (QuestionId >= LEGACY_BEV_QUESTION_ID && QuestionId < LEGACY_BEV_QUESTION_ID + MAX_MENU_NUMBER) {\r
-    Number      = (UINT16) LegacyBEVMenu.MenuNumber;\r
-    CurrentVal  = CurrentNVMap->LegacyBEV;\r
-    Default     = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyBEV;\r
-  }\r
-\r
-  //\r
-  //  First, find the different position\r
-  //  if there is change, it should be only one\r
-  //\r
-  for (Index = 0; Index < Number; Index++) {\r
-    if (CurrentVal[Index] != Default[Index]) {\r
-      OldValue  = Default[Index];\r
-      NewValue  = CurrentVal[Index];\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (Index != Number) {\r
-    //\r
-    // there is change, now process\r
-    //\r
-    if (0xFF == NewValue) {\r
-      //\r
-      // This item will be disable\r
-      // Just move the items behind this forward to overlap it\r
-      //\r
-      Pos = OldValue / 8;\r
-      Bit = 7 - (OldValue % 8);\r
-      DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit));\r
-      for (Index2 = Index; Index2 < Number - 1; Index2++) {\r
-        CurrentVal[Index2] = CurrentVal[Index2 + 1];\r
-      }\r
-\r
-      CurrentVal[Index2] = 0xFF;\r
-    } else {\r
-      for (Index2 = 0; Index2 < Number; Index2++) {\r
-        if (Index2 == Index) {\r
-          continue;\r
-        }\r
-\r
-        if (Default[Index2] == NewValue) {\r
-          //\r
-          // If NewValue is in OldLegacyDev array\r
-          // remember its old position\r
-          //\r
-          NewValuePos = Index2;\r
-          break;\r
-        }\r
-      }\r
-\r
-      if (Index2 != Number) {\r
-        //\r
-        // We will change current item to an existing item\r
-        // (It's hard to describe here, please read code, it's like a cycle-moving)\r
-        //\r
-        for (Index2 = NewValuePos; Index2 != Index;) {\r
-          if (NewValuePos < Index) {\r
-            CurrentVal[Index2] = Default[Index2 + 1];\r
-            Index2++;\r
-          } else {\r
-            CurrentVal[Index2] = Default[Index2 - 1];\r
-            Index2--;\r
-          }\r
-        }\r
-      } else {\r
-        //\r
-        // If NewValue is not in OldlegacyDev array, we are changing to a disabled item\r
-        // so we should modify DisMap to reflect the change\r
-        //\r
-        Pos = NewValue / 8;\r
-        Bit = 7 - (NewValue % 8);\r
-        DisMap[Pos] = (UINT8) (DisMap[Pos] & (~ (UINT8) (1 << Bit)));\r
-        if (0xFF != OldValue) {\r
-          //\r
-          // Because NewValue is a item that was disabled before\r
-          // so after changing the OldValue should be disabled\r
-          // actually we are doing a swap of enable-disable states of two items\r
-          //\r
-          Pos = OldValue / 8;\r
-          Bit = 7 - (OldValue % 8);\r
-          DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit));\r
-        }\r
-      }\r
-    }\r
-    //\r
-    // To prevent DISABLE appears in the middle of the list\r
-    // we should perform a re-ordering\r
-    //\r
-    Index3 = Index;\r
-    Index = 0;\r
-    while (Index < Number) {\r
-      if (0xFF != CurrentVal[Index]) {\r
-        Index++;\r
-        continue;\r
-      }\r
-\r
-      Index2 = Index;\r
-      Index2++;\r
-      while (Index2 < Number) {\r
-        if (0xFF != CurrentVal[Index2]) {\r
-          break;\r
-        }\r
-\r
-        Index2++;\r
-      }\r
-\r
-      if (Index2 < Number) {\r
-        CurrentVal[Index]   = CurrentVal[Index2];\r
-        CurrentVal[Index2]  = 0xFF;\r
-      }\r
-\r
-      Index++;\r
-    }\r
-\r
-    //\r
-    // Return correct question value.\r
-    //\r
-    Value->u16 = CurrentVal[Index3];\r
-    CopyMem (Default, CurrentVal, sizeof (UINT16) * Number);\r
-  }\r
-\r
-  //\r
-  // Pass changed uncommitted data back to Form Browser\r
-  //\r
-  HiiSetBrowserData (&mLegacyBootOptionGuid, mLegacyBootStorageName, sizeof (LEGACY_BOOT_NV_DATA), (UINT8 *) CurrentNVMap, NULL);\r
-}\r
-\r
-/**\r
-  This call back function is registered with Boot Manager formset.\r
-  When user selects a boot option, this call back function will\r
-  be triggered. The boot option is saved for later processing.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBootOptionCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  )\r
-{\r
-  if (Action != EFI_BROWSER_ACTION_CHANGED && Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_FORM_OPEN) {\r
-    //\r
-    // Do nothing for other UEFI Action. Only do call back when data is changed or the form is open.\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if ((Value == NULL) || (ActionRequest == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {\r
-    if (QuestionId == FORM_FLOPPY_BOOT_ID) {\r
-      if (!mFirstEnterLegacyForm) {\r
-        //\r
-        // The leagcyBootMaintUiLib depends on the LegacyBootManagerLib to realize its functionality.\r
-        // We need to do the leagcy boot options related actions after the LegacyBootManagerLib has been initialized.\r
-        // Opening the legacy menus is the appropriate time that the LegacyBootManagerLib has already been initialized.\r
-        //\r
-        mFirstEnterLegacyForm = TRUE;\r
-        GetLegacyOptions ();\r
-        GetLegacyOptionsOrder ();\r
-      }\r
-    }\r
-  }\r
-\r
-  if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
-    switch (QuestionId) {\r
-    case FORM_FLOPPY_BOOT_ID:\r
-    case FORM_HARDDISK_BOOT_ID:\r
-    case FORM_CDROM_BOOT_ID:\r
-    case FORM_NET_BOOT_ID:\r
-    case FORM_BEV_BOOT_ID:\r
-      UpdateLegacyDeviceOrderPage (QuestionId);\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-  } else if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
-    if ((Value == NULL) || (ActionRequest == NULL)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if ((QuestionId >= LEGACY_FD_QUESTION_ID) && (QuestionId < LEGACY_BEV_QUESTION_ID + MAX_MENU_NUMBER)) {\r
-      AdjustOptionValue(QuestionId, Value);\r
-    }\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Create a menu entry by given menu type.\r
-\r
-  @param MenuType        The Menu type to be created.\r
-\r
-  @retval NULL           If failed to create the menu.\r
-  @return the new menu entry.\r
-\r
-**/\r
-LEGACY_MENU_ENTRY *\r
-CreateMenuEntry (\r
-  VOID\r
-  )\r
-{\r
-  LEGACY_MENU_ENTRY *MenuEntry;\r
-\r
-  //\r
-  // Create new menu entry\r
-  //\r
-  MenuEntry = AllocateZeroPool (sizeof (LEGACY_MENU_ENTRY));\r
-  if (MenuEntry == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  MenuEntry->VariableContext = AllocateZeroPool (sizeof (LEGACY_DEVICE_CONTEXT));\r
-  if (MenuEntry->VariableContext == NULL) {\r
-    FreePool (MenuEntry);\r
-    return NULL;\r
-  }\r
-\r
-  MenuEntry->Signature        = LEGACY_MENU_ENTRY_SIGNATURE;\r
-  return MenuEntry;\r
-}\r
-\r
-/**\r
-\r
-  Base on the L"LegacyDevOrder" variable to build the current order data.\r
-\r
-**/\r
-VOID\r
-GetLegacyOptionsOrder (\r
-  VOID\r
-  )\r
-{\r
-  UINTN                       VarSize;\r
-  UINT8                       *VarData;\r
-  UINT8                       *VarTmp;\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  UINT16                      *LegacyDev;\r
-  UINTN                       Index;\r
-  LEGACY_MENU_OPTION          *OptionMenu;\r
-  UINT16                      VarDevOrder;\r
-  UINTN                       Pos;\r
-  UINTN                       Bit;\r
-  UINT8                       *DisMap;\r
-  UINTN                       TotalLength;\r
-\r
-  LegacyDev = NULL;\r
-  OptionMenu = NULL;\r
-\r
-  DisMap = ZeroMem (mLegacyBootOptionPrivate->MaintainMapData->DisableMap, sizeof (mLegacyBootOptionPrivate->MaintainMapData->DisableMap));\r
-\r
-  //\r
-  // Get Device Order from variable\r
-  //\r
-  GetVariable2 (VAR_LEGACY_DEV_ORDER, &gEfiLegacyDevOrderVariableGuid, (VOID **) &VarData, &VarSize);\r
-  VarTmp = VarData;\r
-  if (NULL != VarData) {\r
-    DevOrder    = (LEGACY_DEV_ORDER_ENTRY *) VarData;\r
-    while (VarData < VarTmp + VarSize) {\r
-      switch (DevOrder->BbsType) {\r
-      case BBS_FLOPPY:\r
-        LegacyDev = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyFD;\r
-        OptionMenu = &LegacyFDMenu;\r
-        break;\r
-\r
-      case BBS_HARDDISK:\r
-        LegacyDev = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyHD;\r
-        OptionMenu = &LegacyHDMenu;\r
-        break;\r
-\r
-      case BBS_CDROM:\r
-        LegacyDev = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyCD;\r
-        OptionMenu = &LegacyCDMenu;\r
-        break;\r
-\r
-      case BBS_EMBED_NETWORK:\r
-        LegacyDev = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyNET;\r
-        OptionMenu = &LegacyNETMenu;\r
-        break;\r
-\r
-      case BBS_BEV_DEVICE:\r
-        LegacyDev = mLegacyBootOptionPrivate->MaintainMapData->InitialNvData.LegacyBEV;\r
-        OptionMenu = &LegacyBEVMenu;\r
-        break;\r
-\r
-      case BBS_UNKNOWN:\r
-      default:\r
-        ASSERT (FALSE);\r
-        DEBUG ((DEBUG_ERROR, "Unsupported device type found!\n"));\r
-        break;\r
-      }\r
-\r
-      //\r
-      // Create oneof tag here for FD/HD/CD #1 #2\r
-      //\r
-      for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
-        TotalLength = sizeof (BBS_TYPE) + sizeof (UINT16) + Index * sizeof (UINT16);\r
-        VarDevOrder = *(UINT16 *) ((UINT8 *) DevOrder + TotalLength);\r
-\r
-        if (0xFF00 == (VarDevOrder & 0xFF00)) {\r
-          LegacyDev[Index]  = 0xFF;\r
-          Pos               = (VarDevOrder & 0xFF) / 8;\r
-          Bit               = 7 - ((VarDevOrder & 0xFF) % 8);\r
-          DisMap[Pos]       = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit));\r
-        } else {\r
-          LegacyDev[Index] = VarDevOrder & 0xFF;\r
-        }\r
-      }\r
-\r
-      VarData ++;\r
-      VarData += *(UINT16 *) VarData;\r
-      DevOrder = (LEGACY_DEV_ORDER_ENTRY *) VarData;\r
-    }\r
-  }\r
-\r
-  CopyMem (&mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData, &mLegacyBootOptionPrivate->MaintainMapData->InitialNvData, sizeof (LEGACY_BOOT_NV_DATA));\r
-  CopyMem (&mLegacyBootOptionPrivate->MaintainMapData->CurrentNvData, &mLegacyBootOptionPrivate->MaintainMapData->InitialNvData, sizeof (LEGACY_BOOT_NV_DATA));\r
-}\r
-\r
-/**\r
-\r
-  Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().\r
-\r
-**/\r
-VOID\r
-GetLegacyOptions (\r
-  VOID\r
-  )\r
-{\r
-  LEGACY_MENU_ENTRY             *NewMenuEntry;\r
-  LEGACY_DEVICE_CONTEXT         *NewLegacyDevContext;\r
-  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption;\r
-  UINTN                         BootOptionCount;\r
-  UINT16                        Index;\r
-  UINTN                         FDNum;\r
-  UINTN                         HDNum;\r
-  UINTN                         CDNum;\r
-  UINTN                         NETNum;\r
-  UINTN                         BEVNum;\r
-\r
-  //\r
-  // Initialize Bbs Table Context from BBS info data\r
-  //\r
-  InitializeListHead (&LegacyFDMenu.Head);\r
-  InitializeListHead (&LegacyHDMenu.Head);\r
-  InitializeListHead (&LegacyCDMenu.Head);\r
-  InitializeListHead (&LegacyNETMenu.Head);\r
-  InitializeListHead (&LegacyBEVMenu.Head);\r
-\r
-  FDNum   = 0;\r
-  HDNum   = 0;\r
-  CDNum   = 0;\r
-  NETNum  = 0;\r
-  BEVNum  = 0;\r
-\r
-  EfiBootManagerConnectAll ();\r
-\r
-  //\r
-  // for better user experience\r
-  // 1. User changes HD configuration (e.g.: unplug HDD), here we have a chance to remove the HDD boot option\r
-  // 2. User enables/disables UEFI PXE, here we have a chance to add/remove EFI Network boot option\r
-  //\r
-  EfiBootManagerRefreshAllBootOption ();\r
-\r
-  BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
-  for (Index = 0; Index < BootOptionCount; Index++) {\r
-    if ((DevicePathType (BootOption[Index].FilePath) != BBS_DEVICE_PATH) ||\r
-        (DevicePathSubType (BootOption[Index].FilePath) != BBS_BBS_DP)\r
-       ) {\r
-      continue;\r
-    }\r
-    ASSERT (BootOption[Index].OptionalDataSize == sizeof (LEGACY_BOOT_OPTION_BBS_DATA));\r
-    NewMenuEntry = CreateMenuEntry ();\r
-    ASSERT (NewMenuEntry != NULL);\r
-\r
-    NewLegacyDevContext              = (LEGACY_DEVICE_CONTEXT *) NewMenuEntry->VariableContext;\r
-    NewLegacyDevContext->BbsIndex    = ((LEGACY_BOOT_OPTION_BBS_DATA *) BootOption[Index].OptionalData)->BbsIndex;\r
-    NewLegacyDevContext->Description = AllocateCopyPool (StrSize (BootOption[Index].Description), BootOption[Index].Description);\r
-    ASSERT (NewLegacyDevContext->Description != NULL);\r
-\r
-    NewMenuEntry->DisplayString = NewLegacyDevContext->Description;\r
-    NewMenuEntry->HelpString    = NULL;\r
-\r
-    switch (((BBS_BBS_DEVICE_PATH *) BootOption[Index].FilePath)->DeviceType) {\r
-    case BBS_TYPE_FLOPPY:\r
-      InsertTailList (&LegacyFDMenu.Head, &NewMenuEntry->Link);\r
-      FDNum++;\r
-      break;\r
-\r
-    case BBS_TYPE_HARDDRIVE:\r
-      InsertTailList (&LegacyHDMenu.Head, &NewMenuEntry->Link);\r
-      HDNum++;\r
-      break;\r
-\r
-    case BBS_TYPE_CDROM:\r
-      InsertTailList (&LegacyCDMenu.Head, &NewMenuEntry->Link);\r
-      CDNum++;\r
-      break;\r
-\r
-    case BBS_TYPE_EMBEDDED_NETWORK:\r
-      InsertTailList (&LegacyNETMenu.Head, &NewMenuEntry->Link);\r
-      NETNum++;\r
-      break;\r
-\r
-    case BBS_TYPE_BEV:\r
-      InsertTailList (&LegacyBEVMenu.Head, &NewMenuEntry->Link);\r
-      BEVNum++;\r
-      break;\r
-    }\r
-  }\r
-\r
-  EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);\r
-\r
-  LegacyFDMenu.MenuNumber   = FDNum;\r
-  LegacyHDMenu.MenuNumber   = HDNum;\r
-  LegacyCDMenu.MenuNumber   = CDNum;\r
-  LegacyNETMenu.MenuNumber  = NETNum;\r
-  LegacyBEVMenu.MenuNumber  = BEVNum;\r
-}\r
-\r
-\r
-/**\r
-\r
-  Install Boot Manager Menu driver.\r
-\r
-  @param ImageHandle     The image handle.\r
-  @param SystemTable     The system table.\r
-\r
-  @retval  EFI_SUCEESS  Install Boot manager menu success.\r
-  @retval  Other        Return error status.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBootMaintUiLibConstructor (\r
-  IN EFI_HANDLE                            ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                      *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL          *LegacyBios;\r
-  LEGACY_BOOT_OPTION_CALLBACK_DATA  *LegacyBootOptionData;\r
-\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Create LegacyBootOptionData structures for Driver Callback\r
-    //\r
-    LegacyBootOptionData = AllocateZeroPool (sizeof (LEGACY_BOOT_OPTION_CALLBACK_DATA));\r
-    ASSERT (LegacyBootOptionData != NULL);\r
-\r
-    LegacyBootOptionData->MaintainMapData = AllocateZeroPool (sizeof (LEGACY_BOOT_MAINTAIN_DATA));\r
-    ASSERT (LegacyBootOptionData->MaintainMapData != NULL);\r
-\r
-    LegacyBootOptionData->ConfigAccess.ExtractConfig = LegacyBootOptionExtractConfig;\r
-    LegacyBootOptionData->ConfigAccess.RouteConfig   = LegacyBootOptionRouteConfig;\r
-    LegacyBootOptionData->ConfigAccess.Callback      = LegacyBootOptionCallback;\r
-\r
-    //\r
-    // Install Device Path Protocol and Config Access protocol to driver handle\r
-    //\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &LegacyBootOptionData->DriverHandle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    &mLegacyBootOptionHiiVendorDevicePath,\r
-                    &gEfiHiiConfigAccessProtocolGuid,\r
-                    &LegacyBootOptionData->ConfigAccess,\r
-                    NULL\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Publish our HII data\r
-    //\r
-    LegacyBootOptionData->HiiHandle = HiiAddPackages (\r
-                                      &mLegacyBootOptionGuid,\r
-                                      LegacyBootOptionData->DriverHandle,\r
-                                      LegacyBootMaintUiVfrBin,\r
-                                      LegacyBootMaintUiLibStrings,\r
-                                      NULL\r
-                                      );\r
-    ASSERT (LegacyBootOptionData->HiiHandle != NULL);\r
-\r
-    mLegacyBootOptionPrivate = LegacyBootOptionData;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Destructor of Customized Display Library Instance.\r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS   The destructor completed successfully.\r
-  @retval Other value   The destructor did not complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBootMaintUiLibDestructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-\r
-  if (mLegacyBootOptionPrivate != NULL && mLegacyBootOptionPrivate->DriverHandle != NULL) {\r
-    Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                    mLegacyBootOptionPrivate->DriverHandle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    &mLegacyBootOptionHiiVendorDevicePath,\r
-                    &gEfiHiiConfigAccessProtocolGuid,\r
-                    &mLegacyBootOptionPrivate->ConfigAccess,\r
-                    NULL\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    HiiRemovePackages (mLegacyBootOptionPrivate->HiiHandle);\r
-\r
-    FreePool (mLegacyBootOptionPrivate->MaintainMapData);\r
-    FreePool (mLegacyBootOptionPrivate);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.h b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.h
deleted file mode 100644 (file)
index 0c49131..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/** @file\r
-  Legacy boot maintainence Ui definition.\r
-\r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#ifndef _EFI_LEGACY_BOOT_OPTION_H_\r
-#define _EFI_LEGACY_BOOT_OPTION_H_\r
-\r
-#include <PiDxe.h>\r
-\r
-\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/LegacyDevOrder.h>\r
-#include <Guid/MdeModuleHii.h>\r
-\r
-#include <Protocol/HiiConfigAccess.h>\r
-#include <Protocol/HiiConfigRouting.h>\r
-\r
-#include <Protocol/HiiDatabase.h>\r
-#include <Protocol/LegacyBios.h>\r
-\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/UefiBootManagerLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
-#include "LegacyBootMaintUiVfr.h"\r
-\r
-#define CONFIG_OPTION_OFFSET    0x1200\r
-\r
-//\r
-// VarOffset that will be used to create question\r
-// all these values are computed from the structure\r
-// defined below\r
-//\r
-#define VAR_OFFSET(Field)              ((UINT16) ((UINTN) &(((LEGACY_BOOT_NV_DATA *) 0)->Field)))\r
-\r
-//\r
-// Question Id of Zero is invalid, so add an offset to it\r
-//\r
-#define QUESTION_ID(Field)             (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)\r
-\r
-\r
-#define LEGACY_FD_QUESTION_ID           QUESTION_ID (LegacyFD)\r
-#define LEGACY_HD_QUESTION_ID           QUESTION_ID (LegacyHD)\r
-#define LEGACY_CD_QUESTION_ID           QUESTION_ID (LegacyCD)\r
-#define LEGACY_NET_QUESTION_ID          QUESTION_ID (LegacyNET)\r
-#define LEGACY_BEV_QUESTION_ID          QUESTION_ID (LegacyBEV)\r
-\r
-\r
-//\r
-// String Contant\r
-//\r
-#define STR_FLOPPY          L"Floppy Drive #%02x"\r
-#define STR_HARDDISK        L"HardDisk Drive #%02x"\r
-#define STR_CDROM           L"ATAPI CDROM Drive #%02x"\r
-#define STR_NET             L"NET Drive #%02x"\r
-#define STR_BEV             L"BEV Drive #%02x"\r
-\r
-#define STR_FLOPPY_HELP     L"Select Floppy Drive #%02x"\r
-#define STR_HARDDISK_HELP   L"Select HardDisk Drive #%02x"\r
-#define STR_CDROM_HELP      L"Select ATAPI CDROM Drive #%02x"\r
-#define STR_NET_HELP        L"NET Drive #%02x"\r
-#define STR_BEV_HELP        L"BEV Drive #%02x"\r
-\r
-#define STR_FLOPPY_TITLE    L"Set Legacy Floppy Drive Order"\r
-#define STR_HARDDISK_TITLE  L"Set Legacy HardDisk Drive Order"\r
-#define STR_CDROM_TITLE     L"Set Legacy CDROM Drive Order"\r
-#define STR_NET_TITLE       L"Set Legacy NET Drive Order"\r
-#define STR_BEV_TITLE       L"Set Legacy BEV Drive Order"\r
-\r
-//\r
-// These are the VFR compiler generated data representing our VFR data.\r
-//\r
-extern UINT8 LegacyBootMaintUiVfrBin[];\r
-\r
-#pragma pack(1)\r
-\r
-///\r
-/// HII specific Vendor Device Path definition.\r
-///\r
-typedef struct {\r
-  VENDOR_DEVICE_PATH             VendorDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL       End;\r
-} HII_VENDOR_DEVICE_PATH;\r
-\r
-\r
-\r
-//\r
-// Variable created with this flag will be "Efi:...."\r
-//\r
-#define VAR_FLAG  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE\r
-\r
-\r
-#define LEGACY_BOOT_OPTION_CALLBACK_DATA_SIGNATURE  SIGNATURE_32 ('L', 'G', 'C', 'B')\r
-\r
-typedef struct {\r
-  UINTN                            Signature;\r
-\r
-  //\r
-  // HII relative handles\r
-  //\r
-  EFI_HII_HANDLE                   HiiHandle;\r
-  EFI_HANDLE                       DriverHandle;\r
-\r
-  //\r
-  // Produced protocols\r
-  //\r
-  EFI_HII_CONFIG_ACCESS_PROTOCOL   ConfigAccess;\r
-\r
-  //\r
-  // Maintain the data.\r
-  //\r
-  LEGACY_BOOT_MAINTAIN_DATA        *MaintainMapData;\r
-} LEGACY_BOOT_OPTION_CALLBACK_DATA;\r
-\r
-//\r
-// All of the signatures that will be used in list structure\r
-//\r
-#define LEGACY_MENU_OPTION_SIGNATURE      SIGNATURE_32 ('m', 'e', 'n', 'u')\r
-#define LEGACY_MENU_ENTRY_SIGNATURE       SIGNATURE_32 ('e', 'n', 't', 'r')\r
-\r
-#define LEGACY_LEGACY_DEV_CONTEXT_SELECT  0x9\r
-\r
-typedef struct {\r
-  UINTN           Signature;\r
-  LIST_ENTRY      Head;\r
-  UINTN           MenuNumber;\r
-} LEGACY_MENU_OPTION;\r
-\r
-typedef struct {\r
-  UINT16    BbsIndex;\r
-  CHAR16    *Description;\r
-} LEGACY_DEVICE_CONTEXT;\r
-\r
-typedef struct {\r
-  UINTN           Signature;\r
-  LIST_ENTRY      Link;\r
-  UINTN           OptionNumber;\r
-  UINT16          *DisplayString;\r
-  UINT16          *HelpString;\r
-  EFI_STRING_ID   DisplayStringToken;\r
-  EFI_STRING_ID   HelpStringToken;\r
-  VOID            *VariableContext;\r
-} LEGACY_MENU_ENTRY;\r
-\r
-typedef struct {\r
-  UINT16     BbsIndex;\r
-} LEGACY_BOOT_OPTION_BBS_DATA;\r
-\r
-#pragma pack()\r
-\r
-/**\r
-  This call back function is registered with Boot Manager formset.\r
-  When user selects a boot option, this call back function will\r
-  be triggered. The boot option is saved for later processing.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBootOptionCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  );\r
-\r
-/**\r
-  This function allows a caller to extract the current configuration for one\r
-  or more named elements from the target driver.\r
-\r
-\r
-  @param This            - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Request         - A null-terminated Unicode string in <ConfigRequest> format.\r
-  @param Progress        - On return, points to a character in the Request string.\r
-                         Points to the string's null terminator if request was successful.\r
-                         Points to the most recent '&' before the first failing name/value\r
-                         pair (or the beginning of the string if the failure is in the\r
-                         first name/value pair) if the request was not successful.\r
-  @param Results         - A null-terminated Unicode string in <ConfigAltResp> format which\r
-                         has all values filled in for the names in the Request string.\r
-                         String to be allocated by the called function.\r
-\r
-  @retval  EFI_SUCCESS            The Results is filled with the requested values.\r
-  @retval  EFI_OUT_OF_RESOURCES   Not enough memory to store the results.\r
-  @retval  EFI_INVALID_PARAMETER  Request is NULL, illegal syntax, or unknown name.\r
-  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBootOptionExtractConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Request,\r
-  OUT EFI_STRING                             *Progress,\r
-  OUT EFI_STRING                             *Results\r
-  );\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-\r
-\r
-  @param This            - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Configuration   - A null-terminated Unicode string in <ConfigResp> format.\r
-  @param Progress        - A pointer to a string filled in with the offset of the most\r
-                         recent '&' before the first failing name/value pair (or the\r
-                         beginning of the string if the failure is in the first\r
-                         name/value pair) or the terminating NULL if all was successful.\r
-\r
-  @retval  EFI_SUCCESS            The Results is processed successfully.\r
-  @retval  EFI_INVALID_PARAMETER  Configuration is NULL.\r
-  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBootOptionRouteConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Configuration,\r
-  OUT EFI_STRING                             *Progress\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf
deleted file mode 100644 (file)
index 557b8d8..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-## @file\r
-#  Legacy Boot Maintainence UI module is library for BDS phase.\r
-#\r
-#  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = LegacyBootMaintUiLib\r
-  MODULE_UNI_FILE                = LegacyBootMaintUiLib.uni\r
-  FILE_GUID                      = e6f7f038-3ed9-401a-af1f-5ea7bf644d34\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL|DXE_DRIVER UEFI_APPLICATION\r
-  CONSTRUCTOR                    = LegacyBootMaintUiLibConstructor\r
-  DESTRUCTOR                     = LegacyBootMaintUiLibDestructor\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  LegacyBootMaintUiVfr.h\r
-  LegacyBootMaintUi.h\r
-  LegacyBootMaintUiVfr.Vfr\r
-  LegacyBootMaintUiStrings.uni\r
-  LegacyBootMaintUi.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-[LibraryClasses]\r
-  DevicePathLib\r
-  BaseLib\r
-  UefiRuntimeServicesTableLib\r
-  UefiBootServicesTableLib\r
-  DebugLib\r
-  HiiLib\r
-  MemoryAllocationLib\r
-  UefiBootManagerLib\r
-  UefiLib\r
-  PrintLib\r
-  BaseMemoryLib\r
-\r
-[Guids]\r
-  gEfiIfrTianoGuid                  ## SOMETIMES_PRODUCES ## UNDEFINED # Extended IFR Guid Opcode\r
-  gEfiIfrBootMaintenanceGuid        ## CONSUMES ## HII # BootMaint HII Package\r
-  gEfiLegacyDevOrderVariableGuid    ## PRODUCES ## Variable:L"LegacyDevOrder"\r
-\r
-[Protocols]\r
-  gEfiHiiConfigAccessProtocolGuid             ## PRODUCES\r
-  gEfiLegacyBiosProtocolGuid                  ## CONSUMES\r
-  gEfiHiiConfigRoutingProtocolGuid            ## CONSUMES\r
-\r
-[Depex]\r
-  gEfiHiiDatabaseProtocolGuid\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.uni b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.uni
deleted file mode 100644 (file)
index c2c100d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// /** @file\r
-// Legacy Boot Maintainence UI module is library for BDS phase.\r
-//\r
-// Legacy Boot Maintainence UI module is library for BDS phase.\r
-//\r
-// Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_MODULE_ABSTRACT\r
-#language en-US\r
-"Legacy Boot Maintainence UI module is library for BDS phase."\r
-\r
-#string STR_MODULE_DESCRIPTION\r
-#language en-US\r
-"Legacy Boot Maintainence UI module is library for BDS phase."\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiStrings.uni b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiStrings.uni
deleted file mode 100644 (file)
index 8d40ca1..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-///** @file\r
-//\r
-//    String definitions for Legacy Boot Maintainece Ui.\r
-//\r
-//  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-//**/\r
-\r
-/=#\r
-\r
-#langdef   en-US "English"\r
-#langdef   fr-FR "Français"\r
-\r
-#string STR_LEGACY_BOOT_PROMPT         #language en-US  "Legacy Boot Options Menu"\r
-                                       #language fr-FR  "Legacy Boot Options Menu"\r
-#string STR_LEGACY_BOOT_HELP           #language en-US  "Manager legacy boot options in this driver."\r
-                                       #language fr-FR  "Manager legacy boot options in this driver."\r
-#string STR_FORM_FLOPPY_BOOT_TITLE     #language en-US  "Set Legacy Floppy Driver Order"\r
-                                       #language fr-FR  "Set Legacy Floppy Driver Order"\r
-#string STR_FORM_FLOPPY_BOOT_HELP      #language en-US  "Set Legacy Floppy Driver Order."\r
-                                       #language fr-FR  "Set Legacy Floppy Driver Order."\r
-#string STR_FORM_HARDDISK_BOOT_TITLE   #language en-US  "Set Legacy HARDDISK Driver Order"\r
-                                       #language fr-FR  "Set Legacy HARDDISK Driver Order"\r
-#string STR_FORM_HARDDISK_BOOT_HELP    #language en-US  "Set Legacy HARDDISK Driver Order."\r
-                                       #language fr-FR  "Set Legacy HARDDISK Driver Order."\r
-#string STR_FORM_CDROM_BOOT_TITLE      #language en-US  "Set Legacy CDROM Driver Order"\r
-                                       #language fr-FR  "Set Legacy CDROM Driver Order"\r
-#string STR_FORM_CDROM_BOOT_HELP       #language en-US  "Set Legacy CDROM Driver Order."\r
-                                       #language fr-FR  "Set Legacy CDROM Driver Order."\r
-#string STR_FORM_NET_BOOT_TITLE        #language en-US  "Set Legacy NET Driver Order"\r
-                                       #language fr-FR  "Set Legacy NET Driver Order"\r
-#string STR_FORM_NET_BOOT_HELP         #language en-US  "Set Legacy NET Driver Order."\r
-                                       #language fr-FR  "Set Legacy NET Driver Order."\r
-#string STR_FORM_BEV_BOOT_TITLE        #language en-US  "Set Legacy BEV Driver Order"\r
-                                       #language fr-FR  "Set Legacy BEV Driver Order"\r
-#string STR_FORM_BEV_BOOT_HELP         #language en-US  "Set Legacy BEV Driver Order."\r
-                                       #language fr-FR  "Set Legacy BEV Driver Order."\r
-#string STR_ORDER_CHANGE_PROMPT        #language en-US  "Change Driver Boot Order."\r
-                                       #language fr-FR  "Change Driver Boot Order."\r
-#string STR_DISABLE_LEGACY_DEVICE      #language en-US  "Disabled"\r
-                                       #language fr-FR  "Disabled"\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiVfr.Vfr b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiVfr.Vfr
deleted file mode 100644 (file)
index c879ca5..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-///** @file\r
-//  \r
-//    Browser formset.\r
-//  \r
-//  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//  \r
-//**/\r
-\r
-#include "LegacyBootMaintUiVfr.h"\r
-\r
-\r
-formset\r
-  guid      = LEGACY_BOOT_OPTION_FORMSET_GUID,\r
-  title     = STRING_TOKEN(STR_LEGACY_BOOT_PROMPT),\r
-  help      = STRING_TOKEN(STR_LEGACY_BOOT_HELP),\r
-  classguid = EFI_IFR_BOOT_MAINTENANCE_GUID,\r
-  \r
-  varstore LEGACY_BOOT_NV_DATA,\r
-    varid = VARSTORE_ID_LEGACY_BOOT,\r
-    name = LegacyBootData,\r
-    guid = LEGACY_BOOT_OPTION_FORMSET_GUID;\r
-    \r
-  form formid = LEGACY_BOOT_FORM_ID,\r
-       title  = STRING_TOKEN(STR_LEGACY_BOOT_PROMPT);\r
-       \r
-    goto LEGACY_ORDER_CHANGE_FORM_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_FLOPPY_BOOT_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_FLOPPY_BOOT_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_FLOPPY_BOOT_ID;\r
-\r
-    goto LEGACY_ORDER_CHANGE_FORM_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_HARDDISK_BOOT_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_HARDDISK_BOOT_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_HARDDISK_BOOT_ID;\r
-\r
-    goto LEGACY_ORDER_CHANGE_FORM_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_CDROM_BOOT_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_CDROM_BOOT_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_CDROM_BOOT_ID;\r
-\r
-    goto LEGACY_ORDER_CHANGE_FORM_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_NET_BOOT_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_NET_BOOT_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_NET_BOOT_ID;\r
-\r
-    goto LEGACY_ORDER_CHANGE_FORM_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_BEV_BOOT_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_BEV_BOOT_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_BEV_BOOT_ID;\r
-         \r
-  endform;\r
-\r
-  form formid = LEGACY_ORDER_CHANGE_FORM_ID,\r
-       title  = STRING_TOKEN(STR_ORDER_CHANGE_PROMPT);\r
-       \r
-       label FORM_BOOT_LEGACY_DEVICE_ID;\r
-       label FORM_BOOT_LEGACY_LABEL_END;\r
-         \r
-  endform;\r
-\r
-endformset;\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiVfr.h b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiVfr.h
deleted file mode 100644 (file)
index e16fc39..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/** @file\r
-  Legacy Boot Maintainence UI definition.\r
-\r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#ifndef _EFI_LEGACY_BOOT_OPTION_VFR_H_\r
-#define _EFI_LEGACY_BOOT_OPTION_VFR_H_\r
-\r
-#include <Guid/HiiBootMaintenanceFormset.h>\r
-\r
-#define MAX_MENU_NUMBER 100\r
-\r
-#define LEGACY_BOOT_OPTION_FORMSET_GUID  { 0x6bc75598, 0x89b4, 0x483d, { 0x91, 0x60, 0x7f, 0x46, 0x9a, 0x96, 0x35, 0x31 } }\r
-\r
-#define VARSTORE_ID_LEGACY_BOOT      0x0001\r
-\r
-\r
-#define LEGACY_BOOT_FORM_ID          0x1000\r
-#define LEGACY_ORDER_CHANGE_FORM_ID  0x1001\r
-\r
-\r
-#define FORM_FLOPPY_BOOT_ID          0x2000\r
-#define FORM_HARDDISK_BOOT_ID        0x2001\r
-#define FORM_CDROM_BOOT_ID           0x2002\r
-#define FORM_NET_BOOT_ID             0x2003\r
-#define FORM_BEV_BOOT_ID             0x2004\r
-\r
-\r
-\r
-#define FORM_BOOT_LEGACY_DEVICE_ID   0x9000\r
-#define FORM_BOOT_LEGACY_LABEL_END   0x9001\r
-\r
-\r
-#pragma pack(1)\r
-\r
-///\r
-/// This is the structure that will be used to store the\r
-/// question's current value. Use it at initialize time to\r
-/// set default value for each question. When using at run\r
-/// time, this map is returned by the callback function,\r
-/// so dynamically changing the question's value will be\r
-/// possible through this mechanism\r
-///\r
-typedef struct {\r
-  //\r
-  // Legacy Device Order Selection Storage\r
-  //\r
-  UINT16   LegacyFD[MAX_MENU_NUMBER];\r
-  UINT16   LegacyHD[MAX_MENU_NUMBER];\r
-  UINT16   LegacyCD[MAX_MENU_NUMBER];\r
-  UINT16   LegacyNET[MAX_MENU_NUMBER];\r
-  UINT16   LegacyBEV[MAX_MENU_NUMBER];\r
-} LEGACY_BOOT_NV_DATA;\r
-\r
-///\r
-/// This is the structure that will be used to store the\r
-/// question's current value. Use it at initialize time to\r
-/// set default value for each question. When using at run\r
-/// time, this map is returned by the callback function,\r
-/// so dynamically changing the question's value will be\r
-/// possible through this mechanism\r
-///\r
-typedef struct {\r
-  //\r
-  // Legacy Device Order Selection Storage\r
-  //\r
-  LEGACY_BOOT_NV_DATA   InitialNvData;\r
-  LEGACY_BOOT_NV_DATA   CurrentNvData;\r
-  LEGACY_BOOT_NV_DATA   LastTimeNvData;\r
-  UINT8                 DisableMap[32];\r
-} LEGACY_BOOT_MAINTAIN_DATA;\r
-\r
-#pragma pack()\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/InternalLegacyBm.h b/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/InternalLegacyBm.h
deleted file mode 100644 (file)
index 292e2c1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _INTERNAL_LEGACY_BM_H_\r
-#define _INTERNAL_LEGACY_BM_H_\r
-\r
-#include <PiDxe.h>\r
-#include <Guid/LegacyDevOrder.h>\r
-#include <Guid/GlobalVariable.h>\r
-#include <Protocol/LegacyBios.h>\r
-#include <Protocol/PciRootBridgeIo.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/UefiBootManagerLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/PerformanceLib.h>\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  UINT16     BbsIndex;\r
-} LEGACY_BM_BOOT_OPTION_BBS_DATA;\r
-#pragma pack()\r
-\r
-/**\r
-  Boot the legacy system with the boot option.\r
-\r
-  @param  BootOption The legacy boot option which have BBS device path\r
-                     On return, BootOption->Status contains the boot status.\r
-                     EFI_UNSUPPORTED    There is no legacybios protocol, do not support\r
-                                        legacy boot.\r
-                     EFI_STATUS         The status of LegacyBios->LegacyBoot ().\r
-**/\r
-VOID\r
-EFIAPI\r
-LegacyBmBoot (\r
-  IN  EFI_BOOT_MANAGER_LOAD_OPTION           *BootOption\r
-  );\r
-\r
-/**\r
-  Refresh all legacy boot options.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-LegacyBmRefreshAllBootOption (\r
-  VOID\r
-  );\r
-\r
-#endif // _INTERNAL_LEGACY_BM_H_\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c b/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c
deleted file mode 100644 (file)
index 6138a32..0000000
+++ /dev/null
@@ -1,1530 +0,0 @@
-/** @file\r
-  This function deal with the legacy boot option, it create, delete\r
-  and manage the legacy boot option, all legacy boot option is getting from\r
-  the legacy BBS table.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalLegacyBm.h"\r
-\r
-#define  LEGACY_BM_BOOT_DESCRIPTION_LENGTH  32\r
-\r
-/**\r
-  Initialize legacy boot manager library by call EfiBootManagerRegisterLegacyBootSupport\r
-  function to export two function pointer.\r
-\r
-  @param ImageHandle     The image handle.\r
-  @param SystemTable     The system table.\r
-\r
-  @retval EFI_SUCCESS    The legacy boot manager library is initialized correctly.\r
-  @return Other value if failed to initialize the legacy boot manager library.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyBootManagerLibConstructor (\r
-  IN EFI_HANDLE                            ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                      *SystemTable\r
-)\r
-{\r
-  EfiBootManagerRegisterLegacyBootSupport (\r
-    LegacyBmRefreshAllBootOption,\r
-    LegacyBmBoot\r
-    );\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Get the device type from the input legacy device path.\r
-\r
-  @param DevicePath     The legacy device path.\r
-\r
-  @retval               The legacy device type.\r
-**/\r
-UINT16\r
-LegacyBmDeviceType (\r
-  EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
-  )\r
-{\r
-  ASSERT ((DevicePathType (DevicePath) == BBS_DEVICE_PATH) &&\r
-          (DevicePathSubType (DevicePath) == BBS_BBS_DP));\r
-  return ((BBS_BBS_DEVICE_PATH *) DevicePath)->DeviceType;\r
-}\r
-\r
-/**\r
-  Validate the BbsEntry base on the Boot Priority info in the BbsEntry.\r
-\r
-  @param BbsEntry       The input bbs entry info.\r
-\r
-  @retval TRUE          The BbsEntry is valid.\r
-  @retval FALSE         The BbsEntry is invalid.\r
-**/\r
-BOOLEAN\r
-LegacyBmValidBbsEntry (\r
-  IN BBS_TABLE   *BbsEntry\r
-  )\r
-{\r
-  switch (BbsEntry->BootPriority) {\r
-    case BBS_IGNORE_ENTRY:\r
-    case BBS_DO_NOT_BOOT_FROM:\r
-    case BBS_LOWEST_PRIORITY:\r
-      return FALSE;\r
-    default:\r
-      return TRUE;\r
-  }\r
-}\r
-\r
-/**\r
-  Build Legacy Device Name String according.\r
-\r
-  @param CurBBSEntry     BBS Table.\r
-  @param Index           Index.\r
-  @param BufSize         The buffer size.\r
-  @param BootString      The output string.\r
-\r
-**/\r
-VOID\r
-LegacyBmBuildLegacyDevNameString (\r
-  IN  BBS_TABLE                 *CurBBSEntry,\r
-  IN  UINTN                     Index,\r
-  IN  UINTN                     BufSize,\r
-  OUT CHAR16                    *BootString\r
-  )\r
-{\r
-  CHAR16  *Fmt;\r
-  CHAR16  *Type;\r
-  CHAR8   *StringDesc;\r
-  CHAR8   StringBufferA[LEGACY_BM_BOOT_DESCRIPTION_LENGTH + 1];\r
-  CHAR16  StringBufferU[LEGACY_BM_BOOT_DESCRIPTION_LENGTH + 1];\r
-\r
-  switch (Index) {\r
-  //\r
-  // Primary Master\r
-  //\r
-  case 1:\r
-    Fmt = L"Primary Master %s";\r
-    break;\r
-\r
- //\r
- // Primary Slave\r
- //\r
-  case 2:\r
-    Fmt = L"Primary Slave %s";\r
-    break;\r
-\r
-  //\r
-  // Secondary Master\r
-  //\r
-  case 3:\r
-    Fmt = L"Secondary Master %s";\r
-    break;\r
-\r
-  //\r
-  // Secondary Slave\r
-  //\r
-  case 4:\r
-    Fmt = L"Secondary Slave %s";\r
-    break;\r
-\r
-  default:\r
-    Fmt = L"%s";\r
-    break;\r
-  }\r
-\r
-  switch (CurBBSEntry->DeviceType) {\r
-  case BBS_FLOPPY:\r
-    Type = L"Floppy";\r
-    break;\r
-\r
-  case BBS_HARDDISK:\r
-    Type = L"Harddisk";\r
-    break;\r
-\r
-  case BBS_CDROM:\r
-    Type = L"CDROM";\r
-    break;\r
-\r
-  case BBS_PCMCIA:\r
-    Type = L"PCMCIAe";\r
-    break;\r
-\r
-  case BBS_USB:\r
-    Type = L"USB";\r
-    break;\r
-\r
-  case BBS_EMBED_NETWORK:\r
-    Type = L"Network";\r
-    break;\r
-\r
-  case BBS_BEV_DEVICE:\r
-    Type = L"BEVe";\r
-    break;\r
-\r
-  case BBS_UNKNOWN:\r
-  default:\r
-    Type = L"Unknown";\r
-    break;\r
-  }\r
-  //\r
-  // If current BBS entry has its description then use it.\r
-  //\r
-  StringDesc = (CHAR8 *) (((UINTN) CurBBSEntry->DescStringSegment << 4) + CurBBSEntry->DescStringOffset);\r
-  if (NULL != StringDesc) {\r
-    //\r
-    // Only get fisrt 32 characters, this is suggested by BBS spec\r
-    //\r
-    CopyMem (StringBufferA, StringDesc, LEGACY_BM_BOOT_DESCRIPTION_LENGTH);\r
-    StringBufferA[LEGACY_BM_BOOT_DESCRIPTION_LENGTH] = 0;\r
-    AsciiStrToUnicodeStrS (StringBufferA, StringBufferU, ARRAY_SIZE (StringBufferU));\r
-    Fmt   = L"%s";\r
-    Type  = StringBufferU;\r
-  }\r
-\r
-  //\r
-  // BbsTable 16 entries are for onboard IDE.\r
-  // Set description string for SATA harddisks, Harddisk 0 ~ Harddisk 11\r
-  //\r
-  if (Index >= 5 && Index <= 16 && (CurBBSEntry->DeviceType == BBS_HARDDISK || CurBBSEntry->DeviceType == BBS_CDROM)) {\r
-    Fmt = L"%s %d";\r
-    UnicodeSPrint (BootString, BufSize, Fmt, Type, Index - 5);\r
-  } else {\r
-    UnicodeSPrint (BootString, BufSize, Fmt, Type);\r
-  }\r
-}\r
-\r
-/**\r
-  Get the Bbs index for the input boot option.\r
-\r
-  @param BootOption     The input boot option info.\r
-  @param BbsTable       The input Bbs table.\r
-  @param BbsCount       The input total bbs entry number.\r
-  @param BbsIndexUsed   The array shows how many BBS table indexs have been used.\r
-\r
-  @retval The index for the input boot option.\r
-**/\r
-UINT16\r
-LegacyBmFuzzyMatch (\r
-  EFI_BOOT_MANAGER_LOAD_OPTION   *BootOption,\r
-  BBS_TABLE                      *BbsTable,\r
-  UINT16                         BbsCount,\r
-  BOOLEAN                        *BbsIndexUsed\r
-  )\r
-{\r
-  UINT16                         Index;\r
-  LEGACY_BM_BOOT_OPTION_BBS_DATA *BbsData;\r
-  CHAR16                         Description[LEGACY_BM_BOOT_DESCRIPTION_LENGTH + 1];\r
-\r
-  BbsData = (LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOption->OptionalData;\r
-\r
-  //\r
-  // Directly check the BBS index stored in BootOption\r
-  //\r
-  if ((BbsData->BbsIndex < BbsCount) &&\r
-      (LegacyBmDeviceType (BootOption->FilePath) == BbsTable[BbsData->BbsIndex].DeviceType)) {\r
-    LegacyBmBuildLegacyDevNameString (\r
-      &BbsTable[BbsData->BbsIndex],\r
-      BbsData->BbsIndex,\r
-      sizeof (Description),\r
-      Description\r
-      );\r
-    if ((StrCmp (Description, BootOption->Description) == 0) && !BbsIndexUsed[BbsData->BbsIndex]) {\r
-      //\r
-      // If devices with the same description string are connected,\r
-      // the BbsIndex of the first device is returned for the other device also.\r
-      // So, check if the BbsIndex is already being used, before assigning the BbsIndex.\r
-      //\r
-      BbsIndexUsed[BbsData->BbsIndex] = TRUE;\r
-      return BbsData->BbsIndex;\r
-    }\r
-  }\r
-\r
-  //\r
-  // BBS table could be changed (entry removed/moved)\r
-  // find the correct BBS index\r
-  //\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&BbsTable[Index]) ||\r
-        (BbsTable[Index].DeviceType != LegacyBmDeviceType (BootOption->FilePath))) {\r
-      continue;\r
-    }\r
-\r
-    LegacyBmBuildLegacyDevNameString (\r
-      &BbsTable[Index],\r
-      Index,\r
-      sizeof (Description),\r
-      Description\r
-      );\r
-    if ((StrCmp (Description, BootOption->Description) == 0) && !BbsIndexUsed[Index]) {\r
-      //\r
-      // If devices with the same description string are connected,\r
-      // the BbsIndex of the first device is assigned for the other device also.\r
-      // So, check if the BbsIndex is already being used, before assigning the corrected BbsIndex.\r
-      //\r
-      break;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Add the corrected BbsIndex in the UsedBbsIndex Buffer\r
-  //\r
-  if (Index != BbsCount) {\r
-    BbsIndexUsed[Index] = TRUE;\r
-  }\r
-\r
-  return Index;\r
-}\r
-\r
-/**\r
-\r
-  Update legacy device order base on the input info.\r
-\r
-  @param   LegacyDevOrder     Legacy device order data buffer.\r
-  @param   LegacyDevOrderSize Legacy device order data buffer size.\r
-  @param   DeviceType         Device type which need to check.\r
-  @param   OldBbsIndex        Old Bds Index.\r
-  @param   NewBbsIndex        New Bds Index, if it is -1,means remove this option.\r
-\r
-**/\r
-VOID\r
-LegacyBmUpdateBbsIndex (\r
-  LEGACY_DEV_ORDER_ENTRY   *LegacyDevOrder,\r
-  UINTN                    *LegacyDevOrderSize,\r
-  UINT16                   DeviceType,\r
-  UINT16                   OldBbsIndex,\r
-  UINT16                   NewBbsIndex // Delete entry if -1\r
-  )\r
-{\r
-  LEGACY_DEV_ORDER_ENTRY   *Entry;\r
-  UINTN                    Index;\r
-\r
-  ASSERT (((LegacyDevOrder == NULL) && (*LegacyDevOrderSize == 0)) ||\r
-          ((LegacyDevOrder != NULL) && (*LegacyDevOrderSize != 0))\r
-         );\r
-\r
-  for (Entry = LegacyDevOrder;\r
-       Entry < (LEGACY_DEV_ORDER_ENTRY *) ((UINT8 *) LegacyDevOrder + *LegacyDevOrderSize);\r
-       Entry = (LEGACY_DEV_ORDER_ENTRY *) ((UINTN) Entry + sizeof (BBS_TYPE) + Entry->Length)\r
-       ) {\r
-    if (Entry->BbsType == DeviceType) {\r
-      for (Index = 0; Index < Entry->Length / sizeof (UINT16) - 1; Index++) {\r
-        if (Entry->Data[Index] == OldBbsIndex) {\r
-          if (NewBbsIndex == (UINT16) -1) {\r
-            //\r
-            // Delete the old entry\r
-            //\r
-            CopyMem (\r
-              &Entry->Data[Index],\r
-              &Entry->Data[Index + 1],\r
-              (UINT8 *) LegacyDevOrder + *LegacyDevOrderSize - (UINT8 *) &Entry->Data[Index + 1]\r
-              );\r
-            Entry->Length       -= sizeof (UINT16);\r
-            *LegacyDevOrderSize -= sizeof(UINT16);\r
-          } else {\r
-            Entry->Data[Index]   = NewBbsIndex;\r
-          }\r
-          break;\r
-        }\r
-      }\r
-      break;\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Delete all the legacy boot options.\r
-\r
-  @retval EFI_SUCCESS            All legacy boot options are deleted.\r
-**/\r
-EFI_STATUS\r
-LegacyBmDeleteAllBootOptions (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  UINTN                         Index;\r
-  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption;\r
-  UINTN                         BootOptionCount;\r
-\r
-  BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
-  for (Index = 0; Index < BootOptionCount; Index++) {\r
-    if ((DevicePathType (BootOption[Index].FilePath) == BBS_DEVICE_PATH) &&\r
-        (DevicePathSubType (BootOption[Index].FilePath) == BBS_BBS_DP)) {\r
-      Status = EfiBootManagerDeleteLoadOptionVariable (BootOption[Index].OptionNumber, BootOption[Index].OptionType);\r
-      //\r
-      // Deleting variable with current variable implementation shouldn't fail.\r
-      //\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  VAR_LEGACY_DEV_ORDER,\r
-                  &gEfiLegacyDevOrderVariableGuid,\r
-                  0,\r
-                  0,\r
-                  NULL\r
-                  );\r
-  //\r
-  // Deleting variable with current variable implementation shouldn't fail.\r
-  //\r
-  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Delete all the invalid legacy boot options.\r
-\r
-  @retval EFI_SUCCESS             All invalide legacy boot options are deleted.\r
-  @retval EFI_OUT_OF_RESOURCES    Fail to allocate necessary memory.\r
-  @retval EFI_NOT_FOUND           Fail to retrive variable of boot order.\r
-**/\r
-EFI_STATUS\r
-LegacyBmDeleteAllInvalidBootOptions (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  UINT16                        HddCount;\r
-  UINT16                        BbsCount;\r
-  HDD_INFO                      *HddInfo;\r
-  BBS_TABLE                     *BbsTable;\r
-  UINT16                        BbsIndex;\r
-  EFI_LEGACY_BIOS_PROTOCOL      *LegacyBios;\r
-  UINTN                         Index;\r
-  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption;\r
-  UINTN                         BootOptionCount;\r
-  LEGACY_DEV_ORDER_ENTRY        *LegacyDevOrder;\r
-  UINTN                         LegacyDevOrderSize;\r
-  BOOLEAN                       *BbsIndexUsed;\r
-\r
-  HddCount      = 0;\r
-  BbsCount      = 0;\r
-  HddInfo       = NULL;\r
-  BbsTable      = NULL;\r
-\r
-  Status        = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = LegacyBios->GetBbsInfo (\r
-                         LegacyBios,\r
-                         &HddCount,\r
-                         &HddInfo,\r
-                         &BbsCount,\r
-                         &BbsTable\r
-                         );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  GetVariable2 (VAR_LEGACY_DEV_ORDER, &gEfiLegacyDevOrderVariableGuid, (VOID **) &LegacyDevOrder, &LegacyDevOrderSize);\r
-\r
-  BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
-\r
-  BbsIndexUsed = AllocateZeroPool (BbsCount * sizeof (BOOLEAN));\r
-  ASSERT (BbsIndexUsed != NULL);\r
-\r
-  for (Index = 0; Index < BootOptionCount; Index++) {\r
-    //\r
-    // Skip non legacy boot option\r
-    //\r
-    if ((DevicePathType (BootOption[Index].FilePath) != BBS_DEVICE_PATH) ||\r
-        (DevicePathSubType (BootOption[Index].FilePath) != BBS_BBS_DP)) {\r
-      continue;\r
-    }\r
-\r
-    BbsIndex = LegacyBmFuzzyMatch (&BootOption[Index], BbsTable, BbsCount, BbsIndexUsed);\r
-    if (BbsIndex == BbsCount) {\r
-      DEBUG ((EFI_D_INFO, "[LegacyBds] Delete Boot Option Boot%04x: %s\n", (UINTN) BootOption[Index].OptionNumber, BootOption[Index].Description));\r
-      //\r
-      // Delete entry from LegacyDevOrder\r
-      //\r
-      LegacyBmUpdateBbsIndex (\r
-        LegacyDevOrder,\r
-        &LegacyDevOrderSize,\r
-        LegacyBmDeviceType (BootOption[Index].FilePath),\r
-        ((LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOption[Index].OptionalData)->BbsIndex,\r
-        (UINT16) -1\r
-        );\r
-      EfiBootManagerDeleteLoadOptionVariable (BootOption[Index].OptionNumber, BootOption[Index].OptionType);\r
-    } else {\r
-      if (((LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOption[Index].OptionalData)->BbsIndex != BbsIndex) {\r
-        DEBUG ((EFI_D_INFO, "[LegacyBds] Update Boot Option Boot%04x: %s Bbs0x%04x->Bbs0x%04x\n", (UINTN) BootOption[Index].OptionNumber, BootOption[Index].Description,\r
-                (UINTN) ((LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOption[Index].OptionalData)->BbsIndex, (UINTN) BbsIndex));\r
-        //\r
-        // Update the BBS index in LegacyDevOrder\r
-        //\r
-        LegacyBmUpdateBbsIndex (\r
-          LegacyDevOrder,\r
-          &LegacyDevOrderSize,\r
-          LegacyBmDeviceType (BootOption[Index].FilePath),\r
-          ((LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOption[Index].OptionalData)->BbsIndex,\r
-          BbsIndex\r
-          );\r
-\r
-        //\r
-        // Update the OptionalData in the Boot#### variable\r
-        //\r
-        ((LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOption[Index].OptionalData)->BbsIndex = BbsIndex;\r
-        EfiBootManagerLoadOptionToVariable (&BootOption[Index]);\r
-      }\r
-    }\r
-  }\r
-  EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);\r
-\r
-  if (LegacyDevOrder != NULL) {\r
-    Status = gRT->SetVariable (\r
-                    VAR_LEGACY_DEV_ORDER,\r
-                    &gEfiLegacyDevOrderVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    LegacyDevOrderSize,\r
-                    LegacyDevOrder\r
-                    );\r
-    //\r
-    // Shrink variable with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    FreePool (LegacyDevOrder);\r
-  }\r
-  FreePool(BbsIndexUsed);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Create legacy boot option.\r
-\r
-  @param BootOption        Ponter to the boot option which will be crated.\r
-  @param BbsEntry          The input bbs entry info.\r
-  @param BbsIndex          The BBS index.\r
-\r
-  @retval EFI_SUCCESS            Create legacy boot option successfully.\r
-  @retval EFI_INVALID_PARAMETER  Invalid input parameter.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBmCreateLegacyBootOption (\r
-  IN OUT EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption,\r
-  IN BBS_TABLE                         *BbsEntry,\r
-  IN UINT16                            BbsIndex\r
-  )\r
-{\r
-  EFI_STATUS                   Status;\r
-  EFI_DEVICE_PATH_PROTOCOL     *DevicePath;\r
-  CHAR16                       Description[LEGACY_BM_BOOT_DESCRIPTION_LENGTH + 1];\r
-  CHAR8                        HelpString[LEGACY_BM_BOOT_DESCRIPTION_LENGTH + 1];\r
-  UINTN                        StringLen;\r
-  LEGACY_BM_BOOT_OPTION_BBS_DATA  *OptionalData;\r
-  BBS_BBS_DEVICE_PATH          *BbsNode;\r
-\r
-  if ((BootOption == NULL) || (BbsEntry == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  LegacyBmBuildLegacyDevNameString (BbsEntry, BbsIndex, sizeof (Description), Description);\r
-\r
-  //\r
-  // Create the BBS device path with description string\r
-  //\r
-  UnicodeStrToAsciiStrS (Description, HelpString, sizeof (HelpString));\r
-  StringLen = AsciiStrLen (HelpString);\r
-  DevicePath = AllocatePool (sizeof (BBS_BBS_DEVICE_PATH) + StringLen + END_DEVICE_PATH_LENGTH);\r
-  ASSERT (DevicePath != NULL);\r
-\r
-  BbsNode = (BBS_BBS_DEVICE_PATH *) DevicePath;\r
-  SetDevicePathNodeLength (BbsNode, sizeof (BBS_BBS_DEVICE_PATH) + StringLen);\r
-  BbsNode->Header.Type    = BBS_DEVICE_PATH;\r
-  BbsNode->Header.SubType = BBS_BBS_DP;\r
-  BbsNode->DeviceType     = BbsEntry->DeviceType;\r
-  CopyMem (&BbsNode->StatusFlag, &BbsEntry->StatusFlags, sizeof (BBS_STATUS_FLAGS));\r
-  CopyMem (BbsNode->String, HelpString, StringLen + 1);\r
-\r
-  SetDevicePathEndNode (NextDevicePathNode (BbsNode));\r
-\r
-  //\r
-  // Create the OptionalData\r
-  //\r
-  OptionalData = AllocatePool (sizeof (LEGACY_BM_BOOT_OPTION_BBS_DATA));\r
-  ASSERT (OptionalData != NULL);\r
-  OptionalData->BbsIndex = BbsIndex;\r
-\r
-  //\r
-  // Create the BootOption\r
-  //\r
-  Status = EfiBootManagerInitializeLoadOption (\r
-             BootOption,\r
-             LoadOptionNumberUnassigned,\r
-             LoadOptionTypeBoot,\r
-             LOAD_OPTION_ACTIVE,\r
-             Description,\r
-             DevicePath,\r
-             (UINT8 *) OptionalData,\r
-             sizeof (LEGACY_BM_BOOT_OPTION_BBS_DATA)\r
-             );\r
-  FreePool (DevicePath);\r
-  FreePool (OptionalData);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Fill the device order buffer.\r
-\r
-  @param BbsTable        The BBS table.\r
-  @param BbsType         The BBS Type.\r
-  @param BbsCount        The BBS Count.\r
-  @param Buf             device order buffer.\r
-\r
-  @return The device order buffer.\r
-\r
-**/\r
-UINT16 *\r
-LegacyBmFillDevOrderBuf (\r
-  IN BBS_TABLE                    *BbsTable,\r
-  IN BBS_TYPE                     BbsType,\r
-  IN UINTN                        BbsCount,\r
-  OUT UINT16                      *Buf\r
-  )\r
-{\r
-  UINTN Index;\r
-\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&BbsTable[Index])) {\r
-      continue;\r
-    }\r
-\r
-    if (BbsTable[Index].DeviceType != BbsType) {\r
-      continue;\r
-    }\r
-\r
-    *Buf = (UINT16) (Index & 0xFF);\r
-    Buf++;\r
-  }\r
-\r
-  return Buf;\r
-}\r
-\r
-/**\r
-  Create the device order buffer.\r
-\r
-  @param BbsTable        The BBS table.\r
-  @param BbsCount        The BBS Count.\r
-\r
-  @retval EFI_SUCCES             The buffer is created and the EFI variable named\r
-                                 VAR_LEGACY_DEV_ORDER and EfiLegacyDevOrderGuid is\r
-                                 set correctly.\r
-  @retval EFI_OUT_OF_RESOURCES   Memmory or storage is not enough.\r
-  @retval EFI_DEVICE_ERROR       Fail to add the device order into EFI variable fail\r
-                                 because of hardware error.\r
-**/\r
-EFI_STATUS\r
-LegacyBmCreateDevOrder (\r
-  IN BBS_TABLE                  *BbsTable,\r
-  IN UINT16                     BbsCount\r
-  )\r
-{\r
-  UINTN                       Index;\r
-  UINTN                       FDCount;\r
-  UINTN                       HDCount;\r
-  UINTN                       CDCount;\r
-  UINTN                       NETCount;\r
-  UINTN                       BEVCount;\r
-  UINTN                       TotalSize;\r
-  UINTN                       HeaderSize;\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrderPtr;\r
-  EFI_STATUS                  Status;\r
-\r
-  FDCount     = 0;\r
-  HDCount     = 0;\r
-  CDCount     = 0;\r
-  NETCount    = 0;\r
-  BEVCount    = 0;\r
-  TotalSize   = 0;\r
-  HeaderSize  = sizeof (BBS_TYPE) + sizeof (UINT16);\r
-  DevOrder    = NULL;\r
-  Status      = EFI_SUCCESS;\r
-\r
-  //\r
-  // Count all boot devices\r
-  //\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&BbsTable[Index])) {\r
-      continue;\r
-    }\r
-\r
-    switch (BbsTable[Index].DeviceType) {\r
-    case BBS_FLOPPY:\r
-      FDCount++;\r
-      break;\r
-\r
-    case BBS_HARDDISK:\r
-      HDCount++;\r
-      break;\r
-\r
-    case BBS_CDROM:\r
-      CDCount++;\r
-      break;\r
-\r
-    case BBS_EMBED_NETWORK:\r
-      NETCount++;\r
-      break;\r
-\r
-    case BBS_BEV_DEVICE:\r
-      BEVCount++;\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-  }\r
-\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * FDCount);\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * HDCount);\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * CDCount);\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * NETCount);\r
-  TotalSize += (HeaderSize + sizeof (UINT16) * BEVCount);\r
-\r
-  //\r
-  // Create buffer to hold all boot device order\r
-  //\r
-  DevOrder = AllocateZeroPool (TotalSize);\r
-  if (NULL == DevOrder) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  DevOrderPtr          = DevOrder;\r
-\r
-  DevOrderPtr->BbsType = BBS_FLOPPY;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (DevOrderPtr->Length) + FDCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) LegacyBmFillDevOrderBuf (BbsTable, BBS_FLOPPY, BbsCount, DevOrderPtr->Data);\r
-\r
-  DevOrderPtr->BbsType = BBS_HARDDISK;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + HDCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) LegacyBmFillDevOrderBuf (BbsTable, BBS_HARDDISK, BbsCount, DevOrderPtr->Data);\r
-\r
-  DevOrderPtr->BbsType = BBS_CDROM;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + CDCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) LegacyBmFillDevOrderBuf (BbsTable, BBS_CDROM, BbsCount, DevOrderPtr->Data);\r
-\r
-  DevOrderPtr->BbsType = BBS_EMBED_NETWORK;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + NETCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) LegacyBmFillDevOrderBuf (BbsTable, BBS_EMBED_NETWORK, BbsCount, DevOrderPtr->Data);\r
-\r
-  DevOrderPtr->BbsType = BBS_BEV_DEVICE;\r
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + BEVCount * sizeof (UINT16));\r
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) LegacyBmFillDevOrderBuf (BbsTable, BBS_BEV_DEVICE, BbsCount, DevOrderPtr->Data);\r
-\r
-  ASSERT (TotalSize == ((UINTN) DevOrderPtr - (UINTN) DevOrder));\r
-\r
-  //\r
-  // Save device order for legacy boot device to variable.\r
-  //\r
-  Status = gRT->SetVariable (\r
-                  VAR_LEGACY_DEV_ORDER,\r
-                  &gEfiLegacyDevOrderVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  TotalSize,\r
-                  DevOrder\r
-                  );\r
-  FreePool (DevOrder);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Add the legacy boot devices from BBS table into\r
-  the legacy device boot order.\r
-\r
-  @retval EFI_SUCCESS           The boot devices are added successfully.\r
-  @retval EFI_NOT_FOUND         The legacy boot devices are not found.\r
-  @retval EFI_OUT_OF_RESOURCES  Memmory or storage is not enough.\r
-  @retval EFI_DEVICE_ERROR      Fail to add the legacy device boot order into EFI variable\r
-                                because of hardware error.\r
-**/\r
-EFI_STATUS\r
-LegacyBmUpdateDevOrder (\r
-  VOID\r
-  )\r
-{\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  LEGACY_DEV_ORDER_ENTRY      *NewDevOrder;\r
-  LEGACY_DEV_ORDER_ENTRY      *Ptr;\r
-  LEGACY_DEV_ORDER_ENTRY      *NewPtr;\r
-  EFI_LEGACY_BIOS_PROTOCOL    *LegacyBios;\r
-  EFI_STATUS                  Status;\r
-  UINT16                      HddCount;\r
-  UINT16                      BbsCount;\r
-  HDD_INFO                    *LocalHddInfo;\r
-  BBS_TABLE                   *LocalBbsTable;\r
-  UINTN                       Index;\r
-  UINTN                       Index2;\r
-  UINTN                       *Idx;\r
-  UINTN                       FDCount;\r
-  UINTN                       HDCount;\r
-  UINTN                       CDCount;\r
-  UINTN                       NETCount;\r
-  UINTN                       BEVCount;\r
-  UINTN                       TotalSize;\r
-  UINTN                       HeaderSize;\r
-  UINT16                      *NewFDPtr;\r
-  UINT16                      *NewHDPtr;\r
-  UINT16                      *NewCDPtr;\r
-  UINT16                      *NewNETPtr;\r
-  UINT16                      *NewBEVPtr;\r
-  UINT16                      *NewDevPtr;\r
-  UINTN                       FDIndex;\r
-  UINTN                       HDIndex;\r
-  UINTN                       CDIndex;\r
-  UINTN                       NETIndex;\r
-  UINTN                       BEVIndex;\r
-\r
-  Idx           = NULL;\r
-  FDCount       = 0;\r
-  HDCount       = 0;\r
-  CDCount       = 0;\r
-  NETCount      = 0;\r
-  BEVCount      = 0;\r
-  TotalSize     = 0;\r
-  HeaderSize    = sizeof (BBS_TYPE) + sizeof (UINT16);\r
-  FDIndex       = 0;\r
-  HDIndex       = 0;\r
-  CDIndex       = 0;\r
-  NETIndex      = 0;\r
-  BEVIndex      = 0;\r
-  NewDevPtr     = NULL;\r
-\r
-  Status        = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = LegacyBios->GetBbsInfo (\r
-                         LegacyBios,\r
-                         &HddCount,\r
-                         &LocalHddInfo,\r
-                         &BbsCount,\r
-                         &LocalBbsTable\r
-                         );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  GetVariable2 (VAR_LEGACY_DEV_ORDER, &gEfiLegacyDevOrderVariableGuid, (VOID **) &DevOrder, NULL);\r
-  if (NULL == DevOrder) {\r
-    return LegacyBmCreateDevOrder (LocalBbsTable, BbsCount);\r
-  }\r
-  //\r
-  // First we figure out how many boot devices with same device type respectively\r
-  //\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&LocalBbsTable[Index])) {\r
-      continue;\r
-    }\r
-\r
-    switch (LocalBbsTable[Index].DeviceType) {\r
-    case BBS_FLOPPY:\r
-      FDCount++;\r
-      break;\r
-\r
-    case BBS_HARDDISK:\r
-      HDCount++;\r
-      break;\r
-\r
-    case BBS_CDROM:\r
-      CDCount++;\r
-      break;\r
-\r
-    case BBS_EMBED_NETWORK:\r
-      NETCount++;\r
-      break;\r
-\r
-    case BBS_BEV_DEVICE:\r
-      BEVCount++;\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-  }\r
-\r
-  TotalSize += (HeaderSize + FDCount * sizeof (UINT16));\r
-  TotalSize += (HeaderSize + HDCount * sizeof (UINT16));\r
-  TotalSize += (HeaderSize + CDCount * sizeof (UINT16));\r
-  TotalSize += (HeaderSize + NETCount * sizeof (UINT16));\r
-  TotalSize += (HeaderSize + BEVCount * sizeof (UINT16));\r
-\r
-  NewDevOrder = AllocateZeroPool (TotalSize);\r
-  if (NULL == NewDevOrder) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // copy FD\r
-  //\r
-  Ptr             = DevOrder;\r
-  NewPtr          = NewDevOrder;\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + FDCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_FLOPPY\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[FDIndex] = Ptr->Data[Index];\r
-    FDIndex++;\r
-  }\r
-  NewFDPtr = NewPtr->Data;\r
-\r
-  //\r
-  // copy HD\r
-  //\r
-  Ptr             = (LEGACY_DEV_ORDER_ENTRY *) (&Ptr->Data[Ptr->Length / sizeof (UINT16) - 1]);\r
-  NewPtr          = (LEGACY_DEV_ORDER_ENTRY *) (&NewPtr->Data[NewPtr->Length / sizeof (UINT16) -1]);\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + HDCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_HARDDISK\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[HDIndex] = Ptr->Data[Index];\r
-    HDIndex++;\r
-  }\r
-  NewHDPtr = NewPtr->Data;\r
-\r
-  //\r
-  // copy CD\r
-  //\r
-  Ptr    = (LEGACY_DEV_ORDER_ENTRY *) (&Ptr->Data[Ptr->Length / sizeof (UINT16) - 1]);\r
-  NewPtr = (LEGACY_DEV_ORDER_ENTRY *) (&NewPtr->Data[NewPtr->Length / sizeof (UINT16) -1]);\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + CDCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_CDROM\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[CDIndex] = Ptr->Data[Index];\r
-    CDIndex++;\r
-  }\r
-  NewCDPtr = NewPtr->Data;\r
-\r
-  //\r
-  // copy NET\r
-  //\r
-  Ptr    = (LEGACY_DEV_ORDER_ENTRY *) (&Ptr->Data[Ptr->Length / sizeof (UINT16) - 1]);\r
-  NewPtr = (LEGACY_DEV_ORDER_ENTRY *) (&NewPtr->Data[NewPtr->Length / sizeof (UINT16) -1]);\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + NETCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_EMBED_NETWORK\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[NETIndex] = Ptr->Data[Index];\r
-    NETIndex++;\r
-  }\r
-  NewNETPtr = NewPtr->Data;\r
-\r
-  //\r
-  // copy BEV\r
-  //\r
-  Ptr    = (LEGACY_DEV_ORDER_ENTRY *) (&Ptr->Data[Ptr->Length / sizeof (UINT16) - 1]);\r
-  NewPtr = (LEGACY_DEV_ORDER_ENTRY *) (&NewPtr->Data[NewPtr->Length / sizeof (UINT16) -1]);\r
-  NewPtr->BbsType = Ptr->BbsType;\r
-  NewPtr->Length  = (UINT16) (sizeof (UINT16) + BEVCount * sizeof (UINT16));\r
-  for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||\r
-        LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_BEV_DEVICE\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewPtr->Data[BEVIndex] = Ptr->Data[Index];\r
-    BEVIndex++;\r
-  }\r
-  NewBEVPtr = NewPtr->Data;\r
-\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&LocalBbsTable[Index])) {\r
-      continue;\r
-    }\r
-\r
-    switch (LocalBbsTable[Index].DeviceType) {\r
-    case BBS_FLOPPY:\r
-      Idx       = &FDIndex;\r
-      NewDevPtr = NewFDPtr;\r
-      break;\r
-\r
-    case BBS_HARDDISK:\r
-      Idx       = &HDIndex;\r
-      NewDevPtr = NewHDPtr;\r
-      break;\r
-\r
-    case BBS_CDROM:\r
-      Idx       = &CDIndex;\r
-      NewDevPtr = NewCDPtr;\r
-      break;\r
-\r
-    case BBS_EMBED_NETWORK:\r
-      Idx       = &NETIndex;\r
-      NewDevPtr = NewNETPtr;\r
-      break;\r
-\r
-    case BBS_BEV_DEVICE:\r
-      Idx       = &BEVIndex;\r
-      NewDevPtr = NewBEVPtr;\r
-      break;\r
-\r
-    default:\r
-      Idx = NULL;\r
-      break;\r
-    }\r
-    //\r
-    // at this point we have copied those valid indexes to new buffer\r
-    // and we should check if there is any new appeared boot device\r
-    //\r
-    if (Idx != NULL) {\r
-      for (Index2 = 0; Index2 < *Idx; Index2++) {\r
-        if ((NewDevPtr[Index2] & 0xFF) == (UINT16) Index) {\r
-          break;\r
-        }\r
-      }\r
-\r
-      if (Index2 == *Idx) {\r
-        //\r
-        // Index2 == *Idx means we didn't find Index\r
-        // so Index is a new appeared device's index in BBS table\r
-        // insert it before disabled indexes.\r
-        //\r
-        for (Index2 = 0; Index2 < *Idx; Index2++) {\r
-          if ((NewDevPtr[Index2] & 0xFF00) == 0xFF00) {\r
-            break;\r
-          }\r
-        }\r
-        CopyMem (&NewDevPtr[Index2 + 1], &NewDevPtr[Index2], (*Idx - Index2) * sizeof (UINT16));\r
-        NewDevPtr[Index2] = (UINT16) (Index & 0xFF);\r
-        (*Idx)++;\r
-      }\r
-    }\r
-  }\r
-\r
-  FreePool (DevOrder);\r
-\r
-  Status = gRT->SetVariable (\r
-                  VAR_LEGACY_DEV_ORDER,\r
-                  &gEfiLegacyDevOrderVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  TotalSize,\r
-                  NewDevOrder\r
-                  );\r
-  FreePool (NewDevOrder);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Set Boot Priority for specified device type.\r
-\r
-  @param DeviceType      The device type.\r
-  @param BbsIndex        The BBS index to set the highest priority. Ignore when -1.\r
-  @param LocalBbsTable   The BBS table.\r
-  @param Priority        The prority table.\r
-\r
-  @retval EFI_SUCCESS           The function completes successfully.\r
-  @retval EFI_NOT_FOUND         Failed to find device.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to get the efi variable of device order.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBmSetPriorityForSameTypeDev (\r
-  IN UINT16                                              DeviceType,\r
-  IN UINTN                                               BbsIndex,\r
-  IN OUT BBS_TABLE                                       *LocalBbsTable,\r
-  IN OUT UINT16                                          *Priority\r
-  )\r
-{\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrderPtr;\r
-  UINTN                       DevOrderSize;\r
-  UINTN                       Index;\r
-\r
-  GetVariable2 (VAR_LEGACY_DEV_ORDER, &gEfiLegacyDevOrderVariableGuid, (VOID **) &DevOrder, &DevOrderSize);\r
-  if (NULL == DevOrder) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  DevOrderPtr = DevOrder;\r
-  while ((UINT8 *) DevOrderPtr < (UINT8 *) DevOrder + DevOrderSize) {\r
-    if (DevOrderPtr->BbsType == DeviceType) {\r
-      break;\r
-    }\r
-\r
-    DevOrderPtr = (LEGACY_DEV_ORDER_ENTRY *) ((UINTN) DevOrderPtr + sizeof (BBS_TYPE) + DevOrderPtr->Length);\r
-  }\r
-\r
-  if ((UINT8 *) DevOrderPtr >= (UINT8 *) DevOrder + DevOrderSize) {\r
-    FreePool (DevOrder);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if (BbsIndex != (UINTN) -1) {\r
-    //\r
-    // In case the BBS entry isn't valid because devices were plugged or removed.\r
-    //\r
-    if (!LegacyBmValidBbsEntry (&LocalBbsTable[BbsIndex]) || (LocalBbsTable[BbsIndex].DeviceType != DeviceType)) {\r
-      FreePool (DevOrder);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-    LocalBbsTable[BbsIndex].BootPriority = *Priority;\r
-    (*Priority)++;\r
-  }\r
-  //\r
-  // If the high byte of the DevIndex is 0xFF, it indicates that this device has been disabled.\r
-  //\r
-  for (Index = 0; Index < DevOrderPtr->Length / sizeof (UINT16) - 1; Index++) {\r
-    if ((DevOrderPtr->Data[Index] & 0xFF00) == 0xFF00) {\r
-      //\r
-      // LocalBbsTable[DevIndex[Index] & 0xFF].BootPriority = BBS_DISABLED_ENTRY;\r
-      //\r
-    } else if (DevOrderPtr->Data[Index] != BbsIndex) {\r
-      LocalBbsTable[DevOrderPtr->Data[Index]].BootPriority = *Priority;\r
-      (*Priority)++;\r
-    }\r
-  }\r
-\r
-  FreePool (DevOrder);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Print the BBS Table.\r
-\r
-  @param LocalBbsTable   The BBS table.\r
-  @param BbsCount        The count of entry in BBS table.\r
-**/\r
-VOID\r
-LegacyBmPrintBbsTable (\r
-  IN BBS_TABLE  *LocalBbsTable,\r
-  IN UINT16     BbsCount\r
-  )\r
-{\r
-  UINT16  Index;\r
-\r
-  DEBUG ((DEBUG_INFO, "\n"));\r
-  DEBUG ((DEBUG_INFO, " NO  Prio bb/dd/ff cl/sc Type Stat segm:offs\n"));\r
-  DEBUG ((DEBUG_INFO, "=============================================\n"));\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&LocalBbsTable[Index])) {\r
-      continue;\r
-    }\r
-\r
-    DEBUG (\r
-      (DEBUG_INFO,\r
-      " %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x %04x:%04x\n",\r
-      (UINTN) Index,\r
-      (UINTN) LocalBbsTable[Index].BootPriority,\r
-      (UINTN) LocalBbsTable[Index].Bus,\r
-      (UINTN) LocalBbsTable[Index].Device,\r
-      (UINTN) LocalBbsTable[Index].Function,\r
-      (UINTN) LocalBbsTable[Index].Class,\r
-      (UINTN) LocalBbsTable[Index].SubClass,\r
-      (UINTN) LocalBbsTable[Index].DeviceType,\r
-      (UINTN) * (UINT16 *) &LocalBbsTable[Index].StatusFlags,\r
-      (UINTN) LocalBbsTable[Index].BootHandlerSegment,\r
-      (UINTN) LocalBbsTable[Index].BootHandlerOffset,\r
-      (UINTN) ((LocalBbsTable[Index].MfgStringSegment << 4) + LocalBbsTable[Index].MfgStringOffset),\r
-      (UINTN) ((LocalBbsTable[Index].DescStringSegment << 4) + LocalBbsTable[Index].DescStringOffset))\r
-      );\r
-  }\r
-\r
-  DEBUG ((DEBUG_INFO, "\n"));\r
-}\r
-\r
-/**\r
-  Set the boot priority for BBS entries based on boot option entry and boot order.\r
-\r
-  @param  BootOption            The boot option is to be checked for refresh BBS table.\r
-\r
-  @retval EFI_SUCCESS           The boot priority for BBS entries is refreshed successfully.\r
-  @retval EFI_NOT_FOUND         BBS entries can't be found.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to get the legacy device boot order.\r
-**/\r
-EFI_STATUS\r
-LegacyBmRefreshBbsTableForBoot (\r
-  IN EFI_BOOT_MANAGER_LOAD_OPTION        *BootOption\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  UINT16                        BbsIndex;\r
-  UINT16                        HddCount;\r
-  UINT16                        BbsCount;\r
-  HDD_INFO                      *LocalHddInfo;\r
-  BBS_TABLE                     *LocalBbsTable;\r
-  UINT16                        DevType;\r
-  EFI_LEGACY_BIOS_PROTOCOL      *LegacyBios;\r
-  UINTN                         Index;\r
-  UINT16                        Priority;\r
-  UINT16                        *DeviceType;\r
-  UINTN                         DeviceTypeCount;\r
-  UINTN                         DeviceTypeIndex;\r
-  EFI_BOOT_MANAGER_LOAD_OPTION  *Option;\r
-  UINTN                         OptionCount;\r
-\r
-  HddCount      = 0;\r
-  BbsCount      = 0;\r
-  LocalHddInfo  = NULL;\r
-  LocalBbsTable = NULL;\r
-  DevType       = BBS_UNKNOWN;\r
-\r
-  Status        = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = LegacyBios->GetBbsInfo (\r
-                         LegacyBios,\r
-                         &HddCount,\r
-                         &LocalHddInfo,\r
-                         &BbsCount,\r
-                         &LocalBbsTable\r
-                         );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // First, set all the present devices' boot priority to BBS_UNPRIORITIZED_ENTRY\r
-  // We will set them according to the settings setup by user\r
-  //\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (LegacyBmValidBbsEntry (&LocalBbsTable[Index])) {\r
-      LocalBbsTable[Index].BootPriority = BBS_UNPRIORITIZED_ENTRY;\r
-    }\r
-  }\r
-  //\r
-  // boot priority always starts at 0\r
-  //\r
-  Priority = 0;\r
-  if ((DevicePathType (BootOption->FilePath) == BBS_DEVICE_PATH) &&\r
-      (DevicePathSubType (BootOption->FilePath) == BBS_BBS_DP)) {\r
-    //\r
-    // If BootOption stands for a legacy boot option, we prioritize the devices with the same type first.\r
-    //\r
-    DevType  = LegacyBmDeviceType (BootOption->FilePath);\r
-    BbsIndex = ((LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOption->OptionalData)->BbsIndex;\r
-    Status = LegacyBmSetPriorityForSameTypeDev (\r
-               DevType,\r
-               BbsIndex,\r
-               LocalBbsTable,\r
-               &Priority\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-  //\r
-  // we have to set the boot priority for other BBS entries with different device types\r
-  //\r
-  Option          = EfiBootManagerGetLoadOptions (&OptionCount, LoadOptionTypeBoot);\r
-  DeviceType      = AllocatePool (sizeof (UINT16) * OptionCount);\r
-  ASSERT (DeviceType != NULL);\r
-  DeviceType[0]   = DevType;\r
-  DeviceTypeCount = 1;\r
-  for (Index = 0; Index < OptionCount; Index++) {\r
-    if ((DevicePathType (Option[Index].FilePath) != BBS_DEVICE_PATH) ||\r
-        (DevicePathSubType (Option[Index].FilePath) != BBS_BBS_DP)) {\r
-      continue;\r
-    }\r
-\r
-    DevType = LegacyBmDeviceType (Option[Index].FilePath);\r
-    for (DeviceTypeIndex = 0; DeviceTypeIndex < DeviceTypeCount; DeviceTypeIndex++) {\r
-      if (DeviceType[DeviceTypeIndex] == DevType) {\r
-        break;\r
-      }\r
-    }\r
-    if (DeviceTypeIndex < DeviceTypeCount) {\r
-      //\r
-      // We don't want to process twice for a device type\r
-      //\r
-      continue;\r
-    }\r
-\r
-    DeviceType[DeviceTypeCount] = DevType;\r
-    DeviceTypeCount++;\r
-\r
-    Status = LegacyBmSetPriorityForSameTypeDev (\r
-               DevType,\r
-               (UINTN) -1,\r
-               LocalBbsTable,\r
-               &Priority\r
-               );\r
-  }\r
-  EfiBootManagerFreeLoadOptions (Option, OptionCount);\r
-\r
-  DEBUG_CODE_BEGIN();\r
-    LegacyBmPrintBbsTable (LocalBbsTable, BbsCount);\r
-  DEBUG_CODE_END();\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Boot the legacy system with the boot option.\r
-\r
-  @param  BootOption The legacy boot option which have BBS device path\r
-                     On return, BootOption->Status contains the boot status.\r
-                     EFI_UNSUPPORTED    There is no legacybios protocol, do not support\r
-                                        legacy boot.\r
-                     EFI_STATUS         The status of LegacyBios->LegacyBoot ().\r
-**/\r
-VOID\r
-EFIAPI\r
-LegacyBmBoot (\r
-  IN  EFI_BOOT_MANAGER_LOAD_OPTION           *BootOption\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // If no LegacyBios protocol we do not support legacy boot\r
-    //\r
-    BootOption->Status = EFI_UNSUPPORTED;\r
-    return;\r
-  }\r
-  //\r
-  // Notes: if we separate the int 19, then we don't need to refresh BBS\r
-  //\r
-  Status = LegacyBmRefreshBbsTableForBoot (BootOption);\r
-  if (EFI_ERROR (Status)) {\r
-    BootOption->Status = Status;\r
-    return;\r
-  }\r
-\r
-  BootOption->Status = LegacyBios->LegacyBoot (\r
-                                     LegacyBios,\r
-                                     (BBS_BBS_DEVICE_PATH *) BootOption->FilePath,\r
-                                     BootOption->OptionalDataSize,\r
-                                     BootOption->OptionalData\r
-                                     );\r
-}\r
-\r
-/**\r
-  This function enumerates all the legacy boot options.\r
-\r
-  @param BootOptionCount   Return the legacy boot option count.\r
-\r
-  @retval    Pointer to the legacy boot option buffer.\r
-**/\r
-EFI_BOOT_MANAGER_LOAD_OPTION *\r
-LegacyBmEnumerateAllBootOptions (\r
-  UINTN                         *BootOptionCount\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  UINT16                        HddCount;\r
-  UINT16                        BbsCount;\r
-  HDD_INFO                      *HddInfo;\r
-  BBS_TABLE                     *BbsTable;\r
-  EFI_LEGACY_BIOS_PROTOCOL      *LegacyBios;\r
-  UINT16                        Index;\r
-  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOptions;\r
-\r
-  ASSERT (BootOptionCount != NULL);\r
-\r
-  BootOptions      = NULL;\r
-  *BootOptionCount = 0;\r
-  BbsCount         = 0;\r
-\r
-  Status        = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return NULL;\r
-  }\r
-\r
-  Status = LegacyBios->GetBbsInfo (\r
-                         LegacyBios,\r
-                         &HddCount,\r
-                         &HddInfo,\r
-                         &BbsCount,\r
-                         &BbsTable\r
-                         );\r
-  if (EFI_ERROR (Status)) {\r
-    return NULL;\r
-  }\r
-\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if (!LegacyBmValidBbsEntry (&BbsTable[Index])) {\r
-      continue;\r
-    }\r
-\r
-    BootOptions = ReallocatePool (\r
-                    sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount),\r
-                    sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount + 1),\r
-                    BootOptions\r
-                    );\r
-    ASSERT (BootOptions != NULL);\r
-\r
-    Status = LegacyBmCreateLegacyBootOption (&BootOptions[(*BootOptionCount)++], &BbsTable[Index], Index);\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  return BootOptions;\r
-}\r
-\r
-/**\r
-  Return the index of the boot option in the boot option array.\r
-\r
-  The function compares the Description, FilePath, OptionalData.\r
-\r
-  @param Key         The input boot option which is compared with.\r
-  @param Array       The input boot option array.\r
-  @param Count       The count of the input boot options.\r
-\r
-  @retval  The index of the input boot option in the array.\r
-\r
-**/\r
-INTN\r
-LegacyBmFindBootOption (\r
-  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,\r
-  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,\r
-  IN UINTN                              Count\r
-  )\r
-{\r
-  UINTN                             Index;\r
-\r
-  for (Index = 0; Index < Count; Index++) {\r
-    if ((StrCmp (Key->Description, Array[Index].Description) == 0) &&\r
-        (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&\r
-        (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&\r
-        (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {\r
-      return (INTN) Index;\r
-    }\r
-  }\r
-\r
-  return -1;\r
-}\r
-\r
-/**\r
-  Refresh all legacy boot options.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-LegacyBmRefreshAllBootOption (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                                 Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL                   *LegacyBios;\r
-  UINTN                                      RootBridgeHandleCount;\r
-  EFI_HANDLE                                 *RootBridgeHandleBuffer;\r
-  UINTN                                      HandleCount;\r
-  EFI_HANDLE                                 *HandleBuffer;\r
-  UINTN                                      RootBridgeIndex;\r
-  UINTN                                      Index;\r
-  UINTN                                      Flags;\r
-  EFI_BOOT_MANAGER_LOAD_OPTION               *BootOptions;\r
-  UINTN                                      BootOptionCount;\r
-  EFI_BOOT_MANAGER_LOAD_OPTION               *ExistingBootOptions;\r
-  UINTN                                      ExistingBootOptionCount;\r
-\r
-  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    LegacyBmDeleteAllBootOptions ();\r
-    return;\r
-  }\r
-  PERF_START (NULL, "LegacyBootOptionEnum", "BDS", 0);\r
-\r
-  //\r
-  // Before enumerating the legacy boot option, we need to dispatch all the legacy option roms\r
-  // to ensure the GetBbsInfo() counts all the legacy devices.\r
-  //\r
-  gBS->LocateHandleBuffer (\r
-         ByProtocol,\r
-         &gEfiPciRootBridgeIoProtocolGuid,\r
-         NULL,\r
-         &RootBridgeHandleCount,\r
-         &RootBridgeHandleBuffer\r
-         );\r
-  for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount; RootBridgeIndex++) {\r
-    gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex], NULL, NULL, FALSE);\r
-    gBS->LocateHandleBuffer (\r
-           ByProtocol,\r
-           &gEfiPciIoProtocolGuid,\r
-           NULL,\r
-           &HandleCount,\r
-           &HandleBuffer\r
-           );\r
-    for (Index = 0; Index < HandleCount; Index++) {\r
-      //\r
-      // Start the thunk driver so that the legacy option rom gets dispatched.\r
-      // Note: We don't directly call InstallPciRom because some thunk drivers\r
-      // (e.g. BlockIo thunk driver) depend on the immediate result after dispatching\r
-      //\r
-      Status = LegacyBios->CheckPciRom (\r
-                             LegacyBios,\r
-                             HandleBuffer[Index],\r
-                             NULL,\r
-                             NULL,\r
-                             &Flags\r
-                             );\r
-      if (!EFI_ERROR (Status)) {\r
-        gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE);\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Same algorithm pattern as the EfiBootManagerRefreshAllBootOption\r
-  // Firstly delete the invalid legacy boot options,\r
-  // then enumreate and save the newly appeared legacy boot options\r
-  // the last step is legacy boot option special action to refresh the LegacyDevOrder variable\r
-  //\r
-  LegacyBmDeleteAllInvalidBootOptions ();\r
-\r
-  ExistingBootOptions = EfiBootManagerGetLoadOptions (&ExistingBootOptionCount, LoadOptionTypeBoot);\r
-  BootOptions         = LegacyBmEnumerateAllBootOptions   (&BootOptionCount);\r
-\r
-  for (Index = 0; Index < BootOptionCount; Index++) {\r
-    if (LegacyBmFindBootOption (&BootOptions[Index], ExistingBootOptions, ExistingBootOptionCount) == -1) {\r
-      Status = EfiBootManagerAddLoadOptionVariable (&BootOptions[Index], (UINTN) -1);\r
-      DEBUG ((\r
-        EFI_D_INFO, "[LegacyBds] New Boot Option: Boot%04x Bbs0x%04x %s %r\n",\r
-        (UINTN) BootOptions[Index].OptionNumber,\r
-        (UINTN) ((LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOptions[Index].OptionalData)->BbsIndex,\r
-        BootOptions[Index].Description,\r
-        Status\r
-        ));\r
-      //\r
-      // Continue upon failure to add boot option.\r
-      //\r
-    }\r
-  }\r
-\r
-  EfiBootManagerFreeLoadOptions (ExistingBootOptions, ExistingBootOptionCount);\r
-  EfiBootManagerFreeLoadOptions (BootOptions,         BootOptionCount);\r
-\r
-  //\r
-  // Failure to create LegacyDevOrder variable only impacts the boot order.\r
-  //\r
-  LegacyBmUpdateDevOrder ();\r
-\r
-  PERF_END   (NULL, "LegacyBootOptionEnum", "BDS", 0);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf b/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf
deleted file mode 100644 (file)
index eaf7b72..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-## @file\r
-#  Legacy Boot Manager module is library for BDS phase.\r
-#\r
-#  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = LegacyBootManagerLib\r
-  MODULE_UNI_FILE                = LegacyBootManagerLib.uni\r
-  FILE_GUID                      = F1B87BE4-0ACC-409A-A52B-7BFFABCC96A0\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL|DXE_DRIVER UEFI_APPLICATION\r
-  CONSTRUCTOR                    = LegacyBootManagerLibConstructor\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  LegacyBm.c\r
-  InternalLegacyBm.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  BaseMemoryLib\r
-  UefiBootServicesTableLib\r
-  UefiRuntimeServicesTableLib\r
-  DevicePathLib\r
-  MemoryAllocationLib\r
-  UefiLib\r
-  DebugLib\r
-  PrintLib\r
-  PerformanceLib\r
-  UefiBootManagerLib\r
-\r
-[Guids]\r
-  gEfiGlobalVariableGuid                        ## SOMETIMES_PRODUCES ## Variable:L"Boot####" (Boot option variable)\r
-                                                ## SOMETIMES_CONSUMES ## Variable:L"BootOrder" (The boot option array)\r
-  gEfiLegacyDevOrderVariableGuid\r
-\r
-[Protocols]\r
-  gEfiLegacyBiosProtocolGuid                    ## SOMETIMES_CONSUMES\r
-\r
-[FeaturePcd]\r
-\r
-[Pcd]\r
diff --git a/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.uni b/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.uni
deleted file mode 100644 (file)
index da2915a..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// /** @file\r
-// Legacy Boot Manager module is library for BDS phase.\r
-//\r
-// Legacy Boot Manager module is library for BDS phase.\r
-//\r
-// Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_MODULE_ABSTRACT\r
-#language en-US\r
-"Legacy Boot Manager module is library for BDS phase."\r
-\r
-#string STR_MODULE_DESCRIPTION\r
-#language en-US\r
-"Legacy Boot Manager module is library for BDS phase."\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c
deleted file mode 100644 (file)
index ac3fea3..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/** @file\r
-  LZMA Decompress GUIDed Section Extraction Library, which produces LZMA custom\r
-  decompression algorithm with the converter for the different arch code.\r
-  It wraps Lzma decompress interfaces to GUIDed Section Extraction interfaces\r
-  and registers them into GUIDed handler table.\r
-\r
-  Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LzmaDecompressLibInternal.h"\r
-#include "Sdk/C/Bra.h"\r
-\r
-/**\r
-  Examines a GUIDed section and returns the size of the decoded buffer and the\r
-  size of an scratch buffer required to actually decode the data in a GUIDed section.\r
-\r
-  Examines a GUIDed section specified by InputSection.\r
-  If GUID for InputSection does not match the GUID that this handler supports,\r
-  then RETURN_UNSUPPORTED is returned.\r
-  If the required information can not be retrieved from InputSection,\r
-  then RETURN_INVALID_PARAMETER is returned.\r
-  If the GUID of InputSection does match the GUID that this handler supports,\r
-  then the size required to hold the decoded buffer is returned in OututBufferSize,\r
-  the size of an optional scratch buffer is returned in ScratchSize, and the Attributes field\r
-  from EFI_GUID_DEFINED_SECTION header of InputSection is returned in SectionAttribute.\r
-\r
-  If InputSection is NULL, then ASSERT().\r
-  If OutputBufferSize is NULL, then ASSERT().\r
-  If ScratchBufferSize is NULL, then ASSERT().\r
-  If SectionAttribute is NULL, then ASSERT().\r
-\r
-\r
-  @param[in]  InputSection       A pointer to a GUIDed section of an FFS formatted file.\r
-  @param[out] OutputBufferSize   A pointer to the size, in bytes, of an output buffer required\r
-                                 if the buffer specified by InputSection were decoded.\r
-  @param[out] ScratchBufferSize  A pointer to the size, in bytes, required as scratch space\r
-                                 if the buffer specified by InputSection were decoded.\r
-  @param[out] SectionAttribute   A pointer to the attributes of the GUIDed section. See the Attributes\r
-                                 field of EFI_GUID_DEFINED_SECTION in the PI Specification.\r
-\r
-  @retval  RETURN_SUCCESS            The information about InputSection was returned.\r
-  @retval  RETURN_UNSUPPORTED        The section specified by InputSection does not match the GUID this handler supports.\r
-  @retval  RETURN_INVALID_PARAMETER  The information can not be retrieved from the section specified by InputSection.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaArchGuidedSectionGetInfo (\r
-  IN  CONST VOID  *InputSection,\r
-  OUT UINT32      *OutputBufferSize,\r
-  OUT UINT32      *ScratchBufferSize,\r
-  OUT UINT16      *SectionAttribute\r
-  )\r
-{\r
-  ASSERT (InputSection != NULL);\r
-  ASSERT (OutputBufferSize != NULL);\r
-  ASSERT (ScratchBufferSize != NULL);\r
-  ASSERT (SectionAttribute != NULL);\r
-\r
-  if (IS_SECTION2 (InputSection)) {\r
-    if (!CompareGuid (\r
-        &gLzmaF86CustomDecompressGuid,\r
-        &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {\r
-      return RETURN_INVALID_PARAMETER;\r
-    }\r
-\r
-    *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;\r
-\r
-    return LzmaUefiDecompressGetInfo (\r
-             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
-             SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
-             OutputBufferSize,\r
-             ScratchBufferSize\r
-             );\r
-  } else {\r
-    if (!CompareGuid (\r
-        &gLzmaF86CustomDecompressGuid,\r
-        &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
-      return RETURN_INVALID_PARAMETER;\r
-    }\r
-\r
-    *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;\r
-\r
-    return LzmaUefiDecompressGetInfo (\r
-             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-             SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-             OutputBufferSize,\r
-             ScratchBufferSize\r
-             );\r
-  }\r
-}\r
-\r
-/**\r
-  Decompress a LZAM compressed GUIDed section into a caller allocated output buffer.\r
-\r
-  Decodes the GUIDed section specified by InputSection.\r
-  If GUID for InputSection does not match the GUID that this handler supports, then RETURN_UNSUPPORTED is returned.\r
-  If the data in InputSection can not be decoded, then RETURN_INVALID_PARAMETER is returned.\r
-  If the GUID of InputSection does match the GUID that this handler supports, then InputSection\r
-  is decoded into the buffer specified by OutputBuffer and the authentication status of this\r
-  decode operation is returned in AuthenticationStatus.  If the decoded buffer is identical to the\r
-  data in InputSection, then OutputBuffer is set to point at the data in InputSection.  Otherwise,\r
-  the decoded data will be placed in caller allocated buffer specified by OutputBuffer.\r
-\r
-  If InputSection is NULL, then ASSERT().\r
-  If OutputBuffer is NULL, then ASSERT().\r
-  If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
-  If AuthenticationStatus is NULL, then ASSERT().\r
-\r
-\r
-  @param[in]  InputSection  A pointer to a GUIDed section of an FFS formatted file.\r
-  @param[out] OutputBuffer  A pointer to a buffer that contains the result of a decode operation.\r
-  @param[out] ScratchBuffer A caller allocated buffer that may be required by this function\r
-                            as a scratch buffer to perform the decode operation.\r
-  @param[out] AuthenticationStatus\r
-                            A pointer to the authentication status of the decoded output buffer.\r
-                            See the definition of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI\r
-                            section of the PI Specification. EFI_AUTH_STATUS_PLATFORM_OVERRIDE must\r
-                            never be set by this handler.\r
-\r
-  @retval  RETURN_SUCCESS            The buffer specified by InputSection was decoded.\r
-  @retval  RETURN_UNSUPPORTED        The section specified by InputSection does not match the GUID this handler supports.\r
-  @retval  RETURN_INVALID_PARAMETER  The section specified by InputSection can not be decoded.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaArchGuidedSectionExtraction (\r
-  IN CONST  VOID    *InputSection,\r
-  OUT       VOID    **OutputBuffer,\r
-  OUT       VOID    *ScratchBuffer,        OPTIONAL\r
-  OUT       UINT32  *AuthenticationStatus\r
-  )\r
-{\r
-  EFI_GUID          *InputGuid;\r
-  VOID              *Source;\r
-  UINTN             SourceSize;\r
-  EFI_STATUS        Status;\r
-  UINT32            X86State;\r
-  UINT32            OutputBufferSize;\r
-  UINT32            ScratchBufferSize;\r
-\r
-  ASSERT (OutputBuffer != NULL);\r
-  ASSERT (InputSection != NULL);\r
-\r
-  if (IS_SECTION2 (InputSection)) {\r
-    InputGuid  = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);\r
-    Source     = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;\r
-    SourceSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;\r
-  } else {\r
-    InputGuid  = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);\r
-    Source     = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;\r
-    SourceSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;\r
-  }\r
-\r
-  if (!CompareGuid (&gLzmaF86CustomDecompressGuid, InputGuid)) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Authentication is set to Zero, which may be ignored.\r
-  //\r
-  *AuthenticationStatus = 0;\r
-\r
-  Status = LzmaUefiDecompress (\r
-           Source,\r
-           SourceSize,\r
-           *OutputBuffer,\r
-           ScratchBuffer\r
-           );\r
-\r
-  //\r
-  // After decompress, the data need to be converted to the raw data.\r
-  //\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = LzmaUefiDecompressGetInfo (\r
-             Source,\r
-             (UINT32) SourceSize,\r
-             &OutputBufferSize,\r
-             &ScratchBufferSize\r
-             );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      x86_Convert_Init(X86State);\r
-      x86_Convert(*OutputBuffer, OutputBufferSize, 0, &X86State, 0);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Register LzmaArchDecompress and LzmaArchDecompressGetInfo handlers with LzmaF86CustomDecompressGuid.\r
-\r
-  @retval  RETURN_SUCCESS            Register successfully.\r
-  @retval  RETURN_OUT_OF_RESOURCES   No enough memory to store this handler.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LzmaArchDecompressLibConstructor (\r
-  VOID\r
-  )\r
-{\r
-  return ExtractGuidedSectionRegisterHandlers (\r
-          &gLzmaF86CustomDecompressGuid,\r
-          LzmaArchGuidedSectionGetInfo,\r
-          LzmaArchGuidedSectionExtraction\r
-          );\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c
deleted file mode 100644 (file)
index 8926204..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/** @file\r
-  LZMA Decompress GUIDed Section Extraction Library.\r
-  It wraps Lzma decompress interfaces to GUIDed Section Extraction interfaces\r
-  and registers them into GUIDed handler table.\r
-\r
-  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LzmaDecompressLibInternal.h"\r
-\r
-/**\r
-  Examines a GUIDed section and returns the size of the decoded buffer and the\r
-  size of an scratch buffer required to actually decode the data in a GUIDed section.\r
-\r
-  Examines a GUIDed section specified by InputSection.\r
-  If GUID for InputSection does not match the GUID that this handler supports,\r
-  then RETURN_UNSUPPORTED is returned.\r
-  If the required information can not be retrieved from InputSection,\r
-  then RETURN_INVALID_PARAMETER is returned.\r
-  If the GUID of InputSection does match the GUID that this handler supports,\r
-  then the size required to hold the decoded buffer is returned in OututBufferSize,\r
-  the size of an optional scratch buffer is returned in ScratchSize, and the Attributes field\r
-  from EFI_GUID_DEFINED_SECTION header of InputSection is returned in SectionAttribute.\r
-\r
-  If InputSection is NULL, then ASSERT().\r
-  If OutputBufferSize is NULL, then ASSERT().\r
-  If ScratchBufferSize is NULL, then ASSERT().\r
-  If SectionAttribute is NULL, then ASSERT().\r
-\r
-\r
-  @param[in]  InputSection       A pointer to a GUIDed section of an FFS formatted file.\r
-  @param[out] OutputBufferSize   A pointer to the size, in bytes, of an output buffer required\r
-                                 if the buffer specified by InputSection were decoded.\r
-  @param[out] ScratchBufferSize  A pointer to the size, in bytes, required as scratch space\r
-                                 if the buffer specified by InputSection were decoded.\r
-  @param[out] SectionAttribute   A pointer to the attributes of the GUIDed section. See the Attributes\r
-                                 field of EFI_GUID_DEFINED_SECTION in the PI Specification.\r
-\r
-  @retval  RETURN_SUCCESS            The information about InputSection was returned.\r
-  @retval  RETURN_UNSUPPORTED        The section specified by InputSection does not match the GUID this handler supports.\r
-  @retval  RETURN_INVALID_PARAMETER  The information can not be retrieved from the section specified by InputSection.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaGuidedSectionGetInfo (\r
-  IN  CONST VOID  *InputSection,\r
-  OUT UINT32      *OutputBufferSize,\r
-  OUT UINT32      *ScratchBufferSize,\r
-  OUT UINT16      *SectionAttribute\r
-  )\r
-{\r
-  ASSERT (InputSection != NULL);\r
-  ASSERT (OutputBufferSize != NULL);\r
-  ASSERT (ScratchBufferSize != NULL);\r
-  ASSERT (SectionAttribute != NULL);\r
-\r
-  if (IS_SECTION2 (InputSection)) {\r
-    if (!CompareGuid (\r
-        &gLzmaCustomDecompressGuid,\r
-        &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {\r
-      return RETURN_INVALID_PARAMETER;\r
-    }\r
-\r
-    *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;\r
-\r
-    return LzmaUefiDecompressGetInfo (\r
-             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
-             SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
-             OutputBufferSize,\r
-             ScratchBufferSize\r
-             );\r
-  } else {\r
-    if (!CompareGuid (\r
-        &gLzmaCustomDecompressGuid,\r
-        &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
-      return RETURN_INVALID_PARAMETER;\r
-    }\r
-\r
-    *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;\r
-\r
-    return LzmaUefiDecompressGetInfo (\r
-             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-             SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-             OutputBufferSize,\r
-             ScratchBufferSize\r
-             );\r
-  }\r
-}\r
-\r
-/**\r
-  Decompress a LZAM compressed GUIDed section into a caller allocated output buffer.\r
-\r
-  Decodes the GUIDed section specified by InputSection.\r
-  If GUID for InputSection does not match the GUID that this handler supports, then RETURN_UNSUPPORTED is returned.\r
-  If the data in InputSection can not be decoded, then RETURN_INVALID_PARAMETER is returned.\r
-  If the GUID of InputSection does match the GUID that this handler supports, then InputSection\r
-  is decoded into the buffer specified by OutputBuffer and the authentication status of this\r
-  decode operation is returned in AuthenticationStatus.  If the decoded buffer is identical to the\r
-  data in InputSection, then OutputBuffer is set to point at the data in InputSection.  Otherwise,\r
-  the decoded data will be placed in caller allocated buffer specified by OutputBuffer.\r
-\r
-  If InputSection is NULL, then ASSERT().\r
-  If OutputBuffer is NULL, then ASSERT().\r
-  If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
-  If AuthenticationStatus is NULL, then ASSERT().\r
-\r
-\r
-  @param[in]  InputSection  A pointer to a GUIDed section of an FFS formatted file.\r
-  @param[out] OutputBuffer  A pointer to a buffer that contains the result of a decode operation.\r
-  @param[out] ScratchBuffer A caller allocated buffer that may be required by this function\r
-                            as a scratch buffer to perform the decode operation.\r
-  @param[out] AuthenticationStatus\r
-                            A pointer to the authentication status of the decoded output buffer.\r
-                            See the definition of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI\r
-                            section of the PI Specification. EFI_AUTH_STATUS_PLATFORM_OVERRIDE must\r
-                            never be set by this handler.\r
-\r
-  @retval  RETURN_SUCCESS            The buffer specified by InputSection was decoded.\r
-  @retval  RETURN_UNSUPPORTED        The section specified by InputSection does not match the GUID this handler supports.\r
-  @retval  RETURN_INVALID_PARAMETER  The section specified by InputSection can not be decoded.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaGuidedSectionExtraction (\r
-  IN CONST  VOID    *InputSection,\r
-  OUT       VOID    **OutputBuffer,\r
-  OUT       VOID    *ScratchBuffer,        OPTIONAL\r
-  OUT       UINT32  *AuthenticationStatus\r
-  )\r
-{\r
-  ASSERT (OutputBuffer != NULL);\r
-  ASSERT (InputSection != NULL);\r
-\r
-  if (IS_SECTION2 (InputSection)) {\r
-    if (!CompareGuid (\r
-        &gLzmaCustomDecompressGuid,\r
-        &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {\r
-      return RETURN_INVALID_PARAMETER;\r
-    }\r
-\r
-    //\r
-    // Authentication is set to Zero, which may be ignored.\r
-    //\r
-    *AuthenticationStatus = 0;\r
-\r
-    return LzmaUefiDecompress (\r
-             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
-             SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
-             *OutputBuffer,\r
-             ScratchBuffer\r
-             );\r
-  } else {\r
-    if (!CompareGuid (\r
-        &gLzmaCustomDecompressGuid,\r
-        &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
-      return RETURN_INVALID_PARAMETER;\r
-    }\r
-\r
-    //\r
-    // Authentication is set to Zero, which may be ignored.\r
-    //\r
-    *AuthenticationStatus = 0;\r
-\r
-    return LzmaUefiDecompress (\r
-             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-             SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-             *OutputBuffer,\r
-             ScratchBuffer\r
-    );\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Register LzmaDecompress and LzmaDecompressGetInfo handlers with LzmaCustomerDecompressGuid.\r
-\r
-  @retval  RETURN_SUCCESS            Register successfully.\r
-  @retval  RETURN_OUT_OF_RESOURCES   No enough memory to store this handler.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LzmaDecompressLibConstructor (\r
-  VOID\r
-  )\r
-{\r
-  return ExtractGuidedSectionRegisterHandlers (\r
-          &gLzmaCustomDecompressGuid,\r
-          LzmaGuidedSectionGetInfo,\r
-          LzmaGuidedSectionExtraction\r
-          );\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LZMA-SDK-README.txt b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LZMA-SDK-README.txt
deleted file mode 100644 (file)
index 3f3895b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-LzmaCustomDecompressLib is based on the LZMA SDK 18.05.\r
-LZMA SDK 18.05 was placed in the public domain on\r
-2018-04-30.  It was released on the\r
-http://www.7-zip.org/sdk.html website.\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaArchCustomDecompressLib.inf b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaArchCustomDecompressLib.inf
deleted file mode 100644 (file)
index d789e7d..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-## @file\r
-#  LzmaArchCustomDecompressLib produces LZMA custom decompression algorithm with the converter for the different arch code.\r
-#\r
-#  It is based on the LZMA SDK 18.05\r
-#  LZMA SDK 18.05 was placed in the public domain on 2018-04-30.\r
-#  It was released on the http://www.7-zip.org/sdk.html website.\r
-#\r
-#  Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = LzmaArchDecompressLib\r
-  MODULE_UNI_FILE                = LzmaArchDecompressLib.uni\r
-  FILE_GUID                      = A853C1D2-E003-4cc4-9DD1-8824AD79FE48\r
-  MODULE_TYPE                    = BASE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL\r
-  CONSTRUCTOR                    = LzmaArchDecompressLibConstructor\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64\r
-#\r
-\r
-[Sources]\r
-  LzmaDecompress.c\r
-  Sdk/C/Bra.h\r
-  Sdk/C/LzFind.c\r
-  Sdk/C/LzmaDec.c\r
-  Sdk/C/7zVersion.h\r
-  Sdk/C/CpuArch.h\r
-  Sdk/C/LzFind.h\r
-  Sdk/C/LzHash.h\r
-  Sdk/C/LzmaDec.h\r
-  Sdk/C/7zTypes.h\r
-  Sdk/C/Precomp.h\r
-  Sdk/C/Compiler.h\r
-  UefiLzma.h\r
-  LzmaDecompressLibInternal.h\r
-\r
-[Sources.Ia32, Sources.X64]\r
-  Sdk/C/Bra86.c\r
-  F86GuidedSectionExtraction.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[Guids.Ia32, Guids.X64]\r
-  gLzmaF86CustomDecompressGuid    ## PRODUCES  ## GUID # specifies LZMA custom decompress algorithm with converter for x86 code.\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  DebugLib\r
-  BaseMemoryLib\r
-  ExtractGuidedSectionLib\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaArchDecompressLib.uni b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaArchDecompressLib.uni
deleted file mode 100644 (file)
index b59634c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// LzmaArchCustomDecompressLib produces LZMA custom decompression algorithm with the converter for the different arch code.\r
-//\r
-// It is based on the LZMA SDK 4.65.\r
-// LZMA SDK 4.65 was placed in the public domain on 2009-02-03.\r
-// It was released on the http://www.7-zip.org/sdk.html website.\r
-//\r
-// Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "LzmaArchCustomDecompressLib produces LZMA custom decompression algorithm with the converter for the different arch code."\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "It is based on the LZMA SDK 4.65. LZMA SDK 4.65 was placed in the public domain on 2009-02-03. It was released on the website http://www.7-zip.org/sdk.html ."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
deleted file mode 100644 (file)
index ea6a096..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-## @file\r
-#  LzmaCustomDecompressLib produces LZMA custom decompression algorithm.\r
-#\r
-#  It is based on the LZMA SDK 18.05.\r
-#  LZMA SDK 18.05 was placed in the public domain on 2018-04-30.\r
-#  It was released on the http://www.7-zip.org/sdk.html website.\r
-#\r
-#  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = LzmaDecompressLib\r
-  MODULE_UNI_FILE                = LzmaDecompressLib.uni\r
-  FILE_GUID                      = 35194660-7421-44ad-9636-e44885f092d1\r
-  MODULE_TYPE                    = BASE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL\r
-  CONSTRUCTOR                    = LzmaDecompressLibConstructor\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  LzmaDecompress.c\r
-  Sdk/C/LzFind.c\r
-  Sdk/C/LzmaDec.c\r
-  Sdk/C/7zVersion.h\r
-  Sdk/C/CpuArch.h\r
-  Sdk/C/LzFind.h\r
-  Sdk/C/LzHash.h\r
-  Sdk/C/LzmaDec.h\r
-  Sdk/C/7zTypes.h\r
-  Sdk/C/Precomp.h\r
-  Sdk/C/Compiler.h\r
-  GuidedSectionExtraction.c\r
-  UefiLzma.h\r
-  LzmaDecompressLibInternal.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[Guids]\r
-  gLzmaCustomDecompressGuid  ## PRODUCES  ## UNDEFINED # specifies LZMA custom decompress algorithm.\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  DebugLib\r
-  BaseMemoryLib\r
-  ExtractGuidedSectionLib\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c
deleted file mode 100644 (file)
index c58912e..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-/** @file\r
-  LZMA Decompress interfaces\r
-\r
-  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LzmaDecompressLibInternal.h"\r
-#include "Sdk/C/7zTypes.h"\r
-#include "Sdk/C/7zVersion.h"\r
-#include "Sdk/C/LzmaDec.h"\r
-\r
-#define SCRATCH_BUFFER_REQUEST_SIZE SIZE_64KB\r
-\r
-typedef struct\r
-{\r
-  ISzAlloc Functions;\r
-  VOID     *Buffer;\r
-  UINTN    BufferSize;\r
-} ISzAllocWithData;\r
-\r
-/**\r
-  Allocation routine used by LZMA decompression.\r
-\r
-  @param P                Pointer to the ISzAlloc instance\r
-  @param Size             The size in bytes to be allocated\r
-\r
-  @return The allocated pointer address, or NULL on failure\r
-**/\r
-VOID *\r
-SzAlloc (\r
-  CONST ISzAlloc *P,\r
-  size_t Size\r
-  )\r
-{\r
-  VOID *Addr;\r
-  ISzAllocWithData *Private;\r
-\r
-  Private = (ISzAllocWithData*) P;\r
-\r
-  if (Private->BufferSize >= Size) {\r
-    Addr = Private->Buffer;\r
-    Private->Buffer = (VOID*) ((UINT8*)Addr + Size);\r
-    Private->BufferSize -= Size;\r
-    return Addr;\r
-  } else {\r
-    ASSERT (FALSE);\r
-    return NULL;\r
-  }\r
-}\r
-\r
-/**\r
-  Free routine used by LZMA decompression.\r
-\r
-  @param P                Pointer to the ISzAlloc instance\r
-  @param Address          The address to be freed\r
-**/\r
-VOID\r
-SzFree (\r
-  CONST ISzAlloc *P,\r
-  VOID *Address\r
-  )\r
-{\r
-  //\r
-  // We use the 'scratch buffer' for allocations, so there is no free\r
-  // operation required.  The scratch buffer will be freed by the caller\r
-  // of the decompression code.\r
-  //\r
-}\r
-\r
-#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)\r
-\r
-/**\r
-  Get the size of the uncompressed buffer by parsing EncodeData header.\r
-\r
-  @param EncodedData  Pointer to the compressed data.\r
-\r
-  @return The size of the uncompressed buffer.\r
-**/\r
-UINT64\r
-GetDecodedSizeOfBuf(\r
-  UINT8 *EncodedData\r
-  )\r
-{\r
-  UINT64 DecodedSize;\r
-  INTN   Index;\r
-\r
-  /* Parse header */\r
-  DecodedSize = 0;\r
-  for (Index = LZMA_PROPS_SIZE + 7; Index >= LZMA_PROPS_SIZE; Index--)\r
-    DecodedSize = LShiftU64(DecodedSize, 8) + EncodedData[Index];\r
-\r
-  return DecodedSize;\r
-}\r
-\r
-//\r
-// LZMA functions and data as defined in local LzmaDecompressLibInternal.h\r
-//\r
-\r
-/**\r
-  Given a Lzma compressed source buffer, this function retrieves the size of\r
-  the uncompressed buffer and the size of the scratch buffer required\r
-  to decompress the compressed source buffer.\r
-\r
-  Retrieves the size of the uncompressed buffer and the temporary scratch buffer\r
-  required to decompress the buffer specified by Source and SourceSize.\r
-  The size of the uncompressed buffer is returned in DestinationSize,\r
-  the size of the scratch buffer is returned in ScratchSize, and RETURN_SUCCESS is returned.\r
-  This function does not have scratch buffer available to perform a thorough\r
-  checking of the validity of the source data. It just retrieves the "Original Size"\r
-  field from the LZMA_HEADER_SIZE beginning bytes of the source data and output it as DestinationSize.\r
-  And ScratchSize is specific to the decompression implementation.\r
-\r
-  If SourceSize is less than LZMA_HEADER_SIZE, then ASSERT().\r
-\r
-  @param  Source          The source buffer containing the compressed data.\r
-  @param  SourceSize      The size, in bytes, of the source buffer.\r
-  @param  DestinationSize A pointer to the size, in bytes, of the uncompressed buffer\r
-                          that will be generated when the compressed buffer specified\r
-                          by Source and SourceSize is decompressed.\r
-  @param  ScratchSize     A pointer to the size, in bytes, of the scratch buffer that\r
-                          is required to decompress the compressed buffer specified\r
-                          by Source and SourceSize.\r
-\r
-  @retval  RETURN_SUCCESS The size of the uncompressed data was returned\r
-                          in DestinationSize and the size of the scratch\r
-                          buffer was returned in ScratchSize.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaUefiDecompressGetInfo (\r
-  IN  CONST VOID  *Source,\r
-  IN  UINT32      SourceSize,\r
-  OUT UINT32      *DestinationSize,\r
-  OUT UINT32      *ScratchSize\r
-  )\r
-{\r
-  UInt64  DecodedSize;\r
-\r
-  ASSERT(SourceSize >= LZMA_HEADER_SIZE);\r
-\r
-  DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);\r
-\r
-  *DestinationSize = (UINT32)DecodedSize;\r
-  *ScratchSize = SCRATCH_BUFFER_REQUEST_SIZE;\r
-  return RETURN_SUCCESS;\r
-}\r
-\r
-/**\r
-  Decompresses a Lzma compressed source buffer.\r
-\r
-  Extracts decompressed data to its original form.\r
-  If the compressed source data specified by Source is successfully decompressed\r
-  into Destination, then RETURN_SUCCESS is returned.  If the compressed source data\r
-  specified by Source is not in a valid compressed data format,\r
-  then RETURN_INVALID_PARAMETER is returned.\r
-\r
-  @param  Source      The source buffer containing the compressed data.\r
-  @param  SourceSize  The size of source buffer.\r
-  @param  Destination The destination buffer to store the decompressed data\r
-  @param  Scratch     A temporary scratch buffer that is used to perform the decompression.\r
-                      This is an optional parameter that may be NULL if the\r
-                      required scratch buffer size is 0.\r
-\r
-  @retval  RETURN_SUCCESS Decompression completed successfully, and\r
-                          the uncompressed buffer is returned in Destination.\r
-  @retval  RETURN_INVALID_PARAMETER\r
-                          The source buffer specified by Source is corrupted\r
-                          (not in a valid compressed format).\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaUefiDecompress (\r
-  IN CONST VOID  *Source,\r
-  IN UINTN       SourceSize,\r
-  IN OUT VOID    *Destination,\r
-  IN OUT VOID    *Scratch\r
-  )\r
-{\r
-  SRes              LzmaResult;\r
-  ELzmaStatus       Status;\r
-  SizeT             DecodedBufSize;\r
-  SizeT             EncodedDataSize;\r
-  ISzAllocWithData  AllocFuncs;\r
-\r
-  AllocFuncs.Functions.Alloc  = SzAlloc;\r
-  AllocFuncs.Functions.Free   = SzFree;\r
-  AllocFuncs.Buffer           = Scratch;\r
-  AllocFuncs.BufferSize       = SCRATCH_BUFFER_REQUEST_SIZE;\r
-\r
-  DecodedBufSize = (SizeT)GetDecodedSizeOfBuf((UINT8*)Source);\r
-  EncodedDataSize = (SizeT) (SourceSize - LZMA_HEADER_SIZE);\r
-\r
-  LzmaResult = LzmaDecode(\r
-    Destination,\r
-    &DecodedBufSize,\r
-    (Byte*)((UINT8*)Source + LZMA_HEADER_SIZE),\r
-    &EncodedDataSize,\r
-    Source,\r
-    LZMA_PROPS_SIZE,\r
-    LZMA_FINISH_END,\r
-    &Status,\r
-    &(AllocFuncs.Functions)\r
-    );\r
-\r
-  if (LzmaResult == SZ_OK) {\r
-    return RETURN_SUCCESS;\r
-  } else {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLib.uni b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLib.uni
deleted file mode 100644 (file)
index 89e20c1..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// LzmaCustomDecompressLib produces LZMA custom decompression algorithm.\r
-//\r
-// It is based on the LZMA SDK 4.65.\r
-// LZMA SDK 4.65 was placed in the public domain on 2009-02-03.\r
-// It was released on the http://www.7-zip.org/sdk.html website.\r
-//\r
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "LzmaCustomDecompressLib produces LZMA custom decompression algorithm"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "It is based on the LZMA SDK 4.65. LZMA SDK 4.65 was placed in the public domain on 2009-02-03. It was released on the website http://www.7-zip.org/sdk.html ."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h
deleted file mode 100644 (file)
index 26f110b..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/** @file\r
-  LZMA Decompress Library internal header file declares Lzma decompress interfaces.\r
-\r
-  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __LZMADECOMPRESSLIB_INTERNAL_H__\r
-#define __LZMADECOMPRESSLIB_INTERNAL_H__\r
-\r
-#include <PiPei.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/ExtractGuidedSectionLib.h>\r
-#include <Guid/LzmaDecompress.h>\r
-\r
-/**\r
-  Given a Lzma compressed source buffer, this function retrieves the size of\r
-  the uncompressed buffer and the size of the scratch buffer required\r
-  to decompress the compressed source buffer.\r
-\r
-  Retrieves the size of the uncompressed buffer and the temporary scratch buffer\r
-  required to decompress the buffer specified by Source and SourceSize.\r
-  The size of the uncompressed buffer is returned in DestinationSize,\r
-  the size of the scratch buffer is returned in ScratchSize, and RETURN_SUCCESS is returned.\r
-  This function does not have scratch buffer available to perform a thorough\r
-  checking of the validity of the source data. It just retrieves the "Original Size"\r
-  field from the LZMA_HEADER_SIZE beginning bytes of the source data and output it as DestinationSize.\r
-  And ScratchSize is specific to the decompression implementation.\r
-\r
-  If SourceSize is less than LZMA_HEADER_SIZE, then ASSERT().\r
-\r
-  @param  Source          The source buffer containing the compressed data.\r
-  @param  SourceSize      The size, in bytes, of the source buffer.\r
-  @param  DestinationSize A pointer to the size, in bytes, of the uncompressed buffer\r
-                          that will be generated when the compressed buffer specified\r
-                          by Source and SourceSize is decompressed.\r
-  @param  ScratchSize     A pointer to the size, in bytes, of the scratch buffer that\r
-                          is required to decompress the compressed buffer specified\r
-                          by Source and SourceSize.\r
-\r
-  @retval  RETURN_SUCCESS The size of the uncompressed data was returned\r
-                          in DestinationSize and the size of the scratch\r
-                          buffer was returned in ScratchSize.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaUefiDecompressGetInfo (\r
-  IN  CONST VOID  *Source,\r
-  IN  UINT32      SourceSize,\r
-  OUT UINT32      *DestinationSize,\r
-  OUT UINT32      *ScratchSize\r
-  );\r
-\r
-/**\r
-  Decompresses a Lzma compressed source buffer.\r
-\r
-  Extracts decompressed data to its original form.\r
-  If the compressed source data specified by Source is successfully decompressed\r
-  into Destination, then RETURN_SUCCESS is returned.  If the compressed source data\r
-  specified by Source is not in a valid compressed data format,\r
-  then RETURN_INVALID_PARAMETER is returned.\r
-\r
-  @param  Source      The source buffer containing the compressed data.\r
-  @param  SourceSize  The size of source buffer.\r
-  @param  Destination The destination buffer to store the decompressed data\r
-  @param  Scratch     A temporary scratch buffer that is used to perform the decompression.\r
-                      This is an optional parameter that may be NULL if the\r
-                      required scratch buffer size is 0.\r
-\r
-  @retval  RETURN_SUCCESS Decompression completed successfully, and\r
-                          the uncompressed buffer is returned in Destination.\r
-  @retval  RETURN_INVALID_PARAMETER\r
-                          The source buffer specified by Source is corrupted\r
-                          (not in a valid compressed format).\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaUefiDecompress (\r
-  IN CONST VOID  *Source,\r
-  IN UINTN       SourceSize,\r
-  IN OUT VOID    *Destination,\r
-  IN OUT VOID    *Scratch\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h
deleted file mode 100644 (file)
index a5fcb50..0000000
+++ /dev/null
@@ -1,378 +0,0 @@
-/* 7zTypes.h -- Basic types\r
-2017-07-17 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_TYPES_H\r
-#define __7Z_TYPES_H\r
-\r
-#ifdef _WIN32\r
-/* #include <windows.h> */\r
-#endif\r
-\r
-#ifdef EFIAPI\r
-#include "UefiLzma.h"\r
-#else\r
-#include <stddef.h>\r
-#endif\r
-\r
-#ifndef EXTERN_C_BEGIN\r
-#ifdef __cplusplus\r
-#define EXTERN_C_BEGIN extern "C" {\r
-#define EXTERN_C_END }\r
-#else\r
-#define EXTERN_C_BEGIN\r
-#define EXTERN_C_END\r
-#endif\r
-#endif\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define SZ_OK 0\r
-\r
-#define SZ_ERROR_DATA 1\r
-#define SZ_ERROR_MEM 2\r
-#define SZ_ERROR_CRC 3\r
-#define SZ_ERROR_UNSUPPORTED 4\r
-#define SZ_ERROR_PARAM 5\r
-#define SZ_ERROR_INPUT_EOF 6\r
-#define SZ_ERROR_OUTPUT_EOF 7\r
-#define SZ_ERROR_READ 8\r
-#define SZ_ERROR_WRITE 9\r
-#define SZ_ERROR_PROGRESS 10\r
-#define SZ_ERROR_FAIL 11\r
-#define SZ_ERROR_THREAD 12\r
-\r
-#define SZ_ERROR_ARCHIVE 16\r
-#define SZ_ERROR_NO_ARCHIVE 17\r
-\r
-typedef int SRes;\r
-\r
-\r
-#ifdef _WIN32\r
-\r
-/* typedef DWORD WRes; */\r
-typedef unsigned WRes;\r
-#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x)\r
-\r
-#else\r
-\r
-typedef int WRes;\r
-#define MY__FACILITY_WIN32 7\r
-#define MY__FACILITY__WRes MY__FACILITY_WIN32\r
-#define MY_SRes_HRESULT_FROM_WRes(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (MY__FACILITY__WRes << 16) | 0x80000000)))\r
-\r
-#endif\r
-\r
-\r
-#ifndef RINOK\r
-#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }\r
-#endif\r
-\r
-typedef unsigned char Byte;\r
-typedef short Int16;\r
-typedef unsigned short UInt16;\r
-\r
-#ifdef _LZMA_UINT32_IS_ULONG\r
-typedef long Int32;\r
-typedef unsigned long UInt32;\r
-#else\r
-typedef int Int32;\r
-typedef unsigned int UInt32;\r
-#endif\r
-\r
-#ifdef _SZ_NO_INT_64\r
-\r
-/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.\r
-   NOTES: Some code will work incorrectly in that case! */\r
-\r
-typedef long Int64;\r
-typedef unsigned long UInt64;\r
-\r
-#else\r
-\r
-#if defined(_MSC_VER) || defined(__BORLANDC__)\r
-typedef __int64 Int64;\r
-typedef unsigned __int64 UInt64;\r
-#define UINT64_CONST(n) n\r
-#else\r
-typedef long long int Int64;\r
-typedef unsigned long long int UInt64;\r
-#define UINT64_CONST(n) n ## ULL\r
-#endif\r
-\r
-#endif\r
-\r
-#ifdef _LZMA_NO_SYSTEM_SIZE_T\r
-typedef UInt32 SizeT;\r
-#else\r
-typedef size_t SizeT;\r
-#endif\r
-\r
-typedef int Bool;\r
-#define True 1\r
-#define False 0\r
-\r
-\r
-#ifdef _WIN32\r
-#define MY_STD_CALL __stdcall\r
-#else\r
-#define MY_STD_CALL\r
-#endif\r
-\r
-#ifdef _MSC_VER\r
-\r
-#if _MSC_VER >= 1300\r
-#define MY_NO_INLINE __declspec(noinline)\r
-#else\r
-#define MY_NO_INLINE\r
-#endif\r
-\r
-#define MY_FORCE_INLINE __forceinline\r
-\r
-#define MY_CDECL __cdecl\r
-#define MY_FAST_CALL __fastcall\r
-\r
-#else\r
-\r
-#define MY_NO_INLINE\r
-#define MY_FORCE_INLINE\r
-#define MY_CDECL\r
-#define MY_FAST_CALL\r
-\r
-/* inline keyword : for C++ / C99 */\r
-\r
-/* GCC, clang: */\r
-/*\r
-#if defined (__GNUC__) && (__GNUC__ >= 4)\r
-#define MY_FORCE_INLINE __attribute__((always_inline))\r
-#define MY_NO_INLINE __attribute__((noinline))\r
-#endif\r
-*/\r
-\r
-#endif\r
-\r
-\r
-/* The following interfaces use first parameter as pointer to structure */\r
-\r
-typedef struct IByteIn IByteIn;\r
-struct IByteIn\r
-{\r
-  Byte (*Read)(const IByteIn *p); /* reads one byte, returns 0 in case of EOF or error */\r
-};\r
-#define IByteIn_Read(p) (p)->Read(p)\r
-\r
-\r
-typedef struct IByteOut IByteOut;\r
-struct IByteOut\r
-{\r
-  void (*Write)(const IByteOut *p, Byte b);\r
-};\r
-#define IByteOut_Write(p, b) (p)->Write(p, b)\r
-\r
-\r
-typedef struct ISeqInStream ISeqInStream;\r
-struct ISeqInStream\r
-{\r
-  SRes (*Read)(const ISeqInStream *p, void *buf, size_t *size);\r
-    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.\r
-       (output(*size) < input(*size)) is allowed */\r
-};\r
-#define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size)\r
-\r
-/* it can return SZ_ERROR_INPUT_EOF */\r
-SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size);\r
-SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType);\r
-SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf);\r
-\r
-\r
-typedef struct ISeqOutStream ISeqOutStream;\r
-struct ISeqOutStream\r
-{\r
-  size_t (*Write)(const ISeqOutStream *p, const void *buf, size_t size);\r
-    /* Returns: result - the number of actually written bytes.\r
-       (result < size) means error */\r
-};\r
-#define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size)\r
-\r
-typedef enum\r
-{\r
-  SZ_SEEK_SET = 0,\r
-  SZ_SEEK_CUR = 1,\r
-  SZ_SEEK_END = 2\r
-} ESzSeek;\r
-\r
-\r
-typedef struct ISeekInStream ISeekInStream;\r
-struct ISeekInStream\r
-{\r
-  SRes (*Read)(const ISeekInStream *p, void *buf, size_t *size);  /* same as ISeqInStream::Read */\r
-  SRes (*Seek)(const ISeekInStream *p, Int64 *pos, ESzSeek origin);\r
-};\r
-#define ISeekInStream_Read(p, buf, size)   (p)->Read(p, buf, size)\r
-#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)\r
-\r
-\r
-typedef struct ILookInStream ILookInStream;\r
-struct ILookInStream\r
-{\r
-  SRes (*Look)(const ILookInStream *p, const void **buf, size_t *size);\r
-    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.\r
-       (output(*size) > input(*size)) is not allowed\r
-       (output(*size) < input(*size)) is allowed */\r
-  SRes (*Skip)(const ILookInStream *p, size_t offset);\r
-    /* offset must be <= output(*size) of Look */\r
-\r
-  SRes (*Read)(const ILookInStream *p, void *buf, size_t *size);\r
-    /* reads directly (without buffer). It's same as ISeqInStream::Read */\r
-  SRes (*Seek)(const ILookInStream *p, Int64 *pos, ESzSeek origin);\r
-};\r
-\r
-#define ILookInStream_Look(p, buf, size)   (p)->Look(p, buf, size)\r
-#define ILookInStream_Skip(p, offset)      (p)->Skip(p, offset)\r
-#define ILookInStream_Read(p, buf, size)   (p)->Read(p, buf, size)\r
-#define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)\r
-\r
-\r
-SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size);\r
-SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset);\r
-\r
-/* reads via ILookInStream::Read */\r
-SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType);\r
-SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size);\r
-\r
-\r
-\r
-typedef struct\r
-{\r
-  ILookInStream vt;\r
-  const ISeekInStream *realStream;\r
\r
-  size_t pos;\r
-  size_t size; /* it's data size */\r
-  \r
-  /* the following variables must be set outside */\r
-  Byte *buf;\r
-  size_t bufSize;\r
-} CLookToRead2;\r
-\r
-void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead);\r
-\r
-#define LookToRead2_Init(p) { (p)->pos = (p)->size = 0; }\r
-\r
-\r
-typedef struct\r
-{\r
-  ISeqInStream vt;\r
-  const ILookInStream *realStream;\r
-} CSecToLook;\r
-\r
-void SecToLook_CreateVTable(CSecToLook *p);\r
-\r
-\r
-\r
-typedef struct\r
-{\r
-  ISeqInStream vt;\r
-  const ILookInStream *realStream;\r
-} CSecToRead;\r
-\r
-void SecToRead_CreateVTable(CSecToRead *p);\r
-\r
-\r
-typedef struct ICompressProgress ICompressProgress;\r
-\r
-struct ICompressProgress\r
-{\r
-  SRes (*Progress)(const ICompressProgress *p, UInt64 inSize, UInt64 outSize);\r
-    /* Returns: result. (result != SZ_OK) means break.\r
-       Value (UInt64)(Int64)-1 for size means unknown value. */\r
-};\r
-#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize)\r
-\r
-\r
-\r
-typedef struct ISzAlloc ISzAlloc;\r
-typedef const ISzAlloc * ISzAllocPtr;\r
-\r
-struct ISzAlloc\r
-{\r
-  void *(*Alloc)(ISzAllocPtr p, size_t size);\r
-  void (*Free)(ISzAllocPtr p, void *address); /* address can be 0 */\r
-};\r
-\r
-#define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size)\r
-#define ISzAlloc_Free(p, a) (p)->Free(p, a)\r
-\r
-/* deprecated */\r
-#define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size)\r
-#define IAlloc_Free(p, a) ISzAlloc_Free(p, a)\r
-\r
-\r
-\r
-\r
-\r
-#ifndef MY_offsetof\r
-  #ifdef offsetof\r
-    #define MY_offsetof(type, m) offsetof(type, m)\r
-    /*\r
-    #define MY_offsetof(type, m) FIELD_OFFSET(type, m)\r
-    */\r
-  #else\r
-    #define MY_offsetof(type, m) ((size_t)&(((type *)0)->m))\r
-  #endif\r
-#endif\r
-\r
-\r
-\r
-#ifndef MY_container_of\r
-\r
-/*\r
-#define MY_container_of(ptr, type, m) container_of(ptr, type, m)\r
-#define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m)\r
-#define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m)))\r
-#define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m))))\r
-*/\r
-\r
-/*\r
-  GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly"\r
-    GCC 3.4.4 : classes with constructor\r
-    GCC 4.8.1 : classes with non-public variable members"\r
-*/\r
-\r
-#define MY_container_of(ptr, type, m) ((type *)((char *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m)))\r
-\r
-\r
-#endif\r
-\r
-#define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(ptr))\r
-\r
-/*\r
-#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)\r
-*/\r
-#define CONTAINER_FROM_VTBL(ptr, type, m) MY_container_of(ptr, type, m)\r
-\r
-#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)\r
-/*\r
-#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m)\r
-*/\r
-\r
-\r
-\r
-#ifdef _WIN32\r
-\r
-#define CHAR_PATH_SEPARATOR '\\'\r
-#define WCHAR_PATH_SEPARATOR L'\\'\r
-#define STRING_PATH_SEPARATOR "\\"\r
-#define WSTRING_PATH_SEPARATOR L"\\"\r
-\r
-#else\r
-\r
-#define CHAR_PATH_SEPARATOR '/'\r
-#define WCHAR_PATH_SEPARATOR L'/'\r
-#define STRING_PATH_SEPARATOR "/"\r
-#define WSTRING_PATH_SEPARATOR L"/"\r
-\r
-#endif\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zVersion.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zVersion.h
deleted file mode 100644 (file)
index ed3aa94..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#define MY_VER_MAJOR 18\r
-#define MY_VER_MINOR 05\r
-#define MY_VER_BUILD 0\r
-#define MY_VERSION_NUMBERS "18.05"\r
-#define MY_VERSION MY_VERSION_NUMBERS\r
-\r
-#ifdef MY_CPU_NAME\r
-  #define MY_VERSION_CPU MY_VERSION " (" MY_CPU_NAME ")"\r
-#else\r
-  #define MY_VERSION_CPU MY_VERSION\r
-#endif\r
-\r
-#define MY_DATE "2018-04-30"\r
-#undef MY_COPYRIGHT\r
-#undef MY_VERSION_COPYRIGHT_DATE\r
-#define MY_AUTHOR_NAME "Igor Pavlov"\r
-#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain"\r
-#define MY_COPYRIGHT_CR "Copyright (c) 1999-2018 Igor Pavlov"\r
-\r
-#ifdef USE_COPYRIGHT_CR\r
-  #define MY_COPYRIGHT MY_COPYRIGHT_CR\r
-#else\r
-  #define MY_COPYRIGHT MY_COPYRIGHT_PD\r
-#endif\r
-\r
-#define MY_COPYRIGHT_DATE MY_COPYRIGHT " : " MY_DATE\r
-#define MY_VERSION_COPYRIGHT_DATE MY_VERSION_CPU " : " MY_COPYRIGHT " : " MY_DATE\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra.h
deleted file mode 100644 (file)
index aba8dce..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Bra.h -- Branch converters for executables\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __BRA_H\r
-#define __BRA_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-/*\r
-These functions convert relative addresses to absolute addresses\r
-in CALL instructions to increase the compression ratio.\r
-  \r
-  In:\r
-    data     - data buffer\r
-    size     - size of data\r
-    ip       - current virtual Instruction Pinter (IP) value\r
-    state    - state variable for x86 converter\r
-    encoding - 0 (for decoding), 1 (for encoding)\r
-  \r
-  Out:\r
-    state    - state variable for x86 converter\r
-\r
-  Returns:\r
-    The number of processed bytes. If you call these functions with multiple calls,\r
-    you must start next call with first byte after block of processed bytes.\r
-  \r
-  Type   Endian  Alignment  LookAhead\r
-  \r
-  x86    little      1          4\r
-  ARMT   little      2          2\r
-  ARM    little      4          0\r
-  PPC     big        4          0\r
-  SPARC   big        4          0\r
-  IA64   little     16          0\r
-\r
-  size must be >= Alignment + LookAhead, if it's not last block.\r
-  If (size < Alignment + LookAhead), converter returns 0.\r
-\r
-  Example:\r
-\r
-    UInt32 ip = 0;\r
-    for ()\r
-    {\r
-      ; size must be >= Alignment + LookAhead, if it's not last block\r
-      SizeT processed = Convert(data, size, ip, 1);\r
-      data += processed;\r
-      size -= processed;\r
-      ip += processed;\r
-    }\r
-*/\r
-\r
-#define x86_Convert_Init(state) { state = 0; }\r
-SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding);\r
-SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra86.c b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra86.c
deleted file mode 100644 (file)
index a6463c6..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Bra86.c -- Converter for x86 code (BCJ)\r
-2017-04-03 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Bra.h"\r
-\r
-#define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0)\r
-\r
-SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)\r
-{\r
-  SizeT pos = 0;\r
-  UInt32 mask = *state & 7;\r
-  if (size < 5)\r
-    return 0;\r
-  size -= 4;\r
-  ip += 5;\r
-\r
-  for (;;)\r
-  {\r
-    Byte *p = data + pos;\r
-    const Byte *limit = data + size;\r
-    for (; p < limit; p++)\r
-      if ((*p & 0xFE) == 0xE8)\r
-        break;\r
-\r
-    {\r
-      SizeT d = (SizeT)(p - data - pos);\r
-      pos = (SizeT)(p - data);\r
-      if (p >= limit)\r
-      {\r
-        *state = (d > 2 ? 0 : mask >> (unsigned)d);\r
-        return pos;\r
-      }\r
-      if (d > 2)\r
-        mask = 0;\r
-      else\r
-      {\r
-        mask >>= (unsigned)d;\r
-        if (mask != 0 && (mask > 4 || mask == 3 || Test86MSByte(p[(size_t)(mask >> 1) + 1])))\r
-        {\r
-          mask = (mask >> 1) | 4;\r
-          pos++;\r
-          continue;\r
-        }\r
-      }\r
-    }\r
-\r
-    if (Test86MSByte(p[4]))\r
-    {\r
-      UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);\r
-      UInt32 cur = ip + (UInt32)pos;\r
-      pos += 5;\r
-      if (encoding)\r
-        v += cur;\r
-      else\r
-        v -= cur;\r
-      if (mask != 0)\r
-      {\r
-        unsigned sh = (mask & 6) << 2;\r
-        if (Test86MSByte((Byte)(v >> sh)))\r
-        {\r
-          v ^= (((UInt32)0x100 << sh) - 1);\r
-          if (encoding)\r
-            v += cur;\r
-          else\r
-            v -= cur;\r
-        }\r
-        mask = 0;\r
-      }\r
-      p[1] = (Byte)v;\r
-      p[2] = (Byte)(v >> 8);\r
-      p[3] = (Byte)(v >> 16);\r
-      p[4] = (Byte)(0 - ((v >> 24) & 1));\r
-    }\r
-    else\r
-    {\r
-      mask = (mask >> 1) | 4;\r
-      pos++;\r
-    }\r
-  }\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Compiler.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Compiler.h
deleted file mode 100644 (file)
index c788648..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Compiler.h\r
-2017-04-03 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_COMPILER_H\r
-#define __7Z_COMPILER_H\r
-\r
-#ifdef _MSC_VER\r
-\r
-  #ifdef UNDER_CE\r
-    #define RPC_NO_WINDOWS_H\r
-    /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */\r
-    #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union\r
-    #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int\r
-  #endif\r
-\r
-  #if _MSC_VER >= 1300\r
-    #pragma warning(disable : 4996) // This function or variable may be unsafe\r
-  #else\r
-    #pragma warning(disable : 4511) // copy constructor could not be generated\r
-    #pragma warning(disable : 4512) // assignment operator could not be generated\r
-    #pragma warning(disable : 4514) // unreferenced inline function has been removed\r
-    #pragma warning(disable : 4702) // unreachable code\r
-    #pragma warning(disable : 4710) // not inlined\r
-    #pragma warning(disable : 4714) // function marked as __forceinline not inlined\r
-    #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information\r
-  #endif\r
-\r
-#endif\r
-\r
-#define UNUSED_VAR(x) (void)x;\r
-/* #define UNUSED_VAR(x) x=x; */\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/CpuArch.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/CpuArch.h
deleted file mode 100644 (file)
index 7fb2728..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-/* CpuArch.h -- CPU specific code\r
-2017-09-04 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __CPU_ARCH_H\r
-#define __CPU_ARCH_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-/*\r
-MY_CPU_LE means that CPU is LITTLE ENDIAN.\r
-MY_CPU_BE means that CPU is BIG ENDIAN.\r
-If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of platform.\r
-\r
-MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.\r
-*/\r
-\r
-#if  defined(_M_X64) \\r
-  || defined(_M_AMD64) \\r
-  || defined(__x86_64__) \\r
-  || defined(__AMD64__) \\r
-  || defined(__amd64__)\r
-  #define MY_CPU_AMD64\r
-  #ifdef __ILP32__\r
-    #define MY_CPU_NAME "x32"\r
-  #else\r
-    #define MY_CPU_NAME "x64"\r
-  #endif\r
-  #define MY_CPU_64BIT\r
-#endif\r
-\r
-\r
-#if  defined(_M_IX86) \\r
-  || defined(__i386__)\r
-  #define MY_CPU_X86\r
-  #define MY_CPU_NAME "x86"\r
-  #define MY_CPU_32BIT\r
-#endif\r
-\r
-\r
-#if  defined(_M_ARM64) \\r
-  || defined(__AARCH64EL__) \\r
-  || defined(__AARCH64EB__) \\r
-  || defined(__aarch64__)\r
-  #define MY_CPU_ARM64\r
-  #define MY_CPU_NAME "arm64"\r
-  #define MY_CPU_64BIT\r
-#endif\r
-\r
-\r
-#if  defined(_M_ARM) \\r
-  || defined(_M_ARM_NT) \\r
-  || defined(_M_ARMT) \\r
-  || defined(__arm__) \\r
-  || defined(__thumb__) \\r
-  || defined(__ARMEL__) \\r
-  || defined(__ARMEB__) \\r
-  || defined(__THUMBEL__) \\r
-  || defined(__THUMBEB__)\r
-  #define MY_CPU_ARM\r
-  #define MY_CPU_NAME "arm"\r
-  #define MY_CPU_32BIT\r
-#endif\r
-\r
-\r
-#if  defined(_M_IA64) \\r
-  || defined(__ia64__)\r
-  #define MY_CPU_IA64\r
-  #define MY_CPU_NAME "ia64"\r
-  #define MY_CPU_64BIT\r
-#endif\r
-\r
-\r
-#if  defined(__mips64) \\r
-  || defined(__mips64__) \\r
-  || (defined(__mips) && (__mips == 64 || __mips == 4 || __mips == 3))\r
-  #define MY_CPU_NAME "mips64"\r
-  #define MY_CPU_64BIT\r
-#elif defined(__mips__)\r
-  #define MY_CPU_NAME "mips"\r
-  /* #define MY_CPU_32BIT */\r
-#endif\r
-\r
-\r
-#if  defined(__ppc64__) \\r
-  || defined(__powerpc64__)\r
-  #ifdef __ILP32__\r
-    #define MY_CPU_NAME "ppc64-32"\r
-  #else\r
-    #define MY_CPU_NAME "ppc64"\r
-  #endif\r
-  #define MY_CPU_64BIT\r
-#elif defined(__ppc__) \\r
-  || defined(__powerpc__)\r
-  #define MY_CPU_NAME "ppc"\r
-  #define MY_CPU_32BIT\r
-#endif\r
-\r
-\r
-#if  defined(__sparc64__)\r
-  #define MY_CPU_NAME "sparc64"\r
-  #define MY_CPU_64BIT\r
-#elif defined(__sparc__)\r
-  #define MY_CPU_NAME "sparc"\r
-  /* #define MY_CPU_32BIT */\r
-#endif\r
-\r
-\r
-#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64)\r
-#define MY_CPU_X86_OR_AMD64\r
-#endif\r
-\r
-\r
-#ifdef _WIN32\r
-\r
-  #ifdef MY_CPU_ARM\r
-  #define MY_CPU_ARM_LE\r
-  #endif\r
-\r
-  #ifdef MY_CPU_ARM64\r
-  #define MY_CPU_ARM64_LE\r
-  #endif\r
-\r
-  #ifdef _M_IA64\r
-  #define MY_CPU_IA64_LE\r
-  #endif\r
-\r
-#endif\r
-\r
-\r
-#if defined(MY_CPU_X86_OR_AMD64) \\r
-    || defined(MY_CPU_ARM_LE) \\r
-    || defined(MY_CPU_ARM64_LE) \\r
-    || defined(MY_CPU_IA64_LE) \\r
-    || defined(__LITTLE_ENDIAN__) \\r
-    || defined(__ARMEL__) \\r
-    || defined(__THUMBEL__) \\r
-    || defined(__AARCH64EL__) \\r
-    || defined(__MIPSEL__) \\r
-    || defined(__MIPSEL) \\r
-    || defined(_MIPSEL) \\r
-    || defined(__BFIN__) \\r
-    || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))\r
-  #define MY_CPU_LE\r
-#endif\r
-\r
-#if defined(__BIG_ENDIAN__) \\r
-    || defined(__ARMEB__) \\r
-    || defined(__THUMBEB__) \\r
-    || defined(__AARCH64EB__) \\r
-    || defined(__MIPSEB__) \\r
-    || defined(__MIPSEB) \\r
-    || defined(_MIPSEB) \\r
-    || defined(__m68k__) \\r
-    || defined(__s390__) \\r
-    || defined(__s390x__) \\r
-    || defined(__zarch__) \\r
-    || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))\r
-  #define MY_CPU_BE\r
-#endif\r
-\r
-\r
-#if defined(MY_CPU_LE) && defined(MY_CPU_BE)\r
-  #error Stop_Compiling_Bad_Endian\r
-#endif\r
-\r
-\r
-#if defined(MY_CPU_32BIT) && defined(MY_CPU_64BIT)\r
-  #error Stop_Compiling_Bad_32_64_BIT\r
-#endif\r
-\r
-\r
-#ifndef MY_CPU_NAME\r
-  #ifdef MY_CPU_LE\r
-    #define MY_CPU_NAME "LE"\r
-  #elif defined(MY_CPU_BE)\r
-    #define MY_CPU_NAME "BE"\r
-  #else\r
-    /*\r
-    #define MY_CPU_NAME ""\r
-    */\r
-  #endif\r
-#endif\r
-\r
-\r
-\r
-\r
-\r
-#ifdef MY_CPU_LE\r
-  #if defined(MY_CPU_X86_OR_AMD64) \\r
-      || defined(MY_CPU_ARM64) \\r
-      || defined(__ARM_FEATURE_UNALIGNED)\r
-    #define MY_CPU_LE_UNALIGN\r
-  #endif\r
-#endif\r
-\r
-\r
-#ifdef MY_CPU_LE_UNALIGN\r
-\r
-#define GetUi16(p) (*(const UInt16 *)(const void *)(p))\r
-#define GetUi32(p) (*(const UInt32 *)(const void *)(p))\r
-#define GetUi64(p) (*(const UInt64 *)(const void *)(p))\r
-\r
-#define SetUi16(p, v) { *(UInt16 *)(p) = (v); }\r
-#define SetUi32(p, v) { *(UInt32 *)(p) = (v); }\r
-#define SetUi64(p, v) { *(UInt64 *)(p) = (v); }\r
-\r
-#else\r
-\r
-#define GetUi16(p) ( (UInt16) ( \\r
-             ((const Byte *)(p))[0] | \\r
-    ((UInt16)((const Byte *)(p))[1] << 8) ))\r
-\r
-#define GetUi32(p) ( \\r
-             ((const Byte *)(p))[0]        | \\r
-    ((UInt32)((const Byte *)(p))[1] <<  8) | \\r
-    ((UInt32)((const Byte *)(p))[2] << 16) | \\r
-    ((UInt32)((const Byte *)(p))[3] << 24))\r
-\r
-#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))\r
-\r
-#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \\r
-    _ppp_[0] = (Byte)_vvv_; \\r
-    _ppp_[1] = (Byte)(_vvv_ >> 8); }\r
-\r
-#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \\r
-    _ppp_[0] = (Byte)_vvv_; \\r
-    _ppp_[1] = (Byte)(_vvv_ >> 8); \\r
-    _ppp_[2] = (Byte)(_vvv_ >> 16); \\r
-    _ppp_[3] = (Byte)(_vvv_ >> 24); }\r
-\r
-#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \\r
-    SetUi32(_ppp2_    , (UInt32)_vvv2_); \\r
-    SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)); }\r
-\r
-#endif\r
-\r
-#ifdef __has_builtin\r
-  #define MY__has_builtin(x) __has_builtin(x)\r
-#else\r
-  #define MY__has_builtin(x) 0\r
-#endif\r
-\r
-#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)\r
-\r
-/* Note: we use bswap instruction, that is unsupported in 386 cpu */\r
-\r
-#include <stdlib.h>\r
-\r
-#pragma intrinsic(_byteswap_ushort)\r
-#pragma intrinsic(_byteswap_ulong)\r
-#pragma intrinsic(_byteswap_uint64)\r
-\r
-/* #define GetBe16(p) _byteswap_ushort(*(const UInt16 *)(const Byte *)(p)) */\r
-#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))\r
-#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))\r
-\r
-#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)\r
-\r
-#elif defined(MY_CPU_LE_UNALIGN) && ( \\r
-       (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \\r
-    || (defined(__clang__) && MY__has_builtin(__builtin_bswap16)) )\r
-\r
-/* #define GetBe16(p) __builtin_bswap16(*(const UInt16 *)(const Byte *)(p)) */\r
-#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))\r
-#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))\r
-\r
-#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v)\r
-\r
-#else\r
-\r
-#define GetBe32(p) ( \\r
-    ((UInt32)((const Byte *)(p))[0] << 24) | \\r
-    ((UInt32)((const Byte *)(p))[1] << 16) | \\r
-    ((UInt32)((const Byte *)(p))[2] <<  8) | \\r
-             ((const Byte *)(p))[3] )\r
-\r
-#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))\r
-\r
-#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \\r
-    _ppp_[0] = (Byte)(_vvv_ >> 24); \\r
-    _ppp_[1] = (Byte)(_vvv_ >> 16); \\r
-    _ppp_[2] = (Byte)(_vvv_ >> 8); \\r
-    _ppp_[3] = (Byte)_vvv_; }\r
-\r
-#endif\r
-\r
-\r
-#ifndef GetBe16\r
-\r
-#define GetBe16(p) ( (UInt16) ( \\r
-    ((UInt16)((const Byte *)(p))[0] << 8) | \\r
-             ((const Byte *)(p))[1] ))\r
-\r
-#endif\r
-\r
-\r
-\r
-#ifdef MY_CPU_X86_OR_AMD64\r
-\r
-typedef struct\r
-{\r
-  UInt32 maxFunc;\r
-  UInt32 vendor[3];\r
-  UInt32 ver;\r
-  UInt32 b;\r
-  UInt32 c;\r
-  UInt32 d;\r
-} Cx86cpuid;\r
-\r
-enum\r
-{\r
-  CPU_FIRM_INTEL,\r
-  CPU_FIRM_AMD,\r
-  CPU_FIRM_VIA\r
-};\r
-\r
-void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);\r
-\r
-Bool x86cpuid_CheckAndRead(Cx86cpuid *p);\r
-int x86cpuid_GetFirm(const Cx86cpuid *p);\r
-\r
-#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))\r
-#define x86cpuid_GetModel(ver)  (((ver >> 12) &  0xF0) | ((ver >> 4) & 0xF))\r
-#define x86cpuid_GetStepping(ver) (ver & 0xF)\r
-\r
-Bool CPU_Is_InOrder();\r
-Bool CPU_Is_Aes_Supported();\r
-\r
-#endif\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c
deleted file mode 100644 (file)
index 5128fc9..0000000
+++ /dev/null
@@ -1,1071 +0,0 @@
-/* LzFind.c -- Match finder for LZ algorithms\r
-2017-06-10 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#ifndef EFIAPI\r
-#include <string.h>\r
-#endif\r
-\r
-#include "LzFind.h"\r
-#include "LzHash.h"\r
-\r
-#define kEmptyHashValue 0\r
-#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)\r
-#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */\r
-#define kNormalizeMask (~(UInt32)(kNormalizeStepMin - 1))\r
-#define kMaxHistorySize ((UInt32)7 << 29)\r
-\r
-#define kStartMaxLen 3\r
-\r
-static void LzInWindow_Free(CMatchFinder *p, ISzAllocPtr alloc)\r
-{\r
-  if (!p->directInput)\r
-  {\r
-    ISzAlloc_Free(alloc, p->bufferBase);\r
-    p->bufferBase = NULL;\r
-  }\r
-}\r
-\r
-/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */\r
-\r
-static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAllocPtr alloc)\r
-{\r
-  UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;\r
-  if (p->directInput)\r
-  {\r
-    p->blockSize = blockSize;\r
-    return 1;\r
-  }\r
-  if (!p->bufferBase || p->blockSize != blockSize)\r
-  {\r
-    LzInWindow_Free(p, alloc);\r
-    p->blockSize = blockSize;\r
-    p->bufferBase = (Byte *)ISzAlloc_Alloc(alloc, (size_t)blockSize);\r
-  }\r
-  return (p->bufferBase != NULL);\r
-}\r
-\r
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }\r
-\r
-UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }\r
-\r
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)\r
-{\r
-  p->posLimit -= subValue;\r
-  p->pos -= subValue;\r
-  p->streamPos -= subValue;\r
-}\r
-\r
-static void MatchFinder_ReadBlock(CMatchFinder *p)\r
-{\r
-  if (p->streamEndWasReached || p->result != SZ_OK)\r
-    return;\r
-\r
-  /* We use (p->streamPos - p->pos) value. (p->streamPos < p->pos) is allowed. */\r
-\r
-  if (p->directInput)\r
-  {\r
-    UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos);\r
-    if (curSize > p->directInputRem)\r
-      curSize = (UInt32)p->directInputRem;\r
-    p->directInputRem -= curSize;\r
-    p->streamPos += curSize;\r
-    if (p->directInputRem == 0)\r
-      p->streamEndWasReached = 1;\r
-    return;\r
-  }\r
-  \r
-  for (;;)\r
-  {\r
-    Byte *dest = p->buffer + (p->streamPos - p->pos);\r
-    size_t size = (p->bufferBase + p->blockSize - dest);\r
-    if (size == 0)\r
-      return;\r
-\r
-    p->result = ISeqInStream_Read(p->stream, dest, &size);\r
-    if (p->result != SZ_OK)\r
-      return;\r
-    if (size == 0)\r
-    {\r
-      p->streamEndWasReached = 1;\r
-      return;\r
-    }\r
-    p->streamPos += (UInt32)size;\r
-    if (p->streamPos - p->pos > p->keepSizeAfter)\r
-      return;\r
-  }\r
-}\r
-\r
-void MatchFinder_MoveBlock(CMatchFinder *p)\r
-{\r
-  memmove(p->bufferBase,\r
-      p->buffer - p->keepSizeBefore,\r
-      (size_t)(p->streamPos - p->pos) + p->keepSizeBefore);\r
-  p->buffer = p->bufferBase + p->keepSizeBefore;\r
-}\r
-\r
-int MatchFinder_NeedMove(CMatchFinder *p)\r
-{\r
-  if (p->directInput)\r
-    return 0;\r
-  /* if (p->streamEndWasReached) return 0; */\r
-  return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);\r
-}\r
-\r
-void MatchFinder_ReadIfRequired(CMatchFinder *p)\r
-{\r
-  if (p->streamEndWasReached)\r
-    return;\r
-  if (p->keepSizeAfter >= p->streamPos - p->pos)\r
-    MatchFinder_ReadBlock(p);\r
-}\r
-\r
-static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)\r
-{\r
-  if (MatchFinder_NeedMove(p))\r
-    MatchFinder_MoveBlock(p);\r
-  MatchFinder_ReadBlock(p);\r
-}\r
-\r
-static void MatchFinder_SetDefaultSettings(CMatchFinder *p)\r
-{\r
-  p->cutValue = 32;\r
-  p->btMode = 1;\r
-  p->numHashBytes = 4;\r
-  p->bigHash = 0;\r
-}\r
-\r
-#define kCrcPoly 0xEDB88320\r
-\r
-void MatchFinder_Construct(CMatchFinder *p)\r
-{\r
-  UInt32 i;\r
-  p->bufferBase = NULL;\r
-  p->directInput = 0;\r
-  p->hash = NULL;\r
-  p->expectedDataSize = (UInt64)(Int64)-1;\r
-  MatchFinder_SetDefaultSettings(p);\r
-\r
-  for (i = 0; i < 256; i++)\r
-  {\r
-    UInt32 r = i;\r
-    unsigned j;\r
-    for (j = 0; j < 8; j++)\r
-      r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));\r
-    p->crc[i] = r;\r
-  }\r
-}\r
-\r
-static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAllocPtr alloc)\r
-{\r
-  ISzAlloc_Free(alloc, p->hash);\r
-  p->hash = NULL;\r
-}\r
-\r
-void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc)\r
-{\r
-  MatchFinder_FreeThisClassMemory(p, alloc);\r
-  LzInWindow_Free(p, alloc);\r
-}\r
-\r
-static CLzRef* AllocRefs(size_t num, ISzAllocPtr alloc)\r
-{\r
-  size_t sizeInBytes = (size_t)num * sizeof(CLzRef);\r
-  if (sizeInBytes / sizeof(CLzRef) != num)\r
-    return NULL;\r
-  return (CLzRef *)ISzAlloc_Alloc(alloc, sizeInBytes);\r
-}\r
-\r
-int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,\r
-    UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,\r
-    ISzAllocPtr alloc)\r
-{\r
-  UInt32 sizeReserv;\r
-  \r
-  if (historySize > kMaxHistorySize)\r
-  {\r
-    MatchFinder_Free(p, alloc);\r
-    return 0;\r
-  }\r
-  \r
-  sizeReserv = historySize >> 1;\r
-       if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3;\r
-  else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2;\r
-  \r
-  sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);\r
-\r
-  p->keepSizeBefore = historySize + keepAddBufferBefore + 1;\r
-  p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;\r
-  \r
-  /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */\r
-  \r
-  if (LzInWindow_Create(p, sizeReserv, alloc))\r
-  {\r
-    UInt32 newCyclicBufferSize = historySize + 1;\r
-    UInt32 hs;\r
-    p->matchMaxLen = matchMaxLen;\r
-    {\r
-      p->fixedHashSize = 0;\r
-      if (p->numHashBytes == 2)\r
-        hs = (1 << 16) - 1;\r
-      else\r
-      {\r
-        hs = historySize;\r
-        if (hs > p->expectedDataSize)\r
-          hs = (UInt32)p->expectedDataSize;\r
-        if (hs != 0)\r
-          hs--;\r
-        hs |= (hs >> 1);\r
-        hs |= (hs >> 2);\r
-        hs |= (hs >> 4);\r
-        hs |= (hs >> 8);\r
-        hs >>= 1;\r
-        hs |= 0xFFFF; /* don't change it! It's required for Deflate */\r
-        if (hs > (1 << 24))\r
-        {\r
-          if (p->numHashBytes == 3)\r
-            hs = (1 << 24) - 1;\r
-          else\r
-            hs >>= 1;\r
-          /* if (bigHash) mode, GetHeads4b() in LzFindMt.c needs (hs >= ((1 << 24) - 1))) */\r
-        }\r
-      }\r
-      p->hashMask = hs;\r
-      hs++;\r
-      if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size;\r
-      if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size;\r
-      if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size;\r
-      hs += p->fixedHashSize;\r
-    }\r
-\r
-    {\r
-      size_t newSize;\r
-      size_t numSons;\r
-      p->historySize = historySize;\r
-      p->hashSizeSum = hs;\r
-      p->cyclicBufferSize = newCyclicBufferSize;\r
-      \r
-      numSons = newCyclicBufferSize;\r
-      if (p->btMode)\r
-        numSons <<= 1;\r
-      newSize = hs + numSons;\r
-\r
-      if (p->hash && p->numRefs == newSize)\r
-        return 1;\r
-      \r
-      MatchFinder_FreeThisClassMemory(p, alloc);\r
-      p->numRefs = newSize;\r
-      p->hash = AllocRefs(newSize, alloc);\r
-      \r
-      if (p->hash)\r
-      {\r
-        p->son = p->hash + p->hashSizeSum;\r
-        return 1;\r
-      }\r
-    }\r
-  }\r
-\r
-  MatchFinder_Free(p, alloc);\r
-  return 0;\r
-}\r
-\r
-static void MatchFinder_SetLimits(CMatchFinder *p)\r
-{\r
-  UInt32 limit = kMaxValForNormalize - p->pos;\r
-  UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;\r
-  \r
-  if (limit2 < limit)\r
-    limit = limit2;\r
-  limit2 = p->streamPos - p->pos;\r
-  \r
-  if (limit2 <= p->keepSizeAfter)\r
-  {\r
-    if (limit2 > 0)\r
-      limit2 = 1;\r
-  }\r
-  else\r
-    limit2 -= p->keepSizeAfter;\r
-  \r
-  if (limit2 < limit)\r
-    limit = limit2;\r
-  \r
-  {\r
-    UInt32 lenLimit = p->streamPos - p->pos;\r
-    if (lenLimit > p->matchMaxLen)\r
-      lenLimit = p->matchMaxLen;\r
-    p->lenLimit = lenLimit;\r
-  }\r
-  p->posLimit = p->pos + limit;\r
-}\r
-\r
-\r
-void MatchFinder_Init_LowHash(CMatchFinder *p)\r
-{\r
-  size_t i;\r
-  CLzRef *items = p->hash;\r
-  size_t numItems = p->fixedHashSize;\r
-  for (i = 0; i < numItems; i++)\r
-    items[i] = kEmptyHashValue;\r
-}\r
-\r
-\r
-void MatchFinder_Init_HighHash(CMatchFinder *p)\r
-{\r
-  size_t i;\r
-  CLzRef *items = p->hash + p->fixedHashSize;\r
-  size_t numItems = (size_t)p->hashMask + 1;\r
-  for (i = 0; i < numItems; i++)\r
-    items[i] = kEmptyHashValue;\r
-}\r
-\r
-\r
-void MatchFinder_Init_3(CMatchFinder *p, int readData)\r
-{\r
-  p->cyclicBufferPos = 0;\r
-  p->buffer = p->bufferBase;\r
-  p->pos =\r
-  p->streamPos = p->cyclicBufferSize;\r
-  p->result = SZ_OK;\r
-  p->streamEndWasReached = 0;\r
-  \r
-  if (readData)\r
-    MatchFinder_ReadBlock(p);\r
-  \r
-  MatchFinder_SetLimits(p);\r
-}\r
-\r
-\r
-void MatchFinder_Init(CMatchFinder *p)\r
-{\r
-  MatchFinder_Init_HighHash(p);\r
-  MatchFinder_Init_LowHash(p);\r
-  MatchFinder_Init_3(p, True);\r
-}\r
-\r
-  \r
-static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)\r
-{\r
-  return (p->pos - p->historySize - 1) & kNormalizeMask;\r
-}\r
-\r
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems)\r
-{\r
-  size_t i;\r
-  for (i = 0; i < numItems; i++)\r
-  {\r
-    UInt32 value = items[i];\r
-    if (value <= subValue)\r
-      value = kEmptyHashValue;\r
-    else\r
-      value -= subValue;\r
-    items[i] = value;\r
-  }\r
-}\r
-\r
-static void MatchFinder_Normalize(CMatchFinder *p)\r
-{\r
-  UInt32 subValue = MatchFinder_GetSubValue(p);\r
-  MatchFinder_Normalize3(subValue, p->hash, p->numRefs);\r
-  MatchFinder_ReduceOffsets(p, subValue);\r
-}\r
-\r
-static void MatchFinder_CheckLimits(CMatchFinder *p)\r
-{\r
-  if (p->pos == kMaxValForNormalize)\r
-    MatchFinder_Normalize(p);\r
-  if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos)\r
-    MatchFinder_CheckAndMoveAndRead(p);\r
-  if (p->cyclicBufferPos == p->cyclicBufferSize)\r
-    p->cyclicBufferPos = 0;\r
-  MatchFinder_SetLimits(p);\r
-}\r
-\r
-static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,\r
-    UInt32 *distances, UInt32 maxLen)\r
-{\r
-  son[_cyclicBufferPos] = curMatch;\r
-  for (;;)\r
-  {\r
-    UInt32 delta = pos - curMatch;\r
-    if (cutValue-- == 0 || delta >= _cyclicBufferSize)\r
-      return distances;\r
-    {\r
-      const Byte *pb = cur - delta;\r
-      curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];\r
-      if (pb[maxLen] == cur[maxLen] && *pb == *cur)\r
-      {\r
-        UInt32 len = 0;\r
-        while (++len != lenLimit)\r
-          if (pb[len] != cur[len])\r
-            break;\r
-        if (maxLen < len)\r
-        {\r
-          *distances++ = maxLen = len;\r
-          *distances++ = delta - 1;\r
-          if (len == lenLimit)\r
-            return distances;\r
-        }\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,\r
-    UInt32 *distances, UInt32 maxLen)\r
-{\r
-  CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;\r
-  CLzRef *ptr1 = son + (_cyclicBufferPos << 1);\r
-  UInt32 len0 = 0, len1 = 0;\r
-  for (;;)\r
-  {\r
-    UInt32 delta = pos - curMatch;\r
-    if (cutValue-- == 0 || delta >= _cyclicBufferSize)\r
-    {\r
-      *ptr0 = *ptr1 = kEmptyHashValue;\r
-      return distances;\r
-    }\r
-    {\r
-      CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
-      const Byte *pb = cur - delta;\r
-      UInt32 len = (len0 < len1 ? len0 : len1);\r
-      if (pb[len] == cur[len])\r
-      {\r
-        if (++len != lenLimit && pb[len] == cur[len])\r
-          while (++len != lenLimit)\r
-            if (pb[len] != cur[len])\r
-              break;\r
-        if (maxLen < len)\r
-        {\r
-          *distances++ = maxLen = len;\r
-          *distances++ = delta - 1;\r
-          if (len == lenLimit)\r
-          {\r
-            *ptr1 = pair[0];\r
-            *ptr0 = pair[1];\r
-            return distances;\r
-          }\r
-        }\r
-      }\r
-      if (pb[len] < cur[len])\r
-      {\r
-        *ptr1 = curMatch;\r
-        ptr1 = pair + 1;\r
-        curMatch = *ptr1;\r
-        len1 = len;\r
-      }\r
-      else\r
-      {\r
-        *ptr0 = curMatch;\r
-        ptr0 = pair;\r
-        curMatch = *ptr0;\r
-        len0 = len;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)\r
-{\r
-  CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;\r
-  CLzRef *ptr1 = son + (_cyclicBufferPos << 1);\r
-  UInt32 len0 = 0, len1 = 0;\r
-  for (;;)\r
-  {\r
-    UInt32 delta = pos - curMatch;\r
-    if (cutValue-- == 0 || delta >= _cyclicBufferSize)\r
-    {\r
-      *ptr0 = *ptr1 = kEmptyHashValue;\r
-      return;\r
-    }\r
-    {\r
-      CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
-      const Byte *pb = cur - delta;\r
-      UInt32 len = (len0 < len1 ? len0 : len1);\r
-      if (pb[len] == cur[len])\r
-      {\r
-        while (++len != lenLimit)\r
-          if (pb[len] != cur[len])\r
-            break;\r
-        {\r
-          if (len == lenLimit)\r
-          {\r
-            *ptr1 = pair[0];\r
-            *ptr0 = pair[1];\r
-            return;\r
-          }\r
-        }\r
-      }\r
-      if (pb[len] < cur[len])\r
-      {\r
-        *ptr1 = curMatch;\r
-        ptr1 = pair + 1;\r
-        curMatch = *ptr1;\r
-        len1 = len;\r
-      }\r
-      else\r
-      {\r
-        *ptr0 = curMatch;\r
-        ptr0 = pair;\r
-        curMatch = *ptr0;\r
-        len0 = len;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-#define MOVE_POS \\r
-  ++p->cyclicBufferPos; \\r
-  p->buffer++; \\r
-  if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);\r
-\r
-#define MOVE_POS_RET MOVE_POS return offset;\r
-\r
-static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }\r
-\r
-#define GET_MATCHES_HEADER2(minLen, ret_op) \\r
-  UInt32 lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \\r
-  lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \\r
-  cur = p->buffer;\r
-\r
-#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)\r
-#define SKIP_HEADER(minLen)        GET_MATCHES_HEADER2(minLen, continue)\r
-\r
-#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue\r
-\r
-#define GET_MATCHES_FOOTER(offset, maxLen) \\r
-  offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \\r
-  distances + offset, maxLen) - distances); MOVE_POS_RET;\r
-\r
-#define SKIP_FOOTER \\r
-  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;\r
-\r
-#define UPDATE_maxLen { \\r
-    ptrdiff_t diff = (ptrdiff_t)0 - d2; \\r
-    const Byte *c = cur + maxLen; \\r
-    const Byte *lim = cur + lenLimit; \\r
-    for (; c != lim; c++) if (*(c + diff) != *c) break; \\r
-    maxLen = (UInt32)(c - cur); }\r
-\r
-static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 offset;\r
-  GET_MATCHES_HEADER(2)\r
-  HASH2_CALC;\r
-  curMatch = p->hash[hv];\r
-  p->hash[hv] = p->pos;\r
-  offset = 0;\r
-  GET_MATCHES_FOOTER(offset, 1)\r
-}\r
-\r
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 offset;\r
-  GET_MATCHES_HEADER(3)\r
-  HASH_ZIP_CALC;\r
-  curMatch = p->hash[hv];\r
-  p->hash[hv] = p->pos;\r
-  offset = 0;\r
-  GET_MATCHES_FOOTER(offset, 2)\r
-}\r
-\r
-static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, d2, maxLen, offset, pos;\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(3)\r
-\r
-  HASH3_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-\r
-  d2 = pos - hash[h2];\r
-\r
-  curMatch = (hash + kFix3HashSize)[hv];\r
-  \r
-  hash[h2] = pos;\r
-  (hash + kFix3HashSize)[hv] = pos;\r
-\r
-  maxLen = 2;\r
-  offset = 0;\r
-\r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[0] = maxLen;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-  \r
-  GET_MATCHES_FOOTER(offset, maxLen)\r
-}\r
-\r
-static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, d2, d3, maxLen, offset, pos;\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(4)\r
-\r
-  HASH4_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-\r
-  d2 = pos - hash[                h2];\r
-  d3 = pos - (hash + kFix3HashSize)[h3];\r
-\r
-  curMatch = (hash + kFix4HashSize)[hv];\r
-\r
-  hash[                h2] = pos;\r
-  (hash + kFix3HashSize)[h3] = pos;\r
-  (hash + kFix4HashSize)[hv] = pos;\r
-\r
-  maxLen = 0;\r
-  offset = 0;\r
-  \r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    distances[0] = maxLen = 2;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-  }\r
-  \r
-  if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-  {\r
-    maxLen = 3;\r
-    distances[(size_t)offset + 1] = d3 - 1;\r
-    offset += 2;\r
-    d2 = d3;\r
-  }\r
-  \r
-  if (offset != 0)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[(size_t)offset - 2] = maxLen;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-  \r
-  if (maxLen < 3)\r
-    maxLen = 3;\r
-  \r
-  GET_MATCHES_FOOTER(offset, maxLen)\r
-}\r
-\r
-/*\r
-static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, h4, d2, d3, d4, maxLen, offset, pos;\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(5)\r
-\r
-  HASH5_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-\r
-  d2 = pos - hash[                h2];\r
-  d3 = pos - (hash + kFix3HashSize)[h3];\r
-  d4 = pos - (hash + kFix4HashSize)[h4];\r
-\r
-  curMatch = (hash + kFix5HashSize)[hv];\r
-\r
-  hash[                h2] = pos;\r
-  (hash + kFix3HashSize)[h3] = pos;\r
-  (hash + kFix4HashSize)[h4] = pos;\r
-  (hash + kFix5HashSize)[hv] = pos;\r
-\r
-  maxLen = 0;\r
-  offset = 0;\r
-\r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    distances[0] = maxLen = 2;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-    if (*(cur - d2 + 2) == cur[2])\r
-      distances[0] = maxLen = 3;\r
-    else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-    {\r
-      distances[2] = maxLen = 3;\r
-      distances[3] = d3 - 1;\r
-      offset = 4;\r
-      d2 = d3;\r
-    }\r
-  }\r
-  else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-  {\r
-    distances[0] = maxLen = 3;\r
-    distances[1] = d3 - 1;\r
-    offset = 2;\r
-    d2 = d3;\r
-  }\r
-  \r
-  if (d2 != d4 && d4 < p->cyclicBufferSize\r
-      && *(cur - d4) == *cur\r
-      && *(cur - d4 + 3) == *(cur + 3))\r
-  {\r
-    maxLen = 4;\r
-    distances[(size_t)offset + 1] = d4 - 1;\r
-    offset += 2;\r
-    d2 = d4;\r
-  }\r
-  \r
-  if (offset != 0)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[(size_t)offset - 2] = maxLen;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-\r
-  if (maxLen < 4)\r
-    maxLen = 4;\r
-  \r
-  GET_MATCHES_FOOTER(offset, maxLen)\r
-}\r
-*/\r
-\r
-static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, d2, d3, maxLen, offset, pos;\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(4)\r
-\r
-  HASH4_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-  \r
-  d2 = pos - hash[                h2];\r
-  d3 = pos - (hash + kFix3HashSize)[h3];\r
-  \r
-  curMatch = (hash + kFix4HashSize)[hv];\r
-\r
-  hash[                h2] = pos;\r
-  (hash + kFix3HashSize)[h3] = pos;\r
-  (hash + kFix4HashSize)[hv] = pos;\r
-\r
-  maxLen = 0;\r
-  offset = 0;\r
-\r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    distances[0] = maxLen = 2;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-  }\r
-  \r
-  if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-  {\r
-    maxLen = 3;\r
-    distances[(size_t)offset + 1] = d3 - 1;\r
-    offset += 2;\r
-    d2 = d3;\r
-  }\r
-  \r
-  if (offset != 0)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[(size_t)offset - 2] = maxLen;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      p->son[p->cyclicBufferPos] = curMatch;\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-  \r
-  if (maxLen < 3)\r
-    maxLen = 3;\r
-\r
-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
-      distances + offset, maxLen) - (distances));\r
-  MOVE_POS_RET\r
-}\r
-\r
-/*\r
-static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, h4, d2, d3, d4, maxLen, offset, pos\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(5)\r
-\r
-  HASH5_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-  \r
-  d2 = pos - hash[                h2];\r
-  d3 = pos - (hash + kFix3HashSize)[h3];\r
-  d4 = pos - (hash + kFix4HashSize)[h4];\r
-\r
-  curMatch = (hash + kFix5HashSize)[hv];\r
-\r
-  hash[                h2] = pos;\r
-  (hash + kFix3HashSize)[h3] = pos;\r
-  (hash + kFix4HashSize)[h4] = pos;\r
-  (hash + kFix5HashSize)[hv] = pos;\r
-\r
-  maxLen = 0;\r
-  offset = 0;\r
-\r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    distances[0] = maxLen = 2;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-    if (*(cur - d2 + 2) == cur[2])\r
-      distances[0] = maxLen = 3;\r
-    else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-    {\r
-      distances[2] = maxLen = 3;\r
-      distances[3] = d3 - 1;\r
-      offset = 4;\r
-      d2 = d3;\r
-    }\r
-  }\r
-  else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-  {\r
-    distances[0] = maxLen = 3;\r
-    distances[1] = d3 - 1;\r
-    offset = 2;\r
-    d2 = d3;\r
-  }\r
-  \r
-  if (d2 != d4 && d4 < p->cyclicBufferSize\r
-      && *(cur - d4) == *cur\r
-      && *(cur - d4 + 3) == *(cur + 3))\r
-  {\r
-    maxLen = 4;\r
-    distances[(size_t)offset + 1] = d4 - 1;\r
-    offset += 2;\r
-    d2 = d4;\r
-  }\r
-  \r
-  if (offset != 0)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[(size_t)offset - 2] = maxLen;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      p->son[p->cyclicBufferPos] = curMatch;\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-  \r
-  if (maxLen < 4)\r
-    maxLen = 4;\r
-\r
-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
-      distances + offset, maxLen) - (distances));\r
-  MOVE_POS_RET\r
-}\r
-*/\r
-\r
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 offset;\r
-  GET_MATCHES_HEADER(3)\r
-  HASH_ZIP_CALC;\r
-  curMatch = p->hash[hv];\r
-  p->hash[hv] = p->pos;\r
-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
-      distances, 2) - (distances));\r
-  MOVE_POS_RET\r
-}\r
-\r
-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    SKIP_HEADER(2)\r
-    HASH2_CALC;\r
-    curMatch = p->hash[hv];\r
-    p->hash[hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    SKIP_HEADER(3)\r
-    HASH_ZIP_CALC;\r
-    curMatch = p->hash[hv];\r
-    p->hash[hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(3)\r
-    HASH3_CALC;\r
-    hash = p->hash;\r
-    curMatch = (hash + kFix3HashSize)[hv];\r
-    hash[h2] =\r
-    (hash + kFix3HashSize)[hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2, h3;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(4)\r
-    HASH4_CALC;\r
-    hash = p->hash;\r
-    curMatch = (hash + kFix4HashSize)[hv];\r
-    hash[                h2] =\r
-    (hash + kFix3HashSize)[h3] =\r
-    (hash + kFix4HashSize)[hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-/*\r
-static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2, h3, h4;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(5)\r
-    HASH5_CALC;\r
-    hash = p->hash;\r
-    curMatch = (hash + kFix5HashSize)[hv];\r
-    hash[                h2] =\r
-    (hash + kFix3HashSize)[h3] =\r
-    (hash + kFix4HashSize)[h4] =\r
-    (hash + kFix5HashSize)[hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-*/\r
-\r
-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2, h3;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(4)\r
-    HASH4_CALC;\r
-    hash = p->hash;\r
-    curMatch = (hash + kFix4HashSize)[hv];\r
-    hash[                h2] =\r
-    (hash + kFix3HashSize)[h3] =\r
-    (hash + kFix4HashSize)[hv] = p->pos;\r
-    p->son[p->cyclicBufferPos] = curMatch;\r
-    MOVE_POS\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-/*\r
-static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2, h3, h4;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(5)\r
-    HASH5_CALC;\r
-    hash = p->hash;\r
-    curMatch = hash + kFix5HashSize)[hv];\r
-    hash[                h2] =\r
-    (hash + kFix3HashSize)[h3] =\r
-    (hash + kFix4HashSize)[h4] =\r
-    (hash + kFix5HashSize)[hv] = p->pos;\r
-    p->son[p->cyclicBufferPos] = curMatch;\r
-    MOVE_POS\r
-  }\r
-  while (--num != 0);\r
-}\r
-*/\r
-\r
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    SKIP_HEADER(3)\r
-    HASH_ZIP_CALC;\r
-    curMatch = p->hash[hv];\r
-    p->hash[hv] = p->pos;\r
-    p->son[p->cyclicBufferPos] = curMatch;\r
-    MOVE_POS\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)\r
-{\r
-  vTable->Init = (Mf_Init_Func)MatchFinder_Init;\r
-  vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;\r
-  vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;\r
-  if (!p->btMode)\r
-  {\r
-    /* if (p->numHashBytes <= 4) */\r
-    {\r
-      vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;\r
-      vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;\r
-    }\r
-    /*\r
-    else\r
-    {\r
-      vTable->GetMatches = (Mf_GetMatches_Func)Hc5_MatchFinder_GetMatches;\r
-      vTable->Skip = (Mf_Skip_Func)Hc5_MatchFinder_Skip;\r
-    }\r
-    */\r
-  }\r
-  else if (p->numHashBytes == 2)\r
-  {\r
-    vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;\r
-    vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;\r
-  }\r
-  else if (p->numHashBytes == 3)\r
-  {\r
-    vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;\r
-    vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;\r
-  }\r
-  else /* if (p->numHashBytes == 4) */\r
-  {\r
-    vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;\r
-    vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;\r
-  }\r
-  /*\r
-  else\r
-  {\r
-    vTable->GetMatches = (Mf_GetMatches_Func)Bt5_MatchFinder_GetMatches;\r
-    vTable->Skip = (Mf_Skip_Func)Bt5_MatchFinder_Skip;\r
-  }\r
-  */\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.h
deleted file mode 100644 (file)
index c77adde..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/* LzFind.h -- Match finder for LZ algorithms\r
-2017-06-10 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZ_FIND_H\r
-#define __LZ_FIND_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-typedef UInt32 CLzRef;\r
-\r
-typedef struct _CMatchFinder\r
-{\r
-  Byte *buffer;\r
-  UInt32 pos;\r
-  UInt32 posLimit;\r
-  UInt32 streamPos;\r
-  UInt32 lenLimit;\r
-\r
-  UInt32 cyclicBufferPos;\r
-  UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */\r
-\r
-  Byte streamEndWasReached;\r
-  Byte btMode;\r
-  Byte bigHash;\r
-  Byte directInput;\r
-\r
-  UInt32 matchMaxLen;\r
-  CLzRef *hash;\r
-  CLzRef *son;\r
-  UInt32 hashMask;\r
-  UInt32 cutValue;\r
-\r
-  Byte *bufferBase;\r
-  ISeqInStream *stream;\r
-  \r
-  UInt32 blockSize;\r
-  UInt32 keepSizeBefore;\r
-  UInt32 keepSizeAfter;\r
-\r
-  UInt32 numHashBytes;\r
-  size_t directInputRem;\r
-  UInt32 historySize;\r
-  UInt32 fixedHashSize;\r
-  UInt32 hashSizeSum;\r
-  SRes result;\r
-  UInt32 crc[256];\r
-  size_t numRefs;\r
-\r
-  UInt64 expectedDataSize;\r
-} CMatchFinder;\r
-\r
-#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)\r
-\r
-#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)\r
-\r
-#define Inline_MatchFinder_IsFinishedOK(p) \\r
-    ((p)->streamEndWasReached \\r
-        && (p)->streamPos == (p)->pos \\r
-        && (!(p)->directInput || (p)->directInputRem == 0))\r
-      \r
-int MatchFinder_NeedMove(CMatchFinder *p);\r
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);\r
-void MatchFinder_MoveBlock(CMatchFinder *p);\r
-void MatchFinder_ReadIfRequired(CMatchFinder *p);\r
-\r
-void MatchFinder_Construct(CMatchFinder *p);\r
-\r
-/* Conditions:\r
-     historySize <= 3 GB\r
-     keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB\r
-*/\r
-int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,\r
-    UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,\r
-    ISzAllocPtr alloc);\r
-void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc);\r
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems);\r
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);\r
-\r
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,\r
-    UInt32 *distances, UInt32 maxLen);\r
-\r
-/*\r
-Conditions:\r
-  Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.\r
-  Mf_GetPointerToCurrentPos_Func's result must be used only before any other function\r
-*/\r
-\r
-typedef void (*Mf_Init_Func)(void *object);\r
-typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);\r
-typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);\r
-typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);\r
-typedef void (*Mf_Skip_Func)(void *object, UInt32);\r
-\r
-typedef struct _IMatchFinder\r
-{\r
-  Mf_Init_Func Init;\r
-  Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;\r
-  Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;\r
-  Mf_GetMatches_Func GetMatches;\r
-  Mf_Skip_Func Skip;\r
-} IMatchFinder;\r
-\r
-void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);\r
-\r
-void MatchFinder_Init_LowHash(CMatchFinder *p);\r
-void MatchFinder_Init_HighHash(CMatchFinder *p);\r
-void MatchFinder_Init_3(CMatchFinder *p, int readData);\r
-void MatchFinder_Init(CMatchFinder *p);\r
-\r
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r
-\r
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzHash.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzHash.h
deleted file mode 100644 (file)
index 2191444..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* LzHash.h -- HASH functions for LZ algorithms\r
-2015-04-12 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZ_HASH_H\r
-#define __LZ_HASH_H\r
-\r
-#define kHash2Size (1 << 10)\r
-#define kHash3Size (1 << 16)\r
-#define kHash4Size (1 << 20)\r
-\r
-#define kFix3HashSize (kHash2Size)\r
-#define kFix4HashSize (kHash2Size + kHash3Size)\r
-#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)\r
-\r
-#define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8);\r
-\r
-#define HASH3_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }\r
-\r
-#define HASH4_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  temp ^= ((UInt32)cur[2] << 8); \\r
-  h3 = temp & (kHash3Size - 1); \\r
-  hv = (temp ^ (p->crc[cur[3]] << 5)) & p->hashMask; }\r
-\r
-#define HASH5_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  temp ^= ((UInt32)cur[2] << 8); \\r
-  h3 = temp & (kHash3Size - 1); \\r
-  temp ^= (p->crc[cur[3]] << 5); \\r
-  h4 = temp & (kHash4Size - 1); \\r
-  hv = (temp ^ (p->crc[cur[4]] << 3)) & p->hashMask; }\r
-\r
-/* #define HASH_ZIP_CALC hv = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */\r
-#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;\r
-\r
-\r
-#define MT_HASH2_CALC \\r
-  h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);\r
-\r
-#define MT_HASH3_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }\r
-\r
-#define MT_HASH4_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  temp ^= ((UInt32)cur[2] << 8); \\r
-  h3 = temp & (kHash3Size - 1); \\r
-  h4 = (temp ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.c b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.c
deleted file mode 100644 (file)
index 6d8c6eb..0000000
+++ /dev/null
@@ -1,1187 +0,0 @@
-/* LzmaDec.c -- LZMA Decoder\r
-2018-02-28 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-/* #include "CpuArch.h" */\r
-#include "LzmaDec.h"\r
-\r
-#ifndef EFIAPI\r
-#include <string.h>\r
-#endif\r
-\r
-#define kNumTopBits 24\r
-#define kTopValue ((UInt32)1 << kNumTopBits)\r
-\r
-#define kNumBitModelTotalBits 11\r
-#define kBitModelTotal (1 << kNumBitModelTotalBits)\r
-#define kNumMoveBits 5\r
-\r
-#define RC_INIT_SIZE 5\r
-\r
-#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }\r
-\r
-#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)\r
-#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));\r
-#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));\r
-#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \\r
-  { UPDATE_0(p); i = (i + i); A0; } else \\r
-  { UPDATE_1(p); i = (i + i) + 1; A1; }\r
-\r
-#define TREE_GET_BIT(probs, i) { GET_BIT2(probs + i, i, ;, ;); }\r
-\r
-#define REV_BIT(p, i, A0, A1) IF_BIT_0(p + i) \\r
-  { UPDATE_0(p + i); A0; } else \\r
-  { UPDATE_1(p + i); A1; }\r
-#define REV_BIT_VAR(  p, i, m) REV_BIT(p, i, i += m; m += m, m += m; i += m; )\r
-#define REV_BIT_CONST(p, i, m) REV_BIT(p, i, i += m;       , i += m * 2; )\r
-#define REV_BIT_LAST( p, i, m) REV_BIT(p, i, i -= m        , ; )\r
-\r
-#define TREE_DECODE(probs, limit, i) \\r
-  { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }\r
-\r
-/* #define _LZMA_SIZE_OPT */\r
-\r
-#ifdef _LZMA_SIZE_OPT\r
-#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)\r
-#else\r
-#define TREE_6_DECODE(probs, i) \\r
-  { i = 1; \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  i -= 0x40; }\r
-#endif\r
-\r
-#define NORMAL_LITER_DEC TREE_GET_BIT(prob, symbol)\r
-#define MATCHED_LITER_DEC \\r
-  matchByte += matchByte; \\r
-  bit = offs; \\r
-  offs &= matchByte; \\r
-  probLit = prob + (offs + bit + symbol); \\r
-  GET_BIT2(probLit, symbol, offs ^= bit; , ;)\r
-\r
-\r
-\r
-#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }\r
-\r
-#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)\r
-#define UPDATE_0_CHECK range = bound;\r
-#define UPDATE_1_CHECK range -= bound; code -= bound;\r
-#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \\r
-  { UPDATE_0_CHECK; i = (i + i); A0; } else \\r
-  { UPDATE_1_CHECK; i = (i + i) + 1; A1; }\r
-#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)\r
-#define TREE_DECODE_CHECK(probs, limit, i) \\r
-  { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }\r
-\r
-\r
-#define REV_BIT_CHECK(p, i, m) IF_BIT_0_CHECK(p + i) \\r
-  { UPDATE_0_CHECK; i += m; m += m; } else \\r
-  { UPDATE_1_CHECK; m += m; i += m; }\r
-\r
-\r
-#define kNumPosBitsMax 4\r
-#define kNumPosStatesMax (1 << kNumPosBitsMax)\r
-\r
-#define kLenNumLowBits 3\r
-#define kLenNumLowSymbols (1 << kLenNumLowBits)\r
-#define kLenNumHighBits 8\r
-#define kLenNumHighSymbols (1 << kLenNumHighBits)\r
-\r
-#define LenLow 0\r
-#define LenHigh (LenLow + 2 * (kNumPosStatesMax << kLenNumLowBits))\r
-#define kNumLenProbs (LenHigh + kLenNumHighSymbols)\r
-\r
-#define LenChoice LenLow\r
-#define LenChoice2 (LenLow + (1 << kLenNumLowBits))\r
-\r
-#define kNumStates 12\r
-#define kNumStates2 16\r
-#define kNumLitStates 7\r
-\r
-#define kStartPosModelIndex 4\r
-#define kEndPosModelIndex 14\r
-#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))\r
-\r
-#define kNumPosSlotBits 6\r
-#define kNumLenToPosStates 4\r
-\r
-#define kNumAlignBits 4\r
-#define kAlignTableSize (1 << kNumAlignBits)\r
-\r
-#define kMatchMinLen 2\r
-#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols * 2 + kLenNumHighSymbols)\r
-\r
-/* External ASM code needs same CLzmaProb array layout. So don't change it. */\r
-\r
-/* (probs_1664) is faster and better for code size at some platforms */\r
-/*\r
-#ifdef MY_CPU_X86_OR_AMD64\r
-*/\r
-#define kStartOffset 1664\r
-#define GET_PROBS p->probs_1664\r
-/*\r
-#define GET_PROBS p->probs + kStartOffset\r
-#else\r
-#define kStartOffset 0\r
-#define GET_PROBS p->probs\r
-#endif\r
-*/\r
-\r
-#define SpecPos (-kStartOffset)\r
-#define IsRep0Long (SpecPos + kNumFullDistances)\r
-#define RepLenCoder (IsRep0Long + (kNumStates2 << kNumPosBitsMax))\r
-#define LenCoder (RepLenCoder + kNumLenProbs)\r
-#define IsMatch (LenCoder + kNumLenProbs)\r
-#define Align (IsMatch + (kNumStates2 << kNumPosBitsMax))\r
-#define IsRep (Align + kAlignTableSize)\r
-#define IsRepG0 (IsRep + kNumStates)\r
-#define IsRepG1 (IsRepG0 + kNumStates)\r
-#define IsRepG2 (IsRepG1 + kNumStates)\r
-#define PosSlot (IsRepG2 + kNumStates)\r
-#define Literal (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))\r
-#define NUM_BASE_PROBS (Literal + kStartOffset)\r
-\r
-#if Align != 0 && kStartOffset != 0\r
-  #error Stop_Compiling_Bad_LZMA_kAlign\r
-#endif\r
-\r
-#if NUM_BASE_PROBS != 1984\r
-  #error Stop_Compiling_Bad_LZMA_PROBS\r
-#endif\r
-\r
-\r
-#define LZMA_LIT_SIZE 0x300\r
-\r
-#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))\r
-\r
-\r
-#define CALC_POS_STATE(processedPos, pbMask) (((processedPos) & (pbMask)) << 4)\r
-#define COMBINED_PS_STATE (posState + state)\r
-#define GET_LEN_STATE (posState)\r
-\r
-#define LZMA_DIC_MIN (1 << 12)\r
-\r
-/*\r
-p->remainLen : shows status of LZMA decoder:\r
-    < kMatchSpecLenStart : normal remain\r
-    = kMatchSpecLenStart : finished\r
-    = kMatchSpecLenStart + 1 : need init range coder\r
-    = kMatchSpecLenStart + 2 : need init range coder and state\r
-*/\r
-\r
-/* ---------- LZMA_DECODE_REAL ---------- */\r
-/*\r
-LzmaDec_DecodeReal_3() can be implemented in external ASM file.\r
-3 - is the code compatibility version of that function for check at link time.\r
-*/\r
-\r
-#define LZMA_DECODE_REAL LzmaDec_DecodeReal_3\r
-\r
-/*\r
-LZMA_DECODE_REAL()\r
-In:\r
-  RangeCoder is normalized\r
-  if (p->dicPos == limit)\r
-  {\r
-    LzmaDec_TryDummy() was called before to exclude LITERAL and MATCH-REP cases.\r
-    So first symbol can be only MATCH-NON-REP. And if that MATCH-NON-REP symbol\r
-    is not END_OF_PAYALOAD_MARKER, then function returns error code.\r
-  }\r
-\r
-Processing:\r
-  first LZMA symbol will be decoded in any case\r
-  All checks for limits are at the end of main loop,\r
-  It will decode new LZMA-symbols while (p->buf < bufLimit && dicPos < limit),\r
-  RangeCoder is still without last normalization when (p->buf < bufLimit) is being checked.\r
-\r
-Out:\r
-  RangeCoder is normalized\r
-  Result:\r
-    SZ_OK - OK\r
-    SZ_ERROR_DATA - Error\r
-  p->remainLen:\r
-    < kMatchSpecLenStart : normal remain\r
-    = kMatchSpecLenStart : finished\r
-*/\r
-\r
-\r
-#ifdef _LZMA_DEC_OPT\r
-\r
-int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit);\r
-\r
-#else\r
-\r
-static\r
-int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit)\r
-{\r
-  CLzmaProb *probs = GET_PROBS;\r
-  unsigned state = (unsigned)p->state;\r
-  UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];\r
-  unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;\r
-  unsigned lc = p->prop.lc;\r
-  unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc);\r
-\r
-  Byte *dic = p->dic;\r
-  SizeT dicBufSize = p->dicBufSize;\r
-  SizeT dicPos = p->dicPos;\r
-  \r
-  UInt32 processedPos = p->processedPos;\r
-  UInt32 checkDicSize = p->checkDicSize;\r
-  unsigned len = 0;\r
-\r
-  const Byte *buf = p->buf;\r
-  UInt32 range = p->range;\r
-  UInt32 code = p->code;\r
-\r
-  do\r
-  {\r
-    CLzmaProb *prob;\r
-    UInt32 bound;\r
-    unsigned ttt;\r
-    unsigned posState = CALC_POS_STATE(processedPos, pbMask);\r
-\r
-    prob = probs + IsMatch + COMBINED_PS_STATE;\r
-    IF_BIT_0(prob)\r
-    {\r
-      unsigned symbol;\r
-      UPDATE_0(prob);\r
-      prob = probs + Literal;\r
-      if (processedPos != 0 || checkDicSize != 0)\r
-        prob += (UInt32)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc);\r
-      processedPos++;\r
-\r
-      if (state < kNumLitStates)\r
-      {\r
-        state -= (state < 4) ? state : 3;\r
-        symbol = 1;\r
-        #ifdef _LZMA_SIZE_OPT\r
-        do { NORMAL_LITER_DEC } while (symbol < 0x100);\r
-        #else\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        #endif\r
-      }\r
-      else\r
-      {\r
-        unsigned matchByte = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];\r
-        unsigned offs = 0x100;\r
-        state -= (state < 10) ? 3 : 6;\r
-        symbol = 1;\r
-        #ifdef _LZMA_SIZE_OPT\r
-        do\r
-        {\r
-          unsigned bit;\r
-          CLzmaProb *probLit;\r
-          MATCHED_LITER_DEC\r
-        }\r
-        while (symbol < 0x100);\r
-        #else\r
-        {\r
-          unsigned bit;\r
-          CLzmaProb *probLit;\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-        }\r
-        #endif\r
-      }\r
-\r
-      dic[dicPos++] = (Byte)symbol;\r
-      continue;\r
-    }\r
-    \r
-    {\r
-      UPDATE_1(prob);\r
-      prob = probs + IsRep + state;\r
-      IF_BIT_0(prob)\r
-      {\r
-        UPDATE_0(prob);\r
-        state += kNumStates;\r
-        prob = probs + LenCoder;\r
-      }\r
-      else\r
-      {\r
-        UPDATE_1(prob);\r
-        /*\r
-        // that case was checked before with kBadRepCode\r
-        if (checkDicSize == 0 && processedPos == 0)\r
-          return SZ_ERROR_DATA;\r
-        */\r
-        prob = probs + IsRepG0 + state;\r
-        IF_BIT_0(prob)\r
-        {\r
-          UPDATE_0(prob);\r
-          prob = probs + IsRep0Long + COMBINED_PS_STATE;\r
-          IF_BIT_0(prob)\r
-          {\r
-            UPDATE_0(prob);\r
-            dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];\r
-            dicPos++;\r
-            processedPos++;\r
-            state = state < kNumLitStates ? 9 : 11;\r
-            continue;\r
-          }\r
-          UPDATE_1(prob);\r
-        }\r
-        else\r
-        {\r
-          UInt32 distance;\r
-          UPDATE_1(prob);\r
-          prob = probs + IsRepG1 + state;\r
-          IF_BIT_0(prob)\r
-          {\r
-            UPDATE_0(prob);\r
-            distance = rep1;\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1(prob);\r
-            prob = probs + IsRepG2 + state;\r
-            IF_BIT_0(prob)\r
-            {\r
-              UPDATE_0(prob);\r
-              distance = rep2;\r
-            }\r
-            else\r
-            {\r
-              UPDATE_1(prob);\r
-              distance = rep3;\r
-              rep3 = rep2;\r
-            }\r
-            rep2 = rep1;\r
-          }\r
-          rep1 = rep0;\r
-          rep0 = distance;\r
-        }\r
-        state = state < kNumLitStates ? 8 : 11;\r
-        prob = probs + RepLenCoder;\r
-      }\r
-      \r
-      #ifdef _LZMA_SIZE_OPT\r
-      {\r
-        unsigned lim, offset;\r
-        CLzmaProb *probLen = prob + LenChoice;\r
-        IF_BIT_0(probLen)\r
-        {\r
-          UPDATE_0(probLen);\r
-          probLen = prob + LenLow + GET_LEN_STATE;\r
-          offset = 0;\r
-          lim = (1 << kLenNumLowBits);\r
-        }\r
-        else\r
-        {\r
-          UPDATE_1(probLen);\r
-          probLen = prob + LenChoice2;\r
-          IF_BIT_0(probLen)\r
-          {\r
-            UPDATE_0(probLen);\r
-            probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits);\r
-            offset = kLenNumLowSymbols;\r
-            lim = (1 << kLenNumLowBits);\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1(probLen);\r
-            probLen = prob + LenHigh;\r
-            offset = kLenNumLowSymbols * 2;\r
-            lim = (1 << kLenNumHighBits);\r
-          }\r
-        }\r
-        TREE_DECODE(probLen, lim, len);\r
-        len += offset;\r
-      }\r
-      #else\r
-      {\r
-        CLzmaProb *probLen = prob + LenChoice;\r
-        IF_BIT_0(probLen)\r
-        {\r
-          UPDATE_0(probLen);\r
-          probLen = prob + LenLow + GET_LEN_STATE;\r
-          len = 1;\r
-          TREE_GET_BIT(probLen, len);\r
-          TREE_GET_BIT(probLen, len);\r
-          TREE_GET_BIT(probLen, len);\r
-          len -= 8;\r
-        }\r
-        else\r
-        {\r
-          UPDATE_1(probLen);\r
-          probLen = prob + LenChoice2;\r
-          IF_BIT_0(probLen)\r
-          {\r
-            UPDATE_0(probLen);\r
-            probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits);\r
-            len = 1;\r
-            TREE_GET_BIT(probLen, len);\r
-            TREE_GET_BIT(probLen, len);\r
-            TREE_GET_BIT(probLen, len);\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1(probLen);\r
-            probLen = prob + LenHigh;\r
-            TREE_DECODE(probLen, (1 << kLenNumHighBits), len);\r
-            len += kLenNumLowSymbols * 2;\r
-          }\r
-        }\r
-      }\r
-      #endif\r
-\r
-      if (state >= kNumStates)\r
-      {\r
-        UInt32 distance;\r
-        prob = probs + PosSlot +\r
-            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);\r
-        TREE_6_DECODE(prob, distance);\r
-        if (distance >= kStartPosModelIndex)\r
-        {\r
-          unsigned posSlot = (unsigned)distance;\r
-          unsigned numDirectBits = (unsigned)(((distance >> 1) - 1));\r
-          distance = (2 | (distance & 1));\r
-          if (posSlot < kEndPosModelIndex)\r
-          {\r
-            distance <<= numDirectBits;\r
-            prob = probs + SpecPos;\r
-            {\r
-              UInt32 m = 1;\r
-              distance++;\r
-              do\r
-              {\r
-                REV_BIT_VAR(prob, distance, m);\r
-              }\r
-              while (--numDirectBits);\r
-              distance -= m;\r
-            }\r
-          }\r
-          else\r
-          {\r
-            numDirectBits -= kNumAlignBits;\r
-            do\r
-            {\r
-              NORMALIZE\r
-              range >>= 1;\r
-              \r
-              {\r
-                UInt32 t;\r
-                code -= range;\r
-                t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */\r
-                distance = (distance << 1) + (t + 1);\r
-                code += range & t;\r
-              }\r
-              /*\r
-              distance <<= 1;\r
-              if (code >= range)\r
-              {\r
-                code -= range;\r
-                distance |= 1;\r
-              }\r
-              */\r
-            }\r
-            while (--numDirectBits);\r
-            prob = probs + Align;\r
-            distance <<= kNumAlignBits;\r
-            {\r
-              unsigned i = 1;\r
-              REV_BIT_CONST(prob, i, 1);\r
-              REV_BIT_CONST(prob, i, 2);\r
-              REV_BIT_CONST(prob, i, 4);\r
-              REV_BIT_LAST (prob, i, 8);\r
-              distance |= i;\r
-            }\r
-            if (distance == (UInt32)0xFFFFFFFF)\r
-            {\r
-              len = kMatchSpecLenStart;\r
-              state -= kNumStates;\r
-              break;\r
-            }\r
-          }\r
-        }\r
-        \r
-        rep3 = rep2;\r
-        rep2 = rep1;\r
-        rep1 = rep0;\r
-        rep0 = distance + 1;\r
-        state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;\r
-        if (distance >= (checkDicSize == 0 ? processedPos: checkDicSize))\r
-        {\r
-          p->dicPos = dicPos;\r
-          return SZ_ERROR_DATA;\r
-        }\r
-      }\r
-\r
-      len += kMatchMinLen;\r
-\r
-      {\r
-        SizeT rem;\r
-        unsigned curLen;\r
-        SizeT pos;\r
-        \r
-        if ((rem = limit - dicPos) == 0)\r
-        {\r
-          p->dicPos = dicPos;\r
-          return SZ_ERROR_DATA;\r
-        }\r
-        \r
-        curLen = ((rem < len) ? (unsigned)rem : len);\r
-        pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);\r
-\r
-        processedPos += curLen;\r
-\r
-        len -= curLen;\r
-        if (curLen <= dicBufSize - pos)\r
-        {\r
-          Byte *dest = dic + dicPos;\r
-          ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;\r
-          const Byte *lim = dest + curLen;\r
-          dicPos += curLen;\r
-          do\r
-            *(dest) = (Byte)*(dest + src);\r
-          while (++dest != lim);\r
-        }\r
-        else\r
-        {\r
-          do\r
-          {\r
-            dic[dicPos++] = dic[pos];\r
-            if (++pos == dicBufSize)\r
-              pos = 0;\r
-          }\r
-          while (--curLen != 0);\r
-        }\r
-      }\r
-    }\r
-  }\r
-  while (dicPos < limit && buf < bufLimit);\r
-\r
-  NORMALIZE;\r
-  \r
-  p->buf = buf;\r
-  p->range = range;\r
-  p->code = code;\r
-  p->remainLen = len;\r
-  p->dicPos = dicPos;\r
-  p->processedPos = processedPos;\r
-  p->reps[0] = rep0;\r
-  p->reps[1] = rep1;\r
-  p->reps[2] = rep2;\r
-  p->reps[3] = rep3;\r
-  p->state = state;\r
-\r
-  return SZ_OK;\r
-}\r
-#endif\r
-\r
-static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)\r
-{\r
-  if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)\r
-  {\r
-    Byte *dic = p->dic;\r
-    SizeT dicPos = p->dicPos;\r
-    SizeT dicBufSize = p->dicBufSize;\r
-    unsigned len = (unsigned)p->remainLen;\r
-    SizeT rep0 = p->reps[0]; /* we use SizeT to avoid the BUG of VC14 for AMD64 */\r
-    SizeT rem = limit - dicPos;\r
-    if (rem < len)\r
-      len = (unsigned)(rem);\r
-\r
-    if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)\r
-      p->checkDicSize = p->prop.dicSize;\r
-\r
-    p->processedPos += len;\r
-    p->remainLen -= len;\r
-    while (len != 0)\r
-    {\r
-      len--;\r
-      dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];\r
-      dicPos++;\r
-    }\r
-    p->dicPos = dicPos;\r
-  }\r
-}\r
-\r
-\r
-#define kRange0 0xFFFFFFFF\r
-#define kBound0 ((kRange0 >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1))\r
-#define kBadRepCode (kBound0 + (((kRange0 - kBound0) >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1)))\r
-#if kBadRepCode != (0xC0000000 - 0x400)\r
-  #error Stop_Compiling_Bad_LZMA_Check\r
-#endif\r
-\r
-static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)\r
-{\r
-  do\r
-  {\r
-    SizeT limit2 = limit;\r
-    if (p->checkDicSize == 0)\r
-    {\r
-      UInt32 rem = p->prop.dicSize - p->processedPos;\r
-      if (limit - p->dicPos > rem)\r
-        limit2 = p->dicPos + rem;\r
-\r
-      if (p->processedPos == 0)\r
-        if (p->code >= kBadRepCode)\r
-          return SZ_ERROR_DATA;\r
-    }\r
-\r
-    RINOK(LZMA_DECODE_REAL(p, limit2, bufLimit));\r
-    \r
-    if (p->checkDicSize == 0 && p->processedPos >= p->prop.dicSize)\r
-      p->checkDicSize = p->prop.dicSize;\r
-    \r
-    LzmaDec_WriteRem(p, limit);\r
-  }\r
-  while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);\r
-\r
-  return 0;\r
-}\r
-\r
-typedef enum\r
-{\r
-  DUMMY_ERROR, /* unexpected end of input stream */\r
-  DUMMY_LIT,\r
-  DUMMY_MATCH,\r
-  DUMMY_REP\r
-} ELzmaDummy;\r
-\r
-static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)\r
-{\r
-  UInt32 range = p->range;\r
-  UInt32 code = p->code;\r
-  const Byte *bufLimit = buf + inSize;\r
-  const CLzmaProb *probs = GET_PROBS;\r
-  unsigned state = (unsigned)p->state;\r
-  ELzmaDummy res;\r
-\r
-  {\r
-    const CLzmaProb *prob;\r
-    UInt32 bound;\r
-    unsigned ttt;\r
-    unsigned posState = CALC_POS_STATE(p->processedPos, (1 << p->prop.pb) - 1);\r
-\r
-    prob = probs + IsMatch + COMBINED_PS_STATE;\r
-    IF_BIT_0_CHECK(prob)\r
-    {\r
-      UPDATE_0_CHECK\r
-\r
-      /* if (bufLimit - buf >= 7) return DUMMY_LIT; */\r
-\r
-      prob = probs + Literal;\r
-      if (p->checkDicSize != 0 || p->processedPos != 0)\r
-        prob += ((UInt32)LZMA_LIT_SIZE *\r
-            ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +\r
-            (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));\r
-\r
-      if (state < kNumLitStates)\r
-      {\r
-        unsigned symbol = 1;\r
-        do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);\r
-      }\r
-      else\r
-      {\r
-        unsigned matchByte = p->dic[p->dicPos - p->reps[0] +\r
-            (p->dicPos < p->reps[0] ? p->dicBufSize : 0)];\r
-        unsigned offs = 0x100;\r
-        unsigned symbol = 1;\r
-        do\r
-        {\r
-          unsigned bit;\r
-          const CLzmaProb *probLit;\r
-          matchByte += matchByte;\r
-          bit = offs;\r
-          offs &= matchByte;\r
-          probLit = prob + (offs + bit + symbol);\r
-          GET_BIT2_CHECK(probLit, symbol, offs ^= bit; , ; )\r
-        }\r
-        while (symbol < 0x100);\r
-      }\r
-      res = DUMMY_LIT;\r
-    }\r
-    else\r
-    {\r
-      unsigned len;\r
-      UPDATE_1_CHECK;\r
-\r
-      prob = probs + IsRep + state;\r
-      IF_BIT_0_CHECK(prob)\r
-      {\r
-        UPDATE_0_CHECK;\r
-        state = 0;\r
-        prob = probs + LenCoder;\r
-        res = DUMMY_MATCH;\r
-      }\r
-      else\r
-      {\r
-        UPDATE_1_CHECK;\r
-        res = DUMMY_REP;\r
-        prob = probs + IsRepG0 + state;\r
-        IF_BIT_0_CHECK(prob)\r
-        {\r
-          UPDATE_0_CHECK;\r
-          prob = probs + IsRep0Long + COMBINED_PS_STATE;\r
-          IF_BIT_0_CHECK(prob)\r
-          {\r
-            UPDATE_0_CHECK;\r
-            NORMALIZE_CHECK;\r
-            return DUMMY_REP;\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1_CHECK;\r
-          }\r
-        }\r
-        else\r
-        {\r
-          UPDATE_1_CHECK;\r
-          prob = probs + IsRepG1 + state;\r
-          IF_BIT_0_CHECK(prob)\r
-          {\r
-            UPDATE_0_CHECK;\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1_CHECK;\r
-            prob = probs + IsRepG2 + state;\r
-            IF_BIT_0_CHECK(prob)\r
-            {\r
-              UPDATE_0_CHECK;\r
-            }\r
-            else\r
-            {\r
-              UPDATE_1_CHECK;\r
-            }\r
-          }\r
-        }\r
-        state = kNumStates;\r
-        prob = probs + RepLenCoder;\r
-      }\r
-      {\r
-        unsigned limit, offset;\r
-        const CLzmaProb *probLen = prob + LenChoice;\r
-        IF_BIT_0_CHECK(probLen)\r
-        {\r
-          UPDATE_0_CHECK;\r
-          probLen = prob + LenLow + GET_LEN_STATE;\r
-          offset = 0;\r
-          limit = 1 << kLenNumLowBits;\r
-        }\r
-        else\r
-        {\r
-          UPDATE_1_CHECK;\r
-          probLen = prob + LenChoice2;\r
-          IF_BIT_0_CHECK(probLen)\r
-          {\r
-            UPDATE_0_CHECK;\r
-            probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits);\r
-            offset = kLenNumLowSymbols;\r
-            limit = 1 << kLenNumLowBits;\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1_CHECK;\r
-            probLen = prob + LenHigh;\r
-            offset = kLenNumLowSymbols * 2;\r
-            limit = 1 << kLenNumHighBits;\r
-          }\r
-        }\r
-        TREE_DECODE_CHECK(probLen, limit, len);\r
-        len += offset;\r
-      }\r
-\r
-      if (state < 4)\r
-      {\r
-        unsigned posSlot;\r
-        prob = probs + PosSlot +\r
-            ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) <<\r
-            kNumPosSlotBits);\r
-        TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);\r
-        if (posSlot >= kStartPosModelIndex)\r
-        {\r
-          unsigned numDirectBits = ((posSlot >> 1) - 1);\r
-\r
-          /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */\r
-\r
-          if (posSlot < kEndPosModelIndex)\r
-          {\r
-            prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits);\r
-          }\r
-          else\r
-          {\r
-            numDirectBits -= kNumAlignBits;\r
-            do\r
-            {\r
-              NORMALIZE_CHECK\r
-              range >>= 1;\r
-              code -= range & (((code - range) >> 31) - 1);\r
-              /* if (code >= range) code -= range; */\r
-            }\r
-            while (--numDirectBits);\r
-            prob = probs + Align;\r
-            numDirectBits = kNumAlignBits;\r
-          }\r
-          {\r
-            unsigned i = 1;\r
-            unsigned m = 1;\r
-            do\r
-            {\r
-              REV_BIT_CHECK(prob, i, m);\r
-            }\r
-            while (--numDirectBits);\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-  NORMALIZE_CHECK;\r
-  return res;\r
-}\r
-\r
-\r
-void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)\r
-{\r
-  p->remainLen = kMatchSpecLenStart + 1;\r
-  p->tempBufSize = 0;\r
-\r
-  if (initDic)\r
-  {\r
-    p->processedPos = 0;\r
-    p->checkDicSize = 0;\r
-    p->remainLen = kMatchSpecLenStart + 2;\r
-  }\r
-  if (initState)\r
-    p->remainLen = kMatchSpecLenStart + 2;\r
-}\r
-\r
-void LzmaDec_Init(CLzmaDec *p)\r
-{\r
-  p->dicPos = 0;\r
-  LzmaDec_InitDicAndState(p, True, True);\r
-}\r
-\r
-\r
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,\r
-    ELzmaFinishMode finishMode, ELzmaStatus *status)\r
-{\r
-  SizeT inSize = *srcLen;\r
-  (*srcLen) = 0;\r
-  \r
-  *status = LZMA_STATUS_NOT_SPECIFIED;\r
-\r
-  if (p->remainLen > kMatchSpecLenStart)\r
-  {\r
-    for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)\r
-      p->tempBuf[p->tempBufSize++] = *src++;\r
-    if (p->tempBufSize != 0 && p->tempBuf[0] != 0)\r
-      return SZ_ERROR_DATA;\r
-    if (p->tempBufSize < RC_INIT_SIZE)\r
-    {\r
-      *status = LZMA_STATUS_NEEDS_MORE_INPUT;\r
-      return SZ_OK;\r
-    }\r
-    p->code =\r
-        ((UInt32)p->tempBuf[1] << 24)\r
-      | ((UInt32)p->tempBuf[2] << 16)\r
-      | ((UInt32)p->tempBuf[3] << 8)\r
-      | ((UInt32)p->tempBuf[4]);\r
-    p->range = 0xFFFFFFFF;\r
-    p->tempBufSize = 0;\r
-\r
-    if (p->remainLen > kMatchSpecLenStart + 1)\r
-    {\r
-      SizeT numProbs = LzmaProps_GetNumProbs(&p->prop);\r
-      SizeT i;\r
-      CLzmaProb *probs = p->probs;\r
-      for (i = 0; i < numProbs; i++)\r
-        probs[i] = kBitModelTotal >> 1;\r
-      p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;\r
-      p->state = 0;\r
-    }\r
-\r
-    p->remainLen = 0;\r
-  }\r
-\r
-  LzmaDec_WriteRem(p, dicLimit);\r
-\r
-  while (p->remainLen != kMatchSpecLenStart)\r
-  {\r
-      int checkEndMarkNow = 0;\r
-\r
-      if (p->dicPos >= dicLimit)\r
-      {\r
-        if (p->remainLen == 0 && p->code == 0)\r
-        {\r
-          *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;\r
-          return SZ_OK;\r
-        }\r
-        if (finishMode == LZMA_FINISH_ANY)\r
-        {\r
-          *status = LZMA_STATUS_NOT_FINISHED;\r
-          return SZ_OK;\r
-        }\r
-        if (p->remainLen != 0)\r
-        {\r
-          *status = LZMA_STATUS_NOT_FINISHED;\r
-          return SZ_ERROR_DATA;\r
-        }\r
-        checkEndMarkNow = 1;\r
-      }\r
-\r
-      if (p->tempBufSize == 0)\r
-      {\r
-        SizeT processed;\r
-        const Byte *bufLimit;\r
-        if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)\r
-        {\r
-          int dummyRes = LzmaDec_TryDummy(p, src, inSize);\r
-          if (dummyRes == DUMMY_ERROR)\r
-          {\r
-            memcpy(p->tempBuf, src, inSize);\r
-            p->tempBufSize = (unsigned)inSize;\r
-            (*srcLen) += inSize;\r
-            *status = LZMA_STATUS_NEEDS_MORE_INPUT;\r
-            return SZ_OK;\r
-          }\r
-          if (checkEndMarkNow && dummyRes != DUMMY_MATCH)\r
-          {\r
-            *status = LZMA_STATUS_NOT_FINISHED;\r
-            return SZ_ERROR_DATA;\r
-          }\r
-          bufLimit = src;\r
-        }\r
-        else\r
-          bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;\r
-        p->buf = src;\r
-        if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)\r
-          return SZ_ERROR_DATA;\r
-        processed = (SizeT)(p->buf - src);\r
-        (*srcLen) += processed;\r
-        src += processed;\r
-        inSize -= processed;\r
-      }\r
-      else\r
-      {\r
-        unsigned rem = p->tempBufSize, lookAhead = 0;\r
-        while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)\r
-          p->tempBuf[rem++] = src[lookAhead++];\r
-        p->tempBufSize = rem;\r
-        if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)\r
-        {\r
-          int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);\r
-          if (dummyRes == DUMMY_ERROR)\r
-          {\r
-            (*srcLen) += lookAhead;\r
-            *status = LZMA_STATUS_NEEDS_MORE_INPUT;\r
-            return SZ_OK;\r
-          }\r
-          if (checkEndMarkNow && dummyRes != DUMMY_MATCH)\r
-          {\r
-            *status = LZMA_STATUS_NOT_FINISHED;\r
-            return SZ_ERROR_DATA;\r
-          }\r
-        }\r
-        p->buf = p->tempBuf;\r
-        if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)\r
-          return SZ_ERROR_DATA;\r
-        \r
-        {\r
-          unsigned kkk = (unsigned)(p->buf - p->tempBuf);\r
-          if (rem < kkk)\r
-            return SZ_ERROR_FAIL; /* some internal error */\r
-          rem -= kkk;\r
-          if (lookAhead < rem)\r
-            return SZ_ERROR_FAIL; /* some internal error */\r
-          lookAhead -= rem;\r
-        }\r
-        (*srcLen) += lookAhead;\r
-        src += lookAhead;\r
-        inSize -= lookAhead;\r
-        p->tempBufSize = 0;\r
-      }\r
-  }\r
-  \r
-  if (p->code != 0)\r
-    return SZ_ERROR_DATA;\r
-  *status = LZMA_STATUS_FINISHED_WITH_MARK;\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)\r
-{\r
-  SizeT outSize = *destLen;\r
-  SizeT inSize = *srcLen;\r
-  *srcLen = *destLen = 0;\r
-  for (;;)\r
-  {\r
-    SizeT inSizeCur = inSize, outSizeCur, dicPos;\r
-    ELzmaFinishMode curFinishMode;\r
-    SRes res;\r
-    if (p->dicPos == p->dicBufSize)\r
-      p->dicPos = 0;\r
-    dicPos = p->dicPos;\r
-    if (outSize > p->dicBufSize - dicPos)\r
-    {\r
-      outSizeCur = p->dicBufSize;\r
-      curFinishMode = LZMA_FINISH_ANY;\r
-    }\r
-    else\r
-    {\r
-      outSizeCur = dicPos + outSize;\r
-      curFinishMode = finishMode;\r
-    }\r
-\r
-    res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);\r
-    src += inSizeCur;\r
-    inSize -= inSizeCur;\r
-    *srcLen += inSizeCur;\r
-    outSizeCur = p->dicPos - dicPos;\r
-    memcpy(dest, p->dic + dicPos, outSizeCur);\r
-    dest += outSizeCur;\r
-    outSize -= outSizeCur;\r
-    *destLen += outSizeCur;\r
-    if (res != 0)\r
-      return res;\r
-    if (outSizeCur == 0 || outSize == 0)\r
-      return SZ_OK;\r
-  }\r
-}\r
-\r
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc)\r
-{\r
-  ISzAlloc_Free(alloc, p->probs);\r
-  p->probs = NULL;\r
-}\r
-\r
-static void LzmaDec_FreeDict(CLzmaDec *p, ISzAllocPtr alloc)\r
-{\r
-  ISzAlloc_Free(alloc, p->dic);\r
-  p->dic = NULL;\r
-}\r
-\r
-void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc)\r
-{\r
-  LzmaDec_FreeProbs(p, alloc);\r
-  LzmaDec_FreeDict(p, alloc);\r
-}\r
-\r
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)\r
-{\r
-  UInt32 dicSize;\r
-  Byte d;\r
-  \r
-  if (size < LZMA_PROPS_SIZE)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  else\r
-    dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);\r
\r
-  if (dicSize < LZMA_DIC_MIN)\r
-    dicSize = LZMA_DIC_MIN;\r
-  p->dicSize = dicSize;\r
-\r
-  d = data[0];\r
-  if (d >= (9 * 5 * 5))\r
-    return SZ_ERROR_UNSUPPORTED;\r
-\r
-  p->lc = (Byte)(d % 9);\r
-  d /= 9;\r
-  p->pb = (Byte)(d / 5);\r
-  p->lp = (Byte)(d % 5);\r
-\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAllocPtr alloc)\r
-{\r
-  UInt32 numProbs = LzmaProps_GetNumProbs(propNew);\r
-  if (!p->probs || numProbs != p->numProbs)\r
-  {\r
-    LzmaDec_FreeProbs(p, alloc);\r
-    p->probs = (CLzmaProb *)ISzAlloc_Alloc(alloc, numProbs * sizeof(CLzmaProb));\r
-    if (!p->probs)\r
-      return SZ_ERROR_MEM;\r
-    p->probs_1664 = p->probs + 1664;\r
-    p->numProbs = numProbs;\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc)\r
-{\r
-  CLzmaProps propNew;\r
-  RINOK(LzmaProps_Decode(&propNew, props, propsSize));\r
-  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));\r
-  p->prop = propNew;\r
-  return SZ_OK;\r
-}\r
-\r
-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc)\r
-{\r
-  CLzmaProps propNew;\r
-  SizeT dicBufSize;\r
-  RINOK(LzmaProps_Decode(&propNew, props, propsSize));\r
-  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));\r
-\r
-  {\r
-    UInt32 dictSize = propNew.dicSize;\r
-    SizeT mask = ((UInt32)1 << 12) - 1;\r
-         if (dictSize >= ((UInt32)1 << 30)) mask = ((UInt32)1 << 22) - 1;\r
-    else if (dictSize >= ((UInt32)1 << 22)) mask = ((UInt32)1 << 20) - 1;;\r
-    dicBufSize = ((SizeT)dictSize + mask) & ~mask;\r
-    if (dicBufSize < dictSize)\r
-      dicBufSize = dictSize;\r
-  }\r
-\r
-  if (!p->dic || dicBufSize != p->dicBufSize)\r
-  {\r
-    LzmaDec_FreeDict(p, alloc);\r
-    p->dic = (Byte *)ISzAlloc_Alloc(alloc, dicBufSize);\r
-    if (!p->dic)\r
-    {\r
-      LzmaDec_FreeProbs(p, alloc);\r
-      return SZ_ERROR_MEM;\r
-    }\r
-  }\r
-  p->dicBufSize = dicBufSize;\r
-  p->prop = propNew;\r
-  return SZ_OK;\r
-}\r
-\r
-SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-    const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,\r
-    ELzmaStatus *status, ISzAllocPtr alloc)\r
-{\r
-  CLzmaDec p;\r
-  SRes res;\r
-  SizeT outSize = *destLen, inSize = *srcLen;\r
-  *destLen = *srcLen = 0;\r
-  *status = LZMA_STATUS_NOT_SPECIFIED;\r
-  if (inSize < RC_INIT_SIZE)\r
-    return SZ_ERROR_INPUT_EOF;\r
-  LzmaDec_Construct(&p);\r
-  RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc));\r
-  p.dic = dest;\r
-  p.dicBufSize = outSize;\r
-  LzmaDec_Init(&p);\r
-  *srcLen = inSize;\r
-  res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);\r
-  *destLen = p.dicPos;\r
-  if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)\r
-    res = SZ_ERROR_INPUT_EOF;\r
-  LzmaDec_FreeProbs(&p, alloc);\r
-  return res;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.h
deleted file mode 100644 (file)
index 28ce60c..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/* LzmaDec.h -- LZMA Decoder\r
-2018-04-21 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZMA_DEC_H\r
-#define __LZMA_DEC_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-/* #define _LZMA_PROB32 */\r
-/* _LZMA_PROB32 can increase the speed on some CPUs,\r
-   but memory usage for CLzmaDec::probs will be doubled in that case */\r
-\r
-typedef\r
-#ifdef _LZMA_PROB32\r
-  UInt32\r
-#else\r
-  UInt16\r
-#endif\r
-  CLzmaProb;\r
-\r
-\r
-/* ---------- LZMA Properties ---------- */\r
-\r
-#define LZMA_PROPS_SIZE 5\r
-\r
-typedef struct _CLzmaProps\r
-{\r
-  Byte lc;\r
-  Byte lp;\r
-  Byte pb;\r
-  Byte _pad_;\r
-  UInt32 dicSize;\r
-} CLzmaProps;\r
-\r
-/* LzmaProps_Decode - decodes properties\r
-Returns:\r
-  SZ_OK\r
-  SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-*/\r
-\r
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);\r
-\r
-\r
-/* ---------- LZMA Decoder state ---------- */\r
-\r
-/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.\r
-   Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */\r
-\r
-#define LZMA_REQUIRED_INPUT_MAX 20\r
-\r
-typedef struct\r
-{\r
-  /* Don't change this structure. ASM code can use it. */\r
-  CLzmaProps prop;\r
-  CLzmaProb *probs;\r
-  CLzmaProb *probs_1664;\r
-  Byte *dic;\r
-  SizeT dicBufSize;\r
-  SizeT dicPos;\r
-  const Byte *buf;\r
-  UInt32 range;\r
-  UInt32 code;\r
-  UInt32 processedPos;\r
-  UInt32 checkDicSize;\r
-  UInt32 reps[4];\r
-  UInt32 state;\r
-  UInt32 remainLen;\r
-\r
-  UInt32 numProbs;\r
-  unsigned tempBufSize;\r
-  Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];\r
-} CLzmaDec;\r
-\r
-#define LzmaDec_Construct(p) { (p)->dic = NULL; (p)->probs = NULL; }\r
-\r
-void LzmaDec_Init(CLzmaDec *p);\r
-\r
-/* There are two types of LZMA streams:\r
-     - Stream with end mark. That end mark adds about 6 bytes to compressed size.\r
-     - Stream without end mark. You must know exact uncompressed size to decompress such stream. */\r
-\r
-typedef enum\r
-{\r
-  LZMA_FINISH_ANY,   /* finish at any point */\r
-  LZMA_FINISH_END    /* block must be finished at the end */\r
-} ELzmaFinishMode;\r
-\r
-/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!\r
-\r
-   You must use LZMA_FINISH_END, when you know that current output buffer\r
-   covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.\r
-\r
-   If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,\r
-   and output value of destLen will be less than output buffer size limit.\r
-   You can check status result also.\r
-\r
-   You can use multiple checks to test data integrity after full decompression:\r
-     1) Check Result and "status" variable.\r
-     2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.\r
-     3) Check that output(srcLen) = compressedSize, if you know real compressedSize.\r
-        You must use correct finish mode in that case. */\r
-\r
-typedef enum\r
-{\r
-  LZMA_STATUS_NOT_SPECIFIED,               /* use main error code instead */\r
-  LZMA_STATUS_FINISHED_WITH_MARK,          /* stream was finished with end mark. */\r
-  LZMA_STATUS_NOT_FINISHED,                /* stream was not finished */\r
-  LZMA_STATUS_NEEDS_MORE_INPUT,            /* you must provide more input bytes */\r
-  LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK  /* there is probability that stream was finished without end mark */\r
-} ELzmaStatus;\r
-\r
-/* ELzmaStatus is used only as output value for function call */\r
-\r
-\r
-/* ---------- Interfaces ---------- */\r
-\r
-/* There are 3 levels of interfaces:\r
-     1) Dictionary Interface\r
-     2) Buffer Interface\r
-     3) One Call Interface\r
-   You can select any of these interfaces, but don't mix functions from different\r
-   groups for same object. */\r
-\r
-\r
-/* There are two variants to allocate state for Dictionary Interface:\r
-     1) LzmaDec_Allocate / LzmaDec_Free\r
-     2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs\r
-   You can use variant 2, if you set dictionary buffer manually.\r
-   For Buffer Interface you must always use variant 1.\r
-\r
-LzmaDec_Allocate* can return:\r
-  SZ_OK\r
-  SZ_ERROR_MEM         - Memory allocation error\r
-  SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-*/\r
-   \r
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);\r
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc);\r
-\r
-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);\r
-void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc);\r
-\r
-/* ---------- Dictionary Interface ---------- */\r
-\r
-/* You can use it, if you want to eliminate the overhead for data copying from\r
-   dictionary to some other external buffer.\r
-   You must work with CLzmaDec variables directly in this interface.\r
-\r
-   STEPS:\r
-     LzmaDec_Construct()\r
-     LzmaDec_Allocate()\r
-     for (each new stream)\r
-     {\r
-       LzmaDec_Init()\r
-       while (it needs more decompression)\r
-       {\r
-         LzmaDec_DecodeToDic()\r
-         use data from CLzmaDec::dic and update CLzmaDec::dicPos\r
-       }\r
-     }\r
-     LzmaDec_Free()\r
-*/\r
-\r
-/* LzmaDec_DecodeToDic\r
-   \r
-   The decoding to internal dictionary buffer (CLzmaDec::dic).\r
-   You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!\r
-\r
-finishMode:\r
-  It has meaning only if the decoding reaches output limit (dicLimit).\r
-  LZMA_FINISH_ANY - Decode just dicLimit bytes.\r
-  LZMA_FINISH_END - Stream must be finished after dicLimit.\r
-\r
-Returns:\r
-  SZ_OK\r
-    status:\r
-      LZMA_STATUS_FINISHED_WITH_MARK\r
-      LZMA_STATUS_NOT_FINISHED\r
-      LZMA_STATUS_NEEDS_MORE_INPUT\r
-      LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK\r
-  SZ_ERROR_DATA - Data error\r
-*/\r
-\r
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,\r
-    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);\r
-\r
-\r
-/* ---------- Buffer Interface ---------- */\r
-\r
-/* It's zlib-like interface.\r
-   See LzmaDec_DecodeToDic description for information about STEPS and return results,\r
-   but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need\r
-   to work with CLzmaDec variables manually.\r
-\r
-finishMode:\r
-  It has meaning only if the decoding reaches output limit (*destLen).\r
-  LZMA_FINISH_ANY - Decode just destLen bytes.\r
-  LZMA_FINISH_END - Stream must be finished after (*destLen).\r
-*/\r
-\r
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,\r
-    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);\r
-\r
-\r
-/* ---------- One Call Interface ---------- */\r
-\r
-/* LzmaDecode\r
-\r
-finishMode:\r
-  It has meaning only if the decoding reaches output limit (*destLen).\r
-  LZMA_FINISH_ANY - Decode just destLen bytes.\r
-  LZMA_FINISH_END - Stream must be finished after (*destLen).\r
-\r
-Returns:\r
-  SZ_OK\r
-    status:\r
-      LZMA_STATUS_FINISHED_WITH_MARK\r
-      LZMA_STATUS_NOT_FINISHED\r
-      LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK\r
-  SZ_ERROR_DATA - Data error\r
-  SZ_ERROR_MEM  - Memory allocation error\r
-  SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-  SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).\r
-*/\r
-\r
-SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-    const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,\r
-    ELzmaStatus *status, ISzAllocPtr alloc);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Precomp.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Precomp.h
deleted file mode 100644 (file)
index edb5814..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Precomp.h -- StdAfx\r
-2013-11-12 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_PRECOMP_H\r
-#define __7Z_PRECOMP_H\r
-\r
-#include "Compiler.h"\r
-/* #include "7zTypes.h" */\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/DOC/lzma-history.txt b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/DOC/lzma-history.txt
deleted file mode 100644 (file)
index f479326..0000000
+++ /dev/null
@@ -1,424 +0,0 @@
-HISTORY of the LZMA SDK\r
------------------------\r
-\r
-18.05          2018-04-30\r
--------------------------\r
-- The speed for LZMA/LZMA2 compressing was increased \r
-    by 8% for fastest/fast compression levels and \r
-    by 3% for normal/maximum compression levels.\r
-- Previous versions of 7-Zip could work incorrectly in "Large memory pages" mode in\r
-  Windows 10 because of some BUG with "Large Pages" in Windows 10. \r
-  Now 7-Zip doesn't use "Large Pages" on Windows 10 up to revision 1709 (16299).\r
-- The BUG was fixed in Lzma2Enc.c\r
-    Lzma2Enc_Encode2() function worked incorretly,\r
-      if (inStream == NULL) and the number of block threads is more than 1.\r
-\r
-\r
-18.03 beta     2018-03-04\r
--------------------------\r
-- Asm\x86\LzmaDecOpt.asm: new optimized LZMA decoder written in asm \r
-  for x64 with about 30% higher speed than main version of LZMA decoder written in C.\r
-- The speed for single-thread LZMA/LZMA2 decoder written in C was increased by 3%.\r
-- 7-Zip now can use multi-threading for 7z/LZMA2 decoding,\r
-  if there are multiple independent data chunks in LZMA2 stream.\r
-- 7-Zip now can use multi-threading for xz decoding,\r
-  if there are multiple blocks in xz stream.\r
-\r
-\r
-18.01          2019-01-28\r
--------------------------\r
-- The BUG in 17.01 - 18.00 beta was fixed:\r
-  XzDec.c : random block unpacking and XzUnpacker_IsBlockFinished()\r
-  didn't work correctly for xz archives without checksum (CRC).\r
-\r
-\r
-18.00 beta     2019-01-10\r
--------------------------\r
-- The BUG in xz encoder was fixed:\r
-  There was memory leak of 16 KB for each file compressed with \r
-  xz compression method, if additional filter was used.\r
-\r
-\r
-17.01 beta     2017-08-28\r
--------------------------\r
-- Minor speed optimization for LZMA2 (xz and 7z) multi-threading compression.\r
-  7-Zip now uses additional memory buffers for multi-block LZMA2 compression.\r
-  CPU utilization was slightly improved.\r
-- 7-zip now creates multi-block xz archives by default. Block size can be \r
-  specified with -ms[Size]{m|g} switch.\r
-- xz decoder now can unpack random block from multi-block xz archives.\r
-- 7-Zip command line: @listfile now doesn't work after -- switch.\r
-  Use -i@listfile before -- switch instead.\r
-- The BUGs were fixed:\r
-  7-Zip 17.00 beta crashed for commands that write anti-item to 7z archive.\r
-\r
-\r
-17.00 beta     2017-04-29\r
--------------------------\r
-- NewHandler.h / NewHandler.cpp: \r
-    now it redefines operator new() only for old MSVC compilers (_MSC_VER < 1900).\r
-- C/7zTypes.h : the names of variables in interface structures were changed (vt).\r
-- Some bugs were fixed. 7-Zip could crash in some cases.\r
-- Some internal changes in code.\r
-\r
-\r
-16.04          2016-10-04\r
--------------------------\r
-- The bug was fixed in DllSecur.c.\r
-\r
-\r
-16.03          2016-09-28\r
--------------------------\r
-- SFX modules now use some protection against DLL preloading attack.\r
-- Some bugs in 7z code were fixed.\r
-\r
-\r
-16.02          2016-05-21\r
--------------------------\r
-- The BUG in 16.00 - 16.01 was fixed:\r
-  Split Handler (SplitHandler.cpp) returned incorrect \r
-  total size value (kpidSize) for split archives.\r
-\r
-\r
-16.01          2016-05-19\r
--------------------------      \r
-- Some internal changes to reduce the number of compiler warnings.\r
-\r
-\r
-16.00          2016-05-10\r
--------------------------      \r
-- Some bugs were fixed.\r
-\r
-\r
-15.12          2015-11-19\r
--------------------------      \r
-- The BUG in C version of 7z decoder was fixed:\r
-  7zDec.c : SzDecodeLzma2()\r
-  7z decoder could mistakenly report about decoding error for some 7z archives\r
-  that use LZMA2 compression method.\r
-  The probability to get that mistaken decoding error report was about \r
-  one error per 16384 solid blocks for solid blocks larger than 16 KB (compressed size). \r
-- The BUG (in 9.26-15.11) in C version of 7z decoder was fixed:\r
-  7zArcIn.c : SzReadHeader2()\r
-  7z decoder worked incorrectly for 7z archives that contain \r
-  empty solid blocks, that can be placed to 7z archive, if some file is \r
-  unavailable for reading during archive creation.\r
-\r
-\r
-15.09 beta     2015-10-16\r
--------------------------      \r
-- The BUG in LZMA / LZMA2 encoding code was fixed.\r
-  The BUG in LzFind.c::MatchFinder_ReadBlock() function.\r
-  If input data size is larger than (4 GiB - dictionary_size),\r
-  the following code worked incorrectly:\r
-  -  LZMA : LzmaEnc_MemEncode(), LzmaEncode() : LZMA encoding functions \r
-     for compressing from memory to memory. \r
-     That BUG is not related to LZMA encoder version that works via streams.\r
-  -  LZMA2 : multi-threaded version of LZMA2 encoder worked incorrectly, if \r
-     default value of chunk size (CLzma2EncProps::blockSize) is changed \r
-     to value larger than (4 GiB - dictionary_size).\r
-\r
-\r
-9.38 beta      2015-01-03\r
--------------------------      \r
-- The BUG in 9.31-9.37 was fixed:\r
-  IArchiveGetRawProps interface was disabled for 7z archives.\r
-- The BUG in 9.26-9.36 was fixed:\r
-  Some code in CPP\7zip\Archive\7z\ worked correctly only under Windows.\r
-\r
-\r
-9.36 beta      2014-12-26\r
--------------------------      \r
-- The BUG in command line version was fixed:\r
-  7-Zip created temporary archive in current folder during update archive\r
-  operation, if -w{Path} switch was not specified. \r
-  The fixed 7-Zip creates temporary archive in folder that contains updated archive.\r
-- The BUG in 9.33-9.35 was fixed:\r
-  7-Zip silently ignored file reading errors during 7z or gz archive creation,\r
-  and the created archive contained only part of file that was read before error.\r
-  The fixed 7-Zip stops archive creation and it reports about error.\r
-\r
-\r
-9.35 beta      2014-12-07\r
--------------------------      \r
-- 7zr.exe now support AES encryption.\r
-- SFX mudules were added to LZMA SDK\r
-- Some bugs were fixed.\r
-\r
-\r
-9.21 beta      2011-04-11\r
--------------------------      \r
-- New class FString for file names at file systems.\r
-- Speed optimization in CRC code for big-endian CPUs.\r
-- The BUG in Lzma2Dec.c was fixed:\r
-    Lzma2Decode function didn't work.\r
-\r
-\r
-9.18 beta      2010-11-02\r
--------------------------      \r
-- New small SFX module for installers (SfxSetup).\r
-\r
-\r
-9.12 beta      2010-03-24\r
--------------------------\r
-- The BUG in LZMA SDK 9.* was fixed: LZMA2 codec didn't work,\r
-  if more than 10 threads were used (or more than 20 threads in some modes).\r
-\r
-\r
-9.11 beta      2010-03-15\r
--------------------------\r
-- PPMd compression method support\r
-   \r
-\r
-9.09           2009-12-12\r
--------------------------\r
-- The bug was fixed:\r
-   Utf16_To_Utf8 funstions in UTFConvert.cpp and 7zMain.c\r
-   incorrectly converted surrogate characters (the code >= 0x10000) to UTF-8.\r
-- Some bugs were fixed\r
-\r
-\r
-9.06           2009-08-17\r
--------------------------\r
-- Some changes in ANSI-C 7z Decoder interfaces.\r
-\r
-\r
-9.04           2009-05-30\r
--------------------------\r
-- LZMA2 compression method support\r
-- xz format support\r
-\r
-\r
-4.65           2009-02-03\r
--------------------------\r
-- Some minor fixes\r
-\r
-\r
-4.63           2008-12-31\r
--------------------------\r
-- Some minor fixes\r
-\r
-\r
-4.61 beta      2008-11-23\r
--------------------------\r
-- The bug in ANSI-C LZMA Decoder was fixed:\r
-    If encoded stream was corrupted, decoder could access memory \r
-    outside of allocated range.\r
-- Some changes in ANSI-C 7z Decoder interfaces.\r
-- LZMA SDK is placed in the public domain.\r
-\r
-\r
-4.60 beta      2008-08-19\r
--------------------------\r
-- Some minor fixes.\r
-\r
-\r
-4.59 beta      2008-08-13\r
--------------------------\r
-- The bug was fixed:\r
-    LZMA Encoder in fast compression mode could access memory outside of \r
-    allocated range in some rare cases.\r
-\r
-\r
-4.58 beta      2008-05-05\r
--------------------------\r
-- ANSI-C LZMA Decoder was rewritten for speed optimizations.\r
-- ANSI-C LZMA Encoder was included to LZMA SDK.\r
-- C++ LZMA code now is just wrapper over ANSI-C code.\r
-\r
-\r
-4.57           2007-12-12\r
--------------------------\r
-- Speed optimizations in ?++ LZMA Decoder. \r
-- Small changes for more compatibility with some C/C++ compilers.\r
-\r
-\r
-4.49 beta      2007-07-05\r
--------------------------\r
-- .7z ANSI-C Decoder:\r
-     - now it supports BCJ and BCJ2 filters\r
-     - now it supports files larger than 4 GB.\r
-     - now it supports "Last Write Time" field for files.\r
-- C++ code for .7z archives compressing/decompressing from 7-zip \r
-  was included to LZMA SDK.\r
-  \r
-\r
-4.43           2006-06-04\r
--------------------------\r
-- Small changes for more compatibility with some C/C++ compilers.\r
-  \r
-\r
-4.42           2006-05-15\r
--------------------------\r
-- Small changes in .h files in ANSI-C version.\r
-  \r
-\r
-4.39 beta      2006-04-14\r
--------------------------\r
-- The bug in versions 4.33b:4.38b was fixed:\r
-  C++ version of LZMA encoder could not correctly compress \r
-  files larger than 2 GB with HC4 match finder (-mfhc4).\r
-  \r
-\r
-4.37 beta      2005-04-06\r
--------------------------\r
-- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined. \r
-\r
-\r
-4.35 beta      2005-03-02\r
--------------------------\r
-- The bug was fixed in C++ version of LZMA Decoder:\r
-    If encoded stream was corrupted, decoder could access memory \r
-    outside of allocated range.\r
-\r
-\r
-4.34 beta      2006-02-27\r
--------------------------\r
-- Compressing speed and memory requirements for compressing were increased\r
-- LZMA now can use only these match finders: HC4, BT2, BT3, BT4\r
-\r
-\r
-4.32           2005-12-09\r
--------------------------\r
-- Java version of LZMA SDK was included\r
-\r
-\r
-4.30           2005-11-20\r
--------------------------\r
-- Compression ratio was improved in -a2 mode\r
-- Speed optimizations for compressing in -a2 mode\r
-- -fb switch now supports values up to 273\r
-- The bug in 7z_C (7zIn.c) was fixed:\r
-  It used Alloc/Free functions from different memory pools.\r
-  So if program used two memory pools, it worked incorrectly.\r
-- 7z_C: .7z format supporting was improved\r
-- LZMA# SDK (C#.NET version) was included\r
-\r
-\r
-4.27 (Updated) 2005-09-21\r
--------------------------\r
-- Some GUIDs/interfaces in C++ were changed.\r
- IStream.h:\r
-   ISequentialInStream::Read now works as old ReadPart\r
-   ISequentialOutStream::Write now works as old WritePart\r
-\r
-\r
-4.27           2005-08-07\r
--------------------------\r
-- The bug in LzmaDecodeSize.c was fixed:\r
-   if _LZMA_IN_CB and _LZMA_OUT_READ were defined,\r
-   decompressing worked incorrectly.\r
-\r
-\r
-4.26           2005-08-05\r
--------------------------\r
-- Fixes in 7z_C code and LzmaTest.c:\r
-  previous versions could work incorrectly,\r
-  if malloc(0) returns 0\r
-\r
-\r
-4.23           2005-06-29\r
--------------------------\r
-- Small fixes in C++ code\r
-\r
-\r
-4.22           2005-06-10\r
--------------------------\r
-- Small fixes\r
-\r
-\r
-4.21           2005-06-08\r
--------------------------\r
-- Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed\r
-- New additional version of ANSI-C LZMA Decoder with zlib-like interface:\r
-    - LzmaStateDecode.h\r
-    - LzmaStateDecode.c\r
-    - LzmaStateTest.c\r
-- ANSI-C LZMA Decoder now can decompress files larger than 4 GB\r
-\r
-\r
-4.17           2005-04-18\r
--------------------------\r
-- New example for RAM->RAM compressing/decompressing: \r
-  LZMA + BCJ (filter for x86 code):\r
-    - LzmaRam.h\r
-    - LzmaRam.cpp\r
-    - LzmaRamDecode.h\r
-    - LzmaRamDecode.c\r
-    - -f86 switch for lzma.exe\r
-\r
-\r
-4.16           2005-03-29\r
--------------------------\r
-- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder): \r
-   If _LZMA_OUT_READ was defined, and if encoded stream was corrupted,\r
-   decoder could access memory outside of allocated range.\r
-- Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster).\r
-  Old version of LZMA Decoder now is in file LzmaDecodeSize.c. \r
-  LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c\r
-- Small speed optimization in LZMA C++ code\r
-- filter for SPARC's code was added\r
-- Simplified version of .7z ANSI-C Decoder was included\r
-\r
-\r
-4.06           2004-09-05\r
--------------------------\r
-- The bug in v4.05 was fixed:\r
-    LZMA-Encoder didn't release output stream in some cases.\r
-\r
-\r
-4.05           2004-08-25\r
--------------------------\r
-- Source code of filters for x86, IA-64, ARM, ARM-Thumb \r
-  and PowerPC code was included to SDK\r
-- Some internal minor changes\r
-\r
-\r
-4.04           2004-07-28\r
--------------------------\r
-- More compatibility with some C++ compilers\r
-\r
-\r
-4.03           2004-06-18\r
--------------------------\r
-- "Benchmark" command was added. It measures compressing \r
-  and decompressing speed and shows rating values. \r
-  Also it checks hardware errors.\r
-\r
-\r
-4.02           2004-06-10\r
--------------------------\r
-- C++ LZMA Encoder/Decoder code now is more portable\r
-  and it can be compiled by GCC on Linux.\r
-\r
-\r
-4.01           2004-02-15\r
--------------------------\r
-- Some detection of data corruption was enabled.\r
-    LzmaDecode.c / RangeDecoderReadByte\r
-    .....\r
-    {\r
-      rd->ExtraBytes = 1;\r
-      return 0xFF;\r
-    }\r
-\r
-\r
-4.00           2004-02-13\r
--------------------------\r
-- Original version of LZMA SDK\r
-\r
-\r
-\r
-HISTORY of the LZMA\r
--------------------\r
-  2001-2008:  Improvements to LZMA compressing/decompressing code, \r
-              keeping compatibility with original LZMA format\r
-  1996-2001:  Development of LZMA compression format\r
-\r
-  Some milestones:\r
-\r
-  2001-08-30: LZMA compression was added to 7-Zip\r
-  1999-01-02: First version of 7-Zip was released\r
-  \r
-\r
-End of document\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/DOC/lzma-sdk.txt b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk/DOC/lzma-sdk.txt
deleted file mode 100644 (file)
index 01521e9..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-LZMA SDK 18.05\r
---------------\r
-\r
-LZMA SDK provides the documentation, samples, header files,\r
-libraries, and tools you need to develop applications that \r
-use 7z / LZMA / LZMA2 / XZ compression.\r
-\r
-LZMA is an improved version of famous LZ77 compression algorithm. \r
-It was improved in way of maximum increasing of compression ratio,\r
-keeping high decompression speed and low memory requirements for \r
-decompressing.\r
-\r
-LZMA2 is a LZMA based compression method. LZMA2 provides better \r
-multithreading support for compression than LZMA and some other improvements.\r
-\r
-7z is a file format for data compression and file archiving.\r
-7z is a main file format for 7-Zip compression program (www.7-zip.org).\r
-7z format supports different compression methods: LZMA, LZMA2 and others.\r
-7z also supports AES-256 based encryption.\r
-\r
-XZ is a file format for data compression that uses LZMA2 compression.\r
-XZ format provides additional features: SHA/CRC check, filters for \r
-improved compression ratio, splitting to blocks and streams,\r
-\r
-\r
-\r
-LICENSE\r
--------\r
-\r
-LZMA SDK is written and placed in the public domain by Igor Pavlov.\r
-\r
-Some code in LZMA SDK is based on public domain code from another developers:\r
-  1) PPMd var.H (2001): Dmitry Shkarin\r
-  2) SHA-256: Wei Dai (Crypto++ library)\r
-\r
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute the \r
-original LZMA SDK code, either in source code form or as a compiled binary, for \r
-any purpose, commercial or non-commercial, and by any means.\r
-\r
-LZMA SDK code is compatible with open source licenses, for example, you can \r
-include it to GNU GPL or GNU LGPL code.\r
-\r
-\r
-LZMA SDK Contents\r
------------------\r
-\r
-  Source code:\r
-\r
-    - C / C++ / C# / Java   - LZMA compression and decompression\r
-    - C / C++               - LZMA2 compression and decompression\r
-    - C / C++               - XZ compression and decompression\r
-    - C                     - 7z decompression\r
-    -     C++               - 7z compression and decompression\r
-    - C                     - small SFXs for installers (7z decompression)\r
-    -     C++               - SFXs and SFXs for installers (7z decompression)\r
-\r
-  Precomiled binaries:\r
-\r
-    - console programs for lzma / 7z / xz compression and decompression\r
-    - SFX modules for installers.\r
-\r
-\r
-UNIX/Linux version \r
-------------------\r
-To compile C++ version of file->file LZMA encoding, go to directory\r
-CPP/7zip/Bundles/LzmaCon\r
-and call make to recompile it:\r
-  make -f makefile.gcc clean all\r
-\r
-In some UNIX/Linux versions you must compile LZMA with static libraries.\r
-To compile with static libraries, you can use \r
-LIB = -lm -static\r
-\r
-Also you can use p7zip (port of 7-Zip for POSIX systems like Unix or Linux):\r
-  \r
-  http://p7zip.sourceforge.net/\r
-\r
-\r
-Files\r
------\r
-\r
-DOC/7zC.txt          - 7z ANSI-C Decoder description\r
-DOC/7zFormat.txt     - 7z Format description\r
-DOC/installer.txt    - information about 7-Zip for installers\r
-DOC/lzma.txt         - LZMA compression description\r
-DOC/lzma-sdk.txt     - LZMA SDK description (this file)\r
-DOC/lzma-history.txt - history of LZMA SDK\r
-DOC/lzma-specification.txt - Specification of LZMA\r
-DOC/Methods.txt      - Compression method IDs for .7z\r
-\r
-bin/installer/   - example script to create installer that uses SFX module,\r
-\r
-bin/7zdec.exe    - simplified 7z archive decoder\r
-bin/7zr.exe      - 7-Zip console program (reduced version)\r
-bin/x64/7zr.exe  - 7-Zip console program (reduced version) (x64 version)\r
-bin/lzma.exe     - file->file LZMA encoder/decoder for Windows\r
-bin/7zS2.sfx     - small SFX module for installers (GUI version)\r
-bin/7zS2con.sfx  - small SFX module for installers (Console version)\r
-bin/7zSD.sfx     - SFX module for installers.\r
-\r
-\r
-7zDec.exe\r
----------\r
-7zDec.exe is simplified 7z archive decoder.\r
-It supports only LZMA, LZMA2, and PPMd methods.\r
-7zDec decodes whole solid block from 7z archive to RAM.\r
-The RAM consumption can be high.\r
-\r
-\r
-\r
-\r
-Source code structure\r
----------------------\r
-\r
-\r
-Asm/ - asm files (optimized code for CRC calculation and Intel-AES encryption)\r
-\r
-C/  - C files (compression / decompression and other)\r
-  Util/\r
-    7z       - 7z decoder program (decoding 7z files)\r
-    Lzma     - LZMA program (file->file LZMA encoder/decoder).\r
-    LzmaLib  - LZMA library (.DLL for Windows)\r
-    SfxSetup - small SFX module for installers \r
-\r
-CPP/ -- CPP files\r
-\r
-  Common  - common files for C++ projects\r
-  Windows - common files for Windows related code\r
-\r
-  7zip    - files related to 7-Zip\r
-\r
-    Archive - files related to archiving\r
-\r
-      Common   - common files for archive handling\r
-      7z       - 7z C++ Encoder/Decoder\r
-\r
-    Bundles  - Modules that are bundles of other modules (files)\r
-  \r
-      Alone7z       - 7zr.exe: Standalone 7-Zip console program (reduced version)\r
-      Format7zExtractR  - 7zxr.dll: Reduced version of 7z DLL: extracting from 7z/LZMA/BCJ/BCJ2.\r
-      Format7zR         - 7zr.dll:  Reduced version of 7z DLL: extracting/compressing to 7z/LZMA/BCJ/BCJ2\r
-      LzmaCon       - lzma.exe: LZMA compression/decompression\r
-      LzmaSpec      - example code for LZMA Specification\r
-      SFXCon        - 7zCon.sfx: Console 7z SFX module\r
-      SFXSetup      - 7zS.sfx: 7z SFX module for installers\r
-      SFXWin        - 7z.sfx: GUI 7z SFX module\r
-\r
-    Common   - common files for 7-Zip\r
-\r
-    Compress - files for compression/decompression\r
-\r
-    Crypto   - files for encryption / decompression\r
-\r
-    UI       - User Interface files\r
-         \r
-      Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll\r
-      Common   - Common UI files\r
-      Console  - Code for console program (7z.exe)\r
-      Explorer    - Some code from 7-Zip Shell extension\r
-      FileManager - Some GUI code from 7-Zip File Manager\r
-      GUI         - Some GUI code from 7-Zip\r
-\r
-\r
-CS/ - C# files\r
-  7zip\r
-    Common   - some common files for 7-Zip\r
-    Compress - files related to compression/decompression\r
-      LZ     - files related to LZ (Lempel-Ziv) compression algorithm\r
-      LZMA         - LZMA compression/decompression\r
-      LzmaAlone    - file->file LZMA compression/decompression\r
-      RangeCoder   - Range Coder (special code of compression/decompression)\r
-\r
-Java/  - Java files\r
-  SevenZip\r
-    Compression    - files related to compression/decompression\r
-      LZ           - files related to LZ (Lempel-Ziv) compression algorithm\r
-      LZMA         - LZMA compression/decompression\r
-      RangeCoder   - Range Coder (special code of compression/decompression)\r
-\r
-\r
-Note: \r
-  Asm / C / C++ source code of LZMA SDK is part of 7-Zip's source code.\r
-  7-Zip's source code can be downloaded from 7-Zip's SourceForge page:\r
-\r
-  http://sourceforge.net/projects/sevenzip/\r
-\r
-\r
-\r
-LZMA features\r
--------------\r
-  - Variable dictionary size (up to 1 GB)\r
-  - Estimated compressing speed: about 2 MB/s on 2 GHz CPU\r
-  - Estimated decompressing speed: \r
-      - 20-30 MB/s on modern 2 GHz cpu\r
-      - 1-2 MB/s on 200 MHz simple RISC cpu: (ARM, MIPS, PowerPC)\r
-  - Small memory requirements for decompressing (16 KB + DictionarySize)\r
-  - Small code size for decompressing: 5-8 KB\r
-\r
-LZMA decoder uses only integer operations and can be \r
-implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).\r
-\r
-Some critical operations that affect the speed of LZMA decompression:\r
-  1) 32*16 bit integer multiply\r
-  2) Mispredicted branches (penalty mostly depends from pipeline length)\r
-  3) 32-bit shift and arithmetic operations\r
-\r
-The speed of LZMA decompressing mostly depends from CPU speed.\r
-Memory speed has no big meaning. But if your CPU has small data cache, \r
-overall weight of memory speed will slightly increase.\r
-\r
-\r
-How To Use\r
-----------\r
-\r
-Using LZMA encoder/decoder executable\r
---------------------------------------\r
-\r
-Usage:  LZMA <e|d> inputFile outputFile [<switches>...]\r
-\r
-  e: encode file\r
-\r
-  d: decode file\r
-\r
-  b: Benchmark. There are two tests: compressing and decompressing \r
-     with LZMA method. Benchmark shows rating in MIPS (million \r
-     instructions per second). Rating value is calculated from \r
-     measured speed and it is normalized with Intel's Core 2 results.\r
-     Also Benchmark checks possible hardware errors (RAM \r
-     errors in most cases). Benchmark uses these settings:\r
-     (-a1, -d21, -fb32, -mfbt4). You can change only -d parameter. \r
-     Also you can change the number of iterations. Example for 30 iterations:\r
-       LZMA b 30\r
-     Default number of iterations is 10.\r
-\r
-<Switches>\r
-  \r
-\r
-  -a{N}:  set compression mode 0 = fast, 1 = normal\r
-          default: 1 (normal)\r
-\r
-  d{N}:   Sets Dictionary size - [0, 30], default: 23 (8MB)\r
-          The maximum value for dictionary size is 1 GB = 2^30 bytes.\r
-          Dictionary size is calculated as DictionarySize = 2^N bytes. \r
-          For decompressing file compressed by LZMA method with dictionary \r
-          size D = 2^N you need about D bytes of memory (RAM).\r
-\r
-  -fb{N}: set number of fast bytes - [5, 273], default: 128\r
-          Usually big number gives a little bit better compression ratio \r
-          and slower compression process.\r
-\r
-  -lc{N}: set number of literal context bits - [0, 8], default: 3\r
-          Sometimes lc=4 gives gain for big files.\r
-\r
-  -lp{N}: set number of literal pos bits - [0, 4], default: 0\r
-          lp switch is intended for periodical data when period is \r
-          equal 2^N. For example, for 32-bit (4 bytes) \r
-          periodical data you can use lp=2. Often it's better to set lc0, \r
-          if you change lp switch.\r
-\r
-  -pb{N}: set number of pos bits - [0, 4], default: 2\r
-          pb switch is intended for periodical data \r
-          when period is equal 2^N.\r
-\r
-  -mf{MF_ID}: set Match Finder. Default: bt4. \r
-              Algorithms from hc* group doesn't provide good compression \r
-              ratio, but they often works pretty fast in combination with \r
-              fast mode (-a0).\r
-\r
-              Memory requirements depend from dictionary size \r
-              (parameter "d" in table below). \r
-\r
-               MF_ID     Memory                   Description\r
-\r
-                bt2    d *  9.5 + 4MB  Binary Tree with 2 bytes hashing.\r
-                bt3    d * 11.5 + 4MB  Binary Tree with 3 bytes hashing.\r
-                bt4    d * 11.5 + 4MB  Binary Tree with 4 bytes hashing.\r
-                hc4    d *  7.5 + 4MB  Hash Chain with 4 bytes hashing.\r
-\r
-  -eos:   write End Of Stream marker. By default LZMA doesn't write \r
-          eos marker, since LZMA decoder knows uncompressed size \r
-          stored in .lzma file header.\r
-\r
-  -si:    Read data from stdin (it will write End Of Stream marker).\r
-  -so:    Write data to stdout\r
-\r
-\r
-Examples:\r
-\r
-1) LZMA e file.bin file.lzma -d16 -lc0 \r
-\r
-compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K)  \r
-and 0 literal context bits. -lc0 allows to reduce memory requirements \r
-for decompression.\r
-\r
-\r
-2) LZMA e file.bin file.lzma -lc0 -lp2\r
-\r
-compresses file.bin to file.lzma with settings suitable \r
-for 32-bit periodical data (for example, ARM or MIPS code).\r
-\r
-3) LZMA d file.lzma file.bin\r
-\r
-decompresses file.lzma to file.bin.\r
-\r
-\r
-Compression ratio hints\r
------------------------\r
-\r
-Recommendations\r
----------------\r
-\r
-To increase the compression ratio for LZMA compressing it's desirable \r
-to have aligned data (if it's possible) and also it's desirable to locate\r
-data in such order, where code is grouped in one place and data is \r
-grouped in other place (it's better than such mixing: code, data, code,\r
-data, ...).\r
-\r
-\r
-Filters\r
--------\r
-You can increase the compression ratio for some data types, using\r
-special filters before compressing. For example, it's possible to \r
-increase the compression ratio on 5-10% for code for those CPU ISAs: \r
-x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC.\r
-\r
-You can find C source code of such filters in C/Bra*.* files\r
-\r
-You can check the compression ratio gain of these filters with such \r
-7-Zip commands (example for ARM code):\r
-No filter:\r
-  7z a a1.7z a.bin -m0=lzma\r
-\r
-With filter for little-endian ARM code:\r
-  7z a a2.7z a.bin -m0=arm -m1=lzma        \r
-\r
-It works in such manner:\r
-Compressing    = Filter_encoding + LZMA_encoding\r
-Decompressing  = LZMA_decoding + Filter_decoding\r
-\r
-Compressing and decompressing speed of such filters is very high,\r
-so it will not increase decompressing time too much.\r
-Moreover, it reduces decompression time for LZMA_decoding, \r
-since compression ratio with filtering is higher.\r
-\r
-These filters convert CALL (calling procedure) instructions \r
-from relative offsets to absolute addresses, so such data becomes more \r
-compressible.\r
-\r
-For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.\r
-\r
-\r
-\r
----\r
-\r
-http://www.7-zip.org\r
-http://www.7-zip.org/sdk.html\r
-http://www.7-zip.org/support.html\r
diff --git a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/UefiLzma.h b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/UefiLzma.h
deleted file mode 100644 (file)
index cbdecd3..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/** @file\r
-  LZMA UEFI header file\r
-\r
-  Allows LZMA code to build under UEFI (edk2) build environment\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __UEFILZMA_H__\r
-#define __UEFILZMA_H__\r
-\r
-#include <Uefi.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
-#ifdef _WIN32\r
-#undef _WIN32\r
-#endif\r
-\r
-#ifndef _SIZE_T_DEFINED\r
-#if !defined(_WIN64) || defined(__GNUC__)\r
-typedef unsigned int size_t;\r
-#endif\r
-#endif\r
-\r
-#ifdef _WIN64\r
-#undef _WIN64\r
-#endif\r
-\r
-#ifndef _PTRDIFF_T_DEFINED\r
-typedef int ptrdiff_t;\r
-#endif\r
-\r
-#define memcpy CopyMem\r
-#define memmove CopyMem\r
-\r
-#define _LZMA_SIZE_OPT\r
-\r
-#endif // __UEFILZMA_H__\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
deleted file mode 100644 (file)
index 1840b6d..0000000
+++ /dev/null
@@ -1,600 +0,0 @@
-/** @file\r
-  Debug Library based on report status code library.\r
-\r
-  Note that if the debug message length is larger than the maximum allowable\r
-  record length, then the debug message will be ignored directly.\r
-\r
-  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/DebugPrintErrorLevelLib.h>\r
-\r
-//\r
-// VA_LIST can not initialize to NULL for all compiler, so we use this to\r
-// indicate a null VA_LIST\r
-//\r
-VA_LIST     mVaListNull;\r
-\r
-/**\r
-  Prints a debug message to the debug output device if the specified error level is enabled.\r
-\r
-  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r
-  GetDebugPrintErrorLevel (), then print the message specified by Format and the\r
-  associated variable argument list to the debug output device.\r
-\r
-  If Format is NULL, then ASSERT().\r
-\r
-  If the length of the message string specificed by Format is larger than the maximum allowable\r
-  record length, then directly return and not print it.\r
-\r
-  @param  ErrorLevel  The error level of the debug message.\r
-  @param  Format      Format string for the debug message to print.\r
-  @param  ...         Variable argument list whose contents are accessed\r
-                      based on the format string specified by Format.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-DebugPrint (\r
-  IN  UINTN        ErrorLevel,\r
-  IN  CONST CHAR8  *Format,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST         Marker;\r
-\r
-  VA_START (Marker, Format);\r
-  DebugVPrint (ErrorLevel, Format, Marker);\r
-  VA_END (Marker);\r
-}\r
-\r
-/**\r
-  Prints a debug message to the debug output device if the specified\r
-  error level is enabled base on Null-terminated format string and a\r
-  VA_LIST argument list or a BASE_LIST argument list.\r
-\r
-  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r
-  GetDebugPrintErrorLevel (), then print the message specified by Format and\r
-  the associated variable argument list to the debug output device.\r
-\r
-  Only one list type is used.\r
-  If BaseListMarker == NULL, then use VaListMarker.\r
-  Otherwise use BaseListMarker and the VaListMarker should be initilized as\r
-  mVaListNull.\r
-\r
-  If Format is NULL, then ASSERT().\r
-\r
-  @param  ErrorLevel      The error level of the debug message.\r
-  @param  Format          Format string for the debug message to print.\r
-  @param  VaListMarker    VA_LIST marker for the variable argument list.\r
-  @param  BaseListMarker  BASE_LIST marker for the variable argument list.\r
-\r
-**/\r
-VOID\r
-DebugPrintMarker (\r
-  IN  UINTN         ErrorLevel,\r
-  IN  CONST CHAR8   *Format,\r
-  IN  VA_LIST       VaListMarker,\r
-  IN  BASE_LIST     BaseListMarker\r
-  )\r
-{\r
-  UINT64          Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1];\r
-  EFI_DEBUG_INFO  *DebugInfo;\r
-  UINTN           TotalSize;\r
-  UINTN           DestBufferSize;\r
-  BASE_LIST       BaseListMarkerPointer;\r
-  CHAR8           *FormatString;\r
-  BOOLEAN         Long;\r
-\r
-  //\r
-  // If Format is NULL, then ASSERT().\r
-  //\r
-  ASSERT (Format != NULL);\r
-\r
-  //\r
-  // Check driver Debug Level value and global debug level\r
-  //\r
-  if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Compute the total size of the record.\r
-  // Note that the passing-in format string and variable parameters will be constructed to\r
-  // the following layout:\r
-  //\r
-  //                Buffer->|------------------------|\r
-  //                        |         Padding        | 4 bytes\r
-  //             DebugInfo->|------------------------|\r
-  //                        |      EFI_DEBUG_INFO    | sizeof(EFI_DEBUG_INFO)\r
-  // BaseListMarkerPointer->|------------------------|\r
-  //                        |           ...          |\r
-  //                        |   variable arguments   | 12 * sizeof (UINT64)\r
-  //                        |           ...          |\r
-  //                        |------------------------|\r
-  //                        |       Format String    |\r
-  //                        |------------------------|<- (UINT8 *)Buffer + sizeof(Buffer)\r
-  //\r
-  TotalSize = 4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrSize (Format);\r
-\r
-  //\r
-  // If the TotalSize is larger than the maximum record size, then truncate it.\r
-  //\r
-  if (TotalSize > sizeof (Buffer)) {\r
-    TotalSize = sizeof (Buffer);\r
-  }\r
-\r
-  //\r
-  // Fill in EFI_DEBUG_INFO\r
-  //\r
-  // Here we skip the first 4 bytes of Buffer, because we must ensure BaseListMarkerPointer is\r
-  // 64-bit aligned, otherwise retrieving 64-bit parameter from BaseListMarkerPointer will cause\r
-  // exception on IPF. Buffer starts at 64-bit aligned address, so skipping 4 types (sizeof(EFI_DEBUG_INFO))\r
-  // just makes address of BaseListMarkerPointer, which follows DebugInfo, 64-bit aligned.\r
-  //\r
-  DebugInfo             = (EFI_DEBUG_INFO *)(Buffer) + 1;\r
-  DebugInfo->ErrorLevel = (UINT32)ErrorLevel;\r
-  BaseListMarkerPointer = (BASE_LIST)(DebugInfo + 1);\r
-  FormatString          = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);\r
-\r
-  //\r
-  // Copy the Format string into the record. It will be truncated if it's too long.\r
-  //\r
-  // According to the content structure of Buffer shown above, the size of\r
-  // the FormatString buffer is the size of Buffer minus the Padding\r
-  // (4 bytes), minus the size of EFI_DEBUG_INFO, minus the size of\r
-  // variable arguments (12 * sizeof (UINT64)).\r
-  //\r
-  DestBufferSize = sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * sizeof (UINT64);\r
-  AsciiStrnCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format, DestBufferSize / sizeof (CHAR8) - 1);\r
-\r
-  //\r
-  // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments\r
-  // of format in DEBUG string, which is followed by the DEBUG format string.\r
-  // Here we will process the variable arguments and pack them in this area.\r
-  //\r
-  for (; *Format != '\0'; Format++) {\r
-    //\r
-    // Only format with prefix % is processed.\r
-    //\r
-    if (*Format != '%') {\r
-      continue;\r
-    }\r
-    Long = FALSE;\r
-    //\r
-    // Parse Flags and Width\r
-    //\r
-    for (Format++; TRUE; Format++) {\r
-      if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') {\r
-        //\r
-        // These characters in format field are omitted.\r
-        //\r
-        continue;\r
-      }\r
-      if (*Format >= '0' && *Format <= '9') {\r
-        //\r
-        // These characters in format field are omitted.\r
-        //\r
-        continue;\r
-      }\r
-      if (*Format == 'L' || *Format == 'l') {\r
-        //\r
-        // 'L" or "l" in format field means the number being printed is a UINT64\r
-        //\r
-        Long = TRUE;\r
-        continue;\r
-      }\r
-      if (*Format == '*') {\r
-        //\r
-        // '*' in format field means the precision of the field is specified by\r
-        // a UINTN argument in the argument list.\r
-        //\r
-        if (BaseListMarker == NULL) {\r
-          BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);\r
-        } else {\r
-          BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);\r
-        }\r
-        continue;\r
-      }\r
-      if (*Format == '\0') {\r
-        //\r
-        // Make no output if Format string terminates unexpectedly when\r
-        // looking up for flag, width, precision and type.\r
-        //\r
-        Format--;\r
-      }\r
-      //\r
-      // When valid argument type detected or format string terminates unexpectedly,\r
-      // the inner loop is done.\r
-      //\r
-      break;\r
-    }\r
-\r
-    //\r
-    // Pack variable arguments into the storage area following EFI_DEBUG_INFO.\r
-    //\r
-    if ((*Format == 'p') && (sizeof (VOID *) > 4)) {\r
-      Long = TRUE;\r
-    }\r
-    if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {\r
-      if (Long) {\r
-        if (BaseListMarker == NULL) {\r
-          BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG (VaListMarker, INT64);\r
-        } else {\r
-          BASE_ARG (BaseListMarkerPointer, INT64) = BASE_ARG (BaseListMarker, INT64);\r
-        }\r
-      } else {\r
-        if (BaseListMarker == NULL) {\r
-          BASE_ARG (BaseListMarkerPointer, int) = VA_ARG (VaListMarker, int);\r
-        } else {\r
-          BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG (BaseListMarker, int);\r
-        }\r
-      }\r
-    } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') {\r
-      if (BaseListMarker == NULL) {\r
-        BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG (VaListMarker, VOID *);\r
-      } else {\r
-        BASE_ARG (BaseListMarkerPointer, VOID *) = BASE_ARG (BaseListMarker, VOID *);\r
-      }\r
-    } else if (*Format == 'c') {\r
-      if (BaseListMarker == NULL) {\r
-        BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);\r
-      } else {\r
-        BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);\r
-      }\r
-    } else if (*Format == 'r') {\r
-      if (BaseListMarker == NULL) {\r
-        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);\r
-      } else {\r
-        BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = BASE_ARG (BaseListMarker, RETURN_STATUS);\r
-      }\r
-    }\r
-\r
-    //\r
-    // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then ASSERT()\r
-    // This indicates that the DEBUG() macro is passing in more argument than can be handled by\r
-    // the EFI_DEBUG_INFO record\r
-    //\r
-    ASSERT ((CHAR8 *)BaseListMarkerPointer <= FormatString);\r
-\r
-    //\r
-    // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then return\r
-    //\r
-    if ((CHAR8 *)BaseListMarkerPointer > FormatString) {\r
-      return;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Send the DebugInfo record\r
-  //\r
-  REPORT_STATUS_CODE_EX (\r
-    EFI_DEBUG_CODE,\r
-    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),\r
-    0,\r
-    NULL,\r
-    &gEfiStatusCodeDataTypeDebugGuid,\r
-    DebugInfo,\r
-    TotalSize\r
-    );\r
-}\r
-\r
-/**\r
-  Prints a debug message to the debug output device if the specified\r
-  error level is enabled.\r
-\r
-  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r
-  GetDebugPrintErrorLevel (), then print the message specified by Format and\r
-  the associated variable argument list to the debug output device.\r
-\r
-  If Format is NULL, then ASSERT().\r
-\r
-  @param  ErrorLevel    The error level of the debug message.\r
-  @param  Format        Format string for the debug message to print.\r
-  @param  VaListMarker  VA_LIST marker for the variable argument list.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-DebugVPrint (\r
-  IN  UINTN         ErrorLevel,\r
-  IN  CONST CHAR8   *Format,\r
-  IN  VA_LIST       VaListMarker\r
-  )\r
-{\r
-  DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);\r
-}\r
-\r
-/**\r
-  Prints a debug message to the debug output device if the specified\r
-  error level is enabled.\r
-  This function use BASE_LIST which would provide a more compatible\r
-  service than VA_LIST.\r
-\r
-  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r
-  GetDebugPrintErrorLevel (), then print the message specified by Format and\r
-  the associated variable argument list to the debug output device.\r
-\r
-  If Format is NULL, then ASSERT().\r
-\r
-  @param  ErrorLevel      The error level of the debug message.\r
-  @param  Format          Format string for the debug message to print.\r
-  @param  BaseListMarker  BASE_LIST marker for the variable argument list.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-DebugBPrint (\r
-  IN  UINTN         ErrorLevel,\r
-  IN  CONST CHAR8   *Format,\r
-  IN  BASE_LIST     BaseListMarker\r
-  )\r
-{\r
-  DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);\r
-}\r
-\r
-/**\r
-  Prints an assert message containing a filename, line number, and description.\r
-  This may be followed by a breakpoint or a dead loop.\r
-\r
-  Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"\r
-  to the debug output device.  If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of\r
-  PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if\r
-  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then\r
-  CpuDeadLoop() is called.  If neither of these bits are set, then this function\r
-  returns immediately after the message is printed to the debug output device.\r
-  DebugAssert() must actively prevent recursion.  If DebugAssert() is called while\r
-  processing another DebugAssert(), then DebugAssert() must return immediately.\r
-\r
-  If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.\r
-  If Description is NULL, then a <Description> string of "(NULL) Description" is printed.\r
-\r
-  @param  FileName     Pointer to the name of the source file that generated the assert condition.\r
-  @param  LineNumber   The line number in the source file that generated the assert condition\r
-  @param  Description  Pointer to the description of the assert condition.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-DebugAssert (\r
-  IN CONST CHAR8  *FileName,\r
-  IN UINTN        LineNumber,\r
-  IN CONST CHAR8  *Description\r
-  )\r
-{\r
-  UINT64                 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)];\r
-  EFI_DEBUG_ASSERT_DATA  *AssertData;\r
-  UINTN                  HeaderSize;\r
-  UINTN                  TotalSize;\r
-  CHAR8                  *Temp;\r
-  UINTN                  ModuleNameSize;\r
-  UINTN                  FileNameSize;\r
-  UINTN                  DescriptionSize;\r
-\r
-  //\r
-  // Get string size\r
-  //\r
-  HeaderSize       = sizeof (EFI_DEBUG_ASSERT_DATA);\r
-  //\r
-  // Compute string size of module name enclosed by []\r
-  //\r
-  ModuleNameSize   = 2 + AsciiStrSize (gEfiCallerBaseName);\r
-  FileNameSize     = AsciiStrSize (FileName);\r
-  DescriptionSize  = AsciiStrSize (Description);\r
-\r
-  //\r
-  // Make sure it will all fit in the passed in buffer.\r
-  //\r
-  if (HeaderSize + ModuleNameSize + FileNameSize + DescriptionSize > sizeof (Buffer)) {\r
-    //\r
-    // remove module name if it's too long to be filled into buffer\r
-    //\r
-    ModuleNameSize = 0;\r
-    if (HeaderSize + FileNameSize + DescriptionSize > sizeof (Buffer)) {\r
-      //\r
-      // FileName + Description is too long to be filled into buffer.\r
-      //\r
-      if (HeaderSize + FileNameSize < sizeof (Buffer)) {\r
-        //\r
-        // Description has enough buffer to be truncated.\r
-        //\r
-        DescriptionSize = sizeof (Buffer) - HeaderSize - FileNameSize;\r
-      } else {\r
-        //\r
-        // FileName is too long to be filled into buffer.\r
-        // FileName will be truncated. Reserved one byte for Description NULL terminator.\r
-        //\r
-        DescriptionSize = 1;\r
-        FileNameSize    = sizeof (Buffer) - HeaderSize - DescriptionSize;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Fill in EFI_DEBUG_ASSERT_DATA\r
-  //\r
-  AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;\r
-  AssertData->LineNumber = (UINT32)LineNumber;\r
-  TotalSize  = sizeof (EFI_DEBUG_ASSERT_DATA);\r
-\r
-  Temp = (CHAR8 *)(AssertData + 1);\r
-\r
-  //\r
-  // Copy Ascii [ModuleName].\r
-  //\r
-  if (ModuleNameSize != 0) {\r
-    CopyMem(Temp, "[", 1);\r
-    CopyMem(Temp + 1, gEfiCallerBaseName, ModuleNameSize - 3);\r
-    CopyMem(Temp + ModuleNameSize - 2, "] ", 2);\r
-  }\r
-\r
-  //\r
-  // Copy Ascii FileName including NULL terminator.\r
-  //\r
-  Temp = CopyMem (Temp + ModuleNameSize, FileName, FileNameSize);\r
-  Temp[FileNameSize - 1] = 0;\r
-  TotalSize += (ModuleNameSize + FileNameSize);\r
-\r
-  //\r
-  // Copy Ascii Description include NULL terminator.\r
-  //\r
-  Temp = CopyMem (Temp + FileNameSize, Description, DescriptionSize);\r
-  Temp[DescriptionSize - 1] = 0;\r
-  TotalSize += DescriptionSize;\r
-\r
-  REPORT_STATUS_CODE_EX (\r
-    (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),\r
-    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),\r
-    0,\r
-    NULL,\r
-    NULL,\r
-    AssertData,\r
-    TotalSize\r
-    );\r
-\r
-  //\r
-  // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings\r
-  //\r
-  if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {\r
-    CpuBreakpoint ();\r
-  } else if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {\r
-    CpuDeadLoop ();\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r
-\r
-  This function fills Length bytes of Buffer with the value specified by\r
-  PcdDebugClearMemoryValue, and returns Buffer.\r
-\r
-  If Buffer is NULL, then ASSERT().\r
-  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
-\r
-  @param   Buffer  Pointer to the target buffer to be filled with PcdDebugClearMemoryValue.\r
-  @param   Length  Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.\r
-\r
-  @return  Buffer  Pointer to the target buffer filled with PcdDebugClearMemoryValue.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-DebugClearMemory (\r
-  OUT VOID  *Buffer,\r
-  IN UINTN  Length\r
-  )\r
-{\r
-  ASSERT (Buffer != NULL);\r
-\r
-  return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if ASSERT() macros are enabled.\r
-\r
-  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of\r
-  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.\r
-  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-DebugAssertEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if DEBUG() macros are enabled.\r
-\r
-  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of\r
-  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.\r
-  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-DebugPrintEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if DEBUG_CODE() macros are enabled.\r
-\r
-  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of\r
-  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.\r
-  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-DebugCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.\r
-\r
-  This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of\r
-  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE    The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.\r
-  @retval  FALSE   The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-DebugClearMemoryEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
-}\r
-\r
-/**\r
-  Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel.\r
-\r
-  This function compares the bit mask of ErrorLevel and PcdFixedDebugPrintErrorLevel.\r
-\r
-  @retval  TRUE    Current ErrorLevel is supported.\r
-  @retval  FALSE   Current ErrorLevel is not supported.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-DebugPrintLevelEnabled (\r
-  IN  CONST UINTN        ErrorLevel\r
-  )\r
-{\r
-  return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
deleted file mode 100644 (file)
index b52fc56..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-## @file\r
-#  Debug Library based on report status code library\r
-#\r
-#  Debug Library for PEIMs and DXE drivers that sends debug messages to ReportStatusCode\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = PeiDxeDebugLibReportStatusCode\r
-  MODULE_UNI_FILE                = PeiDxeDebugLibReportStatusCode.uni\r
-  FILE_GUID                      = bda39d3a-451b-4350-8266-81ab10fa0523\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE PEIM SEC PEI_CORE UEFI_APPLICATION UEFI_DRIVER\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  DebugLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  ReportStatusCodeLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  DebugPrintErrorLevelLib\r
-\r
-[Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue  ## SOMETIMES_CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask      ## CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel ## CONSUMES\r
-\r
-[Guids]\r
-  gEfiStatusCodeDataTypeDebugGuid    ## SOMETIMES_CONSUMES ## GUID\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.uni b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.uni
deleted file mode 100644 (file)
index 0b508b2..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// Debug Library based on report status code library\r
-//\r
-// Debug Library for PEIMs and DXE drivers that sends debug messages to ReportStatusCode\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Debug Library based on report status code library"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "Debug Library for PEIMs and DXE drivers that sends debug messages to ReportStatusCode."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.c b/IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.c
deleted file mode 100644 (file)
index 8072f8a..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/** @file\r
-  This Library uses Framework RecoveryModule PPI to do system recovery.\r
-\r
-  This library instance is no longer used and module using this library\r
-  class should update to directly locate EFI_PEI_RECOVERY_MODULE_PPI defined\r
-  in PI 1.2 specification.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-#include <PiPei.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
-#include <Library/DebugLib.h>\r
-\r
-#include <Ppi/RecoveryModule.h>\r
-\r
-/**\r
-  Calling this function causes the system do recovery.\r
-\r
-  @retval EFI_SUCESS   Sucess to do recovery.\r
-  @retval Others       Fail to do recovery.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiRecoverFirmware (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_PEI_RECOVERY_MODULE_PPI     *PeiRecovery;\r
-\r
-  Status = PeiServicesLocatePpi (\r
-             &gEfiPeiRecoveryModulePpiGuid,\r
-             0,\r
-             NULL,\r
-             (VOID **)&PeiRecovery\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return PeiRecovery->LoadRecoveryCapsule ((EFI_PEI_SERVICES  **) GetPeiServicesTablePointer(), PeiRecovery);\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.inf b/IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.inf
deleted file mode 100644 (file)
index 12fe957..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-## @file\r
-#  PEIM Recovery Library supports system recovery boot.\r
-#\r
-#  This library instance is no longer used and module using this library\r
-#  class should update to directly locate EFI_PEI_RECOVERY_MODULE_PPI defined\r
-#  in PI 1.2 specification.\r
-#\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = PeiRecoveryLib\r
-  MODULE_UNI_FILE                = PeiRecoveryLib.uni\r
-  FILE_GUID                      = C0227547-0811-4cbb-ABEA-DECD22829122\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = RecoveryLib|PEIM\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  PeiRecoveryLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  PeiServicesTablePointerLib\r
-  DebugLib\r
-\r
-[Ppis]\r
-  gEfiPeiRecoveryModulePpiGuid            ## CONSUMES\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.uni b/IntelFrameworkModulePkg/Library/PeiRecoveryLib/PeiRecoveryLib.uni
deleted file mode 100644 (file)
index 1b70492..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// PEIM Recovery Library supports system recovery boot.\r
-//\r
-// This library instance is no longer used and module using this library\r
-// class should update to directly locate EFI_PEI_RECOVERY_MODULE_PPI defined\r
-// in PI 1.2 specification.\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "PEIM Recovery Library supports system recovery boot"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This library instance is no longer used and any module using this library class should update to directly locate EFI_PEI_RECOVERY_MODULE_PPI defined in the PI 1.2 Specification."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.c b/IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.c
deleted file mode 100644 (file)
index a858349..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/** @file\r
-  This library provides API to invoke the S3 resume vector in the APCI Table in S3 resume mode.\r
-\r
-  This library instance is no longer used and module using this library\r
-  class should update to directly locate EFI_PEI_S3_RESUME_PPI defined\r
-  in PI 1.2 specification.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
-#include <Library/DebugLib.h>\r
-\r
-#include <Ppi/S3Resume.h>\r
-\r
-/**\r
-  This function is responsible for calling the S3 resume vector in the ACPI Tables.\r
-\r
-  @retval EFI_SUCESS   Success to restore config from S3.\r
-  @retval Others       Fail to restore config from S3.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-AcpiS3ResumeOs (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_PEI_S3_RESUME_PPI   *S3Resume;\r
-\r
-  Status = PeiServicesLocatePpi (\r
-             &gEfiPeiS3ResumePpiGuid,\r
-             0,\r
-             NULL,\r
-             (VOID **)&S3Resume\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return S3Resume->S3RestoreConfig ((EFI_PEI_SERVICES  **) GetPeiServicesTablePointer());\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.inf b/IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.inf
deleted file mode 100644 (file)
index c368db9..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-## @file\r
-#  This library provides API to invoke the S3 resume vector in the ACPI Table in S3 resume mode.\r
-#\r
-#  This library instance is no longer used and module using this library\r
-#  class should update to directly locate EFI_PEI_S3_RESUME_PPI defined\r
-#  in PI 1.2 specification.\r
-#\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = PeiS3Lib\r
-  MODULE_UNI_FILE                = PeiS3Lib.uni\r
-  FILE_GUID                      = EFB7D3A8-DEB9-4bed-B6D6-3B09BEEB835A\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = S3Lib|PEIM\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  PeiS3Lib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-[LibraryClasses]\r
-  PeiServicesTablePointerLib\r
-  DebugLib\r
-\r
-[Ppis]\r
-  gEfiPeiS3ResumePpiGuid                ## CONSUMES\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.uni b/IntelFrameworkModulePkg/Library/PeiS3Lib/PeiS3Lib.uni
deleted file mode 100644 (file)
index 85d004e..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// This library provides API to invoke the S3 resume vector in the ACPI Table in S3 resume mode.\r
-//\r
-// This library instance is no longer used and module using this library\r
-// class should update to directly locate EFI_PEI_S3_RESUME_PPI defined\r
-// in PI 1.2 specification.\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Provides an API to invoke the S3 resume vector in the ACPI Table in S3 resume mode"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This library instance is no longer used and any module using this library class should update to directly locate EFI_PEI_S3_RESUME_PPI defined in the PI 1.2 Specification."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/BdsPlatform.c b/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/BdsPlatform.c
deleted file mode 100644 (file)
index 9173004..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/** @file\r
-  This file include all platform action which can be customized by IBV/OEM.\r
-\r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BdsPlatform.h"\r
-\r
-//\r
-// BDS Platform Functions\r
-//\r
-/**\r
-  Platform Bds init. Include the platform firmware vendor, revision\r
-  and so crc check.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsInit (\r
-  VOID\r
-  )\r
-{\r
-}\r
-\r
-/**\r
-  Connect the predefined platform default console device. Always try to find\r
-  and enable the vga device if have.\r
-\r
-  @param PlatformConsole          Predefined platform default console device array.\r
-\r
-  @retval EFI_SUCCESS             Success connect at least one ConIn and ConOut\r
-                                  device, there must have one ConOut device is\r
-                                  active vga device.\r
-  @return Return the status of BdsLibConnectAllDefaultConsoles ()\r
-\r
-**/\r
-EFI_STATUS\r
-PlatformBdsConnectConsole (\r
-  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Connect with predefined platform connect sequence,\r
-  the OEM/IBV can customize with their own connect sequence.\r
-**/\r
-VOID\r
-PlatformBdsConnectSequence (\r
-  VOID\r
-  )\r
-{\r
-}\r
-\r
-/**\r
-  Load the predefined driver option, OEM/IBV can customize this\r
-  to load their own drivers\r
-\r
-  @param BdsDriverLists  - The header of the driver option link list.\r
-\r
-**/\r
-VOID\r
-PlatformBdsGetDriverOption (\r
-  IN OUT LIST_ENTRY              *BdsDriverLists\r
-  )\r
-{\r
-}\r
-\r
-/**\r
-  Perform the platform diagnostic, such like test memory. OEM/IBV also\r
-  can customize this function to support specific platform diagnostic.\r
-\r
-  @param MemoryTestLevel  The memory test intensive level\r
-  @param QuietBoot        Indicate if need to enable the quiet boot\r
-  @param BaseMemoryTest   A pointer to BdsMemoryTest()\r
-\r
-**/\r
-VOID\r
-PlatformBdsDiagnostics (\r
-  IN EXTENDMEM_COVERAGE_LEVEL    MemoryTestLevel,\r
-  IN BOOLEAN                     QuietBoot,\r
-  IN BASEM_MEMORY_TEST           BaseMemoryTest\r
-  )\r
-{\r
-}\r
-\r
-/**\r
-  The function will execute with as the platform policy, current policy\r
-  is driven by boot mode. IBV/OEM can customize this code for their specific\r
-  policy action.\r
-\r
-  @param  DriverOptionList        The header of the driver option link list\r
-  @param  BootOptionList          The header of the boot option link list\r
-  @param  ProcessCapsules         A pointer to ProcessCapsules()\r
-  @param  BaseMemoryTest          A pointer to BaseMemoryTest()\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsPolicyBehavior (\r
-  IN LIST_ENTRY                      *DriverOptionList,\r
-  IN LIST_ENTRY                      *BootOptionList,\r
-  IN PROCESS_CAPSULES                ProcessCapsules,\r
-  IN BASEM_MEMORY_TEST               BaseMemoryTest\r
-  )\r
-{\r
-}\r
-\r
-/**\r
-  Hook point after a boot attempt succeeds. We don't expect a boot option to\r
-  return, so the UEFI 2.0 specification defines that you will default to an\r
-  interactive mode and stop processing the BootOrder list in this case. This\r
-  is also a platform implementation and can be customized by IBV/OEM.\r
-\r
-  @param  Option                  Pointer to Boot Option that succeeded to boot.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootSuccess (\r
-  IN  BDS_COMMON_OPTION *Option\r
-  )\r
-{\r
-}\r
-\r
-/**\r
-  Hook point after a boot attempt fails.\r
-\r
-  @param  Option                  Pointer to Boot Option that failed to boot.\r
-  @param  Status                  Status returned from failed boot.\r
-  @param  ExitData                Exit data returned from failed boot.\r
-  @param  ExitDataSize            Exit data size returned from failed boot.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootFail (\r
-  IN  BDS_COMMON_OPTION  *Option,\r
-  IN  EFI_STATUS         Status,\r
-  IN  CHAR16             *ExitData,\r
-  IN  UINTN              ExitDataSize\r
-  )\r
-{\r
-}\r
-\r
-/**\r
-  This function locks platform flash that is not allowed to be updated during normal boot path.\r
-  The flash layout is platform specific.\r
-**/\r
-VOID\r
-EFIAPI\r
-PlatformBdsLockNonUpdatableFlash (\r
-  VOID\r
-  )\r
-{\r
-  return ;\r
-}\r
-\r
-\r
-/**\r
-  Lock the ConsoleIn device in system table. All key\r
-  presses will be ignored until the Password is typed in. The only way to\r
-  disable the password is to type it in to a ConIn device.\r
-\r
-  @param  Password        Password used to lock ConIn device.\r
-\r
-  @retval EFI_SUCCESS     lock the Console In Spliter virtual handle successfully.\r
-  @retval EFI_UNSUPPORTED Password not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LockKeyboards (\r
-  IN  CHAR16    *Password\r
-  )\r
-{\r
-    return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/BdsPlatform.h b/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/BdsPlatform.h
deleted file mode 100644 (file)
index 0932364..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/** @file\r
-  Head file for BDS Platform specific code\r
-\r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _BDS_PLATFORM_H_\r
-#define _BDS_PLATFORM_H_\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/GenericBdsLib.h>\r
-#include <Library/PlatformBdsLib.h>\r
-\r
-\r
-#endif // _BDS_PLATFORM_H\r
diff --git a/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformBdsLib.uni b/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformBdsLib.uni
deleted file mode 100644 (file)
index 3e01668..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// NULL implementation for PlatformBdsLib library class interfaces.\r
-//\r
-// NULL implementation for PlatformBdsLib library class interfaces.\r
-//\r
-// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "NULL implementation for PlatformBdsLib library class interfaces"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "NULL implementation for PlatformBdsLib library class interfaces."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf b/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf
deleted file mode 100644 (file)
index 211a47a..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-## @file\r
-#  NULL implementation for PlatformBdsLib library class interfaces.\r
-#\r
-#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = PlatformBdsLib\r
-  MODULE_UNI_FILE                = PlatformBdsLib.uni\r
-  FILE_GUID                      = 143B5044-7C1B-4904-9778-EA16F1F3D554\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PlatformBdsLib|DXE_DRIVER\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  BdsPlatform.c\r
-  PlatformData.c\r
-  BdsPlatform.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  MemoryAllocationLib\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  PcdLib\r
-  GenericBdsLib\r
diff --git a/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformData.c b/IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformData.c
deleted file mode 100644 (file)
index 5d27f1d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/** @file\r
-  Defined the platform specific device path which will be used by\r
-  platform Bbd to perform the platform policy connect.\r
-\r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BdsPlatform.h"\r
-\r
-///\r
-/// Predefined platform default time out value\r
-///\r
-UINT16                      gPlatformBootTimeOutDefault = 10;\r
diff --git a/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/ReportStatusCodeLib.c b/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/ReportStatusCodeLib.c
deleted file mode 100644 (file)
index e4e8661..0000000
+++ /dev/null
@@ -1,487 +0,0 @@
-/** @file\r
-  API implementation for instance of Report Status Code Library.\r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "ReportStatusCodeLibInternal.h"\r
-\r
-/**\r
-  Converts a status code to an 8-bit POST code value.\r
-\r
-  Converts the status code specified by CodeType and Value to an 8-bit POST code\r
-  and returns the 8-bit POST code in PostCode.  If CodeType is an\r
-  EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode\r
-  are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits\r
-  24..26 of Value., and TRUE is returned.  Otherwise, FALSE is returned.\r
-\r
-  If PostCode is NULL, then ASSERT().\r
-\r
-  @param  CodeType  The type of status code being converted.\r
-  @param  Value     The status code value being converted.\r
-  @param  PostCode  A pointer to the 8-bit POST code value to return.\r
-\r
-  @retval  TRUE   The status code specified by CodeType and Value was converted\r
-                  to an 8-bit POST code and returned in  PostCode.\r
-  @retval  FALSE  The status code specified by CodeType and Value could not be\r
-                  converted to an 8-bit POST code value.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-CodeTypeToPostCode (\r
-  IN  EFI_STATUS_CODE_TYPE   CodeType,\r
-  IN  EFI_STATUS_CODE_VALUE  Value,\r
-  OUT UINT8                  *PostCode\r
-  )\r
-{\r
-  //\r
-  // If PostCode is NULL, then ASSERT()\r
-  //\r
-  ASSERT (PostCode != NULL);\r
-\r
-  //\r
-  // Convert Value to an 8 bit post code\r
-  //\r
-  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
-      ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)       ) {\r
-    *PostCode  = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r
-                          (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r
-    return TRUE;\r
-  }\r
-  return FALSE;\r
-}\r
-\r
-\r
-/**\r
-  Extracts ASSERT() information from a status code structure.\r
-\r
-  Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r
-  arguments specified by Filename, Description, and LineNumber.  If CodeType is\r
-  an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and\r
-  Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract\r
-  Filename, Description, and LineNumber from the optional data area of the\r
-  status code buffer specified by Data.  The optional data area of Data contains\r
-  a Null-terminated ASCII string for the FileName, followed by a Null-terminated\r
-  ASCII string for the Description, followed by a 32-bit LineNumber.  If the\r
-  ASSERT() information could be extracted from Data, then return TRUE.\r
-  Otherwise, FALSE is returned.\r
-\r
-  If Data is NULL, then ASSERT().\r
-  If Filename is NULL, then ASSERT().\r
-  If Description is NULL, then ASSERT().\r
-  If LineNumber is NULL, then ASSERT().\r
-\r
-  @param  CodeType     The type of status code being converted.\r
-  @param  Value        The status code value being converted.\r
-  @param  Data         Pointer to status code data buffer.\r
-  @param  Filename     Pointer to the source file name that generated the ASSERT().\r
-  @param  Description  Pointer to the description of the ASSERT().\r
-  @param  LineNumber   Pointer to source line number that generated the ASSERT().\r
-\r
-  @retval  TRUE   The status code specified by CodeType, Value, and Data was\r
-                  converted ASSERT() arguments specified by Filename, Description,\r
-                  and LineNumber.\r
-  @retval  FALSE  The status code specified by CodeType, Value, and Data could\r
-                  not be converted to ASSERT() arguments.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportStatusCodeExtractAssertInfo (\r
-  IN EFI_STATUS_CODE_TYPE        CodeType,\r
-  IN EFI_STATUS_CODE_VALUE       Value,\r
-  IN CONST EFI_STATUS_CODE_DATA  *Data,\r
-  OUT CHAR8                      **Filename,\r
-  OUT CHAR8                      **Description,\r
-  OUT UINT32                     *LineNumber\r
-  )\r
-{\r
-  EFI_DEBUG_ASSERT_DATA  *AssertData;\r
-\r
-  ASSERT (Data        != NULL);\r
-  ASSERT (Filename    != NULL);\r
-  ASSERT (Description != NULL);\r
-  ASSERT (LineNumber  != NULL);\r
-\r
-  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK)      == EFI_ERROR_CODE) &&\r
-      ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK)  == EFI_ERROR_UNRECOVERED) &&\r
-      ((Value    & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {\r
-    AssertData   = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r
-    *Filename    = (CHAR8 *)(AssertData + 1);\r
-    *Description = *Filename + AsciiStrLen (*Filename) + 1;\r
-    *LineNumber  = AssertData->LineNumber;\r
-    return TRUE;\r
-  }\r
-  return FALSE;\r
-}\r
-\r
-\r
-/**\r
-  Extracts DEBUG() information from a status code structure.\r
-\r
-  Converts the status code specified by Data to the DEBUG() arguments specified\r
-  by ErrorLevel, Marker, and Format.  If type GUID in Data is\r
-  EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and\r
-  Format from the optional data area of the status code buffer specified by Data.\r
-  The optional data area of Data contains a 32-bit ErrorLevel followed by Marker\r
-  which is 12 UINTN parameters, followed by a Null-terminated ASCII string for\r
-  the Format.  If the DEBUG() information could be extracted from Data, then\r
-  return TRUE.  Otherwise, FALSE is returned.\r
-\r
-  If Data is NULL, then ASSERT().\r
-  If ErrorLevel is NULL, then ASSERT().\r
-  If Marker is NULL, then ASSERT().\r
-  If Format is NULL, then ASSERT().\r
-\r
-  @param  Data        Pointer to status code data buffer.\r
-  @param  ErrorLevel  Pointer to error level mask for a debug message.\r
-  @param  Marker      Pointer to the variable argument list associated with Format.\r
-  @param  Format      Pointer to a Null-terminated ASCII format string of a\r
-                      debug message.\r
-\r
-  @retval  TRUE   The status code specified by Data was converted DEBUG() arguments\r
-                  specified by ErrorLevel, Marker, and Format.\r
-  @retval  FALSE  The status code specified by Data could not be converted to\r
-                  DEBUG() arguments.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportStatusCodeExtractDebugInfo (\r
-  IN CONST EFI_STATUS_CODE_DATA  *Data,\r
-  OUT UINT32                     *ErrorLevel,\r
-  OUT BASE_LIST                  *Marker,\r
-  OUT CHAR8                      **Format\r
-  )\r
-{\r
-  EFI_DEBUG_INFO  *DebugInfo;\r
-\r
-  ASSERT (Data       != NULL);\r
-  ASSERT (ErrorLevel != NULL);\r
-  ASSERT (Marker     != NULL);\r
-  ASSERT (Format     != NULL);\r
-\r
-  //\r
-  // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE\r
-  //\r
-  if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Retrieve the debug information from the status code record\r
-  //\r
-  DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r
-\r
-  *ErrorLevel = DebugInfo->ErrorLevel;\r
-\r
-  //\r
-  // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments\r
-  // of format in DEBUG string. Its address is returned in Marker and has to be 64-bit aligned.\r
-  // It must be noticed that EFI_DEBUG_INFO follows EFI_STATUS_CODE_DATA, whose size is\r
-  // 20 bytes. The size of EFI_DEBUG_INFO is 4 bytes, so we can ensure that Marker\r
-  // returned is 64-bit aligned.\r
-  // 64-bit aligned is a must, otherwise retrieving 64-bit parameter from BASE_LIST will\r
-  // cause unalignment exception.\r
-  //\r
-  *Marker = (BASE_LIST) (DebugInfo + 1);\r
-  *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code.\r
-\r
-  Reports the status code specified by the parameters Type and Value.  Status\r
-  code also require an instance, caller ID, and extended data.  This function\r
-  passed in a zero instance, NULL extended data, and a caller ID of\r
-  gEfiCallerIdGuid, which is the GUID for the module.\r
-\r
-  ReportStatusCode()must actively prevent recusrsion.  If ReportStatusCode()\r
-  is called while processing another any other Report Status Code Library function,\r
-  then ReportStatusCode() must return immediately.\r
-\r
-  @param  Type   Status code type.\r
-  @param  Value  Status code value.\r
-\r
-  @retval  EFI_SUCCESS       The status code was reported.\r
-  @retval  EFI_DEVICE_ERROR  There status code could not be reported due to a\r
-                             device error.\r
-  @retval  EFI_UNSUPPORTED   Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCode (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value\r
-  )\r
-{\r
-  return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code with a Device Path Protocol as the extended data.\r
-\r
-  Allocates and fills in the extended data section of a status code with the\r
-  Device Path Protocol specified by DevicePath.  This function is responsible\r
-  for allocating a buffer large enough for the standard header and the device\r
-  path.  The standard header is filled in with a GUID of\r
-  gEfiStatusCodeSpecificDataGuid.  The status code is reported with a zero\r
-  instance and a caller ID of gEfiCallerIdGuid.\r
-\r
-  ReportStatusCodeWithDevicePath()must actively prevent recursion.  If\r
-  ReportStatusCodeWithDevicePath() is called while processing another any other\r
-  Report Status Code Library function, then ReportStatusCodeWithDevicePath()\r
-  must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If DevicePath is NULL, then ASSERT().\r
-\r
-  @param  Type        Status code type.\r
-  @param  Value       Status code value.\r
-  @param  DevicePath  Pointer to the Device Path Protocol to be reported.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported with the extended\r
-                                 data specified by DevicePath.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the\r
-                                 extended data section.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeWithDevicePath (\r
-  IN EFI_STATUS_CODE_TYPE            Type,\r
-  IN EFI_STATUS_CODE_VALUE           Value,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  )\r
-{\r
-  ASSERT (DevicePath != NULL);\r
-  return ReportStatusCodeWithExtendedData (\r
-           Type,\r
-           Value,\r
-           (VOID *)DevicePath,\r
-           GetDevicePathSize (DevicePath)\r
-           );\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code with an extended data buffer.\r
-\r
-  Allocates and fills in the extended data section of a status code with the\r
-  extended data specified by ExtendedData and ExtendedDataSize.  ExtendedData\r
-  is assumed to be one of the data structures specified in Related Definitions.\r
-  These data structure do not have the standard header, so this function is\r
-  responsible for allocating a buffer large enough for the standard header and\r
-  the extended data passed into this function.  The standard header is filled\r
-  in with a GUID of  gEfiStatusCodeSpecificDataGuid.  The status code is reported\r
-  with a zero instance and a caller ID of gEfiCallerIdGuid.\r
-\r
-  ReportStatusCodeWithExtendedData()must actively prevent recursion.  If\r
-  ReportStatusCodeWithExtendedData() is called while processing another any other\r
-  Report Status Code Library function, then ReportStatusCodeWithExtendedData()\r
-  must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If ExtendedData is NULL, then ASSERT().\r
-  If ExtendedDataSize is 0, then ASSERT().\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  ExtendedData      Pointer to the extended data buffer to be reported.\r
-  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer to\r
-                            be reported.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported with the extended\r
-                                 data specified by ExtendedData and ExtendedDataSize.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the\r
-                                 extended data section.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeWithExtendedData (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value,\r
-  IN CONST VOID             *ExtendedData,\r
-  IN UINTN                  ExtendedDataSize\r
-  )\r
-{\r
-  ASSERT (ExtendedData     != NULL);\r
-  ASSERT (ExtendedDataSize != 0);\r
-  return ReportStatusCodeEx (\r
-           Type,\r
-           Value,\r
-           0,\r
-           NULL,\r
-           NULL,\r
-           ExtendedData,\r
-           ExtendedDataSize\r
-           );\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code with full parameters.\r
-\r
-  The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize\r
-  is 0, then an extended data buffer is not reported.  If ExtendedData is not\r
-  NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r
-  ExtendedData is assumed not have the standard status code header, so this function\r
-  is responsible for allocating a buffer large enough for the standard header and\r
-  the extended data passed into this function.  The standard header is filled in\r
-  with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a\r
-  GUID of gEfiStatusCodeSpecificDataGuid is used.  The status code is reported with\r
-  an instance specified by Instance and a caller ID specified by CallerId.  If\r
-  CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
-\r
-  ReportStatusCodeEx()must actively prevent recursion. If\r
-  ReportStatusCodeEx() is called while processing another any\r
-  other Report Status Code Library function, then\r
-  ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
-  If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  If this parameter is NULL, then a caller\r
-                            ID of gEfiCallerIdGuid is used.\r
-  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.\r
-                            If this parameter is NULL, then a the status code\r
-                            standard header is filled in with\r
-                            gEfiStatusCodeSpecificDataGuid.\r
-  @param  ExtendedData      Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate\r
-                                 the extended data section if it was specified.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeEx (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value,\r
-  IN UINT32                 Instance,\r
-  IN CONST EFI_GUID         *CallerId          OPTIONAL,\r
-  IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,\r
-  IN CONST VOID             *ExtendedData      OPTIONAL,\r
-  IN UINTN                  ExtendedDataSize\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-\r
-  ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
-  ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
-\r
-  if (ExtendedDataSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
-    DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be reported!\n"));\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Fill in the extended data header\r
-  //\r
-  mStatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);\r
-  mStatusCodeData->Size = (UINT16)ExtendedDataSize;\r
-  if (ExtendedDataGuid == NULL) {\r
-    ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
-  }\r
-  CopyGuid (&mStatusCodeData->Type, ExtendedDataGuid);\r
-\r
-  //\r
-  // Fill in the extended data buffer\r
-  //\r
-  if (ExtendedData != NULL) {\r
-    CopyMem (mStatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
-  }\r
-\r
-  //\r
-  // Report the status code\r
-  //\r
-  if (CallerId == NULL) {\r
-    CallerId = &gEfiCallerIdGuid;\r
-  }\r
-  Status = InternalReportStatusCode (Type, Value, Instance, CallerId, mStatusCodeData);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r
-\r
-  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED\r
-  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is set.\r
-  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportProgressCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r
-\r
-  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED\r
-  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is set.\r
-  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportErrorCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r
-\r
-  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED\r
-  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is set.\r
-  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportDebugCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/ReportStatusCodeLibInternal.h b/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/ReportStatusCodeLibInternal.h
deleted file mode 100644 (file)
index bac6e7e..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/** @file\r
-  Internal Header file of Report Status Code Library for RUNTIME\r
-  DXE Phase.\r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-#ifndef __REPORT_STATUS_CODE_LIB_INTERNAL__H__\r
-#define __REPORT_STATUS_CODE_LIB_INTERNAL__H__\r
-\r
-#include <FrameworkSmm.h>\r
-\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Guid/EventGroup.h>\r
-\r
-#include <Protocol/SmmStatusCode.h>\r
-#include <Protocol/StatusCode.h>\r
-#include <Protocol/SmmBase.h>\r
-\r
-\r
-extern EFI_STATUS_CODE_DATA    *mStatusCodeData;\r
-\r
-/**\r
-  Internal worker function that reports a status code through the status code service.\r
-\r
-  If status code service is not cached, then this function checks if status code service is\r
-  available in system.  If status code service is not available, then EFI_UNSUPPORTED is\r
-  returned.  If status code service is present, then it is cached in mReportStatusCode.\r
-  Finally this function reports status code through the status code service.\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  This is an optional parameter that may be\r
-                            NULL.\r
-  @param  Data              Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-\r
-  @retval EFI_SUCCESS       The status code was reported.\r
-  @retval EFI_UNSUPPORTED   Status code service is not available.\r
-  @retval EFI_UNSUPPORTED   Status code type is not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalReportStatusCode (\r
-  IN EFI_STATUS_CODE_TYPE     Type,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN CONST EFI_GUID           *CallerId OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeReportStatusCodeLibFramework.inf b/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeReportStatusCodeLibFramework.inf
deleted file mode 100644 (file)
index d081f39..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-## @file\r
-#  Framework Report status code library instance which supports logging message in SMM, as well as DXE & runtime phase.\r
-#\r
-#  This library instance supports status code report in SMM, as well as DXE & runtime phase.\r
-#  In SMM, it logs message via SMM Status Code Protocol.\r
-#  Otherwise, it logs message to ReportStatusCode() in framework runtime services table or runtime report status code protocol.\r
-#\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = SmmRuntimeDxeReportStatusCodeLibFramework\r
-  MODULE_UNI_FILE                = SmmRuntimeDxeReportStatusCodeLibFramework.uni\r
-  FILE_GUID                      = D65D9F72-7BCE-4f73-A673-47AF446A1A31\r
-  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = ReportStatusCodeLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER\r
-\r
-  CONSTRUCTOR                    = ReportStatusCodeLibConstruct\r
-  DESTRUCTOR                     = ReportStatusCodeLibDestruct\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  ReportStatusCodeLib.c\r
-  SmmRuntimeDxeSupport.c\r
-  ReportStatusCodeLibInternal.h\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  DebugLib\r
-  UefiRuntimeServicesTableLib\r
-  UefiBootServicesTableLib\r
-  DevicePathLib\r
-  MemoryAllocationLib\r
-\r
-[Guids]\r
-  gEfiStatusCodeSpecificDataGuid                ## SOMETIMES_CONSUMES ## UNDEFINED\r
-  gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_CONSUMES ## UNDEFINED\r
-  gEfiEventExitBootServicesGuid                 ## CONSUMES ## Event\r
-  gEfiEventVirtualAddressChangeGuid             ## CONSUMES ## Event\r
-\r
-\r
-[Protocols]\r
-  gEfiStatusCodeRuntimeProtocolGuid             ## SOMETIMES_CONSUMES\r
-  gEfiSmmBaseProtocolGuid                       ## SOMETIMES_CONSUMES\r
-  gEfiSmmStatusCodeProtocolGuid                 ## SOMETIMES_CONSUMES\r
-\r
-[Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask ## CONSUMES\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeReportStatusCodeLibFramework.uni b/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeReportStatusCodeLibFramework.uni
deleted file mode 100644 (file)
index 9690732..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// Framework Report status code library instance which supports logging message in SMM, as well as DXE & runtime phase.\r
-//\r
-// This library instance supports status code report in SMM, as well as DXE & runtime phase.\r
-// In SMM, it logs message via SMM Status Code Protocol.\r
-// Otherwise, it logs message to ReportStatusCode() in framework runtime services table or runtime report status code protocol.\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Supports logging message in SMM, as well as DXE & runtime phase"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This library instance supports the status code report in SMM, as well as DXE & runtime phase. In SMM, it logs message via the SMM Status Code Protocol. Otherwise, it logs message to ReportStatusCode() in the framework runtime services table or via the runtime report status code protocol."\r
-\r
diff --git a/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeSupport.c b/IntelFrameworkModulePkg/Library/SmmRuntimeDxeReportStatusCodeLibFramework/SmmRuntimeDxeSupport.c
deleted file mode 100644 (file)
index 7dce1d2..0000000
+++ /dev/null
@@ -1,329 +0,0 @@
-/** @file\r
-  Library constructor & destructor, event handlers, and other internal worker functions.\r
-\r
-  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "ReportStatusCodeLibInternal.h"\r
-\r
-EFI_EVENT                     mVirtualAddressChangeEvent;\r
-static EFI_EVENT              mExitBootServicesEvent;\r
-EFI_STATUS_CODE_DATA          *mStatusCodeData;\r
-BOOLEAN                       mInSmm;\r
-EFI_SMM_BASE_PROTOCOL         *mSmmBase;\r
-EFI_RUNTIME_SERVICES          *mInternalRT;\r
-BOOLEAN                       mHaveExitedBootServices = FALSE;\r
-EFI_REPORT_STATUS_CODE        mReportStatusCode = NULL;\r
-EFI_SMM_STATUS_CODE_PROTOCOL  *mSmmStatusCodeProtocol;\r
-\r
-/**\r
-  Locates and caches SMM Status Code Protocol.\r
-\r
-**/\r
-VOID\r
-SmmStatusCodeInitialize (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-\r
-  Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, (VOID **) &mSmmStatusCodeProtocol);\r
-  if (EFI_ERROR (Status)) {\r
-    mSmmStatusCodeProtocol = NULL;\r
-  }\r
-}\r
-\r
-/**\r
-  Report status code via SMM Status Code Protocol.\r
-\r
-  @param  Type          Indicates the type of status code being reported.\r
-  @param  Value         Describes the current status of a hardware or software entity.\r
-                        This included information about the class and subclass that is used to classify the entity\r
-                        as well as an operation.  For progress codes, the operation is the current activity.\r
-                        For error codes, it is the exception.  For debug codes, it is not defined at this time.\r
-  @param  Instance      The enumeration of a hardware or software entity within the system.\r
-                        A system may contain multiple entities that match a class/subclass pairing.\r
-                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable,\r
-                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
-  @param  CallerId      This optional parameter may be used to identify the caller.\r
-                        This parameter allows the status code driver to apply different rules to different callers.\r
-  @param  Data          This optional parameter may be used to pass additional data\r
-\r
-  @retval EFI_SUCCESS   Always return EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-SmmStatusCodeReport (\r
-  IN EFI_STATUS_CODE_TYPE     Type,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL\r
-  )\r
-{\r
-  if (mSmmStatusCodeProtocol != NULL) {\r
-    (mSmmStatusCodeProtocol->ReportStatusCode) (mSmmStatusCodeProtocol, Type, Value, Instance, CallerId, Data);\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Locate the report status code service.\r
-\r
-  In SMM, it tries to retrieve SMM Status Code Protocol.\r
-  Otherwise, it first tries to retrieve ReportStatusCode() in Runtime Services Table.\r
-  If not found, it then tries to retrieve ReportStatusCode() API of Report Status Code Protocol.\r
-\r
-  @return   Function pointer to the report status code service.\r
-            NULL is returned if no status code service is available.\r
-\r
-**/\r
-EFI_REPORT_STATUS_CODE\r
-InternalGetReportStatusCode (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS_CODE_PROTOCOL  *StatusCodeProtocol;\r
-  EFI_STATUS                Status;\r
-\r
-  if (mInSmm) {\r
-    return (EFI_REPORT_STATUS_CODE) SmmStatusCodeReport;\r
-  } else if (mInternalRT != NULL && mInternalRT->Hdr.Revision < 0x20000) {\r
-    return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)mInternalRT)->ReportStatusCode;\r
-  } else if (!mHaveExitedBootServices) {\r
-    //\r
-    // Check gBS just in case. ReportStatusCode is called before gBS is initialized.\r
-    //\r
-    if (gBS != NULL) {\r
-      Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);\r
-      if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {\r
-        return StatusCodeProtocol->ReportStatusCode;\r
-      }\r
-    }\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-/**\r
-  Internal worker function that reports a status code through the status code service.\r
-\r
-  If status code service is not cached, then this function checks if status code service is\r
-  available in system.  If status code service is not available, then EFI_UNSUPPORTED is\r
-  returned.  If status code service is present, then it is cached in mReportStatusCode.\r
-  Finally this function reports status code through the status code service.\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  This is an optional parameter that may be\r
-                            NULL.\r
-  @param  Data              Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-\r
-  @retval EFI_SUCCESS       The status code was reported.\r
-  @retval EFI_UNSUPPORTED   Status code service is not available.\r
-  @retval EFI_UNSUPPORTED   Status code type is not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalReportStatusCode (\r
-  IN EFI_STATUS_CODE_TYPE     Type,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN CONST EFI_GUID           *CallerId OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL\r
-  )\r
-{\r
-  if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
-      (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||\r
-      (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {\r
-    //\r
-    // If mReportStatusCode is NULL, then check if status code service is available in system.\r
-    //\r
-    if (mReportStatusCode == NULL) {\r
-      mReportStatusCode = InternalGetReportStatusCode ();\r
-      if (mReportStatusCode == NULL) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-    }\r
-\r
-    //\r
-    // A status code service is present in system, so pass in all the parameters to the service.\r
-    //\r
-    return (*mReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
-  }\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
-\r
-  @param  Event        Event whose notification function is being invoked.\r
-  @param  Context      Pointer to the notification function's context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-ReportStatusCodeLibVirtualAddressChange (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  if (mReportStatusCode != NULL) {\r
-    mInternalRT->ConvertPointer (0, (VOID **) &mReportStatusCode);\r
-  }\r
-  mInternalRT->ConvertPointer (0, (VOID **) &mStatusCodeData);\r
-  mInternalRT->ConvertPointer (0, (VOID **) &mInternalRT);\r
-}\r
-\r
-/**\r
-  Notification function of EVT_SIGNAL_EXIT_BOOT_SERVICES.\r
-\r
-  @param  Event        Event whose notification function is being invoked.\r
-  @param  Context      Pointer to the notification function's context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-ReportStatusCodeLibExitBootServices (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  //\r
-  // If mReportStatusCode is NULL, then see if a Status Code Protocol instance is present\r
-  // in the handle database.\r
-  //\r
-  if (mReportStatusCode == NULL) {\r
-    mReportStatusCode = InternalGetReportStatusCode ();\r
-  }\r
-\r
-  mHaveExitedBootServices = TRUE;\r
-}\r
-\r
-/**\r
-  The constructor function of SMM Runtime DXE Report Status Code Lib.\r
-\r
-  This function allocates memory for extended status code data, caches\r
-  the report status code service, and registers events.\r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeLibConstruct (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS     Status;\r
-\r
-  //\r
-  // If in SMM mode, then allocates memory from SMRAM for extended status code data.\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, (VOID **) &mSmmBase);\r
-  if (!EFI_ERROR (Status)) {\r
-    mSmmBase->InSmm (mSmmBase, &mInSmm);\r
-    if (mInSmm) {\r
-      Status = mSmmBase->SmmAllocatePool (\r
-                           mSmmBase,\r
-                           EfiRuntimeServicesData,\r
-                           sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE,\r
-                           (VOID **) &mStatusCodeData\r
-                           );\r
-      ASSERT_EFI_ERROR (Status);\r
-      SmmStatusCodeInitialize ();\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-\r
-  //\r
-  // If not in SMM mode, then allocate runtime memory for extended status code data.\r
-  //\r
-  // Library should not use the gRT directly, for it may be converted by other library instance.\r
-  //\r
-  mInternalRT = gRT;\r
-  mInSmm      = FALSE;\r
-\r
-  mStatusCodeData = AllocateRuntimePool (sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE);\r
-  ASSERT (mStatusCodeData != NULL);\r
-  //\r
-  // Cache the report status code service\r
-  //\r
-  mReportStatusCode = InternalGetReportStatusCode ();\r
-\r
-  //\r
-  // Register notify function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  ReportStatusCodeLibVirtualAddressChange,\r
-                  NULL,\r
-                  &gEfiEventVirtualAddressChangeGuid,\r
-                  &mVirtualAddressChangeEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Register notify function for EVT_SIGNAL_EXIT_BOOT_SERVICES\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  ReportStatusCodeLibExitBootServices,\r
-                  NULL,\r
-                  &gEfiEventExitBootServicesGuid,\r
-                  &mExitBootServicesEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  The destructor function of SMM Runtime DXE Report Status Code Lib.\r
-\r
-  The destructor function frees memory allocated by constructor, and closes related events.\r
-  It will ASSERT() if that related operation fails and it will always return EFI_SUCCESS.\r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeLibDestruct (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  if (!mInSmm) {\r
-    ASSERT (gBS != NULL);\r
-    Status = gBS->CloseEvent (mVirtualAddressChangeEvent);\r
-    ASSERT_EFI_ERROR (Status);\r
-    Status = gBS->CloseEvent (mExitBootServicesEvent);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    FreePool (mStatusCodeData);\r
-  } else {\r
-    mSmmBase->SmmFreePool (mSmmBase, mStatusCodeData);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c b/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c
deleted file mode 100644 (file)
index 366ada9..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/** @file\r
-  This is an implementation of the ACPI S3 Save protocol.  This is defined in\r
-  S3 boot path specification 0.9.\r
-\r
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Protocol/AcpiS3Save.h>\r
-\r
-#include "AcpiS3Save.h"\r
-\r
-/**\r
-  Hook point for AcpiVariableThunkPlatform for InstallAcpiS3Save.\r
-**/\r
-VOID\r
-InstallAcpiS3SaveThunk (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Hook point for AcpiVariableThunkPlatform for S3Ready.\r
-\r
-**/\r
-VOID\r
-S3ReadyThunkPlatform (\r
-  VOID\r
-  );\r
-\r
-UINTN     mLegacyRegionSize;\r
-\r
-EFI_ACPI_S3_SAVE_PROTOCOL mS3Save = {\r
-  LegacyGetS3MemorySize,\r
-  S3Ready,\r
-};\r
-\r
-/**\r
-  Allocate memory below 4G memory address.\r
-\r
-  This function allocates memory below 4G memory address.\r
-\r
-  @param  MemoryType   Memory type of memory to allocate.\r
-  @param  Size         Size of memory to allocate.\r
-\r
-  @return Allocated address for output.\r
-\r
-**/\r
-VOID*\r
-AllocateMemoryBelow4G (\r
-  IN EFI_MEMORY_TYPE    MemoryType,\r
-  IN UINTN              Size\r
-  )\r
-{\r
-  UINTN                 Pages;\r
-  EFI_PHYSICAL_ADDRESS  Address;\r
-  EFI_STATUS            Status;\r
-  VOID*                 Buffer;\r
-\r
-  Pages = EFI_SIZE_TO_PAGES (Size);\r
-  Address = 0xffffffff;\r
-\r
-  Status  = gBS->AllocatePages (\r
-                   AllocateMaxAddress,\r
-                   MemoryType,\r
-                   Pages,\r
-                   &Address\r
-                   );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Buffer = (VOID *) (UINTN) Address;\r
-  ZeroMem (Buffer, Size);\r
-\r
-  return Buffer;\r
-}\r
-\r
-/**\r
-  Gets the buffer of legacy memory below 1 MB\r
-  This function is to get the buffer in legacy memory below 1MB that is required during S3 resume.\r
-\r
-  @param This           A pointer to the EFI_ACPI_S3_SAVE_PROTOCOL instance.\r
-  @param Size           The returned size of legacy memory below 1 MB.\r
-\r
-  @retval EFI_SUCCESS           Size is successfully returned.\r
-  @retval EFI_INVALID_PARAMETER The pointer Size is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyGetS3MemorySize (\r
-  IN  EFI_ACPI_S3_SAVE_PROTOCOL   *This,\r
-  OUT UINTN                       *Size\r
-  )\r
-{\r
-  if (Size == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *Size = mLegacyRegionSize;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Prepares all information that is needed in the S3 resume boot path.\r
-\r
-  Allocate the resources or prepare informations and save in ACPI variable set for S3 resume boot path\r
-\r
-  @param This                 A pointer to the EFI_ACPI_S3_SAVE_PROTOCOL instance.\r
-  @param LegacyMemoryAddress  The base address of legacy memory.\r
-\r
-  @retval EFI_NOT_FOUND         Some necessary information cannot be found.\r
-  @retval EFI_SUCCESS           All information was saved successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  Resources were insufficient to save all the information.\r
-  @retval EFI_INVALID_PARAMETER The memory range is not located below 1 MB.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-S3Ready (\r
-  IN EFI_ACPI_S3_SAVE_PROTOCOL    *This,\r
-  IN VOID                         *LegacyMemoryAddress\r
-  )\r
-{\r
-  STATIC BOOLEAN                  AlreadyEntered;\r
-\r
-  DEBUG ((EFI_D_INFO, "S3Ready!\n"));\r
-\r
-  //\r
-  // Platform may invoke AcpiS3Save->S3Save() before ExitPmAuth, because we need save S3 information there, while BDS ReadyToBoot may invoke it again.\r
-  // So if 2nd S3Save() is triggered later, we need ignore it.\r
-  //\r
-  if (AlreadyEntered) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  AlreadyEntered = TRUE;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  The Driver Entry Point.\r
-\r
-  The function is the driver Entry point which will produce AcpiS3SaveProtocol.\r
-\r
-  @param ImageHandle   A handle for the image that is initializing this driver\r
-  @param SystemTable   A pointer to the EFI system table\r
-\r
-  @retval EFI_SUCCESS               Driver initialized successfully\r
-  @retval EFI_UNSUPPORTED           Do not support ACPI S3\r
-  @retval EFI_OUT_OF_RESOURCES      Could not allocate needed resources\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InstallAcpiS3Save (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-\r
-  if (!PcdGetBool (PcdAcpiS3Enable)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (!FeaturePcdGet(PcdPlatformCsmSupport)) {\r
-    //\r
-    // More memory for no CSM tip, because GDT need relocation\r
-    //\r
-    mLegacyRegionSize = 0x250;\r
-  } else {\r
-    mLegacyRegionSize = 0x100;\r
-  }\r
-\r
-  Status = gBS->InstallProtocolInterface (\r
-                  &ImageHandle,\r
-                  &gEfiAcpiS3SaveProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &mS3Save\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.h b/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.h
deleted file mode 100644 (file)
index 554cb3f..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/** @file\r
-  This is an implementation of the ACPI S3 Save protocol.  This is defined in\r
-  S3 boot path specification 0.9.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _ACPI_S3_SAVE_H_\r
-#define _ACPI_S3_SAVE_H_\r
-\r
-/**\r
-  Gets the buffer of legacy memory below 1 MB\r
-  This function is to get the buffer in legacy memory below 1MB that is required during S3 resume.\r
-\r
-  @param This           A pointer to the EFI_ACPI_S3_SAVE_PROTOCOL instance.\r
-  @param Size           The returned size of legacy memory below 1 MB.\r
-\r
-  @retval EFI_SUCCESS           Size is successfully returned.\r
-  @retval EFI_INVALID_PARAMETER The pointer Size is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyGetS3MemorySize (\r
-  IN  EFI_ACPI_S3_SAVE_PROTOCOL    * This,\r
-  OUT UINTN                        * Size\r
-  );\r
-\r
-/**\r
-  Prepares all information that is needed in the S3 resume boot path.\r
-\r
-  Allocate the resources or prepare informations and save in ACPI variable set for S3 resume boot path\r
-\r
-  @param This                 A pointer to the EFI_ACPI_S3_SAVE_PROTOCOL instance.\r
-  @param LegacyMemoryAddress  The base address of legacy memory.\r
-\r
-  @retval EFI_NOT_FOUND         Some necessary information cannot be found.\r
-  @retval EFI_SUCCESS           All information was saved successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  Resources were insufficient to save all the information.\r
-  @retval EFI_INVALID_PARAMETER The memory range is not located below 1 MB.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-S3Ready (\r
-  IN EFI_ACPI_S3_SAVE_PROTOCOL     *This,\r
-  IN VOID                          *LegacyMemoryAddress\r
-  );\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.inf b/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
deleted file mode 100644 (file)
index 0cfcb8c..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-## @file\r
-# AcpiS3Save module installs ACPI S3 Save protocol to prepare S3 boot data.\r
-#\r
-# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = AcpiS3SaveDxe\r
-  MODULE_UNI_FILE                = AcpiS3SaveDxe.uni\r
-  FILE_GUID                      = 2BDED685-F733-455f-A840-43A22B791FB3\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InstallAcpiS3Save\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64\r
-#\r
-\r
-[Sources]\r
-  AcpiS3Save.h\r
-  AcpiS3Save.c\r
-  AcpiVariableThunkPlatform.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  UefiRuntimeServicesTableLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  BaseMemoryLib\r
-  HobLib\r
-  UefiLib\r
-  DebugLib\r
-\r
-[Guids]\r
-  ## SOMETIMES_CONSUMES ## Variable:L"AcpiGlobalVariable"\r
-  ## SOMETIMES_PRODUCES ## Variable:L"AcpiGlobalVariable"\r
-  gEfiAcpiVariableCompatiblityGuid\r
-\r
-[Protocols]\r
-  gEfiAcpiS3SaveProtocolGuid                    ## PRODUCES\r
-  gFrameworkEfiMpServiceProtocolGuid            ## SOMETIMES_CONSUMES\r
-  ## NOTIFY\r
-  ## SOMETIMES_CONSUMES\r
-  gEdkiiVariableLockProtocolGuid\r
-\r
-[FeaturePcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformCsmSupport          ## CONSUMES\r
-\r
-[Pcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize    ## SOMETIMES_CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable                           ## CONSUMES\r
-\r
-[Depex]\r
-  #\r
-  # Note: the extra dependency of gEfiMpServiceProtocolGuid is to ensure that ACPI variable is set by MpDxe driver before\r
-  # AcpiS3SaveDxe module is executed.\r
-  #\r
-  gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid AND gEfiMpServiceProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  AcpiS3SaveDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.uni b/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.uni
deleted file mode 100644 (file)
index 389ff8c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// AcpiS3Save module installs ACPI S3 Save protocol to prepare S3 boot data.\r
-//\r
-// AcpiS3Save module installs ACPI S3 Save protocol to prepare S3 boot data.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Installs ACPI S3 Save protocol to prepare S3 boot data"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "AcpiS3Save module installs ACPI S3 Save protocol to prepare S3 boot data."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxeExtra.uni b/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxeExtra.uni
deleted file mode 100644 (file)
index 4e5643d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// AcpiS3SaveDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"ACPI S3 Save State DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiVariableThunkPlatform.c b/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiVariableThunkPlatform.c
deleted file mode 100644 (file)
index 97bcb55..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/** @file\r
-  This is an implementation of the AcpiVariable platform field for ECP platform.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-==\r
-\r
-typedef struct {\r
-  EFI_PHYSICAL_ADDRESS  AcpiReservedMemoryBase;  <<===\r
-  UINT32                AcpiReservedMemorySize;  <<===\r
-  EFI_PHYSICAL_ADDRESS  S3ReservedLowMemoryBase;\r
-  EFI_PHYSICAL_ADDRESS  AcpiBootScriptTable;\r
-  EFI_PHYSICAL_ADDRESS  RuntimeScriptTableBase;\r
-  EFI_PHYSICAL_ADDRESS  AcpiFacsTable;\r
-  UINT64                SystemMemoryLength;      <<===\r
-  ACPI_CPU_DATA_COMPATIBILITY         AcpiCpuData;\r
-  EFI_PHYSICAL_ADDRESS  VideoOpromAddress;\r
-  UINT32                VideoOpromSize;\r
-  EFI_PHYSICAL_ADDRESS  S3DebugBufferAddress;\r
-  EFI_PHYSICAL_ADDRESS  S3ResumeNvsEntryPoint;\r
-} ACPI_VARIABLE_SET_COMPATIBILITY;\r
-\r
-**/\r
-\r
-#include <FrameworkDxe.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Protocol/FrameworkMpService.h>\r
-#include <Protocol/VariableLock.h>\r
-#include <Guid/AcpiVariableCompatibility.h>\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED\r
-ACPI_VARIABLE_SET_COMPATIBILITY               *mAcpiVariableSetCompatibility = NULL;\r
-\r
-/**\r
-  Allocate memory below 4G memory address.\r
-\r
-  This function allocates memory below 4G memory address.\r
-\r
-  @param  MemoryType   Memory type of memory to allocate.\r
-  @param  Size         Size of memory to allocate.\r
-\r
-  @return Allocated address for output.\r
-\r
-**/\r
-VOID*\r
-AllocateMemoryBelow4G (\r
-  IN EFI_MEMORY_TYPE    MemoryType,\r
-  IN UINTN              Size\r
-  );\r
-\r
-/**\r
-  Hook point for AcpiVariableThunkPlatform for S3Ready.\r
-\r
-**/\r
-VOID\r
-S3ReadyThunkPlatform (\r
-  VOID\r
-  )\r
-{\r
-  EFI_PHYSICAL_ADDRESS                          AcpiMemoryBase;\r
-  UINT32                                        AcpiMemorySize;\r
-  EFI_PEI_HOB_POINTERS                          Hob;\r
-  UINT64                                        MemoryLength;\r
-\r
-  DEBUG ((EFI_D_INFO, "S3ReadyThunkPlatform\n"));\r
-\r
-  if (mAcpiVariableSetCompatibility == NULL) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Allocate ACPI reserved memory under 4G\r
-  //\r
-  AcpiMemoryBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateMemoryBelow4G (EfiReservedMemoryType, PcdGet32 (PcdS3AcpiReservedMemorySize));\r
-  ASSERT (AcpiMemoryBase != 0);\r
-  AcpiMemorySize = PcdGet32 (PcdS3AcpiReservedMemorySize);\r
-\r
-  //\r
-  // Calculate the system memory length by memory hobs\r
-  //\r
-  MemoryLength  = 0x100000;\r
-  Hob.Raw = GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);\r
-  ASSERT (Hob.Raw != NULL);\r
-  while ((Hob.Raw != NULL) && (!END_OF_HOB_LIST (Hob))) {\r
-    if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {\r
-      //\r
-      // Skip the memory region below 1MB\r
-      //\r
-      if (Hob.ResourceDescriptor->PhysicalStart >= 0x100000) {\r
-        MemoryLength += Hob.ResourceDescriptor->ResourceLength;\r
-      }\r
-    }\r
-    Hob.Raw = GET_NEXT_HOB (Hob);\r
-    Hob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, Hob.Raw);\r
-  }\r
-\r
-  mAcpiVariableSetCompatibility->AcpiReservedMemoryBase = AcpiMemoryBase;\r
-  mAcpiVariableSetCompatibility->AcpiReservedMemorySize = AcpiMemorySize;\r
-  mAcpiVariableSetCompatibility->SystemMemoryLength     = MemoryLength;\r
-\r
-  DEBUG((EFI_D_INFO, "AcpiVariableThunkPlatform: AcpiMemoryBase is 0x%8x\n", mAcpiVariableSetCompatibility->AcpiReservedMemoryBase));\r
-  DEBUG((EFI_D_INFO, "AcpiVariableThunkPlatform: AcpiMemorySize is 0x%8x\n", mAcpiVariableSetCompatibility->AcpiReservedMemorySize));\r
-  DEBUG((EFI_D_INFO, "AcpiVariableThunkPlatform: SystemMemoryLength is 0x%8x\n", mAcpiVariableSetCompatibility->SystemMemoryLength));\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Register callback function upon VariableLockProtocol\r
-  to lock ACPI_GLOBAL_VARIABLE variable to avoid malicious code to update it.\r
-\r
-  @param[in] Event    Event whose notification function is being invoked.\r
-  @param[in] Context  Pointer to the notification function's context.\r
-**/\r
-VOID\r
-EFIAPI\r
-VariableLockAcpiGlobalVariable (\r
-  IN  EFI_EVENT                             Event,\r
-  IN  VOID                                  *Context\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EDKII_VARIABLE_LOCK_PROTOCOL  *VariableLock;\r
-  //\r
-  // Mark ACPI_GLOBAL_VARIABLE variable to read-only if the Variable Lock protocol exists\r
-  //\r
-  Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = VariableLock->RequestToLock (VariableLock, ACPI_GLOBAL_VARIABLE, &gEfiAcpiVariableCompatiblityGuid);\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-}\r
-\r
-/**\r
-  Hook point for AcpiVariableThunkPlatform for InstallAcpiS3Save.\r
-**/\r
-VOID\r
-InstallAcpiS3SaveThunk (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                           Status;\r
-  FRAMEWORK_EFI_MP_SERVICES_PROTOCOL   *FrameworkMpService;\r
-  UINTN                                VarSize;\r
-  VOID                                 *Registration;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gFrameworkEfiMpServiceProtocolGuid,\r
-                  NULL,\r
-                  (VOID**) &FrameworkMpService\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // On ECP platform, if framework CPU drivers are in use, The compatible version of ACPI variable set\r
-    // should be produced by CPU driver.\r
-    //\r
-    VarSize = sizeof (mAcpiVariableSetCompatibility);\r
-    Status = gRT->GetVariable (\r
-                    ACPI_GLOBAL_VARIABLE,\r
-                    &gEfiAcpiVariableCompatiblityGuid,\r
-                    NULL,\r
-                    &VarSize,\r
-                    &mAcpiVariableSetCompatibility\r
-                    );\r
-    if (EFI_ERROR (Status) || (VarSize != sizeof (mAcpiVariableSetCompatibility))) {\r
-      DEBUG ((EFI_D_ERROR, "FATAL ERROR: AcpiVariableSetCompatibility was not saved by CPU driver correctly. OS S3 may fail!\n"));\r
-      mAcpiVariableSetCompatibility = NULL;\r
-    }\r
-  } else {\r
-    //\r
-    // Allocate/initialize the compatible version of Acpi Variable Set since Framework chipset/platform\r
-    // driver need this variable. ACPI_GLOBAL_VARIABLE variable is not used in runtime phase,\r
-    // so RT attribute is not needed for it.\r
-    //\r
-    mAcpiVariableSetCompatibility = AllocateMemoryBelow4G (EfiACPIMemoryNVS, sizeof(ACPI_VARIABLE_SET_COMPATIBILITY));\r
-    Status = gRT->SetVariable (\r
-                    ACPI_GLOBAL_VARIABLE,\r
-                    &gEfiAcpiVariableCompatiblityGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    sizeof(mAcpiVariableSetCompatibility),\r
-                    &mAcpiVariableSetCompatibility\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Register callback function upon VariableLockProtocol\r
-      // to lock ACPI_GLOBAL_VARIABLE variable to avoid malicious code to update it.\r
-      //\r
-      EfiCreateProtocolNotifyEvent (\r
-        &gEdkiiVariableLockProtocolGuid,\r
-        TPL_CALLBACK,\r
-        VariableLockAcpiGlobalVariable,\r
-        NULL,\r
-        &Registration\r
-        );\r
-    } else {\r
-      DEBUG ((EFI_D_ERROR, "FATAL ERROR: AcpiVariableSetCompatibility cannot be saved: %r. OS S3 may fail!\n", Status));\r
-      gBS->FreePages (\r
-             (EFI_PHYSICAL_ADDRESS) (UINTN) mAcpiVariableSetCompatibility,\r
-             EFI_SIZE_TO_PAGES (sizeof (ACPI_VARIABLE_SET_COMPATIBILITY))\r
-             );\r
-      mAcpiVariableSetCompatibility = NULL;\r
-    }\r
-  }\r
-\r
-  DEBUG((EFI_D_INFO, "AcpiVariableSetCompatibility is 0x%8x\n", mAcpiVariableSetCompatibility));\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.c b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.c
deleted file mode 100644 (file)
index 85f58a5..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/** @file\r
-  This is an implementation of the ACPI Support protocol.  This is defined in\r
-  the Tiano ACPI External Product Specification, revision 0.3.6.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-//\r
-// Includes\r
-//\r
-#include "AcpiSupport.h"\r
-\r
-//\r
-// Handle to install ACPI Table Protocol (and ACPI Suppport protocol).\r
-//\r
-EFI_HANDLE    mHandle = NULL;\r
-\r
-/**\r
-  Entry point of the ACPI support driver. This function creates and initializes an instance of the ACPI Support\r
-  Protocol and installs it on a new handle.\r
-\r
-  @param ImageHandle   A handle for the image that is initializing this driver\r
-  @param SystemTable   A pointer to the EFI system table\r
-\r
-  @retval EFI_SUCCESS              Driver initialized successfully\r
-  @retval EFI_LOAD_ERROR           Failed to Initialize or has been loaded\r
-  @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InstallAcpiSupport (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_ACPI_SUPPORT_INSTANCE *PrivateData;\r
-\r
-  //\r
-  // Initialize our protocol\r
-  //\r
-  PrivateData = AllocateZeroPool (sizeof (EFI_ACPI_SUPPORT_INSTANCE));\r
-  ASSERT (PrivateData);\r
-  PrivateData->Signature = EFI_ACPI_SUPPORT_SIGNATURE;\r
-\r
-  //\r
-  // Call all constructors per produced protocols\r
-  //\r
-  Status = AcpiSupportAcpiSupportConstructor (PrivateData);\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (PrivateData);\r
-    return EFI_LOAD_ERROR;\r
-  }\r
-\r
-  //\r
-  // Install ACPI Table protocol and optional ACPI support protocol based on\r
-  // feature flag: PcdInstallAcpiSupportProtocol.\r
-  //\r
-  if (FeaturePcdGet (PcdInstallAcpiSupportProtocol)) {\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &mHandle,\r
-                    &gEfiAcpiTableProtocolGuid,\r
-                    &PrivateData->AcpiTableProtocol,\r
-                    &gEfiAcpiSupportProtocolGuid,\r
-                    &PrivateData->AcpiSupport,\r
-                    NULL\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-  } else {\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &mHandle,\r
-                    &gEfiAcpiTableProtocolGuid,\r
-                    &PrivateData->AcpiTableProtocol,\r
-                    NULL\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.h b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.h
deleted file mode 100644 (file)
index 4b576bb..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/** @file\r
-  This is an implementation of the ACPI Support protocol.\r
-  It is in compliance with the 0.9 definition of the protocol.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _ACPI_SUPPORT_H_\r
-#define _ACPI_SUPPORT_H_\r
-\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/AcpiTable.h>\r
-#include <Guid/Acpi.h>\r
-#include <Protocol/AcpiSupport.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-//\r
-// Statements that include other files\r
-//\r
-#include <IndustryStandard/Acpi.h>\r
-\r
-\r
-//\r
-// Private Driver Data\r
-//\r
-//\r
-// ACPI Table Linked List Signature.\r
-//\r
-#define EFI_ACPI_TABLE_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'T', 'L')\r
-\r
-//\r
-// ACPI Table Linked List Entry definition.\r
-//\r
-//  Signature must be set to EFI_ACPI_TABLE_LIST_SIGNATURE\r
-//  Link is the linked list data.\r
-//  Version is the versions of the ACPI tables that this table belongs in.\r
-//  Table is a pointer to the table.\r
-//  PageAddress is the address of the pages allocated for the table.\r
-//  NumberOfPages is the number of pages allocated at PageAddress.\r
-//  Handle is used to identify a particular table.\r
-//\r
-typedef struct {\r
-  UINT32                  Signature;\r
-  LIST_ENTRY          Link;\r
-  EFI_ACPI_TABLE_VERSION  Version;\r
-  EFI_ACPI_COMMON_HEADER  *Table;\r
-  EFI_PHYSICAL_ADDRESS    PageAddress;\r
-  UINTN                   NumberOfPages;\r
-  UINTN                   Handle;\r
-} EFI_ACPI_TABLE_LIST;\r
-\r
-//\r
-// Containment record for linked list.\r
-//\r
-#define EFI_ACPI_TABLE_LIST_FROM_LINK(_link)  CR (_link, EFI_ACPI_TABLE_LIST, Link, EFI_ACPI_TABLE_LIST_SIGNATURE)\r
-\r
-//\r
-// The maximum number of tables this driver supports\r
-//\r
-#define EFI_ACPI_MAX_NUM_TABLES 20\r
-\r
-//\r
-// Protocol private structure definition\r
-//\r
-//\r
-// ACPI support protocol instance signature definition.\r
-//\r
-#define EFI_ACPI_SUPPORT_SIGNATURE  SIGNATURE_32 ('S', 'S', 'A', 'E')\r
-\r
-//\r
-// ACPI support protocol instance data structure\r
-//\r
-typedef struct {\r
-  UINTN                                         Signature;\r
-  EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp1;                 // Pointer to RSD_PTR structure\r
-  EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp3;                 // Pointer to RSD_PTR structure\r
-  EFI_ACPI_DESCRIPTION_HEADER                   *Rsdt1;                 // Pointer to RSDT table header\r
-  EFI_ACPI_DESCRIPTION_HEADER                   *Rsdt3;                 // Pointer to RSDT table header\r
-  EFI_ACPI_DESCRIPTION_HEADER                   *Xsdt;                  // Pointer to XSDT table header\r
-  EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE     *Fadt1;                 // Pointer to FADT table header\r
-  EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE     *Fadt3;                 // Pointer to FADT table header\r
-  EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *Facs1;                 // Pointer to FACS table header\r
-  EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *Facs3;                 // Pointer to FACS table header\r
-  EFI_ACPI_DESCRIPTION_HEADER                   *Dsdt1;                 // Pointer to DSDT table header\r
-  EFI_ACPI_DESCRIPTION_HEADER                   *Dsdt3;                 // Pointer to DSDT table header\r
-  LIST_ENTRY                                TableList;\r
-  UINTN                                         NumberOfTableEntries1;  // Number of ACPI 1.0 tables\r
-  UINTN                                         NumberOfTableEntries3;  // Number of ACPI 3.0 tables\r
-  UINTN                                         CurrentHandle;\r
-  BOOLEAN                                       TablesInstalled1;       // ACPI 1.0 tables published\r
-  BOOLEAN                                       TablesInstalled3;       // ACPI 3.0 tables published\r
-  EFI_ACPI_SUPPORT_PROTOCOL                     AcpiSupport;\r
-  EFI_ACPI_TABLE_PROTOCOL                       AcpiTableProtocol;\r
-} EFI_ACPI_SUPPORT_INSTANCE;\r
-\r
-//\r
-// ACPI support protocol instance containing record macro\r
-//\r
-#define EFI_ACPI_SUPPORT_INSTANCE_FROM_ACPI_SUPPORT_THIS(a) \\r
-  CR (a, \\r
-      EFI_ACPI_SUPPORT_INSTANCE, \\r
-      AcpiSupport, \\r
-      EFI_ACPI_SUPPORT_SIGNATURE \\r
-      )\r
-//\r
-// ACPI table protocol instance containing record macro\r
-//\r
-#define EFI_ACPI_TABLE_INSTANCE_FROM_ACPI_SUPPORT_THIS(a) \\r
-  CR (a, \\r
-      EFI_ACPI_SUPPORT_INSTANCE, \\r
-      AcpiTableProtocol, \\r
-      EFI_ACPI_SUPPORT_SIGNATURE \\r
-      )\r
-\r
-/**\r
-  Constructor for the ACPI support protocol.\r
-\r
-  Constructor for the ACPI support protocol to initializes instance data.\r
-\r
-  @param AcpiSupportInstance   Instance to construct\r
-\r
-  @retval EFI_SUCCESS           Instance initialized.\r
-  @retval EFI_OUT_OF_RESOURCES  Unable to allocate required resources.\r
-**/\r
-EFI_STATUS\r
-AcpiSupportAcpiSupportConstructor (\r
-  IN EFI_ACPI_SUPPORT_INSTANCE                 *AcpiSupportInstance\r
-  );\r
-/**\r
-  Entry point of the ACPI support driver. This function creates and initializes an instance of the ACPI Support\r
-  Protocol and installs it on a new handle.\r
-\r
-  @param ImageHandle   A handle for the image that is initializing this driver\r
-  @param SystemTable   A pointer to the EFI system table\r
-\r
-  @retval EFI_SUCCESS              Driver initialized successfully\r
-  @retval EFI_LOAD_ERROR           Failed to Initialize or has been loaded\r
-  @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InstallAcpiSupport (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  );\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportAcpiSupportProtocol.c b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportAcpiSupportProtocol.c
deleted file mode 100644 (file)
index eab531d..0000000
+++ /dev/null
@@ -1,1911 +0,0 @@
-/** @file\r
-  ACPI Support Protocol implementation\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-//\r
-// Includes\r
-//\r
-#include "AcpiSupport.h"\r
-//\r
-// The maximum number of tables that pre-allocated.\r
-//\r
-UINTN         mEfiAcpiMaxNumTables = EFI_ACPI_MAX_NUM_TABLES;\r
-/**\r
-  This function adds an ACPI table to the table list.  It will detect FACS and\r
-  allocate the correct type of memory and properly align the table.\r
-\r
-  @param  AcpiSupportInstance       Instance of the protocol.\r
-  @param  Table                     Table to add.\r
-  @param  Checksum                  Does the table require checksumming.\r
-  @param  Version                   The version of the list to add the table to.\r
-  @param  Handle                    Pointer for returning the handle.\r
-\r
-  @return EFI_SUCCESS               The function completed successfully.\r
-  @return EFI_OUT_OF_RESOURCES      Could not allocate a required resource.\r
-  @return EFI_ABORTED               The table is a duplicate of a table that is required\r
-                                    to be unique.\r
-**/\r
-EFI_STATUS\r
-AddTableToList (\r
-  IN EFI_ACPI_SUPPORT_INSTANCE            *AcpiSupportInstance,\r
-  IN VOID                                 *Table,\r
-  IN BOOLEAN                              Checksum,\r
-  IN EFI_ACPI_TABLE_VERSION               Version,\r
-  OUT UINTN                               *Handle\r
-  );\r
-/**\r
-  This function finds and removes the table specified by the handle.\r
-\r
-  @param  AcpiSupportInstance  Instance of the protocol.\r
-  @param  Version              Bitmask of which versions to remove.\r
-  @param  Handle               Table to remove.\r
-\r
-  @return EFI_SUCCESS    The function completed successfully.\r
-  @return EFI_ABORTED    An error occurred.\r
-  @return EFI_NOT_FOUND  Handle not found in table list.\r
-**/\r
-EFI_STATUS\r
-RemoveTableFromList (\r
-  IN EFI_ACPI_SUPPORT_INSTANCE            *AcpiSupportInstance,\r
-  IN EFI_ACPI_TABLE_VERSION               Version,\r
-  IN UINTN                                Handle\r
-  );\r
-/**\r
-  This function calculates and updates an UINT8 checksum.\r
-\r
-  @param  Buffer          Pointer to buffer to checksum\r
-  @param  Size            Number of bytes to checksum\r
-  @param  ChecksumOffset  Offset to place the checksum result in\r
-\r
-  @return EFI_SUCCESS             The function completed successfully.\r
-**/\r
-EFI_STATUS\r
-AcpiPlatformChecksum (\r
-  IN VOID       *Buffer,\r
-  IN UINTN      Size,\r
-  IN UINTN      ChecksumOffset\r
-  );\r
-/**\r
-  Checksum all versions of the common tables, RSDP, RSDT, XSDT.\r
-\r
-  @param  AcpiSupportInstance  Protocol instance private data.\r
-\r
-  @return EFI_SUCCESS        The function completed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ChecksumCommonTables (\r
-  IN OUT EFI_ACPI_SUPPORT_INSTANCE        *AcpiSupportInstance\r
-  );\r
-\r
-/**\r
-  This function returns a table specified by an index if it exists.\r
-\r
-  The function returns a buffer containing the table that the caller must free.\r
-  The function also returns a handle used to identify the table for update or\r
-  deletion using the SetAcpiTable function.\r
-\r
-  @param This        Instance of the protocol.\r
-  @param Index       Zero-based index of the table to retrieve.\r
-  @param Table       Returned pointer to the table.\r
-  @param Version     Versions that the table is currently used in.\r
-  @param Handle      Handle of the table, used in updating tables.\r
-\r
-  @retval EFI_SUCCESS             The function completed successfully.\r
-  @retval EFI_NOT_FOUND           The requested table does not exist.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GetAcpiTable (\r
-  IN EFI_ACPI_SUPPORT_PROTOCOL            *This,\r
-  IN INTN                                 Index,\r
-  OUT VOID                                **Table,\r
-  OUT EFI_ACPI_TABLE_VERSION              *Version,\r
-  OUT UINTN                               *Handle\r
-  )\r
-\r
-{\r
-  EFI_ACPI_SUPPORT_INSTANCE *AcpiSupportInstance;\r
-  INTN                  TempIndex;\r
-  LIST_ENTRY            *CurrentLink;\r
-  LIST_ENTRY            *StartLink;\r
-  EFI_ACPI_TABLE_LIST       *CurrentTable;\r
-\r
-  //\r
-  // Check for invalid input parameters\r
-  //\r
-  ASSERT (This);\r
-  ASSERT (Table);\r
-  ASSERT (Handle);\r
-\r
-  //\r
-  // Get the instance of the protocol\r
-  //\r
-  AcpiSupportInstance = EFI_ACPI_SUPPORT_INSTANCE_FROM_ACPI_SUPPORT_THIS (This);\r
-\r
-  //\r
-  // Find the table\r
-  //\r
-  CurrentLink = AcpiSupportInstance->TableList.ForwardLink;\r
-  StartLink   = &AcpiSupportInstance->TableList;\r
-  for (TempIndex = 0; (TempIndex < Index) && (CurrentLink != StartLink) && (CurrentLink != NULL); TempIndex++) {\r
-    CurrentLink = CurrentLink->ForwardLink;\r
-  }\r
-\r
-  if (TempIndex != Index || CurrentLink == StartLink) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Get handle and version\r
-  //\r
-  CurrentTable  = EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink);\r
-  *Handle       = CurrentTable->Handle;\r
-  *Version      = CurrentTable->Version;\r
-\r
-  //\r
-  // Copy the table\r
-  //\r
-  *Table = AllocateCopyPool (CurrentTable->Table->Length, CurrentTable->Table);\r
-  ASSERT (*Table);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function adds, removes, or updates ACPI tables.  If the address is not\r
-  null and the handle value is null, the table is added.  If both the address and\r
-  handle are not null, the table at handle is updated with the table at address.\r
-  If the address is null and the handle is not, the table at handle is deleted.\r
-\r
-  @param  This                 Pointer of the protocol.\r
-  @param  Table                Pointer to a table.\r
-  @param  Checksum             Boolean indicating if the checksum should be calculated.\r
-  @param  Version              Version(s) to set.\r
-  @param  Handle               Handle of the table.\r
-\r
-  @return EFI_SUCCESS             The function completed successfully.\r
-  @return EFI_INVALID_PARAMETER   Both the Table and *Handle were NULL.\r
-  @return EFI_ABORTED             Could not complete the desired request.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SetAcpiTable (\r
-  IN EFI_ACPI_SUPPORT_PROTOCOL            *This,\r
-  IN VOID                                 *Table OPTIONAL,\r
-  IN BOOLEAN                              Checksum,\r
-  IN EFI_ACPI_TABLE_VERSION               Version,\r
-  IN OUT UINTN                            *Handle\r
-  )\r
-{\r
-  EFI_ACPI_SUPPORT_INSTANCE *AcpiSupportInstance;\r
-  UINTN                     SavedHandle;\r
-  EFI_STATUS                Status;\r
-\r
-  //\r
-  // Check for invalid input parameters\r
-  //\r
-  ASSERT (This);\r
-  ASSERT (Handle != NULL);\r
-\r
-  //\r
-  // Get the instance of the protocol\r
-  //\r
-  AcpiSupportInstance = EFI_ACPI_SUPPORT_INSTANCE_FROM_ACPI_SUPPORT_THIS (This);\r
-\r
-  //\r
-  // Initialize locals\r
-  //\r
-  //\r
-  // Determine desired action\r
-  //\r
-  if (*Handle == 0) {\r
-    if (Table == NULL) {\r
-      //\r
-      // Invalid parameter combination\r
-      //\r
-      return EFI_INVALID_PARAMETER;\r
-    } else {\r
-      //\r
-      // Add table\r
-      //\r
-      Status = AddTableToList (AcpiSupportInstance, Table, Checksum, Version, Handle);\r
-    }\r
-  } else {\r
-    if (Table != NULL) {\r
-      //\r
-      // Update table\r
-      //\r
-      //\r
-      // Delete the table list entry\r
-      //\r
-      Status = RemoveTableFromList (AcpiSupportInstance, Version, *Handle);\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // Should not get an error here ever, but abort if we do.\r
-        //\r
-        return EFI_ABORTED;\r
-      }\r
-      //\r
-      // Set the handle to replace the table at the same handle\r
-      //\r
-      SavedHandle                         = AcpiSupportInstance->CurrentHandle;\r
-      AcpiSupportInstance->CurrentHandle  = *Handle;\r
-\r
-      //\r
-      // Add the table\r
-      //\r
-      Status = AddTableToList (AcpiSupportInstance, Table, Checksum, Version, Handle);\r
-\r
-      //\r
-      // Restore the saved current handle\r
-      //\r
-      AcpiSupportInstance->CurrentHandle = SavedHandle;\r
-    } else {\r
-      //\r
-      // Delete table\r
-      //\r
-      Status = RemoveTableFromList (AcpiSupportInstance, Version, *Handle);\r
-    }\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Should not get an error here ever, but abort if we do.\r
-    //\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Done\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function publishes the specified versions of the ACPI tables by\r
-  installing EFI configuration table entries for them.  Any combination of\r
-  table versions can be published.\r
-\r
-  @param  This                 Pointer of the protocol.\r
-  @param  Version              Version(s) to publish.\r
-\r
-  @return EFI_SUCCESS  The function completed successfully.\r
-  @return EFI_ABORTED  The function could not complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PublishTables (\r
-  IN EFI_ACPI_SUPPORT_PROTOCOL            *This,\r
-  IN EFI_ACPI_TABLE_VERSION               Version\r
-  )\r
-{\r
-  EFI_ACPI_SUPPORT_INSTANCE *AcpiSupportInstance;\r
-  EFI_STATUS                Status;\r
-  UINT32                    *CurrentRsdtEntry;\r
-  VOID                      *CurrentXsdtEntry;\r
-  UINT64                    Buffer64;\r
-\r
-  //\r
-  // Get the instance of the protocol\r
-  //\r
-  AcpiSupportInstance = EFI_ACPI_SUPPORT_INSTANCE_FROM_ACPI_SUPPORT_THIS (This);\r
-\r
-  //\r
-  // Reorder tables as some operating systems don't seem to find the\r
-  // FADT correctly if it is not in the first few entries\r
-  //\r
-\r
-  //\r
-  // Add FADT as the first entry\r
-  //\r
-  if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {\r
-    CurrentRsdtEntry  = (UINT32 *) ((UINT8 *) AcpiSupportInstance->Rsdt1 + sizeof (EFI_ACPI_DESCRIPTION_HEADER));\r
-    *CurrentRsdtEntry = (UINT32) (UINTN) AcpiSupportInstance->Fadt1;\r
-  }\r
-  if ((Version & EFI_ACPI_TABLE_VERSION_2_0) != 0 || (Version & EFI_ACPI_TABLE_VERSION_3_0) != 0) {\r
-    CurrentRsdtEntry  = (UINT32 *) ((UINT8 *) AcpiSupportInstance->Rsdt3 + sizeof (EFI_ACPI_DESCRIPTION_HEADER));\r
-    *CurrentRsdtEntry = (UINT32) (UINTN) AcpiSupportInstance->Fadt3;\r
-    CurrentXsdtEntry  = (VOID *) ((UINT8 *) AcpiSupportInstance->Xsdt + sizeof (EFI_ACPI_DESCRIPTION_HEADER));\r
-    //\r
-    // Add entry to XSDT, XSDT expects 64 bit pointers, but\r
-    // the table pointers in XSDT are not aligned on 8 byte boundary.\r
-    //\r
-    Buffer64 = (UINT64) (UINTN) AcpiSupportInstance->Fadt3;\r
-    CopyMem (\r
-      CurrentXsdtEntry,\r
-      &Buffer64,\r
-      sizeof (UINT64)\r
-      );\r
-  }\r
-\r
-  //\r
-  // Do checksum again because Dsdt/Xsdt is updated.\r
-  //\r
-  ChecksumCommonTables (AcpiSupportInstance);\r
-\r
-  //\r
-  // Add the RSD_PTR to the system table and store that we have installed the\r
-  // tables.\r
-  //\r
-  if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0 && !AcpiSupportInstance->TablesInstalled1) {\r
-    Status = gBS->InstallConfigurationTable (&gEfiAcpi10TableGuid, AcpiSupportInstance->Rsdp1);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_ABORTED;\r
-    }\r
-\r
-    AcpiSupportInstance->TablesInstalled1 = TRUE;\r
-  }\r
-\r
-  if (((Version & EFI_ACPI_TABLE_VERSION_2_0) != 0 || (Version & EFI_ACPI_TABLE_VERSION_3_0) != 0) &&\r
-      !AcpiSupportInstance->TablesInstalled3) {\r
-    Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, AcpiSupportInstance->Rsdp3);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_ABORTED;\r
-    }\r
-\r
-    AcpiSupportInstance->TablesInstalled3= TRUE;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Installs an ACPI table into the RSDT/XSDT.\r
-  Note that the ACPI table should be checksumed before installing it.\r
-  Otherwise it will assert.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  AcpiTableBuffer      A pointer to a buffer containing the ACPI table to be installed.\r
-  @param  AcpiTableBufferSize  Specifies the size, in bytes, of the AcpiTableBuffer buffer.\r
-  @param  TableKey             Reurns a key to refer to the ACPI table.\r
-\r
-  @return EFI_SUCCESS            The table was successfully inserted.\r
-  @return EFI_INVALID_PARAMETER  Either AcpiTableBuffer is NULL, TableKey is NULL, or AcpiTableBufferSize\r
-                                 and the size field embedded in the ACPI table pointed to by AcpiTableBuffer\r
-                                 are not in sync.\r
-  @return EFI_OUT_OF_RESOURCES   Insufficient resources exist to complete the request.\r
-  @retval EFI_ACCESS_DENIED      The table signature matches a table already\r
-                                 present in the system and platform policy\r
-                                 does not allow duplicate tables of this type.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InstallAcpiTable (\r
-  IN   EFI_ACPI_TABLE_PROTOCOL                    *This,\r
-  IN   VOID                                       *AcpiTableBuffer,\r
-  IN   UINTN                                      AcpiTableBufferSize,\r
-  OUT  UINTN                                      *TableKey\r
-  )\r
-{\r
-  EFI_ACPI_SUPPORT_INSTANCE *AcpiSupportInstance;\r
-  EFI_ACPI_SUPPORT_PROTOCOL *AcpiSupport;\r
-  EFI_STATUS                Status;\r
-  VOID                      *AcpiTableBufferConst;\r
-\r
-  //\r
-  // Check for invalid input parameters\r
-  //\r
-  if ((AcpiTableBuffer == NULL) || (TableKey == NULL)\r
-     || (((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTableBuffer)->Length != AcpiTableBufferSize)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Get the instance of the ACPI support protocol\r
-  //\r
-  AcpiSupportInstance = EFI_ACPI_TABLE_INSTANCE_FROM_ACPI_SUPPORT_THIS (This);\r
-  AcpiSupport = &AcpiSupportInstance->AcpiSupport;\r
-\r
-  //\r
-  // Install the ACPI table by using ACPI support protocol\r
-  //\r
-  AcpiTableBufferConst = AllocateCopyPool (AcpiTableBufferSize, AcpiTableBuffer);\r
-  *TableKey = 0;\r
-  Status = AddTableToList (\r
-             AcpiSupportInstance,\r
-             AcpiTableBufferConst,\r
-             TRUE,\r
-             EFI_ACPI_TABLE_VERSION_1_0B | EFI_ACPI_TABLE_VERSION_2_0 | EFI_ACPI_TABLE_VERSION_3_0,\r
-             TableKey\r
-             );\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = AcpiSupport->PublishTables (\r
-                            AcpiSupport,\r
-                            EFI_ACPI_TABLE_VERSION_1_0B | EFI_ACPI_TABLE_VERSION_2_0 | EFI_ACPI_TABLE_VERSION_3_0\r
-                            );\r
-  }\r
-  FreePool (AcpiTableBufferConst);\r
-\r
-  return Status;\r
-}\r
-/**\r
-  Removes an ACPI table from the RSDT/XSDT.\r
-\r
-  @param  This      Protocol instance pointer.\r
-  @param  TableKey  Specifies the table to uninstall.  The key was returned from InstallAcpiTable().\r
-\r
-  @return EFI_SUCCESS    The table was successfully uninstalled.\r
-  @return EFI_NOT_FOUND  TableKey does not refer to a valid key for a table entry.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UninstallAcpiTable (\r
-  IN  EFI_ACPI_TABLE_PROTOCOL                    *This,\r
-  IN  UINTN                                      TableKey\r
-  )\r
-{\r
-  EFI_ACPI_SUPPORT_INSTANCE *AcpiSupportInstance;\r
-  EFI_ACPI_SUPPORT_PROTOCOL *AcpiSupport;\r
-  EFI_STATUS                Status;\r
-\r
-  //\r
-  // Get the instance of the ACPI support protocol\r
-  //\r
-  AcpiSupportInstance = EFI_ACPI_TABLE_INSTANCE_FROM_ACPI_SUPPORT_THIS (This);\r
-  AcpiSupport = &AcpiSupportInstance->AcpiSupport;\r
-\r
-  //\r
-  // Uninstall the ACPI table by using ACPI support protocol\r
-  //\r
-  Status = RemoveTableFromList (\r
-             AcpiSupportInstance,\r
-             EFI_ACPI_TABLE_VERSION_1_0B | EFI_ACPI_TABLE_VERSION_2_0 | EFI_ACPI_TABLE_VERSION_3_0,\r
-             TableKey\r
-             );\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = AcpiSupport->PublishTables (\r
-                            AcpiSupport,\r
-                            EFI_ACPI_TABLE_VERSION_1_0B | EFI_ACPI_TABLE_VERSION_2_0 | EFI_ACPI_TABLE_VERSION_3_0\r
-                            );\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  } else {\r
-    return EFI_SUCCESS;\r
-  }\r
-}\r
-/**\r
-  If the number of APCI tables exceeds the preallocated max table number, enlarge the table buffer.\r
-\r
-  @param  AcpiSupportInstance       ACPI support protocol instance data structure\r
-\r
-  @return EFI_SUCCESS             reallocate the table beffer successfully.\r
-  @return EFI_OUT_OF_RESOURCES    Unable to allocate required resources.\r
-\r
-**/\r
-EFI_STATUS\r
-ReallocateAcpiTableBuffer (\r
-  IN EFI_ACPI_SUPPORT_INSTANCE            *AcpiSupportInstance\r
-  )\r
-{\r
-  UINTN                      NewMaxTableNumber;\r
-  UINTN                      TotalSize;\r
-  UINT8                      *Pointer;\r
-  EFI_PHYSICAL_ADDRESS       PageAddress;\r
-  EFI_ACPI_SUPPORT_INSTANCE  TempPrivateData;\r
-  EFI_STATUS                 Status;\r
-  UINT64                     CurrentData;\r
-\r
-  CopyMem (&TempPrivateData, AcpiSupportInstance, sizeof (EFI_ACPI_SUPPORT_INSTANCE));\r
-  //\r
-  // Enlarge the max table number from mEfiAcpiMaxNumTables to mEfiAcpiMaxNumTables + EFI_ACPI_MAX_NUM_TABLES\r
-  //\r
-  NewMaxTableNumber = mEfiAcpiMaxNumTables + EFI_ACPI_MAX_NUM_TABLES;\r
-  //\r
-  // Create RSDT, XSDT structures and allocate buffers.\r
-  //\r
-  TotalSize = sizeof (EFI_ACPI_DESCRIPTION_HEADER) +         // for ACPI 1.0 RSDT\r
-              NewMaxTableNumber * sizeof (UINT32) +\r
-              sizeof (EFI_ACPI_DESCRIPTION_HEADER) +         // for ACPI 2.0/3.0 RSDT\r
-              NewMaxTableNumber * sizeof (UINT32) +\r
-              sizeof (EFI_ACPI_DESCRIPTION_HEADER) +         // for ACPI 2.0/3.0 XSDT\r
-              NewMaxTableNumber * sizeof (UINT64);\r
-\r
-  //\r
-  // Allocate memory in the lower 32 bit of address range for\r
-  // compatibility with ACPI 1.0 OS.\r
-  //\r
-  // This is done because ACPI 1.0 pointers are 32 bit values.\r
-  // ACPI 2.0 OS and all 64 bit OS must use the 64 bit ACPI table addresses.\r
-  // There is no architectural reason these should be below 4GB, it is purely\r
-  // for convenience of implementation that we force memory below 4GB.\r
-  //\r
-  PageAddress = 0xFFFFFFFF;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiACPIReclaimMemory,\r
-                  EFI_SIZE_TO_PAGES (TotalSize),\r
-                  &PageAddress\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Pointer = (UINT8 *) (UINTN) PageAddress;\r
-  ZeroMem (Pointer, TotalSize);\r
-\r
-  AcpiSupportInstance->Rsdt1 = (EFI_ACPI_DESCRIPTION_HEADER *) Pointer;\r
-  Pointer += (sizeof (EFI_ACPI_DESCRIPTION_HEADER) + NewMaxTableNumber * sizeof (UINT32));\r
-  AcpiSupportInstance->Rsdt3 = (EFI_ACPI_DESCRIPTION_HEADER *) Pointer;\r
-  Pointer += (sizeof (EFI_ACPI_DESCRIPTION_HEADER) + NewMaxTableNumber * sizeof (UINT32));\r
-  AcpiSupportInstance->Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) Pointer;\r
-\r
-  //\r
-  // Update RSDP to point to the new Rsdt and Xsdt address.\r
-  //\r
-  AcpiSupportInstance->Rsdp1->RsdtAddress = (UINT32) (UINTN) AcpiSupportInstance->Rsdt1;\r
-  AcpiSupportInstance->Rsdp3->RsdtAddress = (UINT32) (UINTN) AcpiSupportInstance->Rsdt3;\r
-  CurrentData = (UINT64) (UINTN) AcpiSupportInstance->Xsdt;\r
-  CopyMem (&AcpiSupportInstance->Rsdp3->XsdtAddress, &CurrentData, sizeof (UINT64));\r
-\r
-  //\r
-  // copy the original Rsdt1, Rsdt3 and Xsdt structure to new buffer\r
-  //\r
-  CopyMem (AcpiSupportInstance->Rsdt1, TempPrivateData.Rsdt1, (sizeof (EFI_ACPI_DESCRIPTION_HEADER) + mEfiAcpiMaxNumTables * sizeof (UINT32)));\r
-  CopyMem (AcpiSupportInstance->Rsdt3, TempPrivateData.Rsdt3, (sizeof (EFI_ACPI_DESCRIPTION_HEADER) + mEfiAcpiMaxNumTables * sizeof (UINT32)));\r
-  CopyMem (AcpiSupportInstance->Xsdt, TempPrivateData.Xsdt, (sizeof (EFI_ACPI_DESCRIPTION_HEADER) + mEfiAcpiMaxNumTables * sizeof (UINT64)));\r
-\r
-  //\r
-  // Calculate orignal ACPI table buffer size\r
-  //\r
-  TotalSize = sizeof (EFI_ACPI_DESCRIPTION_HEADER) +         // for ACPI 1.0 RSDT\r
-              mEfiAcpiMaxNumTables * sizeof (UINT32) +\r
-              sizeof (EFI_ACPI_DESCRIPTION_HEADER) +         // for ACPI 2.0/3.0 RSDT\r
-              mEfiAcpiMaxNumTables * sizeof (UINT32) +\r
-              sizeof (EFI_ACPI_DESCRIPTION_HEADER) +         // for ACPI 2.0/3.0 XSDT\r
-              mEfiAcpiMaxNumTables * sizeof (UINT64);\r
-  gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)TempPrivateData.Rsdt1, EFI_SIZE_TO_PAGES (TotalSize));\r
-\r
-  //\r
-  // Update the Max ACPI table number\r
-  //\r
-  mEfiAcpiMaxNumTables = NewMaxTableNumber;\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function adds an ACPI table to the table list.  It will detect FACS and\r
-  allocate the correct type of memory and properly align the table.\r
-\r
-  @param  AcpiSupportInstance       Instance of the protocol.\r
-  @param  Table                     Table to add.\r
-  @param  Checksum                  Does the table require checksumming.\r
-  @param  Version                   The version of the list to add the table to.\r
-  @param  Handle                    Pointer for returning the handle.\r
-\r
-  @return EFI_SUCCESS               The function completed successfully.\r
-  @return EFI_OUT_OF_RESOURCES      Could not allocate a required resource.\r
-  @retval EFI_ACCESS_DENIED         The table signature matches a table already\r
-                                    present in the system and platform policy\r
-                                    does not allow duplicate tables of this type.\r
-**/\r
-EFI_STATUS\r
-AddTableToList (\r
-  IN EFI_ACPI_SUPPORT_INSTANCE            *AcpiSupportInstance,\r
-  IN VOID                                 *Table,\r
-  IN BOOLEAN                              Checksum,\r
-  IN EFI_ACPI_TABLE_VERSION               Version,\r
-  OUT UINTN                               *Handle\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-  EFI_ACPI_TABLE_LIST *CurrentTableList;\r
-  UINT32              CurrentTableSignature;\r
-  UINT32              CurrentTableSize;\r
-  UINT32              *CurrentRsdtEntry;\r
-  VOID                *CurrentXsdtEntry;\r
-  UINT64              Buffer64;\r
-  BOOLEAN             AddToRsdt;\r
-\r
-  //\r
-  // Check for invalid input parameters\r
-  //\r
-  ASSERT (AcpiSupportInstance);\r
-  ASSERT (Table);\r
-  ASSERT (Handle);\r
-\r
-  //\r
-  // Init locals\r
-  //\r
-  AddToRsdt = TRUE;\r
-\r
-  //\r
-  // Create a new list entry\r
-  //\r
-  CurrentTableList = AllocatePool (sizeof (EFI_ACPI_TABLE_LIST));\r
-  ASSERT (CurrentTableList);\r
-\r
-  //\r
-  // Determine table type and size\r
-  //\r
-  CurrentTableSignature = ((EFI_ACPI_COMMON_HEADER *) Table)->Signature;\r
-  CurrentTableSize      = ((EFI_ACPI_COMMON_HEADER *) Table)->Length;\r
-\r
-  //\r
-  // Allocate a buffer for the table.  All tables are allocated in the lower 32 bits of address space\r
-  // for backwards compatibility with ACPI 1.0 OS.\r
-  //\r
-  // This is done because ACPI 1.0 pointers are 32 bit values.\r
-  // ACPI 2.0 OS and all 64 bit OS must use the 64 bit ACPI table addresses.\r
-  // There is no architectural reason these should be below 4GB, it is purely\r
-  // for convenience of implementation that we force memory below 4GB.\r
-  //\r
-  CurrentTableList->PageAddress   = 0xFFFFFFFF;\r
-  CurrentTableList->NumberOfPages = EFI_SIZE_TO_PAGES (CurrentTableSize);\r
-\r
-  //\r
-  // Allocation memory type depends on the type of the table\r
-  //\r
-  if ((CurrentTableSignature == EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) ||\r
-      (CurrentTableSignature == EFI_ACPI_4_0_UEFI_ACPI_DATA_TABLE_SIGNATURE)) {\r
-    //\r
-    // Allocate memory for the FACS.  This structure must be aligned\r
-    // on a 64 byte boundary and must be ACPI NVS memory.\r
-    // Using AllocatePages should ensure that it is always aligned.\r
-    // Do not change signature for new ACPI version because they are same.\r
-    //\r
-    // UEFI table also need to be in ACPI NVS memory, because some data field\r
-    // could be updated by OS present agent. For example, BufferPtrAddress in\r
-    // SMM communication ACPI table.\r
-    //\r
-    ASSERT ((EFI_PAGE_SIZE % 64) == 0);\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiACPIMemoryNVS,\r
-                    CurrentTableList->NumberOfPages,\r
-                    &CurrentTableList->PageAddress\r
-                    );\r
-  } else {\r
-    //\r
-    // All other tables are ACPI reclaim memory, no alignment requirements.\r
-    //\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiACPIReclaimMemory,\r
-                    CurrentTableList->NumberOfPages,\r
-                    &CurrentTableList->PageAddress\r
-                    );\r
-  }\r
-  //\r
-  // Check return value from memory alloc.\r
-  //\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (CurrentTableList);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Update the table pointer with the allocated memory start\r
-  //\r
-  CurrentTableList->Table = (EFI_ACPI_COMMON_HEADER *) (UINTN) CurrentTableList->PageAddress;\r
-\r
-  //\r
-  // Initialize the table contents\r
-  //\r
-  CurrentTableList->Signature = EFI_ACPI_TABLE_LIST_SIGNATURE;\r
-  CopyMem (CurrentTableList->Table, Table, CurrentTableSize);\r
-  CurrentTableList->Handle  = AcpiSupportInstance->CurrentHandle++;\r
-  *Handle                   = CurrentTableList->Handle;\r
-  CurrentTableList->Version = Version;\r
-\r
-  //\r
-  // Update internal pointers if this is a required table.  If it is a required\r
-  // table and a table of that type already exists, return an error.\r
-  //\r
-  // Calculate the checksum if the table is not FACS.\r
-  //\r
-  switch (CurrentTableSignature) {\r
-\r
-  case EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE:\r
-    //\r
-    // We don't add the FADT in the standard way because some\r
-    // OS expect the FADT to be early in the table list.\r
-    // So we always add it as the first element in the list.\r
-    //\r
-    AddToRsdt = FALSE;\r
-\r
-    //\r
-    // Check that the table has not been previously added.\r
-    //\r
-   if (((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0 && AcpiSupportInstance->Fadt1 != NULL) ||\r
-        ((Version & EFI_ACPI_TABLE_VERSION_2_0)  != 0 && AcpiSupportInstance->Fadt3 != NULL) ||\r
-        ((Version & EFI_ACPI_TABLE_VERSION_3_0)  != 0 && AcpiSupportInstance->Fadt3 != NULL)\r
-        ) {\r
-      gBS->FreePages (CurrentTableList->PageAddress, CurrentTableList->NumberOfPages);\r
-      gBS->FreePool (CurrentTableList);\r
-      return EFI_ACCESS_DENIED;\r
-    }\r
-    //\r
-    // Add the table to the appropriate table version\r
-    //\r
-    if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {\r
-      //\r
-      // Save a pointer to the table\r
-      //\r
-      AcpiSupportInstance->Fadt1 = (EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE *) CurrentTableList->Table;\r
-\r
-      //\r
-      // Update pointers in FADT.  If tables don't exist this will put NULL pointers there.\r
-      //\r
-      AcpiSupportInstance->Fadt1->FirmwareCtrl  = (UINT32) (UINTN) AcpiSupportInstance->Facs1;\r
-      AcpiSupportInstance->Fadt1->Dsdt          = (UINT32) (UINTN) AcpiSupportInstance->Dsdt1;\r
-\r
-      //\r
-      // RSDP OEM information is updated to match the FADT OEM information\r
-      //\r
-      CopyMem (\r
-        &AcpiSupportInstance->Rsdp1->OemId,\r
-        &AcpiSupportInstance->Fadt1->Header.OemId,\r
-        6\r
-        );\r
-\r
-      //\r
-      // RSDT OEM information is updated to match the FADT OEM information.\r
-      //\r
-      CopyMem (\r
-        &AcpiSupportInstance->Rsdt1->OemId,\r
-        &AcpiSupportInstance->Fadt1->Header.OemId,\r
-        6\r
-        );\r
-\r
-      CopyMem (\r
-        &AcpiSupportInstance->Rsdt1->OemTableId,\r
-        &AcpiSupportInstance->Fadt1->Header.OemTableId,\r
-        sizeof (UINT64)\r
-        );\r
-      AcpiSupportInstance->Rsdt1->OemRevision = AcpiSupportInstance->Fadt1->Header.OemRevision;\r
-    }\r
-\r
-    if ((Version & EFI_ACPI_TABLE_VERSION_2_0) != 0 ||\r
-        (Version & EFI_ACPI_TABLE_VERSION_3_0) != 0) {\r
-      //\r
-      // Save a pointer to the table\r
-      //\r
-      AcpiSupportInstance->Fadt3 = (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) CurrentTableList->Table;\r
-\r
-      //\r
-      // Update pointers in FADT.  If tables don't exist this will put NULL pointers there.\r
-      // Note: If the FIRMWARE_CTRL is non-zero, then X_FIRMWARE_CTRL must be zero, and\r
-      // vice-versa.\r
-      //\r
-      if ((UINT64)(UINTN)AcpiSupportInstance->Facs3 < BASE_4GB) {\r
-        AcpiSupportInstance->Fadt3->FirmwareCtrl = (UINT32) (UINTN) AcpiSupportInstance->Facs3;\r
-        ZeroMem (\r
-          &AcpiSupportInstance->Fadt3->XFirmwareCtrl,\r
-          sizeof (UINT64)\r
-          );\r
-      } else {\r
-        AcpiSupportInstance->Fadt3->FirmwareCtrl = 0;\r
-        Buffer64 = (UINT64) (UINTN) AcpiSupportInstance->Facs3;\r
-        CopyMem (\r
-          &AcpiSupportInstance->Fadt3->XFirmwareCtrl,\r
-          &Buffer64,\r
-          sizeof (UINT64)\r
-          );\r
-      }\r
-      AcpiSupportInstance->Fadt3->Dsdt  = (UINT32) (UINTN) AcpiSupportInstance->Dsdt3;\r
-      Buffer64                          = (UINT64) (UINTN) AcpiSupportInstance->Dsdt3;\r
-      CopyMem (\r
-        &AcpiSupportInstance->Fadt3->XDsdt,\r
-        &Buffer64,\r
-        sizeof (UINT64)\r
-        );\r
-\r
-      //\r
-      // RSDP OEM information is updated to match the FADT OEM information\r
-      //\r
-      CopyMem (\r
-        &AcpiSupportInstance->Rsdp3->OemId,\r
-        &AcpiSupportInstance->Fadt3->Header.OemId,\r
-        6\r
-        );\r
-\r
-      //\r
-      // RSDT OEM information is updated to match FADT OEM information.\r
-      //\r
-      CopyMem (\r
-        &AcpiSupportInstance->Rsdt3->OemId,\r
-        &AcpiSupportInstance->Fadt3->Header.OemId,\r
-        6\r
-        );\r
-      CopyMem (\r
-        &AcpiSupportInstance->Rsdt3->OemTableId,\r
-        &AcpiSupportInstance->Fadt3->Header.OemTableId,\r
-        sizeof (UINT64)\r
-        );\r
-      AcpiSupportInstance->Rsdt3->OemRevision = AcpiSupportInstance->Fadt3->Header.OemRevision;\r
-\r
-      //\r
-      // XSDT OEM information is updated to match FADT OEM information.\r
-      //\r
-      CopyMem (\r
-        &AcpiSupportInstance->Xsdt->OemId,\r
-        &AcpiSupportInstance->Fadt3->Header.OemId,\r
-        6\r
-        );\r
-      CopyMem (\r
-        &AcpiSupportInstance->Xsdt->OemTableId,\r
-        &AcpiSupportInstance->Fadt3->Header.OemTableId,\r
-        sizeof (UINT64)\r
-        );\r
-      AcpiSupportInstance->Xsdt->OemRevision = AcpiSupportInstance->Fadt3->Header.OemRevision;\r
-    }\r
-\r
-    //\r
-    // Checksum the table\r
-    //\r
-    if (Checksum) {\r
-      AcpiPlatformChecksum (\r
-        CurrentTableList->Table,\r
-        CurrentTableList->Table->Length,\r
-        OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-        Checksum)\r
-        );\r
-    }\r
-    break;\r
-\r
-  case EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE:\r
-    //\r
-    // Check that the table has not been previously added.\r
-    //\r
-   if (((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0 && AcpiSupportInstance->Facs1 != NULL) ||\r
-        ((Version & EFI_ACPI_TABLE_VERSION_2_0)  != 0 && AcpiSupportInstance->Facs3 != NULL) ||\r
-        ((Version & EFI_ACPI_TABLE_VERSION_3_0)  != 0 && AcpiSupportInstance->Facs3 != NULL)\r
-        ) {\r
-      gBS->FreePages (CurrentTableList->PageAddress, CurrentTableList->NumberOfPages);\r
-      gBS->FreePool (CurrentTableList);\r
-      return EFI_ACCESS_DENIED;\r
-    }\r
-    //\r
-    // FACS is referenced by FADT and is not part of RSDT\r
-    //\r
-    AddToRsdt = FALSE;\r
-\r
-    //\r
-    // Add the table to the appropriate table version\r
-    //\r
-    if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {\r
-      //\r
-      // Save a pointer to the table\r
-      //\r
-      AcpiSupportInstance->Facs1 = (EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) CurrentTableList->Table;\r
-\r
-      //\r
-      // If FADT already exists, update table pointers.\r
-      //\r
-      if (AcpiSupportInstance->Fadt1 != NULL) {\r
-        AcpiSupportInstance->Fadt1->FirmwareCtrl = (UINT32) (UINTN) AcpiSupportInstance->Facs1;\r
-\r
-        //\r
-        // Checksum FADT table\r
-        //\r
-        AcpiPlatformChecksum (\r
-          AcpiSupportInstance->Fadt1,\r
-          AcpiSupportInstance->Fadt1->Header.Length,\r
-          OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-          Checksum)\r
-          );\r
-      }\r
-    }\r
-\r
-    if ((Version & EFI_ACPI_TABLE_VERSION_2_0) != 0 ||\r
-        (Version & EFI_ACPI_TABLE_VERSION_3_0) != 0) {\r
-      //\r
-      // Save a pointer to the table\r
-      //\r
-      AcpiSupportInstance->Facs3 = (EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) CurrentTableList->Table;\r
-\r
-      //\r
-      // If FADT already exists, update table pointers.\r
-      //\r
-      if (AcpiSupportInstance->Fadt3 != NULL) {\r
-        //\r
-        // Note: If the FIRMWARE_CTRL is non-zero, then X_FIRMWARE_CTRL must be zero, and\r
-        // vice-versa.\r
-        //\r
-        if ((UINT64)(UINTN)AcpiSupportInstance->Facs3 < BASE_4GB) {\r
-          AcpiSupportInstance->Fadt3->FirmwareCtrl  = (UINT32) (UINTN) AcpiSupportInstance->Facs3;\r
-        } else {\r
-          Buffer64 = (UINT64) (UINTN) AcpiSupportInstance->Facs3;\r
-          CopyMem (\r
-            &AcpiSupportInstance->Fadt3->XFirmwareCtrl,\r
-            &Buffer64,\r
-            sizeof (UINT64)\r
-            );\r
-        }\r
-\r
-        //\r
-        // Checksum FADT table\r
-        //\r
-        AcpiPlatformChecksum (\r
-          AcpiSupportInstance->Fadt3,\r
-          AcpiSupportInstance->Fadt3->Header.Length,\r
-          OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-          Checksum)\r
-          );\r
-      }\r
-    }\r
-\r
-    break;\r
-\r
-  case EFI_ACPI_1_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE:\r
-    //\r
-    // Check that the table has not been previously added.\r
-    //\r
-   if (((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0 && AcpiSupportInstance->Dsdt1 != NULL) ||\r
-        ((Version & EFI_ACPI_TABLE_VERSION_2_0)  != 0 && AcpiSupportInstance->Dsdt3 != NULL) ||\r
-        ((Version & EFI_ACPI_TABLE_VERSION_3_0)  != 0 && AcpiSupportInstance->Dsdt3 != NULL)\r
-        ) {\r
-      gBS->FreePages (CurrentTableList->PageAddress, CurrentTableList->NumberOfPages);\r
-      gBS->FreePool (CurrentTableList);\r
-      return EFI_ACCESS_DENIED;\r
-    }\r
-    //\r
-    // DSDT is referenced by FADT and is not part of RSDT\r
-    //\r
-    AddToRsdt = FALSE;\r
-\r
-    //\r
-    // Add the table to the appropriate table version\r
-    //\r
-    if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {\r
-      //\r
-      // Save a pointer to the table\r
-      //\r
-      AcpiSupportInstance->Dsdt1 = (EFI_ACPI_DESCRIPTION_HEADER *) CurrentTableList->Table;\r
-\r
-      //\r
-      // If FADT already exists, update table pointers.\r
-      //\r
-      if (AcpiSupportInstance->Fadt1 != NULL) {\r
-        AcpiSupportInstance->Fadt1->Dsdt = (UINT32) (UINTN) AcpiSupportInstance->Dsdt1;\r
-\r
-        //\r
-        // Checksum FADT table\r
-        //\r
-        AcpiPlatformChecksum (\r
-          AcpiSupportInstance->Fadt1,\r
-          AcpiSupportInstance->Fadt1->Header.Length,\r
-          OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-          Checksum)\r
-          );\r
-      }\r
-    }\r
-\r
-     if ((Version & EFI_ACPI_TABLE_VERSION_2_0) != 0 ||\r
-        (Version & EFI_ACPI_TABLE_VERSION_3_0) != 0) {\r
-      //\r
-      // Save a pointer to the table\r
-      //\r
-      AcpiSupportInstance->Dsdt3 = (EFI_ACPI_DESCRIPTION_HEADER *) CurrentTableList->Table;\r
-\r
-      //\r
-      // If FADT already exists, update table pointers.\r
-      //\r
-      if (AcpiSupportInstance->Fadt3 != NULL) {\r
-        AcpiSupportInstance->Fadt3->Dsdt  = (UINT32) (UINTN) AcpiSupportInstance->Dsdt3;\r
-        Buffer64                          = (UINT64) (UINTN) AcpiSupportInstance->Dsdt3;\r
-        CopyMem (\r
-          &AcpiSupportInstance->Fadt3->XDsdt,\r
-          &Buffer64,\r
-          sizeof (UINT64)\r
-          );\r
-\r
-        //\r
-        // Checksum FADT table\r
-        //\r
-        AcpiPlatformChecksum (\r
-          AcpiSupportInstance->Fadt3,\r
-          AcpiSupportInstance->Fadt3->Header.Length,\r
-          OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-          Checksum)\r
-          );\r
-      }\r
-    }\r
-    //\r
-    // Checksum the table\r
-    //\r
-    if (Checksum) {\r
-      AcpiPlatformChecksum (\r
-        CurrentTableList->Table,\r
-        CurrentTableList->Table->Length,\r
-        OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-        Checksum)\r
-        );\r
-    }\r
-    break;\r
-\r
-  default:\r
-    //\r
-    // Checksum the table\r
-    //\r
-    if (Checksum) {\r
-      AcpiPlatformChecksum (\r
-        CurrentTableList->Table,\r
-        CurrentTableList->Table->Length,\r
-        OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-        Checksum)\r
-        );\r
-    }\r
-    break;\r
-  }\r
-  //\r
-  // Add the table to the current list of tables\r
-  //\r
-  InsertTailList (&AcpiSupportInstance->TableList, &CurrentTableList->Link);\r
-\r
-  //\r
-  // Add the table to RSDT and/or XSDT table entry lists.\r
-  //\r
-  //\r
-  // Add to ACPI 1.0b table tree\r
-  //\r
-  if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {\r
-    if (AddToRsdt) {\r
-      //\r
-      // If the table number exceed the gEfiAcpiMaxNumTables, enlarge the table buffer\r
-      //\r
-      if (AcpiSupportInstance->NumberOfTableEntries1 >= mEfiAcpiMaxNumTables) {\r
-        Status = ReallocateAcpiTableBuffer (AcpiSupportInstance);\r
-        ASSERT_EFI_ERROR (Status);\r
-      }\r
-      CurrentRsdtEntry = (UINT32 *)\r
-        (\r
-          (UINT8 *) AcpiSupportInstance->Rsdt1 +\r
-          sizeof (EFI_ACPI_DESCRIPTION_HEADER) +\r
-          AcpiSupportInstance->NumberOfTableEntries1 *\r
-          sizeof (UINT32)\r
-        );\r
-\r
-      //\r
-      // Add entry to the RSDT unless its the FACS or DSDT\r
-      //\r
-      *CurrentRsdtEntry = (UINT32) (UINTN) CurrentTableList->Table;\r
-\r
-      //\r
-      // Update RSDT length\r
-      //\r
-      AcpiSupportInstance->Rsdt1->Length = AcpiSupportInstance->Rsdt1->Length + sizeof (UINT32);\r
-\r
-      AcpiSupportInstance->NumberOfTableEntries1++;\r
-    }\r
-  }\r
-  //\r
-  // Add to ACPI 2.0/3.0  table tree\r
-  //\r
-  if ((Version & EFI_ACPI_TABLE_VERSION_2_0) != 0 || (Version & EFI_ACPI_TABLE_VERSION_3_0) != 0) {\r
-    if (AddToRsdt) {\r
-       //\r
-       // If the table number exceed the gEfiAcpiMaxNumTables, enlarge the table buffer\r
-       //\r
-       if (AcpiSupportInstance->NumberOfTableEntries3 >= mEfiAcpiMaxNumTables) {\r
-         Status = ReallocateAcpiTableBuffer (AcpiSupportInstance);\r
-         ASSERT_EFI_ERROR (Status);\r
-       }\r
-      //\r
-      // At this time, it is assumed that RSDT and XSDT maintain parallel lists of tables.\r
-      // If it becomes necessary to maintain separate table lists, changes will be required.\r
-      //\r
-      CurrentRsdtEntry = (UINT32 *)\r
-        (\r
-          (UINT8 *) AcpiSupportInstance->Rsdt3 +\r
-          sizeof (EFI_ACPI_DESCRIPTION_HEADER) +\r
-          AcpiSupportInstance->NumberOfTableEntries3 *\r
-          sizeof (UINT32)\r
-        );\r
-\r
-      //\r
-      // This pointer must not be directly dereferenced as the XSDT entries may not\r
-      // be 64 bit aligned resulting in a possible fault.  Use CopyMem to update.\r
-      //\r
-      CurrentXsdtEntry = (VOID *)\r
-        (\r
-          (UINT8 *) AcpiSupportInstance->Xsdt +\r
-          sizeof (EFI_ACPI_DESCRIPTION_HEADER) +\r
-          AcpiSupportInstance->NumberOfTableEntries3 *\r
-          sizeof (UINT64)\r
-        );\r
-\r
-      //\r
-      // Add entry to the RSDT\r
-      //\r
-      *CurrentRsdtEntry = (UINT32) (UINTN) CurrentTableList->Table;\r
-\r
-      //\r
-      // Update RSDT length\r
-      //\r
-      AcpiSupportInstance->Rsdt3->Length = AcpiSupportInstance->Rsdt3->Length + sizeof (UINT32);\r
-\r
-      //\r
-      // Add entry to XSDT, XSDT expects 64 bit pointers, but\r
-      // the table pointers in XSDT are not aligned on 8 byte boundary.\r
-      //\r
-      Buffer64 = (UINT64) (UINTN) CurrentTableList->Table;\r
-      CopyMem (\r
-        CurrentXsdtEntry,\r
-        &Buffer64,\r
-        sizeof (UINT64)\r
-        );\r
-\r
-      //\r
-      // Update length\r
-      //\r
-      AcpiSupportInstance->Xsdt->Length = AcpiSupportInstance->Xsdt->Length + sizeof (UINT64);\r
-\r
-      AcpiSupportInstance->NumberOfTableEntries3++;\r
-    }\r
-  }\r
-\r
-  ChecksumCommonTables (AcpiSupportInstance);\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function finds the table specified by the handle and returns a pointer to it.\r
-  If the handle is not found, EFI_NOT_FOUND is returned and the contents of Table are\r
-  undefined.\r
-\r
-  @param  Handle      Table to find.\r
-  @param  TableList   Table list to search\r
-  @param  Table       Pointer to table found.\r
-\r
-  @return EFI_SUCCESS    The function completed successfully.\r
-  @return EFI_NOT_FOUND  No table found matching the handle specified.\r
-\r
-**/\r
-EFI_STATUS\r
-FindTableByHandle (\r
-  IN UINTN                                Handle,\r
-  IN LIST_ENTRY                       *TableList,\r
-  OUT EFI_ACPI_TABLE_LIST                 **Table\r
-  )\r
-{\r
-  LIST_ENTRY      *CurrentLink;\r
-  EFI_ACPI_TABLE_LIST *CurrentTable;\r
-\r
-  //\r
-  // Check for invalid input parameters\r
-  //\r
-  ASSERT (Table);\r
-\r
-  //\r
-  // Find the table\r
-  //\r
-  CurrentLink = TableList->ForwardLink;\r
-\r
-  while (CurrentLink != TableList) {\r
-    CurrentTable = EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink);\r
-    if (CurrentTable->Handle == Handle) {\r
-      //\r
-      // Found handle, so return this table.\r
-      //\r
-      *Table = CurrentTable;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    CurrentLink = CurrentLink->ForwardLink;\r
-  }\r
-  //\r
-  // Table not found\r
-  //\r
-  return EFI_NOT_FOUND;\r
-}\r
-/**\r
-  This function removes a basic table from the RSDT and/or XSDT.\r
-  For Acpi 1.0 tables, pass in the Rsdt.\r
-  For Acpi 2.0 tables, pass in both Rsdt and Xsdt.\r
-\r
-  @param  Table                 Pointer to table found.\r
-  @param  NumberOfTableEntries  Current number of table entries in the RSDT/XSDT\r
-  @param  Rsdt                  Pointer to the RSDT to remove from\r
-  @param  Xsdt                  Pointer to the Xsdt to remove from\r
-\r
-  @return EFI_SUCCESS            The function completed successfully.\r
-  @return EFI_INVALID_PARAMETER  The table was not found in both Rsdt and Xsdt.\r
-\r
-**/\r
-EFI_STATUS\r
-RemoveTableFromRsdt (\r
-  IN OUT EFI_ACPI_TABLE_LIST              * Table,\r
-  IN OUT UINTN                            *NumberOfTableEntries,\r
-  IN OUT EFI_ACPI_DESCRIPTION_HEADER      * Rsdt,\r
-  IN OUT EFI_ACPI_DESCRIPTION_HEADER      * Xsdt OPTIONAL\r
-  )\r
-{\r
-  UINT32  *CurrentRsdtEntry;\r
-  VOID    *CurrentXsdtEntry;\r
-  UINT64  CurrentTablePointer64;\r
-  UINTN   TempIndex;\r
-\r
-  //\r
-  // Check for invalid input parameters\r
-  //\r
-  ASSERT (Table);\r
-  ASSERT (NumberOfTableEntries);\r
-  ASSERT (Rsdt);\r
-\r
-  //\r
-  // Find the table entry in the RSDT and XSDT\r
-  //\r
-  for (TempIndex = 0; TempIndex < *NumberOfTableEntries; TempIndex++) {\r
-    //\r
-    // At this time, it is assumed that RSDT and XSDT maintain parallel lists of tables.\r
-    // If it becomes necessary to maintain separate table lists, changes will be required.\r
-    //\r
-    CurrentRsdtEntry = (UINT32 *) ((UINT8 *) Rsdt + sizeof (EFI_ACPI_DESCRIPTION_HEADER) + TempIndex * sizeof (UINT32));\r
-    if (Xsdt != NULL) {\r
-      //\r
-      // This pointer must not be directly dereferenced as the XSDT entries may not\r
-      // be 64 bit aligned resulting in a possible fault.  Use CopyMem to update.\r
-      //\r
-      CurrentXsdtEntry = (VOID *) ((UINT8 *) Xsdt + sizeof (EFI_ACPI_DESCRIPTION_HEADER) + TempIndex * sizeof (UINT64));\r
-\r
-      //\r
-      // Read the entry value out of the XSDT\r
-      //\r
-      CopyMem (&CurrentTablePointer64, CurrentXsdtEntry, sizeof (UINT64));\r
-    } else {\r
-      //\r
-      // Initialize to NULL\r
-      //\r
-      CurrentXsdtEntry      = 0;\r
-      CurrentTablePointer64 = 0;\r
-    }\r
-    //\r
-    // Check if we have found the corresponding entry in both RSDT and XSDT\r
-    //\r
-    if (*CurrentRsdtEntry == (UINT32) (UINTN) Table->Table &&\r
-        ((Xsdt == NULL) || CurrentTablePointer64 == (UINT64) (UINTN) Table->Table)\r
-        ) {\r
-      //\r
-      // Found entry, so copy all following entries and shrink table\r
-      // We actually copy all + 1 to copy the initialized value of memory over\r
-      // the last entry.\r
-      //\r
-      CopyMem (CurrentRsdtEntry, CurrentRsdtEntry + 1, (*NumberOfTableEntries - TempIndex) * sizeof (UINT32));\r
-      Rsdt->Length = Rsdt->Length - sizeof (UINT32);\r
-      if (Xsdt != NULL) {\r
-        CopyMem (CurrentXsdtEntry, ((UINT64 *) CurrentXsdtEntry) + 1, (*NumberOfTableEntries - TempIndex) * sizeof (UINT64));\r
-        Xsdt->Length = Xsdt->Length - sizeof (UINT64);\r
-      }\r
-      break;\r
-    } else if (TempIndex + 1 == *NumberOfTableEntries) {\r
-      //\r
-      // At the last entry, and table not found\r
-      //\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Checksum the tables\r
-  //\r
-  AcpiPlatformChecksum (\r
-    Rsdt,\r
-    Rsdt->Length,\r
-    OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-    Checksum)\r
-    );\r
-\r
-  if (Xsdt != NULL) {\r
-    AcpiPlatformChecksum (\r
-      Xsdt,\r
-      Xsdt->Length,\r
-      OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-      Checksum)\r
-      );\r
-  }\r
-  //\r
-  // Decrement the number of tables\r
-  //\r
-  (*NumberOfTableEntries)--;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function removes a table and frees any associated memory.\r
-\r
-  @param  AcpiSupportInstance  Instance of the protocol.\r
-  @param  Version            Version(s) to delete.\r
-  @param  Table              Pointer to table found.\r
-\r
-  @return EFI_SUCCESS  The function completed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-DeleteTable (\r
-  IN EFI_ACPI_SUPPORT_INSTANCE            *AcpiSupportInstance,\r
-  IN EFI_ACPI_TABLE_VERSION               Version,\r
-  IN OUT EFI_ACPI_TABLE_LIST              *Table\r
-  )\r
-{\r
-  UINT32  CurrentTableSignature;\r
-  BOOLEAN RemoveFromRsdt;\r
-\r
-  //\r
-  // Check for invalid input parameters\r
-  //\r
-  ASSERT (AcpiSupportInstance);\r
-  ASSERT (Table);\r
-\r
-  //\r
-  // Init locals\r
-  //\r
-  RemoveFromRsdt        = TRUE;\r
-\r
-  if (Table->Table != NULL) {\r
-    CurrentTableSignature = ((EFI_ACPI_COMMON_HEADER *) Table->Table)->Signature;\r
-\r
-    //\r
-    // Basic tasks to accomplish delete are:\r
-    //   Determine removal requirements (in RSDT/XSDT or not)\r
-    //   Remove entry from RSDT/XSDT\r
-    //   Remove any table references to the table\r
-    //   If no one is using the table\r
-    //      Free the table (removing pointers from private data and tables)\r
-    //      Remove from list\r
-    //      Free list structure\r
-    //\r
-    //\r
-    // Determine if this table is in the RSDT or XSDT\r
-    //\r
-    if ((CurrentTableSignature == EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) ||\r
-        (CurrentTableSignature == EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) ||\r
-        (CurrentTableSignature == EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE)\r
-        ) {\r
-      RemoveFromRsdt = FALSE;\r
-    }\r
-    //\r
-    // We don't remove the FADT in the standard way because some\r
-    // OS expect the FADT to be early in the table list.\r
-    // So we always put it as the first element in the list.\r
-    //\r
-    if (CurrentTableSignature == EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {\r
-      RemoveFromRsdt = FALSE;\r
-    }\r
-\r
-    //\r
-    // Remove the table from RSDT and XSDT\r
-    //\r
-\r
-    //\r
-    // This is a basic table, remove it from any lists and the Rsdt and/or Xsdt\r
-    //\r
-    if (Version & EFI_ACPI_TABLE_VERSION_NONE & Table->Version) {\r
-      //\r
-      // Remove this version from the table\r
-      //\r
-      Table->Version = Table->Version &~EFI_ACPI_TABLE_VERSION_NONE;\r
-    }\r
-\r
-    if (Version & EFI_ACPI_TABLE_VERSION_1_0B & Table->Version) {\r
-      //\r
-      // Remove this version from the table\r
-      //\r
-      Table->Version = Table->Version &~EFI_ACPI_TABLE_VERSION_1_0B;\r
-\r
-      //\r
-      // Remove from Rsdt.  We don't care about the return value because it is\r
-      // acceptable for the table to not exist in Rsdt.\r
-      // We didn't add some tables so we don't remove them.\r
-      //\r
-      if (RemoveFromRsdt) {\r
-        RemoveTableFromRsdt (\r
-          Table,\r
-          &AcpiSupportInstance->NumberOfTableEntries1,\r
-          AcpiSupportInstance->Rsdt1,\r
-          NULL\r
-          );\r
-      }\r
-    }\r
-\r
-    if ((Version & EFI_ACPI_TABLE_VERSION_2_0 & Table->Version) ||\r
-        (Version & EFI_ACPI_TABLE_VERSION_3_0 & Table->Version)) {\r
-      //\r
-      // Remove this version from the table\r
-      //\r
-      if (Version & EFI_ACPI_TABLE_VERSION_2_0 & Table->Version) {\r
-        Table->Version = Table->Version &~EFI_ACPI_TABLE_VERSION_2_0;\r
-      }\r
-      if (Version & EFI_ACPI_TABLE_VERSION_3_0 & Table->Version) {\r
-        Table->Version = Table->Version &~EFI_ACPI_TABLE_VERSION_3_0;\r
-      }\r
-\r
-      //\r
-      // Remove from Rsdt and Xsdt.  We don't care about the return value\r
-      // because it is acceptable for the table to not exist in Rsdt/Xsdt.\r
-      // We didn't add some tables so we don't remove them.\r
-      //\r
-      if (RemoveFromRsdt) {\r
-        RemoveTableFromRsdt (\r
-          Table,\r
-          &AcpiSupportInstance->NumberOfTableEntries3,\r
-          AcpiSupportInstance->Rsdt3,\r
-          AcpiSupportInstance->Xsdt\r
-          );\r
-      }\r
-    }\r
-    //\r
-    // Free the table, clean up any dependent tables and our private data pointers.\r
-    //\r
-    switch (Table->Table->Signature) {\r
-\r
-    case EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE:\r
-      if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {\r
-        AcpiSupportInstance->Fadt1 = NULL;\r
-      }\r
-\r
-      if ((Version & EFI_ACPI_TABLE_VERSION_2_0) != 0 ||\r
-          (Version & EFI_ACPI_TABLE_VERSION_3_0) != 0) {\r
-        AcpiSupportInstance->Fadt3 = NULL;\r
-      }\r
-      break;\r
-\r
-    case EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE:\r
-      if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {\r
-        AcpiSupportInstance->Facs1 = NULL;\r
-\r
-        //\r
-        // Update FADT table pointers\r
-        //\r
-        if (AcpiSupportInstance->Fadt1 != NULL) {\r
-          AcpiSupportInstance->Fadt1->FirmwareCtrl = 0;\r
-\r
-          //\r
-          // Checksum table\r
-          //\r
-          AcpiPlatformChecksum (\r
-            AcpiSupportInstance->Fadt1,\r
-            AcpiSupportInstance->Fadt1->Header.Length,\r
-            OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-            Checksum)\r
-            );\r
-        }\r
-      }\r
-\r
-      if ((Version & EFI_ACPI_TABLE_VERSION_2_0) != 0 ||\r
-          (Version & EFI_ACPI_TABLE_VERSION_3_0) != 0) {\r
-        AcpiSupportInstance->Facs3 = NULL;\r
-\r
-        //\r
-        // Update FADT table pointers\r
-        //\r
-        if (AcpiSupportInstance->Fadt3 != NULL) {\r
-          AcpiSupportInstance->Fadt3->FirmwareCtrl = 0;\r
-          ZeroMem (&AcpiSupportInstance->Fadt3->XFirmwareCtrl, sizeof (UINT64));\r
-\r
-          //\r
-          // Checksum table\r
-          //\r
-          AcpiPlatformChecksum (\r
-            AcpiSupportInstance->Fadt3,\r
-            AcpiSupportInstance->Fadt3->Header.Length,\r
-            OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-            Checksum)\r
-            );\r
-        }\r
-      }\r
-      break;\r
-\r
-    case EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE:\r
-      if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {\r
-        AcpiSupportInstance->Dsdt1 = NULL;\r
-\r
-        //\r
-        // Update FADT table pointers\r
-        //\r
-        if (AcpiSupportInstance->Fadt1 != NULL) {\r
-          AcpiSupportInstance->Fadt1->Dsdt = 0;\r
-\r
-          //\r
-          // Checksum table\r
-          //\r
-          AcpiPlatformChecksum (\r
-            AcpiSupportInstance->Fadt1,\r
-            AcpiSupportInstance->Fadt1->Header.Length,\r
-            OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-            Checksum)\r
-            );\r
-        }\r
-      }\r
-\r
-\r
-      if ((Version & EFI_ACPI_TABLE_VERSION_2_0) != 0 ||\r
-          (Version & EFI_ACPI_TABLE_VERSION_3_0) != 0) {\r
-        AcpiSupportInstance->Dsdt3 = NULL;\r
-\r
-        //\r
-        // Update FADT table pointers\r
-        //\r
-        if (AcpiSupportInstance->Fadt3 != NULL) {\r
-          AcpiSupportInstance->Fadt3->Dsdt = 0;\r
-          ZeroMem (&AcpiSupportInstance->Fadt3->XDsdt, sizeof (UINT64));\r
-\r
-          //\r
-          // Checksum table\r
-          //\r
-          AcpiPlatformChecksum (\r
-            AcpiSupportInstance->Fadt3,\r
-            AcpiSupportInstance->Fadt3->Header.Length,\r
-            OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-            Checksum)\r
-            );\r
-        }\r
-      }\r
-      break;\r
-\r
-    default:\r
-      //\r
-      // Do nothing\r
-      //\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // If no version is using this table anymore, remove and free list entry.\r
-  //\r
-  if (Table->Version == 0) {\r
-    //\r
-    // Free the Table\r
-    //\r
-    gBS->FreePages (Table->PageAddress, Table->NumberOfPages);\r
-    RemoveEntryList (&(Table->Link));\r
-    gBS->FreePool (Table);\r
-  }\r
-  //\r
-  // Done\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function finds and removes the table specified by the handle.\r
-\r
-  @param  AcpiSupportInstance  Instance of the protocol.\r
-  @param  Version              Bitmask of which versions to remove.\r
-  @param  Handle               Table to remove.\r
-\r
-  @return EFI_SUCCESS    The function completed successfully.\r
-  @return EFI_ABORTED    An error occurred.\r
-  @return EFI_NOT_FOUND  Handle not found in table list.\r
-**/\r
-EFI_STATUS\r
-RemoveTableFromList (\r
-  IN EFI_ACPI_SUPPORT_INSTANCE            *AcpiSupportInstance,\r
-  IN EFI_ACPI_TABLE_VERSION               Version,\r
-  IN UINTN                                Handle\r
-  )\r
-{\r
-  EFI_ACPI_TABLE_LIST *Table;\r
-  EFI_STATUS          Status;\r
-\r
-  Table = NULL;\r
-\r
-  //\r
-  // Check for invalid input parameters\r
-  //\r
-  ASSERT (AcpiSupportInstance);\r
-\r
-  //\r
-  // Find the table\r
-  //\r
-  Status = FindTableByHandle (\r
-            Handle,\r
-            &AcpiSupportInstance->TableList,\r
-            &Table\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Remove the table\r
-  //\r
-  Status = DeleteTable (AcpiSupportInstance, Version, Table);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Completed successfully\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  This function calculates and updates an UINT8 checksum.\r
-\r
-  @param  Buffer          Pointer to buffer to checksum\r
-  @param  Size            Number of bytes to checksum\r
-  @param  ChecksumOffset  Offset to place the checksum result in\r
-\r
-  @return EFI_SUCCESS             The function completed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-AcpiPlatformChecksum (\r
-  IN VOID       *Buffer,\r
-  IN UINTN      Size,\r
-  IN UINTN      ChecksumOffset\r
-  )\r
-{\r
-  UINT8 Sum;\r
-  UINT8 *Ptr;\r
-\r
-  Sum = 0;\r
-  //\r
-  // Initialize pointer\r
-  //\r
-  Ptr = Buffer;\r
-\r
-  //\r
-  // set checksum to 0 first\r
-  //\r
-  Ptr[ChecksumOffset] = 0;\r
-\r
-  //\r
-  // add all content of buffer\r
-  //\r
-  while ((Size--) != 0) {\r
-    Sum = (UINT8) (Sum + (*Ptr++));\r
-  }\r
-  //\r
-  // set checksum\r
-  //\r
-  Ptr                 = Buffer;\r
-  Ptr[ChecksumOffset] = (UINT8) (0xff - Sum + 1);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Checksum all versions of the common tables, RSDP, RSDT, XSDT.\r
-\r
-  @param  AcpiSupportInstance  Protocol instance private data.\r
-\r
-  @return EFI_SUCCESS        The function completed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ChecksumCommonTables (\r
-  IN OUT EFI_ACPI_SUPPORT_INSTANCE                 *AcpiSupportInstance\r
-  )\r
-{\r
-  //\r
-  // RSDP ACPI 1.0 checksum for 1.0 table.  This is only the first 20 bytes of the structure\r
-  //\r
-  AcpiPlatformChecksum (\r
-    AcpiSupportInstance->Rsdp1,\r
-    sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER),\r
-    OFFSET_OF (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER,\r
-    Checksum)\r
-    );\r
-\r
-  //\r
-  // RSDP ACPI 1.0 checksum for 2.0/3.0 table.  This is only the first 20 bytes of the structure\r
-  //\r
-  AcpiPlatformChecksum (\r
-    AcpiSupportInstance->Rsdp3,\r
-    sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER),\r
-    OFFSET_OF (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER,\r
-    Checksum)\r
-    );\r
-\r
-  //\r
-  // RSDP ACPI 2.0/3.0 checksum, this is the entire table\r
-  //\r
-  AcpiPlatformChecksum (\r
-    AcpiSupportInstance->Rsdp3,\r
-    sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER),\r
-    OFFSET_OF (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER,\r
-    ExtendedChecksum)\r
-    );\r
-\r
-  //\r
-  // RSDT checksums\r
-  //\r
-  AcpiPlatformChecksum (\r
-    AcpiSupportInstance->Rsdt1,\r
-    AcpiSupportInstance->Rsdt1->Length,\r
-    OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-    Checksum)\r
-    );\r
-\r
-  AcpiPlatformChecksum (\r
-    AcpiSupportInstance->Rsdt3,\r
-    AcpiSupportInstance->Rsdt3->Length,\r
-    OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-    Checksum)\r
-    );\r
-\r
-  //\r
-  // XSDT checksum\r
-  //\r
-  AcpiPlatformChecksum (\r
-    AcpiSupportInstance->Xsdt,\r
-    AcpiSupportInstance->Xsdt->Length,\r
-    OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER,\r
-    Checksum)\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/**\r
-  Constructor for the ACPI support protocol to initializes instance data.\r
-\r
-  @param AcpiSupportInstance   Instance to construct\r
-\r
-  @retval EFI_SUCCESS             Instance initialized.\r
-  @retval  EFI_OUT_OF_RESOURCES  Unable to allocate required resources.\r
-**/\r
-EFI_STATUS\r
-AcpiSupportAcpiSupportConstructor (\r
-  IN EFI_ACPI_SUPPORT_INSTANCE                 *AcpiSupportInstance\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  UINT64                CurrentData;\r
-  UINTN                 TotalSize;\r
-  UINTN                 RsdpTableSize;\r
-  UINT8                 *Pointer;\r
-  EFI_PHYSICAL_ADDRESS  PageAddress;\r
-\r
-  //\r
-  // Check for invalid input parameters\r
-  //\r
-  ASSERT (AcpiSupportInstance);\r
-\r
-  InitializeListHead (&AcpiSupportInstance->TableList);\r
-  AcpiSupportInstance->CurrentHandle              = 1;\r
-  AcpiSupportInstance->AcpiSupport.GetAcpiTable   = GetAcpiTable;\r
-  AcpiSupportInstance->AcpiSupport.SetAcpiTable   = SetAcpiTable;\r
-  AcpiSupportInstance->AcpiSupport.PublishTables  = PublishTables;\r
-\r
-  AcpiSupportInstance->AcpiTableProtocol.InstallAcpiTable   = InstallAcpiTable;\r
-  AcpiSupportInstance->AcpiTableProtocol.UninstallAcpiTable = UninstallAcpiTable;\r
-\r
-  //\r
-  // Create RSDP table\r
-  //\r
-  RsdpTableSize = sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER) +\r
-                  sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER);\r
-\r
-  PageAddress = 0xFFFFFFFF;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiACPIReclaimMemory,\r
-                  EFI_SIZE_TO_PAGES (RsdpTableSize),\r
-                  &PageAddress\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Pointer = (UINT8 *) (UINTN) PageAddress;\r
-  ZeroMem (Pointer, RsdpTableSize);\r
-\r
-  AcpiSupportInstance->Rsdp1 = (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) Pointer;\r
-  Pointer += sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER);\r
-  AcpiSupportInstance->Rsdp3 = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) Pointer;\r
-\r
-  //\r
-  // Create RSDT, XSDT structures\r
-  //\r
-  TotalSize = sizeof (EFI_ACPI_DESCRIPTION_HEADER) +         // for ACPI 1.0 RSDT\r
-              mEfiAcpiMaxNumTables * sizeof (UINT32) +\r
-              sizeof (EFI_ACPI_DESCRIPTION_HEADER) +         // for ACPI 2.0/3.0 RSDT\r
-              mEfiAcpiMaxNumTables * sizeof (UINT32) +\r
-              sizeof (EFI_ACPI_DESCRIPTION_HEADER) +         // for ACPI 2.0/3.0 XSDT\r
-              mEfiAcpiMaxNumTables * sizeof (UINT64);\r
-\r
-  //\r
-  // Allocate memory in the lower 32 bit of address range for\r
-  // compatibility with ACPI 1.0 OS.\r
-  //\r
-  // This is done because ACPI 1.0 pointers are 32 bit values.\r
-  // ACPI 2.0 OS and all 64 bit OS must use the 64 bit ACPI table addresses.\r
-  // There is no architectural reason these should be below 4GB, it is purely\r
-  // for convenience of implementation that we force memory below 4GB.\r
-  //\r
-  PageAddress = 0xFFFFFFFF;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiACPIReclaimMemory,\r
-                  EFI_SIZE_TO_PAGES (TotalSize),\r
-                  &PageAddress\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)AcpiSupportInstance->Rsdp1, EFI_SIZE_TO_PAGES (RsdpTableSize));\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Pointer = (UINT8 *) (UINTN) PageAddress;\r
-  ZeroMem (Pointer, TotalSize);\r
-\r
-  AcpiSupportInstance->Rsdt1 = (EFI_ACPI_DESCRIPTION_HEADER *) Pointer;\r
-  Pointer += (sizeof (EFI_ACPI_DESCRIPTION_HEADER) + EFI_ACPI_MAX_NUM_TABLES * sizeof (UINT32));\r
-  AcpiSupportInstance->Rsdt3 = (EFI_ACPI_DESCRIPTION_HEADER *) Pointer;\r
-  Pointer += (sizeof (EFI_ACPI_DESCRIPTION_HEADER) + EFI_ACPI_MAX_NUM_TABLES * sizeof (UINT32));\r
-  AcpiSupportInstance->Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) Pointer;\r
-\r
-  //\r
-  // Initialize RSDP\r
-  //\r
-  CurrentData = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE;\r
-  CopyMem (&AcpiSupportInstance->Rsdp1->Signature, &CurrentData, sizeof (UINT64));\r
-  CopyMem (AcpiSupportInstance->Rsdp1->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Rsdp1->OemId));\r
-  AcpiSupportInstance->Rsdp1->Reserved    = EFI_ACPI_RESERVED_BYTE;\r
-  AcpiSupportInstance->Rsdp1->RsdtAddress = (UINT32) (UINTN) AcpiSupportInstance->Rsdt1;\r
-\r
-  CurrentData = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE;\r
-  CopyMem (&AcpiSupportInstance->Rsdp3->Signature, &CurrentData, sizeof (UINT64));\r
-  CopyMem (AcpiSupportInstance->Rsdp3->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Rsdp3->OemId));\r
-  AcpiSupportInstance->Rsdp3->Revision    = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION;\r
-  AcpiSupportInstance->Rsdp3->RsdtAddress = (UINT32) (UINTN) AcpiSupportInstance->Rsdt3;\r
-  AcpiSupportInstance->Rsdp3->Length      = sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER);\r
-  CurrentData = (UINT64) (UINTN) AcpiSupportInstance->Xsdt;\r
-  CopyMem (&AcpiSupportInstance->Rsdp3->XsdtAddress, &CurrentData, sizeof (UINT64));\r
-  SetMem (AcpiSupportInstance->Rsdp3->Reserved, 3, EFI_ACPI_RESERVED_BYTE);\r
-\r
-  //\r
-  // Initialize Rsdt\r
-  //\r
-  // Note that we "reserve" one entry for the FADT so it can always be\r
-  // at the beginning of the list of tables.  Some OS don't seem\r
-  // to find it correctly if it is too far down the list.\r
-  //\r
-  AcpiSupportInstance->Rsdt1->Signature = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;\r
-  AcpiSupportInstance->Rsdt1->Length    = sizeof (EFI_ACPI_DESCRIPTION_HEADER);\r
-  AcpiSupportInstance->Rsdt1->Revision  = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION;\r
-  CopyMem (AcpiSupportInstance->Rsdt1->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Rsdt1->OemId));\r
-  CurrentData = PcdGet64 (PcdAcpiDefaultOemTableId);\r
-  CopyMem (&AcpiSupportInstance->Rsdt1->OemTableId, &CurrentData, sizeof (UINT64));\r
-  AcpiSupportInstance->Rsdt1->OemRevision     = PcdGet32 (PcdAcpiDefaultOemRevision);\r
-  AcpiSupportInstance->Rsdt1->CreatorId       = PcdGet32 (PcdAcpiDefaultCreatorId);\r
-  AcpiSupportInstance->Rsdt1->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);\r
-  //\r
-  // We always reserve first one for FADT\r
-  //\r
-  AcpiSupportInstance->NumberOfTableEntries1  = 1;\r
-  AcpiSupportInstance->Rsdt1->Length          = AcpiSupportInstance->Rsdt1->Length + sizeof(UINT32);\r
-\r
-  AcpiSupportInstance->Rsdt3->Signature       = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;\r
-  AcpiSupportInstance->Rsdt3->Length          = sizeof (EFI_ACPI_DESCRIPTION_HEADER);\r
-  AcpiSupportInstance->Rsdt3->Revision        = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION;\r
-  CopyMem (AcpiSupportInstance->Rsdt3->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Rsdt3->OemId));\r
-  CurrentData = PcdGet64 (PcdAcpiDefaultOemTableId);\r
-  CopyMem (&AcpiSupportInstance->Rsdt3->OemTableId, &CurrentData, sizeof (UINT64));\r
-  AcpiSupportInstance->Rsdt3->OemRevision     = PcdGet32 (PcdAcpiDefaultOemRevision);\r
-  AcpiSupportInstance->Rsdt3->CreatorId       = PcdGet32 (PcdAcpiDefaultCreatorId);\r
-  AcpiSupportInstance->Rsdt3->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);\r
-  //\r
-  // We always reserve first one for FADT\r
-  //\r
-  AcpiSupportInstance->NumberOfTableEntries3  = 1;\r
-  AcpiSupportInstance->Rsdt3->Length          = AcpiSupportInstance->Rsdt3->Length + sizeof(UINT32);\r
-\r
-  //\r
-  // Initialize Xsdt\r
-  //\r
-  AcpiSupportInstance->Xsdt->Signature  = EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;\r
-  AcpiSupportInstance->Xsdt->Length     = sizeof (EFI_ACPI_DESCRIPTION_HEADER);\r
-  AcpiSupportInstance->Xsdt->Revision   = EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION;\r
-  CopyMem (AcpiSupportInstance->Xsdt->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Xsdt->OemId));\r
-  CurrentData = PcdGet64 (PcdAcpiDefaultOemTableId);\r
-  CopyMem (&AcpiSupportInstance->Xsdt->OemTableId, &CurrentData, sizeof (UINT64));\r
-  AcpiSupportInstance->Xsdt->OemRevision      = PcdGet32 (PcdAcpiDefaultOemRevision);\r
-  AcpiSupportInstance->Xsdt->CreatorId        = PcdGet32 (PcdAcpiDefaultCreatorId);\r
-  AcpiSupportInstance->Xsdt->CreatorRevision  = PcdGet32 (PcdAcpiDefaultCreatorRevision);\r
-  //\r
-  // We always reserve first one for FADT\r
-  //\r
-  AcpiSupportInstance->Xsdt->Length           = AcpiSupportInstance->Xsdt->Length + sizeof(UINT64);\r
-\r
-  ChecksumCommonTables (AcpiSupportInstance);\r
-\r
-  //\r
-  // Completed successfully\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.inf b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.inf
deleted file mode 100644 (file)
index cfabfbe..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-## @file\r
-# Acpi Support Dirver to install Framework Acpi Support Protocol.\r
-#\r
-# This driver initializes ACPI support protocol instance data structure and intstall\r
-# ACPI support protocol to provide Get, Set and Publish Table services.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = AcpiSupportDxe\r
-  MODULE_UNI_FILE                = AcpiSupportDxe.uni\r
-  FILE_GUID                      = 506533a6-e626-4500-b14f-17939c0e5b60\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InstallAcpiSupport\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  AcpiSupportAcpiSupportProtocol.c\r
-  AcpiSupport.h\r
-  AcpiSupport.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  UefiDriverEntryPoint\r
-  BaseMemoryLib\r
-  UefiLib\r
-  DebugLib\r
-  BaseLib\r
-  PcdLib\r
-\r
-\r
-[Guids]\r
-  gEfiAcpi10TableGuid                           ## PRODUCES ## SystemTable\r
-  gEfiAcpiTableGuid                             ## PRODUCES ## SystemTable\r
-\r
-[FeaturePcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdInstallAcpiSupportProtocol ## CONSUMES\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId            ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId       ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision      ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId        ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision  ## CONSUMES\r
-\r
-[Protocols]\r
-  gEfiAcpiTableProtocolGuid                     ## PRODUCES\r
-  gEfiAcpiSupportProtocolGuid                   ## SOMETIMES_PRODUCES\r
-\r
-[Depex]\r
-  TRUE\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  AcpiSupportDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.uni b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.uni
deleted file mode 100644 (file)
index 4c3f12a..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// /** @file\r
-// Acpi Support Dirver to install Framework Acpi Support Protocol.\r
-//\r
-// This driver initializes ACPI support protocol instance data structure and intstall\r
-// ACPI support protocol to provide Get, Set and Publish Table services.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "ACPI Support Driver to install the FrameworkAcpiSupportProtocol"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This driver initializes ACPI support protocol instance data structure and installs ACPI support protocol to provide Get, Set and Publish Table services."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxeExtra.uni b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxeExtra.uni
deleted file mode 100644 (file)
index 2266432..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// AcpiSupportDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"ACPI Support DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h b/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
deleted file mode 100644 (file)
index 5239a66..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/** @file\r
-  Head file for BDS Architectural Protocol implementation\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _BDS_MODULE_H_\r
-#define _BDS_MODULE_H_\r
-\r
-#include <FrameworkDxe.h>\r
-#include <IndustryStandard/PeImage.h>\r
-#include <Guid/MdeModuleHii.h>\r
-#include <Guid/FileSystemVolumeLabelInfo.h>\r
-#include <Guid/HiiPlatformSetupFormset.h>\r
-#include <Guid/StatusCodeDataTypeVariable.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <IndustryStandard/SmBios.h>\r
-#include <Protocol/LoadFile.h>\r
-#include <Guid/FileInfo.h>\r
-#include <Protocol/HiiConfigRouting.h>\r
-#include <Protocol/Bds.h>\r
-#include <Protocol/Smbios.h>\r
-#include <Protocol/UgaDraw.h>\r
-#include <Protocol/BlockIo.h>\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/CapsuleVendor.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/LegacyDevOrder.h>\r
-#include <Guid/BdsHii.h>\r
-#include <Guid/ConnectConInEvent.h>\r
-#include <Guid/FmpCapsule.h>\r
-#include <Protocol/GenericMemoryTest.h>\r
-#include <Protocol/FormBrowser2.h>\r
-#include <Protocol/HiiConfigAccess.h>\r
-#include <Protocol/GraphicsOutput.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/HiiDatabase.h>\r
-#include <Protocol/HiiString.h>\r
-#include <Protocol/SerialIo.h>\r
-#include <Protocol/LegacyBios.h>\r
-#include <Protocol/SimpleTextInEx.h>\r
-#include <Protocol/DriverHealth.h>\r
-#include <Protocol/BootLogo.h>\r
-#include <Protocol/VariableLock.h>\r
-\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PerformanceLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/CapsuleLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/UefiHiiServicesLib.h>\r
-\r
-#include <Library/GenericBdsLib.h>\r
-#include <Library/PlatformBdsLib.h>\r
-\r
-#pragma pack(1)\r
-\r
-///\r
-/// HII specific Vendor Device Path definition.\r
-///\r
-typedef struct {\r
-  VENDOR_DEVICE_PATH             VendorDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL       End;\r
-} HII_VENDOR_DEVICE_PATH;\r
-\r
-#pragma pack()\r
-\r
-/**\r
-\r
-  Show progress bar with title above it. It only works in Graphics mode.\r
-\r
-  @param TitleForeground Foreground color for Title.\r
-  @param TitleBackground Background color for Title.\r
-  @param Title           Title above progress bar.\r
-  @param ProgressColor   Progress bar color.\r
-  @param Progress        Progress (0-100)\r
-  @param PreviousValue   The previous value of the progress.\r
-\r
-  @retval  EFI_STATUS       Success update the progress bar\r
-\r
-**/\r
-EFI_STATUS\r
-PlatformBdsShowProgress (\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,\r
-  IN CHAR16                        *Title,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,\r
-  IN UINTN                         Progress,\r
-  IN UINTN                         PreviousValue\r
-  );\r
-\r
-//\r
-// Prototypes\r
-//\r
-\r
-/**\r
-\r
-  Install Boot Device Selection Protocol\r
-\r
-  @param ImageHandle     The image handle.\r
-  @param SystemTable     The system table.\r
-\r
-  @retval  EFI_SUCEESS  BDS has finished initializing.\r
-                        Return the dispatcher and recall BDS.Entry\r
-  @retval  Other        Return status from AllocatePool() or gBS->InstallProtocolInterface\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsInitialize (\r
-  IN EFI_HANDLE                     ImageHandle,\r
-  IN EFI_SYSTEM_TABLE               *SystemTable\r
-  );\r
-\r
-/**\r
-\r
-  Service routine for BdsInstance->Entry(). Devices are connected, the\r
-  consoles are initialized, and the boot options are tried.\r
-\r
-  @param This            Protocol Instance structure.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsEntry (\r
-  IN  EFI_BDS_ARCH_PROTOCOL *This\r
-  );\r
-\r
-\r
-/**\r
-  Perform the memory test base on the memory test intensive level,\r
-  and update the memory resource.\r
-\r
-  @param  Level         The memory test intensive level.\r
-\r
-  @retval EFI_STATUS    Success test all the system memory and update\r
-                        the memory resource\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsMemoryTest (\r
-  IN EXTENDMEM_COVERAGE_LEVEL Level\r
-  );\r
-\r
-/**\r
-\r
-  This routine is called to see if there are any capsules we need to process.\r
-  If the boot mode is not UPDATE, then we do nothing. Otherwise find the\r
-  capsule HOBS and produce firmware volumes for them via the DXE service.\r
-  Then call the dispatcher to dispatch drivers from them. Finally, check\r
-  the status of the updates.\r
-\r
-  This function should be called by BDS in case we need to do some\r
-  sort of processing even if there is no capsule to process. We\r
-  need to do this if an earlier update went away and we need to\r
-  clear the capsule variable so on the next reset PEI does not see it and\r
-  think there is a capsule available.\r
-\r
-  @param BootMode                 the current boot mode\r
-\r
-  @retval EFI_INVALID_PARAMETER   boot mode is not correct for an update\r
-  @retval EFI_SUCCESS             There is no error when processing capsule\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsProcessCapsules (\r
-  EFI_BOOT_MODE BootMode\r
-  );\r
-\r
-/**\r
-  Set the variable and report the error through status code upon failure.\r
-\r
-  @param  VariableName           A Null-terminated string that is the name of the vendor's variable.\r
-                                 Each VariableName is unique for each VendorGuid. VariableName must\r
-                                 contain 1 or more characters. If VariableName is an empty string,\r
-                                 then EFI_INVALID_PARAMETER is returned.\r
-  @param  VendorGuid             A unique identifier for the vendor.\r
-  @param  Attributes             Attributes bitmask to set for the variable.\r
-  @param  DataSize               The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,\r
-                                 EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or\r
-                                 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero\r
-                                 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is\r
-                                 set, then a SetVariable() call with a DataSize of zero will not cause any change to\r
-                                 the variable value (the timestamp associated with the variable may be updated however\r
-                                 even if no new data value is provided,see the description of the\r
-                                 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not\r
-                                 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).\r
-  @param  Data                   The contents for the variable.\r
-\r
-  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r
-                                 defined by the Attributes.\r
-  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits, name, and GUID was supplied, or the\r
-                                 DataSize exceeds the maximum allowed.\r
-  @retval EFI_INVALID_PARAMETER  VariableName is an empty string.\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
-  @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question is read-only.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.\r
-  @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\r
-                                 or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo\r
-                                 does NOT pass the validation check carried out by the firmware.\r
-\r
-  @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.\r
-**/\r
-EFI_STATUS\r
-BdsDxeSetVariableAndReportStatusCodeOnError (\r
-  IN CHAR16     *VariableName,\r
-  IN EFI_GUID   *VendorGuid,\r
-  IN UINT32     Attributes,\r
-  IN UINTN      DataSize,\r
-  IN VOID       *Data\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
deleted file mode 100644 (file)
index f381f6e..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-## @file\r
-#  BDSDxe module is core driver for BDS phase.\r
-#\r
-#  When DxeCore dispatching all DXE driver, this module will produce architecture protocol\r
-#  gEfiBdsArchProtocolGuid. After DxeCore finish dispatching, DxeCore will invoke Entry\r
-#  interface of protocol gEfiBdsArchProtocolGuid, then BDS phase is entered.\r
-#\r
-#  Generally, this module take reposiblity to connect all necessary devices for platform boot,\r
-#  these boot device path are hold in PlatformBdsLib library instance produced by platform.\r
-#  For legacy boot, BDS will transfer control to legacy BIOS after legacy boot device is select.\r
-#  For EFI boot, BDS will load boot loader file EFI\BOOT\BOOTIA32.EFI, EFI\BOOT\BOOTX64.EFI,\r
-#  EFI\BOOT\BOOTIA64.EFI file from selected boot device and transfer control to boot loader.\r
-#\r
-#  BDSDxe also maintain the UI for "Boot Manager, Boot Maintaince Manager, Device Manager" which\r
-#  is used for user to configure boot option or maintain hardware device.\r
-#\r
-#  Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = BdsDxe\r
-  MODULE_UNI_FILE                = BdsDxe.uni\r
-  FILE_GUID                      = FC5C7020-1A48-4198-9BE2-EAD5ABC8CF2F\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = BdsInitialize\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  FrontPage.h\r
-  Language.h\r
-  Bds.h\r
-  Hotkey.h\r
-  BootMaint/BBSsupport.h\r
-  BootMngr/BootManager.h\r
-  BootMaint/BootMaint.h\r
-  String.h\r
-  BootMaint/FormGuid.h\r
-  HwErrRecSupport.c\r
-  HwErrRecSupport.h\r
-\r
-  DeviceMngr/DeviceManager.h\r
-  DeviceMngr/DeviceManagerVfr.h\r
-  DeviceMngr/DeviceManagerVfr.Vfr\r
-  DeviceMngr/DriverHealthVfr.Vfr\r
-  DeviceMngr/DeviceManagerStrings.uni\r
-  DeviceMngr/DeviceManager.c\r
-  BootMngr/BootManagerVfr.Vfr\r
-  BootMngr/BootManagerStrings.uni\r
-  BootMngr/BootManager.c\r
-  BootMaint/FE.vfr\r
-  BootMaint/FileExplorer.c\r
-  BootMaint/BootMaint.c\r
-  BootMaint/BBSsupport.c\r
-  BootMaint/UpdatePage.c\r
-  BootMaint/Variable.c\r
-  BootMaint/Data.c\r
-  BootMaint/ConsoleOption.c\r
-  BootMaint/BootOption.c\r
-  BootMaint/BmLib.c\r
-  BootMaint/Bm.vfr\r
-  BootMaint/Bmstring.uni\r
-  Hotkey.c\r
-  MemoryTest.c\r
-  Capsules.c\r
-  Strings.uni\r
-  String.c\r
-  Language.c\r
-  FrontPageVfr.Vfr\r
-  FrontPageStrings.uni\r
-  FrontPage.c\r
-  BdsEntry.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  DevicePathLib\r
-  BaseLib\r
-  HobLib\r
-  UefiRuntimeServicesTableLib\r
-  GenericBdsLib\r
-  ReportStatusCodeLib\r
-  PerformanceLib\r
-  MemoryAllocationLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  PrintLib\r
-  HiiLib\r
-  UefiDriverEntryPoint\r
-  PlatformBdsLib\r
-  CapsuleLib\r
-  PcdLib\r
-  UefiHiiServicesLib\r
-\r
-[Guids]\r
-  ## SOMETIMES_PRODUCES ## Variable:L"BootXXXX"          # Boot option variable\r
-  ## SOMETIMES_PRODUCES ## Variable:L"DriverXXXX"        # Driver load option.\r
-  ## SOMETIMES_PRODUCES ## Variable:L"PlatformLang"      # Platform supported languange in Rfc4646 format\r
-  ## SOMETIMES_PRODUCES ## Variable:L"Lang"              # Platform supported languange in Iso639 format\r
-  ## SOMETIMES_PRODUCES ## Variable:L"LangCodes"         # Value of PcdUefiVariableDefaultLangCodes\r
-  ## PRODUCES           ## Variable:L"PlatformLangCodes" # Value of PcdUefiVariableDefaultPlatformLangCodes\r
-  ## SOMETIMES_PRODUCES ## Variable:L"KeyXXXX"  # Hotkey option variable\r
-  ## PRODUCES           ## Variable:L"HwErrRecSupport"   # The level of platform supported hardware Error Record Persistence\r
-  ## PRODUCES           ## Variable:L"Timeout"     # The time out value in second of showing progress bar\r
-  ## SOMETIMES_PRODUCES ## Variable:L"BootOptionSupport" # The feature supported in boot option menu, value could be: EFI_BOOT_OPTION_SUPPORT_KEY, EFI_BOOT_OPTION_SUPPORT_APP\r
-  ## SOMETIMES_PRODUCES ## Variable:L"BootOrder"   # The boot option array\r
-  ## SOMETIMES_PRODUCES ## Variable:L"DriverOrder" # The driver order list\r
-  ## SOMETIMES_CONSUMES ## Variable:L"ConIn"  # The device path of console in device\r
-  ## SOMETIMES_PRODUCES ## Variable:L"ConIn"  # The device path of console in device\r
-  ## SOMETIMES_CONSUMES ## Variable:L"ConOut" # The device path of console out device\r
-  ## SOMETIMES_PRODUCES ## Variable:L"ConOut" # The device path of console out device\r
-  ## SOMETIMES_CONSUMES ## Variable:L"ErrOut" # The device path of error out device\r
-  ## SOMETIMES_PRODUCES ## Variable:L"ErrOut" # The device path of error out device\r
-  ## SOMETIMES_CONSUMES ## Variable:L"ConInDev"  # The device path of console in device\r
-  ## SOMETIMES_CONSUMES ## Variable:L"ConOutDev" # The device path of console out device\r
-  ## SOMETIMES_CONSUMES ## Variable:L"ErrOutDev" # The device path of error out device\r
-  ## SOMETIMES_PRODUCES ## Variable:L"BootNext"  # The number of next boot option\r
-  gEfiGlobalVariableGuid\r
-  gEfiFileSystemVolumeLabelInfoIdGuid           ## SOMETIMES_CONSUMES ## UNDEFINED # Indicate the information type is volume\r
-  gEfiFileInfoGuid                              ## SOMETIMES_CONSUMES ## UNDEFINED # Indicate the information type is file\r
-  gEfiHiiPlatformSetupFormsetGuid               ## SOMETIMES_CONSUMES ## UNDEFINED # Indicate the formset class guid to be displayed\r
-  gEfiIfrTianoGuid                              ## SOMETIMES_PRODUCES ## UNDEFINED # Extended IFR Guid Opcode\r
-  gEfiHiiDriverHealthFormsetGuid                ## SOMETIMES_CONSUMES ## UNDEFINED # Indicate the Driver Health formset class guid to be displayed\r
-  ## SOMETIMES_PRODUCES ## Variable:L"LegacyDevOrder"\r
-  ## SOMETIMES_CONSUMES ## Variable:L"LegacyDevOrder"\r
-  gEfiLegacyDevOrderVariableGuid\r
-  gFrontPageFormSetGuid                         ## SOMETIMES_CONSUMES ## HII # FrontPage HII Package\r
-  gBootMaintFormSetGuid                         ## SOMETIMES_CONSUMES ## HII # BootMaint HII Package\r
-  gFileExploreFormSetGuid                       ## SOMETIMES_CONSUMES ## HII # FileExplore HII Package\r
-  gBootManagerFormSetGuid                       ## SOMETIMES_CONSUMES ## HII # BootManager HII Package\r
-  gDeviceManagerFormSetGuid                     ## SOMETIMES_CONSUMES ## HII # DeviceManager HII Package\r
-  gDriverHealthFormSetGuid                      ## SOMETIMES_CONSUMES ## HII # DriverHealth HII Package\r
-  ## SOMETIMES_PRODUCES ## Event\r
-  ## SOMETIMES_CONSUMES ## Event\r
-  gConnectConInEventGuid\r
-  gEfiFmpCapsuleGuid                            ## SOMETIMES_CONSUMES ## GUID # FMP Capsule\r
-  gEdkiiStatusCodeDataTypeVariableGuid          ## SOMETIMES_CONSUMES ## GUID\r
-  gEfiUartDevicePathGuid                        ## SOMETIMES_CONSUMES ## GUID (Identify the device path for UARD device)\r
-\r
-[Protocols]\r
-  gEfiSimpleFileSystemProtocolGuid              ## SOMETIMES_CONSUMES\r
-  gEfiLoadFileProtocolGuid                      ## SOMETIMES_CONSUMES\r
-  gEfiBdsArchProtocolGuid                       ## PRODUCES\r
-  gEfiSmbiosProtocolGuid                        ## CONSUMES\r
-  gEfiGenericMemTestProtocolGuid                ## SOMETIMES_CONSUMES\r
-  gEfiLegacyBiosProtocolGuid                    ## SOMETIMES_CONSUMES\r
-  gEfiUgaDrawProtocolGuid |gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## SOMETIMES_CONSUMES\r
-  gEfiBlockIoProtocolGuid                       ## SOMETIMES_CONSUMES\r
-  gEfiGraphicsOutputProtocolGuid                ## SOMETIMES_CONSUMES\r
-  ## CONSUMES\r
-  ## NOTIFY\r
-  gEfiSimpleTextInputExProtocolGuid\r
-  gEfiHiiConfigAccessProtocolGuid               ## SOMETIMES_PRODUCES\r
-  gEfiFormBrowser2ProtocolGuid                  ## CONSUMES\r
-  gEfiSerialIoProtocolGuid                      ## SOMETIMES_CONSUMES\r
-  gEfiDevicePathProtocolGuid                    ## CONSUMES\r
-  gEfiDriverHealthProtocolGuid                  ## SOMETIMES_CONSUMES\r
-  gEfiPciIoProtocolGuid                         ## SOMETIMES_CONSUMES\r
-  gEfiBootLogoProtocolGuid                      ## SOMETIMES_CONSUMES\r
-  gEdkiiVariableLockProtocolGuid                ## SOMETIMES_CONSUMES\r
-\r
-[FeaturePcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate    ## CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport                   ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootlogoOnlyEnable ## CONSUMES\r
-\r
-[Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangCodes          ## SOMETIMES_CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLang               ## SOMETIMES_CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes  ## CONSUMES\r
-  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang       ## SOMETIMES_CONSUMES\r
-  ## CONSUMES\r
-  ## PRODUCES\r
-  gEfiMdePkgTokenSpaceGuid.PcdHardwareErrorRecordLevel\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow     ## PRODUCES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn  ## PRODUCES\r
-  ## SOMETIMES_CONSUMES\r
-  ## SOMETIMES_PRODUCES\r
-  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
-  ## CONSUMES\r
-  ## PRODUCES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootState\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor   ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution  ## PRODUCES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution    ## PRODUCES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand       ## SOMETIMES_CONSUMES\r
-  ## CONSUMES\r
-  ## SOMETIMES_PRODUCES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn\r
-  ## CONSUMES\r
-  ## SOMETIMES_PRODUCES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution            ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution              ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable                      ## CONSUMES\r
-\r
-[Depex]\r
-  TRUE\r
-\r
-#\r
-# [BootMode]\r
-#   FLASH_UPDATE    ## SOMETIMES_CONSUMES # Update Capsule Image\r
-#\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  BdsDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.uni b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.uni
deleted file mode 100644 (file)
index 4ec111b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// /** @file\r
-// BDSDxe module is core driver for BDS phase.\r
-//\r
-// When DxeCore dispatching all DXE driver, this module will produce architecture protocol\r
-// gEfiBdsArchProtocolGuid. After DxeCore finish dispatching, DxeCore will invoke Entry\r
-// interface of protocol gEfiBdsArchProtocolGuid, then BDS phase is entered.\r
-//\r
-// Generally, this module take reposiblity to connect all necessary devices for platform boot,\r
-// these boot device path are hold in PlatformBdsLib library instance produced by platform.\r
-// For legacy boot, BDS will transfer control to legacy BIOS after legacy boot device is select.\r
-// For EFI boot, BDS will load boot loader file EFI\BOOT\BOOTIA32.EFI, EFI\BOOT\BOOTX64.EFI,\r
-// EFI\BOOT\BOOTIA64.EFI file from selected boot device and transfer control to boot loader.\r
-//\r
-// BDSDxe also maintain the UI for "Boot Manager, Boot Maintaince Manager, Device Manager" which\r
-// is used for user to configure boot option or maintain hardware device.\r
-//\r
-// Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "BDSDxe module is core driver for BDS phase"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "When DxeCore dispatching all DXE driver, this module will produce architecture protocol gEfiBdsArchProtocolGuid. After DxeCore finishes dispatching, DxeCore will invoke the Entry interface of protocol gEfiBdsArchProtocolGuid. Then BDS phase is entered.  Generally, this module takes reposiblity to connect all necessary devices for platform boot. These boot device paths are held in PlatformBdsLib a library instance produced by the platform. For legacy boot, BDS will transfer control to legacy BIOS after legacy boot device is selected. For EFI boot, BDS will load boot loader file EFI\BOOT\BOOTIA32.EFI, EFI\BOOT\BOOTX64.EFI, EFI\BOOT\BOOTIA64.EFI files from selected boot devices, and transfers control to the boot loader.  BDSDxe also maintains the UI for \"Boot Manager, Boot Maintaince Manager, Device Manager\", which is used by the user to configure boot options or to maintain hardware devices."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxeExtra.uni b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxeExtra.uni
deleted file mode 100644 (file)
index de3d15f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// BdsDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Boot Device Selection Core DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
deleted file mode 100644 (file)
index 8c7c340..0000000
+++ /dev/null
@@ -1,675 +0,0 @@
-/** @file\r
-  This module produce main entry for BDS phase - BdsEntry.\r
-  When this module was dispatched by DxeCore, gEfiBdsArchProtocolGuid will be installed\r
-  which contains interface of BdsEntry.\r
-  After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked\r
-  to enter BDS phase.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Bds.h"\r
-#include "Language.h"\r
-#include "FrontPage.h"\r
-#include "Hotkey.h"\r
-#include "HwErrRecSupport.h"\r
-\r
-///\r
-/// BDS arch protocol instance initial value.\r
-///\r
-/// Note: Current BDS not directly get the BootMode, DefaultBoot,\r
-/// TimeoutDefault, MemoryTestLevel value from the BDS arch protocol.\r
-/// Please refer to the library useage of BdsLibGetBootMode, BdsLibGetTimeout\r
-/// and PlatformBdsDiagnostics in BdsPlatform.c\r
-///\r
-EFI_HANDLE  gBdsHandle = NULL;\r
-\r
-EFI_BDS_ARCH_PROTOCOL  gBds = {\r
-  BdsEntry\r
-};\r
-\r
-UINT16                          *mBootNext = NULL;\r
-\r
-///\r
-/// The read-only variables defined in UEFI Spec.\r
-///\r
-CHAR16  *mReadOnlyVariables[] = {\r
-  L"PlatformLangCodes",\r
-  L"LangCodes",\r
-  L"BootOptionSupport",\r
-  L"HwErrRecSupport",\r
-  L"OsIndicationsSupported"\r
-  };\r
-\r
-/**\r
-\r
-  Install Boot Device Selection Protocol\r
-\r
-  @param ImageHandle     The image handle.\r
-  @param SystemTable     The system table.\r
-\r
-  @retval  EFI_SUCEESS  BDS has finished initializing.\r
-                        Return the dispatcher and recall BDS.Entry\r
-  @retval  Other        Return status from AllocatePool() or gBS->InstallProtocolInterface\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsInitialize (\r
-  IN EFI_HANDLE                            ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                      *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Install protocol interface\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &gBdsHandle,\r
-                  &gEfiBdsArchProtocolGuid, &gBds,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-\r
-  This function attempts to boot for the boot order specified\r
-  by platform policy.\r
-\r
-**/\r
-VOID\r
-BdsBootDeviceSelect (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  LIST_ENTRY        *Link;\r
-  BDS_COMMON_OPTION *BootOption;\r
-  UINTN             ExitDataSize;\r
-  CHAR16            *ExitData;\r
-  UINT16            Timeout;\r
-  LIST_ENTRY        BootLists;\r
-  CHAR16            Buffer[20];\r
-  BOOLEAN           BootNextExist;\r
-  LIST_ENTRY        *LinkBootNext;\r
-  EFI_EVENT         ConnectConInEvent;\r
-\r
-  //\r
-  // Got the latest boot option\r
-  //\r
-  BootNextExist = FALSE;\r
-  LinkBootNext  = NULL;\r
-  ConnectConInEvent = NULL;\r
-  InitializeListHead (&BootLists);\r
-\r
-  //\r
-  // First check the boot next option\r
-  //\r
-  ZeroMem (Buffer, sizeof (Buffer));\r
-\r
-  //\r
-  // Create Event to signal ConIn connection request\r
-  //\r
-  if (PcdGetBool (PcdConInConnectOnDemand)) {\r
-    Status = gBS->CreateEventEx (\r
-                    EVT_NOTIFY_SIGNAL,\r
-                    TPL_CALLBACK,\r
-                    EfiEventEmptyFunction,\r
-                    NULL,\r
-                    &gConnectConInEventGuid,\r
-                    &ConnectConInEvent\r
-                    );\r
-    if (EFI_ERROR(Status)) {\r
-      ConnectConInEvent = NULL;\r
-    }\r
-  }\r
-\r
-  if (mBootNext != NULL) {\r
-    //\r
-    // Indicate we have the boot next variable, so this time\r
-    // boot will always have this boot option\r
-    //\r
-    BootNextExist = TRUE;\r
-\r
-    //\r
-    // Clear the this variable so it's only exist in this time boot\r
-    //\r
-    Status = gRT->SetVariable (\r
-                    L"BootNext",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    0,\r
-                    NULL\r
-                    );\r
-    //\r
-    // Deleting variable with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Add the boot next boot option\r
-    //\r
-    UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *mBootNext);\r
-    BootOption = BdsLibVariableToOption (&BootLists, Buffer);\r
-\r
-    //\r
-    // If fail to get boot option from variable, just return and do nothing.\r
-    //\r
-    if (BootOption == NULL) {\r
-      return;\r
-    }\r
-\r
-    BootOption->BootCurrent = *mBootNext;\r
-  }\r
-  //\r
-  // Parse the boot order to get boot option\r
-  //\r
-  BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r
-\r
-  //\r
-  // When we didn't have chance to build boot option variables in the first\r
-  // full configuration boot (e.g.: Reset in the first page or in Device Manager),\r
-  // we have no boot options in the following mini configuration boot.\r
-  // Give the last chance to enumerate the boot options.\r
-  //\r
-  if (IsListEmpty (&BootLists)) {\r
-    BdsLibEnumerateAllBootOption (&BootLists);\r
-  }\r
-\r
-  Link = BootLists.ForwardLink;\r
-\r
-  //\r
-  // Parameter check, make sure the loop will be valid\r
-  //\r
-  if (Link == NULL) {\r
-    return ;\r
-  }\r
-  //\r
-  // Here we make the boot in a loop, every boot success will\r
-  // return to the front page\r
-  //\r
-  for (;;) {\r
-    //\r
-    // Check the boot option list first\r
-    //\r
-    if (Link == &BootLists) {\r
-      //\r
-      // When LazyConIn enabled, signal connect ConIn event before enter UI\r
-      //\r
-      if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {\r
-        gBS->SignalEvent (ConnectConInEvent);\r
-      }\r
-\r
-      //\r
-      // There are two ways to enter here:\r
-      // 1. There is no active boot option, give user chance to\r
-      //    add new boot option\r
-      // 2. All the active boot option processed, and there is no\r
-      //    one is success to boot, then we back here to allow user\r
-      //    add new active boot option\r
-      //\r
-      Timeout = 0xffff;\r
-      PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-      InitializeListHead (&BootLists);\r
-      BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r
-      Link = BootLists.ForwardLink;\r
-      continue;\r
-    }\r
-    //\r
-    // Get the boot option from the link list\r
-    //\r
-    BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
-\r
-    //\r
-    // According to EFI Specification, if a load option is not marked\r
-    // as LOAD_OPTION_ACTIVE, the boot manager will not automatically\r
-    // load the option.\r
-    //\r
-    if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r
-      //\r
-      // skip the header of the link list, because it has no boot option\r
-      //\r
-      Link = Link->ForwardLink;\r
-      continue;\r
-    }\r
-    //\r
-    // Make sure the boot option device path connected,\r
-    // but ignore the BBS device path\r
-    //\r
-    if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r
-      //\r
-      // Notes: the internal shell can not been connected with device path\r
-      // so we do not check the status here\r
-      //\r
-      BdsLibConnectDevicePath (BootOption->DevicePath);\r
-    }\r
-\r
-    //\r
-    // Restore to original mode before launching boot option.\r
-    //\r
-    BdsSetConsoleMode (FALSE);\r
-\r
-    //\r
-    // All the driver options should have been processed since\r
-    // now boot will be performed.\r
-    //\r
-    Status = BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
-    if (Status != EFI_SUCCESS) {\r
-      //\r
-      // Call platform action to indicate the boot fail\r
-      //\r
-      BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));\r
-      PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize);\r
-\r
-      //\r
-      // Check the next boot option\r
-      //\r
-      Link = Link->ForwardLink;\r
-\r
-    } else {\r
-      //\r
-      // Call platform action to indicate the boot success\r
-      //\r
-      BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));\r
-      PlatformBdsBootSuccess (BootOption);\r
-\r
-      //\r
-      // Boot success, then stop process the boot order, and\r
-      // present the boot manager menu, front page\r
-      //\r
-\r
-      //\r
-      // When LazyConIn enabled, signal connect ConIn Event before enter UI\r
-      //\r
-      if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {\r
-        gBS->SignalEvent (ConnectConInEvent);\r
-      }\r
-\r
-      Timeout = 0xffff;\r
-      PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-\r
-      //\r
-      // Rescan the boot option list, avoid potential risk of the boot\r
-      // option change in front page\r
-      //\r
-      if (BootNextExist) {\r
-        LinkBootNext = BootLists.ForwardLink;\r
-      }\r
-\r
-      InitializeListHead (&BootLists);\r
-      if (LinkBootNext != NULL) {\r
-        //\r
-        // Reserve the boot next option\r
-        //\r
-        InsertTailList (&BootLists, LinkBootNext);\r
-      }\r
-\r
-      BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r
-      Link = BootLists.ForwardLink;\r
-    }\r
-  }\r
-\r
-}\r
-\r
-/**\r
-\r
-  Validate input console variable data.\r
-\r
-  If found the device path is not a valid device path, remove the variable.\r
-\r
-  @param VariableName             Input console variable name.\r
-\r
-**/\r
-VOID\r
-BdsFormalizeConsoleVariable (\r
-  IN  CHAR16          *VariableName\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  UINTN                     VariableSize;\r
-  EFI_STATUS                Status;\r
-\r
-  DevicePath = BdsLibGetVariableAndSize (\r
-                      VariableName,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &VariableSize\r
-                      );\r
-  if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) {\r
-    Status = gRT->SetVariable (\r
-                    VariableName,\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    0,\r
-                    NULL\r
-                    );\r
-    //\r
-    // Deleting variable with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Formalize Bds global variables.\r
-\r
- 1. For ConIn/ConOut/ConErr, if found the device path is not a valid device path, remove the variable.\r
- 2. For OsIndicationsSupported, Create a BS/RT/UINT64 variable to report caps\r
- 3. Delete OsIndications variable if it is not NV/BS/RT UINT64\r
- Item 3 is used to solve case when OS corrupts OsIndications. Here simply delete this NV variable.\r
-\r
-**/\r
-VOID\r
-BdsFormalizeEfiGlobalVariable (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-  UINT64     OsIndicationSupport;\r
-  UINT64     OsIndication;\r
-  UINTN      DataSize;\r
-  UINT32     Attributes;\r
-\r
-  //\r
-  // Validate Console variable.\r
-  //\r
-  BdsFormalizeConsoleVariable (L"ConIn");\r
-  BdsFormalizeConsoleVariable (L"ConOut");\r
-  BdsFormalizeConsoleVariable (L"ErrOut");\r
-\r
-  //\r
-  // OS indicater support variable\r
-  //\r
-  OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI \\r
-                      | EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED;\r
-\r
-  BdsDxeSetVariableAndReportStatusCodeOnError (\r
-    L"OsIndicationsSupported",\r
-    &gEfiGlobalVariableGuid,\r
-    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-    sizeof(UINT64),\r
-    &OsIndicationSupport\r
-    );\r
-\r
-  //\r
-  // If OsIndications is invalid, remove it.\r
-  // Invalid case\r
-  //   1. Data size != UINT64\r
-  //   2. OsIndication value inconsistence\r
-  //   3. OsIndication attribute inconsistence\r
-  //\r
-  OsIndication = 0;\r
-  Attributes = 0;\r
-  DataSize = sizeof(UINT64);\r
-  Status = gRT->GetVariable (\r
-                  L"OsIndications",\r
-                  &gEfiGlobalVariableGuid,\r
-                  &Attributes,\r
-                  &DataSize,\r
-                  &OsIndication\r
-                  );\r
-\r
-  if (!EFI_ERROR(Status)) {\r
-    if (DataSize != sizeof(UINT64) ||\r
-        (OsIndication & ~OsIndicationSupport) != 0 ||\r
-        Attributes != (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE)){\r
-\r
-      DEBUG ((EFI_D_ERROR, "Unformalized OsIndications variable exists. Delete it\n"));\r
-      Status = gRT->SetVariable (\r
-                      L"OsIndications",\r
-                      &gEfiGlobalVariableGuid,\r
-                      0,\r
-                      0,\r
-                      NULL\r
-                      );\r
-      //\r
-      // Deleting variable with current variable implementation shouldn't fail.\r
-      //\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-\r
-}\r
-\r
-/**\r
-\r
-  Service routine for BdsInstance->Entry(). Devices are connected, the\r
-  consoles are initialized, and the boot options are tried.\r
-\r
-  @param This             Protocol Instance structure.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsEntry (\r
-  IN EFI_BDS_ARCH_PROTOCOL  *This\r
-  )\r
-{\r
-  LIST_ENTRY                      DriverOptionList;\r
-  LIST_ENTRY                      BootOptionList;\r
-  UINTN                           BootNextSize;\r
-  CHAR16                          *FirmwareVendor;\r
-  EFI_STATUS                      Status;\r
-  UINT16                          BootTimeOut;\r
-  UINTN                           Index;\r
-  EDKII_VARIABLE_LOCK_PROTOCOL    *VariableLock;\r
-\r
-  //\r
-  // Insert the performance probe\r
-  //\r
-  PERF_END (NULL, "DXE", NULL, 0);\r
-  PERF_START (NULL, "BDS", NULL, 0);\r
-\r
-  //\r
-  // Initialize the global system boot option and driver option\r
-  //\r
-  InitializeListHead (&DriverOptionList);\r
-  InitializeListHead (&BootOptionList);\r
-\r
-  //\r
-  // Initialize hotkey service\r
-  //\r
-  InitializeHotkeyService ();\r
-\r
-  //\r
-  // Fill in FirmwareVendor and FirmwareRevision from PCDs\r
-  //\r
-  FirmwareVendor = (CHAR16 *)PcdGetPtr (PcdFirmwareVendor);\r
-  gST->FirmwareVendor = AllocateRuntimeCopyPool (StrSize (FirmwareVendor), FirmwareVendor);\r
-  ASSERT (gST->FirmwareVendor != NULL);\r
-  gST->FirmwareRevision = PcdGet32 (PcdFirmwareRevision);\r
-\r
-  //\r
-  // Fixup Tasble CRC after we updated Firmware Vendor and Revision\r
-  //\r
-  gST->Hdr.CRC32 = 0;\r
-  gBS->CalculateCrc32 ((VOID *)gST, sizeof(EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);\r
-\r
-  //\r
-  // Validate Variable.\r
-  //\r
-  BdsFormalizeEfiGlobalVariable();\r
-\r
-  //\r
-  // Mark the read-only variables if the Variable Lock protocol exists\r
-  //\r
-  Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r
-  DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));\r
-  if (!EFI_ERROR (Status)) {\r
-    for (Index = 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) {\r
-      Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Report Status Code to indicate connecting drivers will happen\r
-  //\r
-  REPORT_STATUS_CODE (\r
-    EFI_PROGRESS_CODE,\r
-    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS)\r
-    );\r
-\r
-  InitializeHwErrRecSupport();\r
-\r
-  //\r
-  // Initialize L"Timeout" EFI global variable.\r
-  //\r
-  BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);\r
-  if (BootTimeOut != 0xFFFF) {\r
-    //\r
-    // If time out value equal 0xFFFF, no need set to 0xFFFF to variable area because UEFI specification\r
-    // define same behavior between no value or 0xFFFF value for L"Timeout".\r
-    //\r
-    BdsDxeSetVariableAndReportStatusCodeOnError (\r
-                    L"Timeout",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    sizeof (UINT16),\r
-                    &BootTimeOut\r
-                    );\r
-  }\r
-\r
-  //\r
-  // bugbug: platform specific code\r
-  // Initialize the platform specific string and language\r
-  //\r
-  InitializeStringSupport ();\r
-  InitializeLanguage (TRUE);\r
-  InitializeFrontPage (TRUE);\r
-\r
-  //\r
-  // Do the platform init, can be customized by OEM/IBV\r
-  //\r
-  PERF_START (NULL, "PlatformBds", "BDS", 0);\r
-  PlatformBdsInit ();\r
-\r
-  //\r
-  // Set up the device list based on EFI 1.1 variables\r
-  // process Driver#### and Load the driver's in the\r
-  // driver option list\r
-  //\r
-  BdsLibBuildOptionFromVar (&DriverOptionList, L"DriverOrder");\r
-  if (!IsListEmpty (&DriverOptionList)) {\r
-    BdsLibLoadDrivers (&DriverOptionList);\r
-  }\r
-  //\r
-  // Check if we have the boot next option\r
-  //\r
-  mBootNext = BdsLibGetVariableAndSize (\r
-                L"BootNext",\r
-                &gEfiGlobalVariableGuid,\r
-                &BootNextSize\r
-                );\r
-\r
-  //\r
-  // Setup some platform policy here\r
-  //\r
-  PlatformBdsPolicyBehavior (&DriverOptionList, &BootOptionList, BdsProcessCapsules, BdsMemoryTest);\r
-  PERF_END (NULL, "PlatformBds", "BDS", 0);\r
-\r
-  //\r
-  // BDS select the boot device to load OS\r
-  //\r
-  BdsBootDeviceSelect ();\r
-\r
-  //\r
-  // Only assert here since this is the right behavior, we should never\r
-  // return back to DxeCore.\r
-  //\r
-  ASSERT (FALSE);\r
-\r
-  return ;\r
-}\r
-\r
-\r
-/**\r
-  Set the variable and report the error through status code upon failure.\r
-\r
-  @param  VariableName           A Null-terminated string that is the name of the vendor's variable.\r
-                                 Each VariableName is unique for each VendorGuid. VariableName must\r
-                                 contain 1 or more characters. If VariableName is an empty string,\r
-                                 then EFI_INVALID_PARAMETER is returned.\r
-  @param  VendorGuid             A unique identifier for the vendor.\r
-  @param  Attributes             Attributes bitmask to set for the variable.\r
-  @param  DataSize               The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,\r
-                                 EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or\r
-                                 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero\r
-                                 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is\r
-                                 set, then a SetVariable() call with a DataSize of zero will not cause any change to\r
-                                 the variable value (the timestamp associated with the variable may be updated however\r
-                                 even if no new data value is provided,see the description of the\r
-                                 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not\r
-                                 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).\r
-  @param  Data                   The contents for the variable.\r
-\r
-  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r
-                                 defined by the Attributes.\r
-  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits, name, and GUID was supplied, or the\r
-                                 DataSize exceeds the maximum allowed.\r
-  @retval EFI_INVALID_PARAMETER  VariableName is an empty string.\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
-  @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question is read-only.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.\r
-  @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\r
-                                 or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo\r
-                                 does NOT pass the validation check carried out by the firmware.\r
-\r
-  @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.\r
-**/\r
-EFI_STATUS\r
-BdsDxeSetVariableAndReportStatusCodeOnError (\r
-  IN CHAR16     *VariableName,\r
-  IN EFI_GUID   *VendorGuid,\r
-  IN UINT32     Attributes,\r
-  IN UINTN      DataSize,\r
-  IN VOID       *Data\r
-  )\r
-{\r
-  EFI_STATUS                 Status;\r
-  EDKII_SET_VARIABLE_STATUS  *SetVariableStatus;\r
-  UINTN                      NameSize;\r
-\r
-  Status = gRT->SetVariable (\r
-                  VariableName,\r
-                  VendorGuid,\r
-                  Attributes,\r
-                  DataSize,\r
-                  Data\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    NameSize = StrSize (VariableName);\r
-    SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize);\r
-    if (SetVariableStatus != NULL) {\r
-      CopyGuid (&SetVariableStatus->Guid, VendorGuid);\r
-      SetVariableStatus->NameSize   = NameSize;\r
-      SetVariableStatus->DataSize   = DataSize;\r
-      SetVariableStatus->SetStatus  = Status;\r
-      SetVariableStatus->Attributes = Attributes;\r
-      CopyMem (SetVariableStatus + 1,                          VariableName, NameSize);\r
-      CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data,         DataSize);\r
-\r
-      REPORT_STATUS_CODE_EX (\r
-        EFI_ERROR_CODE,\r
-        PcdGet32 (PcdErrorCodeSetVariable),\r
-        0,\r
-        NULL,\r
-        &gEdkiiStatusCodeDataTypeVariableGuid,\r
-        SetVariableStatus,\r
-        sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize\r
-        );\r
-\r
-      FreePool (SetVariableStatus);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
deleted file mode 100644 (file)
index 7ba4fa2..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-/** @file\r
-  This function deal with the legacy boot option, it create, delete\r
-  and manage the legacy boot option, all legacy boot option is getting from\r
-  the legacy BBS table.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BBSsupport.h"\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  BBS_TABLE BbsEntry;\r
-  UINT16    BbsIndex;\r
-} LEGACY_BOOT_OPTION_BBS_DATA;\r
-#pragma pack()\r
-\r
-/**\r
-  Re-order the Boot Option according to the DevOrder.\r
-\r
-  The routine re-orders the Boot Option in BootOption array according to\r
-  the order specified by DevOrder.\r
-\r
-  @param DevOrder           Pointer to buffer containing the BBS Index,\r
-                            high 8-bit value 0xFF indicating a disabled boot option\r
-  @param DevOrderCount      Count of the BBS Index\r
-  @param EnBootOption       Callee allocated buffer containing the enabled Boot Option Numbers\r
-  @param EnBootOptionCount  Count of the enabled Boot Option Numbers\r
-  @param DisBootOption      Callee allocated buffer containing the disabled Boot Option Numbers\r
-  @param DisBootOptionCount Count of the disabled Boot Option Numbers\r
-**/\r
-VOID\r
-OrderLegacyBootOption4SameType (\r
-  UINT16                   *DevOrder,\r
-  UINTN                    DevOrderCount,\r
-  UINT16                   **EnBootOption,\r
-  UINTN                    *EnBootOptionCount,\r
-  UINT16                   **DisBootOption,\r
-  UINTN                    *DisBootOptionCount\r
-  )\r
-{\r
-  EFI_STATUS               Status;\r
-  UINT16                   *NewBootOption;\r
-  UINT16                   *BootOrder;\r
-  UINTN                    BootOrderSize;\r
-  UINTN                    Index;\r
-  UINTN                    StartPosition;\r
-\r
-  BDS_COMMON_OPTION        *BootOption;\r
-\r
-  CHAR16                   OptionName[sizeof ("Boot####")];\r
-  UINT16                   *BbsIndexArray;\r
-  UINT16                   *DeviceTypeArray;\r
-  LIST_ENTRY               List;\r
-\r
-  BootOrder = BdsLibGetVariableAndSize (\r
-                L"BootOrder",\r
-                &gEfiGlobalVariableGuid,\r
-                &BootOrderSize\r
-                );\r
-  ASSERT (BootOrder != NULL);\r
-\r
-  BbsIndexArray       = AllocatePool (BootOrderSize);\r
-  DeviceTypeArray     = AllocatePool (BootOrderSize);\r
-  *EnBootOption       = AllocatePool (BootOrderSize);\r
-  *DisBootOption      = AllocatePool (BootOrderSize);\r
-  *DisBootOptionCount = 0;\r
-  *EnBootOptionCount  = 0;\r
-  Index               = 0;\r
-\r
-  ASSERT (BbsIndexArray != NULL);\r
-  ASSERT (DeviceTypeArray != NULL);\r
-  ASSERT (*EnBootOption != NULL);\r
-  ASSERT (*DisBootOption != NULL);\r
-\r
-  for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
-\r
-    UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);\r
-    InitializeListHead (&List);\r
-    BootOption = BdsLibVariableToOption (&List, OptionName);\r
-    ASSERT (BootOption != NULL);\r
-\r
-    if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) &&\r
-        (DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) {\r
-      //\r
-      // Legacy Boot Option\r
-      //\r
-      ASSERT (BootOption->LoadOptionsSize == sizeof (LEGACY_BOOT_OPTION_BBS_DATA));\r
-\r
-      DeviceTypeArray[Index] = ((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType;\r
-      BbsIndexArray  [Index] = ((LEGACY_BOOT_OPTION_BBS_DATA *) BootOption->LoadOptions)->BbsIndex;\r
-    } else {\r
-      DeviceTypeArray[Index] = BBS_TYPE_UNKNOWN;\r
-      BbsIndexArray  [Index] = 0xFFFF;\r
-    }\r
-    FreePool (BootOption->DevicePath);\r
-    FreePool (BootOption->Description);\r
-    FreePool (BootOption->LoadOptions);\r
-    FreePool (BootOption);\r
-  }\r
-\r
-  //\r
-  // Record the corresponding Boot Option Numbers according to the DevOrder\r
-  // Record the EnBootOption and DisBootOption according to the DevOrder\r
-  //\r
-  StartPosition = BootOrderSize / sizeof (UINT16);\r
-  NewBootOption = AllocatePool (DevOrderCount * sizeof (UINT16));\r
-  ASSERT (NewBootOption != NULL);\r
-  while (DevOrderCount-- != 0) {\r
-    for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
-      if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) {\r
-        StartPosition = MIN (StartPosition, Index);\r
-        NewBootOption[DevOrderCount] = BootOrder[Index];\r
-\r
-        if ((DevOrder[DevOrderCount] & 0xFF00) == 0xFF00) {\r
-          (*DisBootOption)[*DisBootOptionCount] = BootOrder[Index];\r
-          (*DisBootOptionCount)++;\r
-        } else {\r
-          (*EnBootOption)[*EnBootOptionCount] = BootOrder[Index];\r
-          (*EnBootOptionCount)++;\r
-        }\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Overwrite the old BootOption\r
-  //\r
-  CopyMem (&BootOrder[StartPosition], NewBootOption, (*DisBootOptionCount + *EnBootOptionCount) * sizeof (UINT16));\r
-  Status = gRT->SetVariable (\r
-                  L"BootOrder",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  BootOrderSize,\r
-                  BootOrder\r
-                  );\r
-  //\r
-  // Changing content without increasing its size with current variable implementation shouldn't fail.\r
-  //\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  FreePool (NewBootOption);\r
-  FreePool (DeviceTypeArray);\r
-  FreePool (BbsIndexArray);\r
-  FreePool (BootOrder);\r
-}\r
-\r
-/**\r
-  Group the legacy boot options in the BootOption.\r
-\r
-  The routine assumes the boot options in the beginning that covers all the device\r
-  types are ordered properly and re-position the following boot options just after\r
-  the corresponding boot options with the same device type.\r
-  For example:\r
-  1. Input  = [Harddisk1 CdRom2 Efi1 Harddisk0 CdRom0 CdRom1 Harddisk2 Efi0]\r
-     Assuming [Harddisk1 CdRom2 Efi1] is ordered properly\r
-     Output = [Harddisk1 Harddisk0 Harddisk2 CdRom2 CdRom0 CdRom1 Efi1 Efi0]\r
-\r
-  2. Input  = [Efi1 Efi0 CdRom1 Harddisk0 Harddisk1 Harddisk2 CdRom0 CdRom2]\r
-     Assuming [Efi1 Efi0 CdRom1 Harddisk0] is ordered properly\r
-     Output = [Efi1 Efi0 CdRom1 CdRom0 CdRom2 Harddisk0 Harddisk1 Harddisk2]\r
-\r
-**/\r
-VOID\r
-GroupMultipleLegacyBootOption4SameType (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                   Status;\r
-  UINTN                        Index;\r
-  UINTN                        DeviceIndex;\r
-  UINTN                        DeviceTypeIndex[7];\r
-  UINTN                        *NextIndex;\r
-  UINT16                       OptionNumber;\r
-  UINT16                       *BootOrder;\r
-  UINTN                        BootOrderSize;\r
-  CHAR16                       OptionName[sizeof ("Boot####")];\r
-  BDS_COMMON_OPTION            *BootOption;\r
-  LIST_ENTRY                   List;\r
-\r
-  SetMem (DeviceTypeIndex, sizeof (DeviceTypeIndex), 0xff);\r
-\r
-  BootOrder = BdsLibGetVariableAndSize (\r
-                L"BootOrder",\r
-                &gEfiGlobalVariableGuid,\r
-                &BootOrderSize\r
-                );\r
-\r
-  for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
-    UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);\r
-    InitializeListHead (&List);\r
-    BootOption = BdsLibVariableToOption (&List, OptionName);\r
-    ASSERT (BootOption != NULL);\r
-\r
-    if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) &&\r
-        (DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) {\r
-      //\r
-      // Legacy Boot Option\r
-      //\r
-      ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex));\r
-      NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF];\r
-\r
-      if (*NextIndex == (UINTN) -1) {\r
-        //\r
-        // *NextIndex is the Index in BootOrder to put the next Option Number for the same type\r
-        //\r
-        *NextIndex = Index + 1;\r
-      } else {\r
-        //\r
-        // insert the current boot option before *NextIndex, causing [*Next .. Index] shift right one position\r
-        //\r
-        OptionNumber = BootOrder[Index];\r
-        CopyMem (&BootOrder[*NextIndex + 1], &BootOrder[*NextIndex], (Index - *NextIndex) * sizeof (UINT16));\r
-        BootOrder[*NextIndex] = OptionNumber;\r
-\r
-        //\r
-        // Update the DeviceTypeIndex array to reflect the right shift operation\r
-        //\r
-        for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) {\r
-          if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) {\r
-            DeviceTypeIndex[DeviceIndex]++;\r
-          }\r
-        }\r
-      }\r
-    }\r
-    FreePool (BootOption->DevicePath);\r
-    FreePool (BootOption->Description);\r
-    FreePool (BootOption->LoadOptions);\r
-    FreePool (BootOption);\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  L"BootOrder",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  BootOrderSize,\r
-                  BootOrder\r
-                  );\r
-  //\r
-  // Changing content without increasing its size with current variable implementation shouldn't fail.\r
-  //\r
-  ASSERT_EFI_ERROR (Status);\r
-  FreePool (BootOrder);\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.h b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.h
deleted file mode 100644 (file)
index 0fa3518..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/** @file\r
-  declares interface functions\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _EFI_BDS_BBS_SUPPORT_H_\r
-#define _EFI_BDS_BBS_SUPPORT_H_\r
-\r
-#include "BootMaint.h"\r
-\r
-/**\r
-  Build Legacy Device Name String according.\r
-\r
-  @param CurBBSEntry     BBS Table.\r
-  @param Index           Index.\r
-  @param BufSize         The buffer size.\r
-  @param BootString      The output string.\r
-\r
-  @return VOID           No output.\r
-\r
-**/\r
-VOID\r
-BdsBuildLegacyDevNameString (\r
-  IN BBS_TABLE                     *CurBBSEntry,\r
-  IN UINTN                         Index,\r
-  IN UINTN                         BufSize,\r
-  OUT CHAR16                       *BootString\r
-  );\r
-\r
-/**\r
-  Group the legacy boot options in the BootOption.\r
-\r
-  The routine assumes the boot options in the beginning that covers all the device\r
-  types are ordered properly and re-position the following boot options just after\r
-  the corresponding boot options with the same device type.\r
-  For example:\r
-  1. Input  = [Harddisk1 CdRom2 Efi1 Harddisk0 CdRom0 CdRom1 Harddisk2 Efi0]\r
-     Assuming [Harddisk1 CdRom2 Efi1] is ordered properly\r
-     Output = [Harddisk1 Harddisk0 Harddisk2 CdRom2 CdRom0 CdRom1 Efi1 Efi0]\r
-\r
-  2. Input  = [Efi1 Efi0 CdRom1 Harddisk0 Harddisk1 Harddisk2 CdRom0 CdRom2]\r
-     Assuming [Efi1 Efi0 CdRom1 Harddisk0] is ordered properly\r
-     Output = [Efi1 Efi0 CdRom1 CdRom0 CdRom2 Harddisk0 Harddisk1 Harddisk2]\r
-**/\r
-VOID\r
-GroupMultipleLegacyBootOption4SameType (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Re-order the Boot Option according to the DevOrder.\r
-\r
-  The routine re-orders the Boot Option in BootOption array according to\r
-  the order specified by DevOrder.\r
-\r
-  @param DevOrder           Pointer to buffer containing the BBS Index,\r
-                            high 8-bit value 0xFF indicating a disabled boot option\r
-  @param DevOrderCount      Count of the BBS Index\r
-  @param EnBootOption       Callee allocated buffer containing the enabled Boot Option Numbers\r
-  @param EnBootOptionCount  Count of the enabled Boot Option Numbers\r
-  @param DisBootOption      Callee allocated buffer containing the disabled Boot Option Numbers\r
-  @param DisBootOptionCount Count of the disabled Boot Option Numbers\r
-**/\r
-VOID\r
-OrderLegacyBootOption4SameType (\r
-  UINT16                   *DevOrder,\r
-  UINTN                    DevOrderCount,\r
-  UINT16                   **EnBootOption,\r
-  UINTN                    *EnBootOptionCount,\r
-  UINT16                   **DisBootOption,\r
-  UINTN                    *DisBootOptionCount\r
-  );\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Bm.vfr b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Bm.vfr
deleted file mode 100644 (file)
index 990c063..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-///** @file\r
-//\r
-//    Boot Maintenance Utility Formset\r
-//\r
-//  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-//**/\r
-\r
-#include "FormGuid.h"\r
-\r
-formset\r
-  guid = BOOT_MAINT_FORMSET_GUID,\r
-  title = STRING_TOKEN(STR_FORM_MAIN_TITLE),\r
-  help = STRING_TOKEN(STR_NULL_STRING),\r
-  classguid = BOOT_MAINT_FORMSET_GUID,\r
-\r
-  varstore BMM_FAKE_NV_DATA,\r
-    varid = VARSTORE_ID_BOOT_MAINT,\r
-    name = BmmData,\r
-    guid = BOOT_MAINT_FORMSET_GUID;\r
-\r
-  form formid = FORM_MAIN_ID,\r
-       title = STRING_TOKEN(STR_FORM_MAIN_TITLE);\r
-\r
-    goto FORM_BOOT_SETUP_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_BOOT_SETUP_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_BOOT_SETUP_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_BOOT_SETUP_ID;\r
-\r
-    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
-    goto FORM_DRIVER_SETUP_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_DRIVER_SETUP_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_DRIVER_SETUP_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_DRIVER_SETUP_ID;\r
-\r
-    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
-    goto FORM_CON_MAIN_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_CON_MAIN_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_CON_MAIN_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_CON_MAIN_ID;\r
-\r
-    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
-    goto FORM_BOOT_FROM_FILE_ID,\r
-         prompt = STRING_TOKEN(STR_BOOT_FROM_FILE),\r
-         help   = STRING_TOKEN(STR_BOOT_FROM_FILE_HELP),\r
-         flags = INTERACTIVE,\r
-         key = KEY_VALUE_BOOT_FROM_FILE;\r
-\r
-    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
-//    label FORM_MAIN_ID;\r
-\r
-    goto FORM_BOOT_NEXT_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_BOOT_NEXT_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_BOOT_NEXT_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_BOOT_NEXT_ID;\r
-\r
-    goto FORM_TIME_OUT_ID,\r
-         prompt = STRING_TOKEN(STR_FORM_TIME_OUT_TITLE),\r
-         help = STRING_TOKEN(STR_FORM_TIME_OUT_HELP),\r
-         flags = INTERACTIVE,\r
-         key = FORM_TIME_OUT_ID;\r
-\r
-    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
-    text\r
-         help   = STRING_TOKEN(STR_RESET),\r
-         text   = STRING_TOKEN(STR_RESET),\r
-         flags  = INTERACTIVE,\r
-         key    = FORM_RESET;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_BOOT_SETUP_ID,\r
-       title = STRING_TOKEN(STR_FORM_BOOT_SETUP_TITLE);\r
-\r
-       goto FORM_MAIN_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
-            help = STRING_TOKEN(STR_FORM_GOTO_MAIN);\r
-            //flags = INTERACTIVE,\r
-            //key = FORM_MAIN_ID;\r
-\r
-       goto FORM_BOOT_ADD_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE),\r
-            help = STRING_TOKEN(STR_FORM_BOOT_ADD_HELP),\r
-            flags = INTERACTIVE,\r
-            key = FORM_BOOT_ADD_ID;\r
-\r
-       goto FORM_BOOT_DEL_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE),\r
-            help = STRING_TOKEN(STR_FORM_BOOT_IMMEDIATE_HELP),\r
-            flags = INTERACTIVE,\r
-            key = FORM_BOOT_DEL_ID;\r
-\r
-       goto FORM_BOOT_CHG_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE),\r
-            help = STRING_TOKEN(STR_FORM_BOOT_IMMEDIATE_HELP),\r
-            flags = INTERACTIVE,\r
-            key = FORM_BOOT_CHG_ID;\r
-\r
-       subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-           //\r
-     // We will add "Select Legacy Boot Floppy Drive" and "Select Legacy Boot Hard Drive"\r
-     // here dynamically\r
-     //\r
-       label FORM_BOOT_LEGACY_DEVICE_ID;\r
-       label LABEL_END;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_DRIVER_SETUP_ID,\r
-       title = STRING_TOKEN(STR_FORM_DRIVER_SETUP_TITLE);\r
-\r
-       goto FORM_MAIN_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
-            help = STRING_TOKEN(STR_FORM_GOTO_MAIN);\r
-            //help = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
-            //flags = INTERACTIVE,\r
-            //key = FORM_MAIN_ID;\r
-\r
-       goto FORM_DRV_ADD_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_DRV_ADD_TITLE),\r
-            help = STRING_TOKEN(STR_FORM_DRV_ADD_HELP),\r
-            flags = INTERACTIVE,\r
-            key = FORM_DRV_ADD_ID;\r
-\r
-       goto FORM_DRV_DEL_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE),\r
-            help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),\r
-            flags = INTERACTIVE,\r
-            key = FORM_DRV_DEL_ID;\r
-\r
-       goto FORM_DRV_CHG_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE),\r
-            help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),\r
-            flags = INTERACTIVE,\r
-            key = FORM_DRV_CHG_ID;\r
-  endform;\r
-\r
-  form formid = FORM_BOOT_DEL_ID,\r
-       title = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE);\r
-\r
-       label FORM_BOOT_DEL_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_BOOT_CHG_ID,\r
-       title = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE);\r
-\r
-       label FORM_BOOT_CHG_ID;\r
-       label LABEL_END;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_BOOT_NEXT_ID,\r
-       title = STRING_TOKEN(STR_FORM_BOOT_NEXT_TITLE);\r
-\r
-       label FORM_BOOT_NEXT_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_TIME_OUT_ID,\r
-       title = STRING_TOKEN(STR_FORM_TIME_OUT_TITLE);\r
-\r
-       label FORM_TIME_OUT_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_DRV_ADD_ID,\r
-       title = STRING_TOKEN(STR_FORM_DRV_ADD_TITLE);\r
-\r
-       goto FORM_MAIN_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
-            help = STRING_TOKEN(STR_FORM_GOTO_MAIN);\r
-            //flags = INTERACTIVE,\r
-            //key = FORM_MAIN_ID;\r
-\r
-       goto FORM_DRV_ADD_FILE_ID,\r
-            prompt = STRING_TOKEN(STR_FORM_DRV_ADD_FILE_TITLE),\r
-            help = STRING_TOKEN(STR_FORM_DRV_ADD_FILE_TITLE),\r
-            flags = INTERACTIVE,\r
-            key = FORM_DRV_ADD_FILE_ID;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_DRV_DEL_ID,\r
-       title = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE);\r
-\r
-       label FORM_DRV_DEL_ID;\r
-       label LABEL_END;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_DRV_CHG_ID,\r
-       title = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE);\r
-\r
-       label FORM_DRV_CHG_ID;\r
-       label LABEL_END;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_CON_MAIN_ID,\r
-       title = STRING_TOKEN(STR_FORM_CON_MAIN_TITLE);\r
-\r
-       goto FORM_MAIN_ID,\r
-       prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
-       help = STRING_TOKEN(STR_FORM_GOTO_MAIN);\r
-       //flags = INTERACTIVE,\r
-       //key = FORM_MAIN_ID;\r
-\r
-       goto FORM_CON_IN_ID,\r
-       prompt = STRING_TOKEN(STR_FORM_CON_IN_TITLE),\r
-       help = STRING_TOKEN(STR_FORM_CON_IN_HELP),\r
-       flags = INTERACTIVE,\r
-       key = FORM_CON_IN_ID;\r
-\r
-       goto FORM_CON_OUT_ID,\r
-       prompt = STRING_TOKEN(STR_FORM_CON_OUT_TITLE),\r
-       help = STRING_TOKEN(STR_FORM_CON_OUT_HELP),\r
-       flags = INTERACTIVE,\r
-       key = FORM_CON_OUT_ID;\r
-\r
-       goto FORM_CON_ERR_ID,\r
-       prompt = STRING_TOKEN(STR_FORM_STD_ERR_TITLE),\r
-       help = STRING_TOKEN(STR_FORM_STD_ERR_HELP),\r
-       flags = INTERACTIVE,\r
-       key = FORM_CON_ERR_ID;\r
-\r
-       goto FORM_CON_MODE_ID,\r
-       prompt = STRING_TOKEN(STR_FORM_MODE_TITLE),\r
-       help = STRING_TOKEN(STR_FORM_MODE_HELP),\r
-       flags = INTERACTIVE,\r
-       key = FORM_CON_MODE_ID;\r
-\r
-       goto FORM_CON_COM_ID,\r
-       prompt = STRING_TOKEN(STR_FORM_COM_TITLE),\r
-       help = STRING_TOKEN(STR_FORM_COM_HELP),\r
-       flags = INTERACTIVE,\r
-       key = FORM_CON_COM_ID;\r
-  endform;\r
-\r
-  form formid = FORM_CON_MODE_ID,\r
-       title = STRING_TOKEN(STR_FORM_MODE_TITLE);\r
-\r
-       label FORM_CON_MODE_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_CON_COM_ID,\r
-       title = STRING_TOKEN(STR_FORM_COM_TITLE);\r
-\r
-       label FORM_CON_COM_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_CON_COM_SETUP_ID,\r
-       title = STRING_TOKEN(STR_CON_COM_SETUP);\r
-\r
-       label FORM_CON_COM_SETUP_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_FILE_SEEK_ID,\r
-       title = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE);\r
-\r
-       label FORM_FILE_SEEK_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_FILE_NEW_SEEK_ID,\r
-       title = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE);\r
-\r
-       label FORM_FILE_NEW_SEEK_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_DRV_ADD_HANDLE_ID,\r
-       title = STRING_TOKEN(STR_FORM_DRV_ADD_HANDLE_TITLE);\r
-\r
-       label FORM_DRV_ADD_HANDLE_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_DRV_ADD_HANDLE_DESC_ID,\r
-       title = STRING_TOKEN(STR_FORM_DRV_ADD_DESC_TITLE);\r
-\r
-       label FORM_DRV_ADD_HANDLE_DESC_ID;\r
-       label LABEL_END;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_CON_IN_ID,\r
-       title = STRING_TOKEN(STR_FORM_CON_IN_TITLE);\r
-\r
-       label FORM_CON_IN_ID;\r
-       label LABEL_END;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_CON_OUT_ID,\r
-       title = STRING_TOKEN(STR_FORM_CON_OUT_TITLE);\r
-\r
-       label FORM_CON_OUT_ID;\r
-       label LABEL_END;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_CON_ERR_ID,\r
-       title = STRING_TOKEN(STR_FORM_STD_ERR_TITLE);\r
-\r
-       label FORM_CON_ERR_ID;\r
-       label LABEL_END;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_SET_FD_ORDER_ID,\r
-       title = STRING_TOKEN(STR_FORM_SET_FD_ORDER_TITLE);\r
-\r
-       label FORM_SET_FD_ORDER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_SET_HD_ORDER_ID,\r
-       title = STRING_TOKEN(STR_FORM_SET_HD_ORDER_TITLE);\r
-\r
-       label FORM_SET_HD_ORDER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_SET_CD_ORDER_ID,\r
-       title = STRING_TOKEN(STR_FORM_SET_CD_ORDER_TITLE);\r
-\r
-       label FORM_SET_CD_ORDER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_SET_NET_ORDER_ID,\r
-       title = STRING_TOKEN(STR_FORM_SET_NET_ORDER_TITLE);\r
-\r
-       label FORM_SET_NET_ORDER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_SET_BEV_ORDER_ID,\r
-       title = STRING_TOKEN(STR_FORM_SET_BEV_ORDER_TITLE);\r
-\r
-       label FORM_SET_BEV_ORDER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-endformset;\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BmLib.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BmLib.c
deleted file mode 100644 (file)
index e5d9640..0000000
+++ /dev/null
@@ -1,369 +0,0 @@
-/** @file\r
-  Utility routines used by boot maintenance modules.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BootMaint.h"\r
-\r
-/**\r
-\r
-  Function opens and returns a file handle to the root directory of a volume.\r
-\r
-  @param DeviceHandle    A handle for a device\r
-\r
-  @return A valid file handle or NULL is returned\r
-\r
-**/\r
-EFI_FILE_HANDLE\r
-EfiLibOpenRoot (\r
-  IN EFI_HANDLE                   DeviceHandle\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;\r
-  EFI_FILE_HANDLE                 File;\r
-\r
-  File = NULL;\r
-\r
-  //\r
-  // File the file system interface to the device\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  DeviceHandle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  (VOID *) &Volume\r
-                  );\r
-\r
-  //\r
-  // Open the root directory of the volume\r
-  //\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = Volume->OpenVolume (\r
-                      Volume,\r
-                      &File\r
-                      );\r
-  }\r
-  //\r
-  // Done\r
-  //\r
-  return EFI_ERROR (Status) ? NULL : File;\r
-}\r
-\r
-/**\r
-\r
-  Helper function called as part of the code needed\r
-  to allocate the proper sized buffer for various\r
-  EFI interfaces.\r
-\r
-\r
-  @param Status          Current status\r
-  @param Buffer          Current allocated buffer, or NULL\r
-  @param BufferSize      Current buffer size needed\r
-\r
-  @retval  TRUE  if the buffer was reallocated and the caller\r
-                 should try the API again.\r
-  @retval  FALSE The caller should not call this function again.\r
-\r
-**/\r
-BOOLEAN\r
-EfiGrowBuffer (\r
-  IN OUT EFI_STATUS   *Status,\r
-  IN OUT VOID         **Buffer,\r
-  IN UINTN            BufferSize\r
-  )\r
-{\r
-  BOOLEAN TryAgain;\r
-\r
-  //\r
-  // If this is an initial request, buffer will be null with a new buffer size\r
-  //\r
-  if ((*Buffer == NULL) && (BufferSize != 0)) {\r
-    *Status = EFI_BUFFER_TOO_SMALL;\r
-  }\r
-  //\r
-  // If the status code is "buffer too small", resize the buffer\r
-  //\r
-  TryAgain = FALSE;\r
-  if (*Status == EFI_BUFFER_TOO_SMALL) {\r
-\r
-    if (*Buffer != NULL) {\r
-      FreePool (*Buffer);\r
-    }\r
-\r
-    *Buffer = AllocateZeroPool (BufferSize);\r
-\r
-    if (*Buffer != NULL) {\r
-      TryAgain = TRUE;\r
-    } else {\r
-      *Status = EFI_OUT_OF_RESOURCES;\r
-    }\r
-  }\r
-  //\r
-  // If there's an error, free the buffer\r
-  //\r
-  if (!TryAgain && EFI_ERROR (*Status) && (*Buffer != NULL)) {\r
-    FreePool (*Buffer);\r
-    *Buffer = NULL;\r
-  }\r
-\r
-  return TryAgain;\r
-}\r
-\r
-/**\r
-  Function returns the value of the specified variable.\r
-\r
-\r
-  @param Name            A Null-terminated Unicode string that is\r
-                         the name of the vendor's variable.\r
-  @param VendorGuid      A unique identifier for the vendor.\r
-\r
-  @return               The payload of the variable.\r
-  @retval NULL          If the variable can't be read.\r
-\r
-**/\r
-VOID *\r
-EfiLibGetVariable (\r
-  IN CHAR16               *Name,\r
-  IN EFI_GUID             *VendorGuid\r
-  )\r
-{\r
-  UINTN VarSize;\r
-\r
-  return BdsLibGetVariableAndSize (Name, VendorGuid, &VarSize);\r
-}\r
-\r
-/**\r
-  Function deletes the variable specified by VarName and VarGuid.\r
-\r
-  @param VarName           A Null-terminated Unicode string that is\r
-                           the name of the vendor's variable.\r
-\r
-  @param VarGuid           A unique identifier for the vendor.\r
-\r
-  @retval  EFI_SUCCESS           The variable was found and removed\r
-  @retval  EFI_UNSUPPORTED       The variable store was inaccessible\r
-  @retval  EFI_OUT_OF_RESOURCES  The temporary buffer was not available\r
-  @retval  EFI_NOT_FOUND         The variable was not found\r
-\r
-**/\r
-EFI_STATUS\r
-EfiLibDeleteVariable (\r
-  IN CHAR16   *VarName,\r
-  IN EFI_GUID *VarGuid\r
-  )\r
-{\r
-  VOID        *VarBuf;\r
-  EFI_STATUS  Status;\r
-\r
-  VarBuf  = EfiLibGetVariable (VarName, VarGuid);\r
-  Status  = EFI_NOT_FOUND;\r
-\r
-  if (VarBuf != NULL) {\r
-    //\r
-    // Delete variable from Storage\r
-    //\r
-    Status = gRT->SetVariable (\r
-                    VarName,\r
-                    VarGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    0,\r
-                    NULL\r
-                    );\r
-    //\r
-    // Deleting variable with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-    FreePool (VarBuf);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-\r
-  Function gets the file system information from an open file descriptor,\r
-  and stores it in a buffer allocated from pool.\r
-\r
-\r
-  @param FHand           The file handle.\r
-\r
-  @return                A pointer to a buffer with file information.\r
-  @retval                NULL is returned if failed to get Vaolume Label Info.\r
-\r
-**/\r
-EFI_FILE_SYSTEM_VOLUME_LABEL *\r
-EfiLibFileSystemVolumeLabelInfo (\r
-  IN EFI_FILE_HANDLE      FHand\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_FILE_SYSTEM_VOLUME_LABEL      *Buffer;\r
-  UINTN                             BufferSize;\r
-  //\r
-  // Initialize for GrowBuffer loop\r
-  //\r
-  Buffer      = NULL;\r
-  BufferSize  = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL + 200;\r
-\r
-  //\r
-  // Call the real function\r
-  //\r
-  while (EfiGrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {\r
-    Status = FHand->GetInfo (\r
-                      FHand,\r
-                      &gEfiFileSystemVolumeLabelInfoIdGuid,\r
-                      &BufferSize,\r
-                      Buffer\r
-                      );\r
-  }\r
-\r
-  return Buffer;\r
-}\r
-\r
-/**\r
-  Duplicate a string.\r
-\r
-  @param Src             The source.\r
-\r
-  @return A new string which is duplicated copy of the source.\r
-  @retval NULL If there is not enough memory.\r
-\r
-**/\r
-CHAR16 *\r
-EfiStrDuplicate (\r
-  IN CHAR16   *Src\r
-  )\r
-{\r
-  CHAR16  *Dest;\r
-  UINTN   Size;\r
-\r
-  Size  = StrSize (Src);\r
-  Dest  = AllocateZeroPool (Size);\r
-  ASSERT (Dest != NULL);\r
-  if (Dest != NULL) {\r
-    CopyMem (Dest, Src, Size);\r
-  }\r
-\r
-  return Dest;\r
-}\r
-\r
-/**\r
-\r
-  Function gets the file information from an open file descriptor, and stores it\r
-  in a buffer allocated from pool.\r
-\r
-  @param FHand           File Handle.\r
-\r
-  @return                A pointer to a buffer with file information or NULL is returned\r
-\r
-**/\r
-EFI_FILE_INFO *\r
-EfiLibFileInfo (\r
-  IN EFI_FILE_HANDLE      FHand\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  EFI_FILE_INFO *Buffer;\r
-  UINTN         BufferSize;\r
-\r
-  //\r
-  // Initialize for GrowBuffer loop\r
-  //\r
-  Buffer      = NULL;\r
-  BufferSize  = SIZE_OF_EFI_FILE_INFO + 200;\r
-\r
-  //\r
-  // Call the real function\r
-  //\r
-  while (EfiGrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {\r
-    Status = FHand->GetInfo (\r
-                      FHand,\r
-                      &gEfiFileInfoGuid,\r
-                      &BufferSize,\r
-                      Buffer\r
-                      );\r
-  }\r
-\r
-  return Buffer;\r
-}\r
-\r
-/**\r
-  Function is used to determine the number of device path instances\r
-  that exist in a device path.\r
-\r
-\r
-  @param DevicePath      A pointer to a device path data structure.\r
-\r
-  @return This function counts and returns the number of device path instances\r
-          in DevicePath.\r
-\r
-**/\r
-UINTN\r
-EfiDevicePathInstanceCount (\r
-  IN EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
-  )\r
-{\r
-  UINTN Count;\r
-  UINTN Size;\r
-\r
-  Count = 0;\r
-  while (GetNextDevicePathInstance (&DevicePath, &Size) != NULL) {\r
-    Count += 1;\r
-  }\r
-\r
-  return Count;\r
-}\r
-\r
-\r
-/**\r
-  Get a string from the Data Hub record based on\r
-  a device path.\r
-\r
-  @param DevPath         The device Path.\r
-\r
-  @return A string located from the Data Hub records based on\r
-          the device path.\r
-  @retval NULL  If failed to get the String from Data Hub.\r
-\r
-**/\r
-UINT16 *\r
-EfiLibStrFromDatahub (\r
-  IN EFI_DEVICE_PATH_PROTOCOL                 *DevPath\r
-  )\r
-{\r
-  return NULL;\r
-}\r
-\r
-/**\r
-\r
-  Find the first instance of this Protocol\r
-  in the system and return it's interface.\r
-\r
-\r
-  @param ProtocolGuid    Provides the protocol to search for\r
-  @param Interface       On return, a pointer to the first interface\r
-                         that matches ProtocolGuid\r
-\r
-  @retval  EFI_SUCCESS      A protocol instance matching ProtocolGuid was found\r
-  @retval  EFI_NOT_FOUND    No protocol instances were found that match ProtocolGuid\r
-\r
-**/\r
-EFI_STATUS\r
-EfiLibLocateProtocol (\r
-  IN  EFI_GUID    *ProtocolGuid,\r
-  OUT VOID        **Interface\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  ProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) Interface\r
-                  );\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Bmstring.uni b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Bmstring.uni
deleted file mode 100644 (file)
index 98a8c0d..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-///** @file\r
-//\r
-//    String definitions for Boot Maintenance Utility.\r
-//\r
-//  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-//**/\r
-\r
-/=#\r
-\r
-#langdef   en-US "English"\r
-#langdef   fr-FR "Français"\r
-\r
-#string STR_NULL_STRING                #language en-US  " "\r
-                                       #language fr-FR  " "\r
-#string STR_NONE                       #language en-US  "NONE"\r
-                                       #language fr-FR  "NONE"\r
-#string STR_FORM_MAIN_TITLE            #language en-US  "Boot Maintenance Manager"\r
-                                       #language fr-FR  "Boot Maintenance Manager"\r
-#string STR_FORM_BOOT_SETUP_TITLE      #language en-US  "Boot Options"\r
-                                       #language fr-FR  "Boot Options"\r
-#string STR_FORM_BOOT_SETUP_HELP       #language en-US  "Modify system boot options"\r
-                                       #language fr-FR  "Modify system boot options"\r
-#string STR_FORM_DRIVER_SETUP_TITLE    #language en-US  "Driver Options"\r
-                                       #language fr-FR  "Driver Options"\r
-#string STR_FORM_DRIVER_SETUP_HELP     #language en-US  "Modify boot driver options"\r
-                                       #language fr-FR  "Modify boot driver options"\r
-#string STR_FORM_BOOT_ADD_TITLE        #language en-US  "Add Boot Option"\r
-                                       #language fr-FR  "Add Boot Option"\r
-#string STR_FORM_BOOT_ADD_HELP         #language en-US  "Add EFI Application or Removable Fs as Boot Option"\r
-                                       #language fr-FR  "Add EFI Application or Removable Fs as Boot Option"\r
-#string STR_FORM_BOOT_DEL_TITLE        #language en-US  "Delete Boot Option"\r
-                                       #language fr-FR  "Delete Boot Option"\r
-#string STR_FORM_BOOT_IMMEDIATE_HELP   #language en-US  "Will be valid immediately"\r
-                                       #language fr-FR  "Will be valid immediately"\r
-#string STR_FORM_BOOT_CHG_TITLE        #language en-US  "Change Boot Order"\r
-                                       #language fr-FR  "Change Boot Order"\r
-#string STR_FORM_DRV_ADD_TITLE         #language en-US  "Add Driver Option"\r
-                                       #language fr-FR  "Add Driver Option"\r
-#string STR_FORM_DRV_ADD_HELP          #language en-US  "Add .EFI Driver as Driver Option"\r
-                                       #language fr-FR  "Add .EFI Driver as Driver Option"\r
-#string STR_FORM_DRV_DEL_TITLE         #language en-US  "Delete Driver Option"\r
-                                       #language fr-FR  "Delete Driver Option"\r
-#string STR_FORM_DRV_CHG_TITLE         #language en-US  "Change Driver Order"\r
-                                       #language fr-FR  "Change Driver Order"\r
-#string STR_FORM_NEXT_BOOT_HELP        #language en-US  "Will be valid on next boot"\r
-                                       #language fr-FR  "Will be valid on next boot"\r
-#string STR_FORM_BOOT_NEXT_TITLE       #language en-US  "Set Boot Next Value"\r
-                                       #language fr-FR  "Set Boot Next Value"\r
-#string STR_FORM_BOOT_NEXT_HELP        #language en-US  "Modify next boot behavior"\r
-                                       #language fr-FR  "Modify next boot behavior"\r
-#string STR_FORM_TIME_OUT_TITLE        #language en-US  "Set Time Out Value"\r
-                                       #language fr-FR  "Set Time Out Value"\r
-#string STR_FORM_TIME_OUT_HELP         #language en-US  "Modify automatic boot time-out value"\r
-                                       #language fr-FR  "Modify automatic boot time-out value"\r
-#string STR_FORM_CON_MAIN_TITLE        #language en-US  "Console Options"\r
-                                       #language fr-FR  "Console Options"\r
-#string STR_FORM_CON_MAIN_HELP         #language en-US  "Modify system console options"\r
-                                       #language fr-FR  "Modify system console options"\r
-#string STR_FORM_CON_IN_TITLE          #language en-US  "Console Input Device Select"\r
-                                       #language fr-FR  "Console Input Device Select"\r
-#string STR_FORM_CON_IN_HELP           #language en-US  "Enable console device as ConIn"\r
-                                       #language fr-FR  "Enable console device as ConIn"\r
-#string STR_FORM_SET_FD_ORDER_TITLE    #language en-US  "Set Legacy Floppy Drive Order"\r
-                                       #language fr-FR  "Set Legacy Floppy Drive Order"\r
-#string STR_FORM_SET_HD_ORDER_TITLE    #language en-US  "Set Legacy HardDisk Drive Order"\r
-                                       #language fr-FR  "Set Legacy HardDisk Drive Order"\r
-#string STR_FORM_SET_CD_ORDER_TITLE    #language en-US  "Set Legacy CD-ROM Drive Order"\r
-                                       #language fr-FR  "Set Legacy CD-ROM Drive Order"\r
-#string STR_FORM_SET_NET_ORDER_TITLE   #language en-US  "Set Legacy NET Drive Order"\r
-                                       #language fr-FR  "Set Legacy NET Drive Order"\r
-#string STR_FORM_SET_BEV_ORDER_TITLE   #language en-US  "Set Legacy BEV Drive Order"\r
-                                       #language fr-FR  "Set Legacy BEV Drive Order"\r
-#string STR_FORM_GOTO_SETTING          #language en-US  "Go Back To Setting Page"\r
-                                       #language fr-FR  "Go Back To Setting Page"\r
-#string STR_COM1                       #language en-US  "COM1"\r
-                                       #language fr-FR  "COM1"\r
-#string STR_COM2                       #language en-US  "COM2"\r
-                                       #language fr-FR  "COM2"\r
-#string STR_COM_AS_CONSOLE_OPTION      #language en-US  "Select this COM port as Console"\r
-                                       #language fr-FR  "Select this COM port as Console"\r
-#string STR_FORM_CON_OUT_TITLE         #language en-US  "Console Output Device Select"\r
-                                       #language fr-FR  "Console Output Device Select"\r
-#string STR_FORM_CON_OUT_HELP          #language en-US  "Enable console device as ConOut"\r
-                                       #language fr-FR  "Enable console device as ConOut"\r
-#string STR_FORM_STD_ERR_TITLE         #language en-US  "Console Standard Error Device Select"\r
-                                       #language fr-FR  "Console Standard Error Device Select"\r
-#string STR_FORM_STD_ERR_HELP          #language en-US  "Enable console device as StdErr"\r
-                                       #language fr-FR  "Enable console device as StdErr"\r
-#string STR_FORM_MODE_TITLE            #language en-US  "Console Output Mode Select"\r
-                                       #language fr-FR  "Console Output Mode Select"\r
-#string STR_FORM_MODE_HELP             #language en-US  "Select Console Output Mode: 80x25, 100x31, etc."\r
-                                       #language fr-FR  "Select Console Output Mode: 80x25, 100x31, etc."\r
-#string STR_FORM_COM_TITLE             #language en-US  "COM Attribute Setup Page"\r
-                                       #language fr-FR  "COM Attribute Setup Page"\r
-#string STR_FORM_COM_HELP              #language en-US  "Setup ComPort BaudRate, DataBits, StopBits, Parity and TerminalType"\r
-                                       #language fr-FR  "Setup ComPort BaudRate, DataBits, StopBits, Parity and TerminalType"\r
-#string STR_FORM_DRV_ADD_FILE_TITLE    #language en-US  "Add Driver Option Using File"\r
-                                       #language fr-FR  "Add Driver Option Using File"\r
-#string STR_FORM_DRV_ADD_HANDLE_TITLE  #language en-US  "Add Driver Option Using Handle"\r
-                                       #language fr-FR  "Add Driver Option Using Handle"\r
-#string STR_FORM_BOOT_ADD_DESC_TITLE   #language en-US  "Modify Boot Option Description"\r
-                                       #language fr-FR  "Modify Boot Option Description"\r
-#string STR_FORM_DRV_ADD_DESC_TITLE    #language en-US  "Modify Driver Option Description"\r
-                                       #language fr-FR  "Modify Driver Option Description"\r
-#string STR_NUM_AUTO_BOOT              #language en-US  "Auto Boot Time-out"\r
-                                       #language fr-FR  "Auto Boot Time-out"\r
-#string STR_HLP_AUTO_BOOT              #language en-US  "Range: 0 to 65535 seconds, 0 means no wait, 65535 means waiting for key"\r
-                                       #language fr-FR  "Range: 0 to 65535 seconds, 0 means no wait, 65535 means waiting for key"\r
-#string STR_BOOT_NEXT                  #language en-US  "Boot Next Value"\r
-                                       #language fr-FR  "Boot Next Value"\r
-#string STR_BOOT_NEXT_HELP             #language en-US  "Next boot use this boot option"\r
-                                       #language fr-FR  "Next boot use this boot option"\r
-#string STR_LOAD_OPTION_DEVPATH        #language en-US  "This is the devicepath"\r
-                                       #language fr-FR  "This is the devicepath"\r
-#string STR_LOAD_OPTION_DESC           #language en-US  "Input the description"\r
-                                       #language fr-FR  "Input the description"\r
-#string STR_LOAD_OPTION_ACTIVE         #language en-US  "Load Option Active"\r
-                                       #language fr-FR  "Load Option Active"\r
-#string STR_LOAD_OPTION_FORCE_RECON    #language en-US  "Load Option Reconnect"\r
-                                       #language fr-FR  "Load Option Reconnect"\r
-#string STR_SAVE_AND_EXIT              #language en-US  "Commit Changes and Exit"\r
-                                       #language fr-FR  "Commit Changes and Exit"\r
-#string STR_NO_SAVE_AND_EXIT           #language en-US  "Discard Changes and Exit"\r
-                                       #language fr-FR  "Discard Changes and Exit"\r
-#string STR_CON_IN_SETUP               #language en-US  "Set Console Input Device"\r
-                                       #language fr-FR  "Set Console Input Device"\r
-#string STR_CON_OUT_SETUP              #language en-US  "Set Console Output Device"\r
-                                       #language fr-FR  "Set Console Output Device"\r
-#string STR_CON_ERR_SETUP              #language en-US  "Set Error Output Device"\r
-                                       #language fr-FR  "Set Error Output Device"\r
-#string STR_CON_MODE_SETUP             #language en-US  "Set Console Output Mode"\r
-                                       #language fr-FR  "Set Console Output Mode"\r
-#string STR_CON_COM_SETUP              #language en-US  "Set COM Attributes"\r
-                                       #language fr-FR  "Set COM Attributes"\r
-#string STR_COM_TERMI_TYPE             #language en-US  "Set COM Terminal Type"\r
-                                       #language fr-FR  "Set COM Terminal Type"\r
-#string STR_COM_FLOW_CONTROL           #language en-US  "Set COM Flow Control"\r
-                                       #language fr-FR  "Set COM Flow Control"\r
-#string STR_COM_BAUD_RATE              #language en-US  "Set COM Baud Rate"\r
-                                       #language fr-FR  "Set COM Baud Rate"\r
-#string STR_COM_DATA_BITS              #language en-US  "Set COM Data Bits"\r
-                                       #language fr-FR  "Set COM Data Bits"\r
-#string STR_COM_PARITY                 #language en-US  "Set COM Parity"\r
-                                       #language fr-FR  "Set COM Parity"\r
-#string STR_COM_STOP_BITS              #language en-US  "Set COM Stop Bits"\r
-                                       #language fr-FR  "Set COM Stop Bits"\r
-#string STR_COM_BAUD_RATE_0            #language en-US  "115200"\r
-                                       #language fr-FR  "115200"\r
-#string STR_COM_BAUD_RATE_1            #language en-US  "57600"\r
-                                       #language fr-FR  "57600"\r
-#string STR_COM_BAUD_RATE_2            #language en-US  "38400"\r
-                                       #language fr-FR  "38400"\r
-#string STR_COM_BAUD_RATE_3            #language en-US  "19200"\r
-                                       #language fr-FR  "19200"\r
-#string STR_COM_BAUD_RATE_4            #language en-US  "9600"\r
-                                       #language fr-FR  "9600"\r
-#string STR_COM_BAUD_RATE_5            #language en-US  "7200"\r
-                                       #language fr-FR  "7200"\r
-#string STR_COM_BAUD_RATE_6            #language en-US  "4800"\r
-                                       #language fr-FR  "4800"\r
-#string STR_COM_BAUD_RATE_7            #language en-US  "3600"\r
-                                       #language fr-FR  "3600"\r
-#string STR_COM_BAUD_RATE_8            #language en-US  "2400"\r
-                                       #language fr-FR  "2400"\r
-#string STR_COM_BAUD_RATE_9            #language en-US  "2000"\r
-                                       #language fr-FR  "2000"\r
-#string STR_COM_BAUD_RATE_10           #language en-US  "1800"\r
-                                       #language fr-FR  "1800"\r
-#string STR_COM_BAUD_RATE_11           #language en-US  "1200"\r
-                                       #language fr-FR  "1200"\r
-#string STR_COM_BAUD_RATE_12           #language en-US  "600"\r
-                                       #language fr-FR  "600"\r
-#string STR_COM_BAUD_RATE_13           #language en-US  "300"\r
-                                       #language fr-FR  "300"\r
-#string STR_COM_BAUD_RATE_14           #language en-US  "150"\r
-                                       #language fr-FR  "150"\r
-#string STR_COM_BAUD_RATE_15           #language en-US  "134"\r
-                                       #language fr-FR  "134"\r
-#string STR_COM_BAUD_RATE_16           #language en-US  "110"\r
-                                       #language fr-FR  "110"\r
-#string STR_COM_BAUD_RATE_17           #language en-US  "75"\r
-                                       #language fr-FR  "75"\r
-#string STR_COM_BAUD_RATE_18           #language en-US  "50"\r
-                                       #language fr-FR  "50"\r
-#string STR_COM_DATA_BITS_0            #language en-US  "5"\r
-                                       #language fr-FR  "5"\r
-#string STR_COM_DATA_BITS_1            #language en-US  "6"\r
-                                       #language fr-FR  "6"\r
-#string STR_COM_DATA_BITS_2            #language en-US  "7"\r
-                                       #language fr-FR  "7"\r
-#string STR_COM_DATA_BITS_3            #language en-US  "8"\r
-                                       #language fr-FR  "8"\r
-#string STR_COM_PAR_0                  #language en-US  "None"\r
-                                       #language fr-FR  "None"\r
-#string STR_COM_PAR_1                  #language en-US  "Even"\r
-                                       #language fr-FR  "Even"\r
-#string STR_COM_PAR_2                  #language en-US  "Odd"\r
-                                       #language fr-FR  "Odd"\r
-#string STR_COM_PAR_3                  #language en-US  "Mark"\r
-                                       #language fr-FR  "Mark"\r
-#string STR_COM_PAR_4                  #language en-US  "Space"\r
-                                       #language fr-FR  "Space"\r
-#string STR_COM_STOP_BITS_0            #language en-US  "One"\r
-                                       #language fr-FR  "One"\r
-#string STR_COM_STOP_BITS_1            #language en-US  "One And A Half"\r
-                                       #language fr-FR  "One And A Half"\r
-#string STR_COM_STOP_BITS_2            #language en-US  "Two"\r
-                                       #language fr-FR  "Two"\r
-#string STR_COM_TYPE_0                 #language en-US  "PC_ANSI"\r
-                                       #language fr-FR  "PC_ANSI"\r
-#string STR_COM_TYPE_1                 #language en-US  "VT_100"\r
-                                       #language fr-FR  "VT_100"\r
-#string STR_COM_TYPE_2                 #language en-US  "VT_100_PLUS"\r
-                                       #language fr-FR  "VT_100_PLUS"\r
-#string STR_COM_TYPE_3                 #language en-US  "VT_UTF8"\r
-                                       #language fr-FR  "VT_UTF8"\r
-#string STR_RESET                      #language en-US  "Reset System"\r
-                                       #language fr-FR  "Reset System"\r
-#string STR_FORM_GOTO_MAIN             #language en-US  "Go Back To Main Page"\r
-                                       #language fr-FR  "Go Back To Main Page"\r
-#string STR_BOOT_FROM_FILE             #language en-US  "Boot From File"\r
-                                       #language fr-FR  "Boot From File"\r
-#string STR_BOOT_FROM_FILE_HELP        #language en-US  "Boot system from a file or device"\r
-                                       #language fr-FR  "Boot system from a file or device"\r
-#string STR_OPTIONAL_DATA              #language en-US  "Input Optional Data"\r
-                                       #language fr-FR  "Input Optional Data"\r
-#string STR_CHANGE_ORDER               #language en-US  "Change the order"\r
-                                       #language fr-FR  "Change the order"\r
-#string STR_BOOT_LEGACY                #language en-US  "Boot Legacy System"\r
-                                       #language fr-FR  "Boot Legacy System"\r
-#string STR_BOOT_LEGACY_HELP           #language en-US  "Supports boot from legacy FD, HD, CD, PCMCIA, USB, and Network"\r
-                                       #language fr-FR  "Supports boot from legacy FD, HD, CD, PCMCIA, USB, and Network"\r
-#string STR_BOOT_LEGACY_FLOPPY         #language en-US  "Boot From Floppy"\r
-                                       #language fr-FR  "Boot From Floppy"\r
-#string STR_BOOT_LEGACY_HARDDRIVE      #language en-US  "Boot From Hard Drive"\r
-                                       #language fr-FR  "Boot From Hard Drive"\r
-#string STR_BOOT_LEGACY_CDROM          #language en-US  "Boot From CD Rom"\r
-                                       #language fr-FR  "Boot From CD Rom"\r
-#string STR_BOOT_LEGACY_PCMCIA         #language en-US  "Boot From PCMCIA"\r
-                                       #language fr-FR  "Boot From PCMCIA"\r
-#string STR_BOOT_LEGACY_USB            #language en-US  "Boot From USB Device"\r
-                                       #language fr-FR  "Boot From USB Device"\r
-#string STR_BOOT_LEGACY_NETWORK        #language en-US  "Boot From Network"\r
-                                       #language fr-FR  "Boot From Network"\r
-#string STR_DISABLE_LEGACY_DEVICE      #language en-US  "Disabled"\r
-                                       #language fr-FR  "Disabled"\r
-#string STR_FILE_EXPLORER_TITLE        #language en-US  "File Explorer"\r
-                                       #language fr-FR  "File Explorer"\r
-#string STR_HARDWARE_FLOW_CONTROL      #language fr-FR  "Hardware"\r
-                                       #language en-US  "Hardware"\r
-#string STR_NONE_FLOW_CONTROL          #language fr-FR  "None"\r
-                                       #language en-US  "None"\r
-//\r
-// BugBug : need someone to translate these strings to french\r
-//\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
deleted file mode 100644 (file)
index ea50502..0000000
+++ /dev/null
@@ -1,1684 +0,0 @@
-/** @file\r
-  The functions for Boot Maintainence Main menu.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BootMaint.h"\r
-#include "FormGuid.h"\r
-#include "Bds.h"\r
-#include "FrontPage.h"\r
-\r
-EFI_DEVICE_PATH_PROTOCOL  EndDevicePath[] = {\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      END_DEVICE_PATH_LENGTH,\r
-      0\r
-    }\r
-  }\r
-};\r
-\r
-HII_VENDOR_DEVICE_PATH  mBmmHiiVendorDevicePath = {\r
-  {\r
-    {\r
-      HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,\r
-      {\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    BOOT_MAINT_FORMSET_GUID\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      (UINT8) (END_DEVICE_PATH_LENGTH),\r
-      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
-    }\r
-  }\r
-};\r
-\r
-HII_VENDOR_DEVICE_PATH  mFeHiiVendorDevicePath = {\r
-  {\r
-    {\r
-      HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,\r
-      {\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    FILE_EXPLORE_FORMSET_GUID\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      (UINT8) (END_DEVICE_PATH_LENGTH),\r
-      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
-    }\r
-  }\r
-};\r
-\r
-CHAR16  mBootMaintStorageName[]     = L"BmmData";\r
-CHAR16  mFileExplorerStorageName[]  = L"FeData";\r
-BMM_CALLBACK_DATA *mBmmCallbackInfo = NULL;\r
-\r
-/**\r
-  Init all memu.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-InitAllMenu (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-/**\r
-  Free up all Menu Option list.\r
-\r
-**/\r
-VOID\r
-FreeAllMenu (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Initialize all of BMM configuration data in BmmFakeNvData and BmmOldFakeNVData member\r
-  in BMM context data and create all of dynamic OP code for BMM.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-InitializeBmmConfig (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT *NewLoadContext;\r
-  UINT16          Index;\r
-\r
-  ASSERT (CallbackData != NULL);\r
-\r
-  //\r
-  // Initialize data which located in BMM main page\r
-  //\r
-  CallbackData->BmmFakeNvData.BootNext = (UINT16) (BootOptionMenu.MenuNumber);\r
-  for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
-    NewMenuEntry    = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
-    NewLoadContext  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-\r
-    if (NewLoadContext->IsBootNext) {\r
-      CallbackData->BmmFakeNvData.BootNext = Index;\r
-      break;\r
-    }\r
-  }\r
-\r
-  CallbackData->BmmFakeNvData.BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);\r
-\r
-  //\r
-  // Initialize data which located in Boot Options Menu\r
-  //\r
-  GetBootOrder (CallbackData);\r
-  GetLegacyDeviceOrder (CallbackData);\r
-\r
-  //\r
-  // Initialize data which located in Driver Options Menu\r
-  //\r
-  GetDriverOrder (CallbackData);\r
-\r
-  //\r
-  // Initialize data which located in Console Options Menu\r
-  //\r
-  GetConsoleOutMode (CallbackData);\r
-  GetConsoleInCheck (CallbackData);\r
-  GetConsoleOutCheck (CallbackData);\r
-  GetConsoleErrCheck (CallbackData);\r
-  GetTerminalAttribute (CallbackData);\r
-\r
-  //\r
-  // Backup Initialize BMM configuartion data to BmmOldFakeNVData\r
-  //\r
-  CopyMem (&CallbackData->BmmOldFakeNVData, &CallbackData->BmmFakeNvData, sizeof (BMM_FAKE_NV_DATA));\r
-}\r
-\r
-/**\r
-  Create string tokens for a menu from its help strings and display strings\r
-\r
-  @param CallbackData       The BMM context data.\r
-  @param HiiHandle          Hii Handle of the package to be updated.\r
-  @param MenuOption         The Menu whose string tokens need to be created\r
-\r
-  @retval  EFI_SUCCESS      String tokens created successfully\r
-  @retval  others           contain some errors\r
-**/\r
-EFI_STATUS\r
-CreateMenuStringToken (\r
-  IN BMM_CALLBACK_DATA                *CallbackData,\r
-  IN EFI_HII_HANDLE                   HiiHandle,\r
-  IN BM_MENU_OPTION                   *MenuOption\r
-  )\r
-{\r
-  BM_MENU_ENTRY *NewMenuEntry;\r
-  UINTN         Index;\r
-\r
-  for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r
-    NewMenuEntry = BOpt_GetMenuEntry (MenuOption, Index);\r
-\r
-    NewMenuEntry->DisplayStringToken = HiiSetString (\r
-                                         HiiHandle,\r
-                                         0,\r
-                                         NewMenuEntry->DisplayString,\r
-                                         NULL\r
-                                         );\r
-\r
-    if (NULL == NewMenuEntry->HelpString) {\r
-      NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;\r
-    } else {\r
-      NewMenuEntry->HelpStringToken = HiiSetString (\r
-                                        HiiHandle,\r
-                                        0,\r
-                                        NewMenuEntry->HelpString,\r
-                                        NULL\r
-                                        );\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function allows a caller to extract the current configuration for one\r
-  or more named elements from the target driver.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Request         A null-terminated Unicode string in <ConfigRequest> format.\r
-  @param Progress        On return, points to a character in the Request string.\r
-                         Points to the string's null terminator if request was successful.\r
-                         Points to the most recent '&' before the first failing name/value\r
-                         pair (or the beginning of the string if the failure is in the\r
-                         first name/value pair) if the request was not successful.\r
-  @param Results         A null-terminated Unicode string in <ConfigAltResp> format which\r
-                         has all values filled in for the names in the Request string.\r
-                         String to be allocated by the called function.\r
-\r
-  @retval  EFI_SUCCESS            The Results is filled with the requested values.\r
-  @retval  EFI_OUT_OF_RESOURCES   Not enough memory to store the results.\r
-  @retval  EFI_INVALID_PARAMETER  Request is NULL, illegal syntax, or unknown name.\r
-  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BootMaintExtractConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Request,\r
-  OUT EFI_STRING                             *Progress,\r
-  OUT EFI_STRING                             *Results\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  UINTN              BufferSize;\r
-  BMM_CALLBACK_DATA  *Private;\r
-  EFI_STRING                       ConfigRequestHdr;\r
-  EFI_STRING                       ConfigRequest;\r
-  BOOLEAN                          AllocatedRequest;\r
-  UINTN                            Size;\r
-\r
-  if (Progress == NULL || Results == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *Progress = Request;\r
-  if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gBootMaintFormSetGuid, mBootMaintStorageName)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  ConfigRequestHdr = NULL;\r
-  ConfigRequest    = NULL;\r
-  AllocatedRequest = FALSE;\r
-  Size             = 0;\r
-\r
-  Private = BMM_CALLBACK_DATA_FROM_THIS (This);\r
-  //\r
-  // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
-  //\r
-  BufferSize = sizeof (BMM_FAKE_NV_DATA);\r
-  ConfigRequest = Request;\r
-  if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
-    //\r
-    // Request has no request element, construct full request string.\r
-    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
-    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
-    //\r
-    ConfigRequestHdr = HiiConstructConfigHdr (&gBootMaintFormSetGuid, mBootMaintStorageName, Private->BmmDriverHandle);\r
-    Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
-    ConfigRequest = AllocateZeroPool (Size);\r
-    ASSERT (ConfigRequest != NULL);\r
-    AllocatedRequest = TRUE;\r
-    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
-    FreePool (ConfigRequestHdr);\r
-  }\r
-\r
-  Status = gHiiConfigRouting->BlockToConfig (\r
-                                gHiiConfigRouting,\r
-                                ConfigRequest,\r
-                                (UINT8 *) &Private->BmmFakeNvData,\r
-                                BufferSize,\r
-                                Results,\r
-                                Progress\r
-                                );\r
-  //\r
-  // Free the allocated config request string.\r
-  //\r
-  if (AllocatedRequest) {\r
-    FreePool (ConfigRequest);\r
-    ConfigRequest = NULL;\r
-  }\r
-  //\r
-  // Set Progress string to the original request string.\r
-  //\r
-  if (Request == NULL) {\r
-    *Progress = NULL;\r
-  } else if (StrStr (Request, L"OFFSET") == NULL) {\r
-    *Progress = Request + StrLen (Request);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function applies changes in a driver's configuration.\r
-  Input is a Configuration, which has the routing data for this\r
-  driver followed by name / value configuration pairs. The driver\r
-  must apply those pairs to its configurable storage. If the\r
-  driver's configuration is stored in a linear block of data\r
-  and the driver's name / value pairs are in <BlockConfig>\r
-  format, it may use the ConfigToBlock helper function (above) to\r
-  simplify the job. Currently not implemented.\r
-\r
-  @param[in]  This                Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param[in]  Configuration       A null-terminated Unicode string in\r
-                                  <ConfigString> format.\r
-  @param[out] Progress            A pointer to a string filled in with the\r
-                                  offset of the most recent '&' before the\r
-                                  first failing name / value pair (or the\r
-                                  beginn ing of the string if the failure\r
-                                  is in the first name / value pair) or\r
-                                  the terminating NULL if all was\r
-                                  successful.\r
-\r
-  @retval EFI_SUCCESS             The results have been distributed or are\r
-                                  awaiting distribution.\r
-  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the\r
-                                  parts of the results that must be\r
-                                  stored awaiting possible future\r
-                                  protocols.\r
-  @retval EFI_INVALID_PARAMETERS  Passing in a NULL for the\r
-                                  Results parameter would result\r
-                                  in this type of error.\r
-  @retval EFI_NOT_FOUND           Target for the specified routing data\r
-                                  was not found.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BootMaintRouteConfig (\r
-  IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
-  IN CONST EFI_STRING                     Configuration,\r
-  OUT EFI_STRING                          *Progress\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  UINTN                           BufferSize;\r
-  EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;\r
-  BMM_FAKE_NV_DATA                *NewBmmData;\r
-  BMM_FAKE_NV_DATA                *OldBmmData;\r
-  BM_CONSOLE_CONTEXT              *NewConsoleContext;\r
-  BM_TERMINAL_CONTEXT             *NewTerminalContext;\r
-  BM_MENU_ENTRY                   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT                 *NewLoadContext;\r
-  UINT16                          Index;\r
-  BOOLEAN                         TerminalAttChange;\r
-  BMM_CALLBACK_DATA               *Private;\r
-\r
-  if (Progress == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  *Progress = Configuration;\r
-\r
-  if (Configuration == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Check routing data in <ConfigHdr>.\r
-  // Note: there is no name for Name/Value storage, only GUID will be checked\r
-  //\r
-  if (!HiiIsConfigHdrMatch (Configuration, &gBootMaintFormSetGuid, mBootMaintStorageName)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiHiiConfigRoutingProtocolGuid,\r
-                  NULL,\r
-                  (VOID**) &ConfigRouting\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Private = BMM_CALLBACK_DATA_FROM_THIS (This);\r
-  //\r
-  // Get Buffer Storage data from EFI variable\r
-  //\r
-  BufferSize = sizeof (BMM_FAKE_NV_DATA);\r
-  OldBmmData = &Private->BmmOldFakeNVData;\r
-  NewBmmData = &Private->BmmFakeNvData;\r
-  //\r
-  // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()\r
-  //\r
-  Status = ConfigRouting->ConfigToBlock (\r
-                            ConfigRouting,\r
-                            Configuration,\r
-                            (UINT8 *) NewBmmData,\r
-                            &BufferSize,\r
-                            Progress\r
-                            );\r
-  ASSERT_EFI_ERROR (Status);\r
-  //\r
-  // Compare new and old BMM configuration data and only do action for modified item to\r
-  // avoid setting unnecessary non-volatile variable\r
-  //\r
-\r
-  //\r
-  // Check data which located in BMM main page and save the settings if need\r
-  //\r
-  if (CompareMem (NewBmmData->LegacyFD, OldBmmData->LegacyFD, sizeof (NewBmmData->LegacyFD)) != 0) {\r
-    Var_UpdateBBSOption (Private, FORM_SET_FD_ORDER_ID);\r
-  }\r
-\r
-  if (CompareMem (NewBmmData->LegacyHD, OldBmmData->LegacyHD, sizeof (NewBmmData->LegacyHD)) != 0) {\r
-    Var_UpdateBBSOption (Private, FORM_SET_HD_ORDER_ID);\r
-  }\r
-\r
-  if (CompareMem (NewBmmData->LegacyCD, OldBmmData->LegacyCD, sizeof (NewBmmData->LegacyCD)) != 0) {\r
-    Var_UpdateBBSOption (Private, FORM_SET_CD_ORDER_ID);\r
-  }\r
-\r
-  if (CompareMem (NewBmmData->LegacyNET, OldBmmData->LegacyNET, sizeof (NewBmmData->LegacyNET)) != 0) {\r
-    Var_UpdateBBSOption (Private, FORM_SET_NET_ORDER_ID);\r
-  }\r
-\r
-  if (CompareMem (NewBmmData->LegacyBEV, OldBmmData->LegacyBEV, sizeof (NewBmmData->LegacyBEV)) != 0) {\r
-    Var_UpdateBBSOption (Private, FORM_SET_BEV_ORDER_ID);\r
-  }\r
-\r
-  //\r
-  // Change for "delete boot option" page need update NewBmmData->BootOptionOrder, so process\r
-  // NewBmmData->BootOptionOrder before NewBmmData->BootOptionDel\r
-  //\r
-  if (CompareMem (NewBmmData->BootOptionOrder, OldBmmData->BootOptionOrder, sizeof (NewBmmData->BootOptionOrder)) != 0) {\r
-    Status = Var_UpdateBootOrder (Private);\r
-  }\r
-\r
-  //\r
-  // Change for "delete driver option" page need update NewBmmData->DriverOptionOrder, so process\r
-  // NewBmmData->DriverOptionOrder before NewBmmData->DriverOptionDel\r
-  //\r
-  if (CompareMem (NewBmmData->DriverOptionOrder, OldBmmData->DriverOptionOrder, sizeof (NewBmmData->DriverOptionOrder)) != 0) {\r
-    Status = Var_UpdateDriverOrder (Private);\r
-  }\r
-\r
-  //\r
-  // Check data which located in Boot Options Menu and save the settings if need\r
-  //\r
-  if (CompareMem (NewBmmData->BootOptionDel, OldBmmData->BootOptionDel, sizeof (NewBmmData->BootOptionDel)) != 0) {\r
-    for (Index = 0;\r
-         ((Index < BootOptionMenu.MenuNumber) && (Index < (sizeof (NewBmmData->BootOptionDel) / sizeof (NewBmmData->BootOptionDel[0]))));\r
-         Index ++) {\r
-      NewMenuEntry            = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
-      NewLoadContext          = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-      NewLoadContext->Deleted = NewBmmData->BootOptionDel[Index];\r
-      NewBmmData->BootOptionDel[Index] = FALSE;\r
-      NewBmmData->BootOptionDelMark[Index] = FALSE;\r
-    }\r
-\r
-    Var_DelBootOption ();\r
-  }\r
-\r
-  //\r
-  // Check data which located in Driver Options Menu and save the settings if need\r
-  //\r
-  if (CompareMem (NewBmmData->DriverOptionDel, OldBmmData->DriverOptionDel, sizeof (NewBmmData->DriverOptionDel)) != 0) {\r
-    for (Index = 0;\r
-         ((Index < DriverOptionMenu.MenuNumber) && (Index < (sizeof (NewBmmData->DriverOptionDel) / sizeof (NewBmmData->DriverOptionDel[0]))));\r
-         Index++) {\r
-      NewMenuEntry            = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
-      NewLoadContext          = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-      NewLoadContext->Deleted = NewBmmData->DriverOptionDel[Index];\r
-      NewBmmData->DriverOptionDel[Index] = FALSE;\r
-      NewBmmData->DriverOptionDelMark[Index] = FALSE;\r
-    }\r
-    Var_DelDriverOption ();\r
-  }\r
-\r
-  if (CompareMem (&NewBmmData->BootTimeOut, &OldBmmData->BootTimeOut, sizeof (NewBmmData->BootTimeOut)) != 0) {\r
-    Status = gRT->SetVariable (\r
-                    L"Timeout",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    sizeof (UINT16),\r
-                    &(NewBmmData->BootTimeOut)\r
-                    );\r
-    ASSERT_EFI_ERROR(Status);\r
-\r
-    //\r
-    // Bugbug: code not exit in UiApp but in IntelFrameworkModulePkg, need do more check.\r
-    //\r
-    Private->BmmOldFakeNVData.BootTimeOut = NewBmmData->BootTimeOut;\r
-  }\r
-\r
-  if (CompareMem (&NewBmmData->BootNext, &OldBmmData->BootNext, sizeof (NewBmmData->BootNext)) != 0) {\r
-    Status = Var_UpdateBootNext (Private);\r
-  }\r
-\r
-  if (CompareMem (&NewBmmData->ConsoleOutMode, &OldBmmData->ConsoleOutMode, sizeof (NewBmmData->ConsoleOutMode)) != 0) {\r
-    Var_UpdateConMode (Private);\r
-  }\r
-\r
-  TerminalAttChange = FALSE;\r
-  for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
-\r
-    //\r
-    // only need update modified items\r
-    //\r
-    if (CompareMem (&NewBmmData->COMBaudRate[Index], &OldBmmData->COMBaudRate[Index], sizeof (NewBmmData->COMBaudRate[Index])) == 0 &&\r
-         CompareMem (&NewBmmData->COMDataRate[Index], &OldBmmData->COMDataRate[Index], sizeof (NewBmmData->COMDataRate[Index])) == 0 &&\r
-         CompareMem (&NewBmmData->COMStopBits[Index], &OldBmmData->COMStopBits[Index], sizeof (NewBmmData->COMStopBits[Index])) == 0 &&\r
-         CompareMem (&NewBmmData->COMParity[Index], &OldBmmData->COMParity[Index], sizeof (NewBmmData->COMParity[Index])) == 0 &&\r
-         CompareMem (&NewBmmData->COMTerminalType[Index], &OldBmmData->COMTerminalType[Index], sizeof (NewBmmData->COMTerminalType[Index])) == 0 &&\r
-         CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmmData->COMFlowControl[Index], sizeof (NewBmmData->COMFlowControl[Index])) == 0) {\r
-      continue;\r
-    }\r
-\r
-    NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
-    ASSERT (NewMenuEntry != NULL);\r
-    NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
-    NewTerminalContext->BaudRateIndex = NewBmmData->COMBaudRate[Index];\r
-    ASSERT (NewBmmData->COMBaudRate[Index] < (ARRAY_SIZE (BaudRateList)));\r
-    NewTerminalContext->BaudRate      = BaudRateList[NewBmmData->COMBaudRate[Index]].Value;\r
-    NewTerminalContext->DataBitsIndex = NewBmmData->COMDataRate[Index];\r
-    ASSERT (NewBmmData->COMDataRate[Index] < (ARRAY_SIZE (DataBitsList)));\r
-    NewTerminalContext->DataBits      = (UINT8) DataBitsList[NewBmmData->COMDataRate[Index]].Value;\r
-    NewTerminalContext->StopBitsIndex = NewBmmData->COMStopBits[Index];\r
-    ASSERT (NewBmmData->COMStopBits[Index] < (ARRAY_SIZE (StopBitsList)));\r
-    NewTerminalContext->StopBits      = (UINT8) StopBitsList[NewBmmData->COMStopBits[Index]].Value;\r
-    NewTerminalContext->ParityIndex   = NewBmmData->COMParity[Index];\r
-    ASSERT (NewBmmData->COMParity[Index] < (ARRAY_SIZE (ParityList)));\r
-    NewTerminalContext->Parity        = (UINT8) ParityList[NewBmmData->COMParity[Index]].Value;\r
-    NewTerminalContext->TerminalType  = NewBmmData->COMTerminalType[Index];\r
-    NewTerminalContext->FlowControl   = NewBmmData->COMFlowControl[Index];\r
-    ChangeTerminalDevicePath (\r
-      &(NewTerminalContext->DevicePath),\r
-      FALSE\r
-      );\r
-    TerminalAttChange = TRUE;\r
-  }\r
-  if (TerminalAttChange) {\r
-    Var_UpdateConsoleInpOption ();\r
-    Var_UpdateConsoleOutOption ();\r
-    Var_UpdateErrorOutOption ();\r
-  }\r
-\r
-  //\r
-  // Check data which located in Console Options Menu and save the settings if need\r
-  //\r
-  if (CompareMem (NewBmmData->ConsoleInCheck, OldBmmData->ConsoleInCheck, sizeof (NewBmmData->ConsoleInCheck)) != 0) {\r
-    for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++) {\r
-      NewMenuEntry                = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);\r
-      NewConsoleContext           = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-      ASSERT (Index < MAX_MENU_NUMBER);\r
-      NewConsoleContext->IsActive = NewBmmData->ConsoleInCheck[Index];\r
-    }\r
-\r
-    Var_UpdateConsoleInpOption ();\r
-  }\r
-\r
-  if (CompareMem (NewBmmData->ConsoleOutCheck, OldBmmData->ConsoleOutCheck, sizeof (NewBmmData->ConsoleOutCheck)) != 0) {\r
-    for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++) {\r
-      NewMenuEntry                = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);\r
-      NewConsoleContext           = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-      ASSERT (Index < MAX_MENU_NUMBER);\r
-      NewConsoleContext->IsActive = NewBmmData->ConsoleOutCheck[Index];\r
-    }\r
-\r
-    Var_UpdateConsoleOutOption ();\r
-  }\r
-\r
-  if (CompareMem (NewBmmData->ConsoleErrCheck, OldBmmData->ConsoleErrCheck, sizeof (NewBmmData->ConsoleErrCheck)) != 0) {\r
-    for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++) {\r
-      NewMenuEntry                = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);\r
-      NewConsoleContext           = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-      ASSERT (Index < MAX_MENU_NUMBER);\r
-      NewConsoleContext->IsActive = NewBmmData->ConsoleErrCheck[Index];\r
-    }\r
-\r
-    Var_UpdateErrorOutOption ();\r
-  }\r
-\r
-  //\r
-  // After user do the save action, need to update OldBmmData.\r
-  //\r
-  CopyMem (OldBmmData, NewBmmData, sizeof (BMM_FAKE_NV_DATA));\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Create GoTo OP code into FORM_BOOT_LEGACY_DEVICE label for legacy boot option.\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeLegacyBootOption (\r
-  VOID\r
-  )\r
-{\r
-  RefreshUpdateData ();\r
-  mStartLabel->Number = FORM_BOOT_LEGACY_DEVICE_ID;\r
-\r
-  //\r
-  // If LegacyBios Protocol is installed, add 3 tags about legacy boot option\r
-  // in BootOption form: legacy FD/HD/CD/NET/BEV\r
-  //\r
-  HiiCreateGotoOpCode (\r
-    mStartOpCodeHandle,\r
-    FORM_SET_FD_ORDER_ID,\r
-    STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE),\r
-    STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE),\r
-    EFI_IFR_FLAG_CALLBACK,\r
-    FORM_SET_FD_ORDER_ID\r
-    );\r
-\r
-  HiiCreateGotoOpCode (\r
-    mStartOpCodeHandle,\r
-    FORM_SET_HD_ORDER_ID,\r
-    STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE),\r
-    STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE),\r
-    EFI_IFR_FLAG_CALLBACK,\r
-    FORM_SET_HD_ORDER_ID\r
-    );\r
-\r
-  HiiCreateGotoOpCode (\r
-    mStartOpCodeHandle,\r
-    FORM_SET_CD_ORDER_ID,\r
-    STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE),\r
-    STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE),\r
-    EFI_IFR_FLAG_CALLBACK,\r
-    FORM_SET_CD_ORDER_ID\r
-    );\r
-\r
-  HiiCreateGotoOpCode (\r
-    mStartOpCodeHandle,\r
-    FORM_SET_NET_ORDER_ID,\r
-    STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE),\r
-    STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE),\r
-    EFI_IFR_FLAG_CALLBACK,\r
-    FORM_SET_NET_ORDER_ID\r
-    );\r
-\r
-  HiiCreateGotoOpCode (\r
-    mStartOpCodeHandle,\r
-    FORM_SET_BEV_ORDER_ID,\r
-    STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE),\r
-    STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE),\r
-    EFI_IFR_FLAG_CALLBACK,\r
-    FORM_SET_BEV_ORDER_ID\r
-    );\r
-\r
-  HiiUpdateForm (\r
-    mBmmCallbackInfo->BmmHiiHandle,\r
-    &gBootMaintFormSetGuid,\r
-    FORM_BOOT_SETUP_ID,\r
-    mStartOpCodeHandle, // Label FORM_BOOT_LEGACY_DEVICE_ID\r
-    mEndOpCodeHandle    // LABEL_END\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-\r
-\r
-  @param This               Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action             Specifies the type of action taken by the browser.\r
-  @param QuestionId         A unique value which is sent to the original exporting driver\r
-                            so that it can identify the type of data to expect.\r
-  @param Type               The type of value for the question.\r
-  @param Value              A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest      On return, points to the action requested by the callback function.\r
-\r
-  @retval EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval EFI_OUT_OF_RESOURCES  Not enough storage is available to hold the variable and its data.\r
-  @retval EFI_DEVICE_ERROR      The variable could not be saved.\r
-  @retval EFI_UNSUPPORTED       The specified Action is not supported by the callback.\r
-  @retval EFI_INVALID_PARAMETER The parameter of Value or ActionRequest is invalid.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BootMaintCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL         *This,\r
-  IN        EFI_BROWSER_ACTION                     Action,\r
-  IN        EFI_QUESTION_ID                        QuestionId,\r
-  IN        UINT8                                  Type,\r
-  IN        EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT       EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  )\r
-{\r
-  BMM_CALLBACK_DATA *Private;\r
-  BM_MENU_ENTRY     *NewMenuEntry;\r
-  BMM_FAKE_NV_DATA  *CurrentFakeNVMap;\r
-  EFI_STATUS        Status;\r
-  UINTN             OldValue;\r
-  UINTN             NewValue;\r
-  UINTN             Number;\r
-  UINTN             Pos;\r
-  UINTN             Bit;\r
-  UINT16            NewValuePos;\r
-  UINT16            Index3;\r
-  UINT16            Index2;\r
-  UINT16            Index;\r
-  UINT8             *OldLegacyDev;\r
-  UINT8             *NewLegacyDev;\r
-  UINT8             *DisMap;\r
-  EFI_LEGACY_BIOS_PROTOCOL    *LegacyBios;\r
-\r
-  Private = BMM_CALLBACK_DATA_FROM_THIS (This);\r
-  if (Action == EFI_BROWSER_ACTION_FORM_OPEN && QuestionId == FORM_BOOT_SETUP_ID) {\r
-    //\r
-    // Initilize Form for legacy boot option.\r
-    //\r
-    Status = EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid, (VOID **) &LegacyBios);\r
-    if (!EFI_ERROR (Status)) {\r
-      InitializeLegacyBootOption ();\r
-    }\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {\r
-    //\r
-    // All other action return unsupported.\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status       = EFI_SUCCESS;\r
-  OldValue     = 0;\r
-  NewValue     = 0;\r
-  Number       = 0;\r
-  OldLegacyDev = NULL;\r
-  NewLegacyDev = NULL;\r
-  NewValuePos  = 0;\r
-  DisMap       = NULL;\r
-\r
-  Private      = BMM_CALLBACK_DATA_FROM_THIS (This);\r
-  //\r
-  // Retrieve uncommitted data from Form Browser\r
-  //\r
-  CurrentFakeNVMap = &Private->BmmFakeNvData;\r
-  HiiGetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap);\r
-  if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
-    if (Value == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    UpdatePageId (Private, QuestionId);\r
-\r
-    if (QuestionId < FILE_OPTION_OFFSET) {\r
-      if (QuestionId < CONFIG_OPTION_OFFSET) {\r
-        switch (QuestionId) {\r
-        case KEY_VALUE_BOOT_FROM_FILE:\r
-          Private->FeCurrentState = FileExplorerStateBootFromFile;\r
-          break;\r
-\r
-        case FORM_BOOT_ADD_ID:\r
-          Private->FeCurrentState = FileExplorerStateAddBootOption;\r
-          break;\r
-\r
-        case FORM_DRV_ADD_FILE_ID:\r
-          Private->FeCurrentState = FileExplorerStateAddDriverOptionState;\r
-          break;\r
-\r
-        case FORM_DRV_ADD_HANDLE_ID:\r
-          CleanUpPage (FORM_DRV_ADD_HANDLE_ID, Private);\r
-          UpdateDrvAddHandlePage (Private);\r
-          break;\r
-\r
-        case FORM_BOOT_DEL_ID:\r
-          CleanUpPage (FORM_BOOT_DEL_ID, Private);\r
-          UpdateBootDelPage (Private);\r
-          break;\r
-\r
-        case FORM_BOOT_CHG_ID:\r
-        case FORM_DRV_CHG_ID:\r
-          UpdatePageBody (QuestionId, Private);\r
-          break;\r
-\r
-        case FORM_DRV_DEL_ID:\r
-          CleanUpPage (FORM_DRV_DEL_ID, Private);\r
-          UpdateDrvDelPage (Private);\r
-          break;\r
-\r
-        case FORM_BOOT_NEXT_ID:\r
-          CleanUpPage (FORM_BOOT_NEXT_ID, Private);\r
-          UpdateBootNextPage (Private);\r
-          break;\r
-\r
-        case FORM_TIME_OUT_ID:\r
-          CleanUpPage (FORM_TIME_OUT_ID, Private);\r
-          UpdateTimeOutPage (Private);\r
-          break;\r
-\r
-        case FORM_CON_IN_ID:\r
-        case FORM_CON_OUT_ID:\r
-        case FORM_CON_ERR_ID:\r
-          UpdatePageBody (QuestionId, Private);\r
-          break;\r
-\r
-        case FORM_CON_MODE_ID:\r
-          CleanUpPage (FORM_CON_MODE_ID, Private);\r
-          UpdateConModePage (Private);\r
-          break;\r
-\r
-        case FORM_CON_COM_ID:\r
-          CleanUpPage (FORM_CON_COM_ID, Private);\r
-          UpdateConCOMPage (Private);\r
-          break;\r
-\r
-        case FORM_SET_FD_ORDER_ID:\r
-        case FORM_SET_HD_ORDER_ID:\r
-        case FORM_SET_CD_ORDER_ID:\r
-        case FORM_SET_NET_ORDER_ID:\r
-        case FORM_SET_BEV_ORDER_ID:\r
-          CleanUpPage (QuestionId, Private);\r
-          UpdateSetLegacyDeviceOrderPage (QuestionId, Private);\r
-          break;\r
-\r
-        default:\r
-          break;\r
-        }\r
-      } else if ((QuestionId >= TERMINAL_OPTION_OFFSET) && (QuestionId < CONSOLE_OPTION_OFFSET)) {\r
-        Index2                    = (UINT16) (QuestionId - TERMINAL_OPTION_OFFSET);\r
-        Private->CurrentTerminal  = Index2;\r
-\r
-        CleanUpPage (FORM_CON_COM_SETUP_ID, Private);\r
-        UpdateTerminalPage (Private);\r
-\r
-      } else if (QuestionId >= HANDLE_OPTION_OFFSET) {\r
-        Index2                  = (UINT16) (QuestionId - HANDLE_OPTION_OFFSET);\r
-\r
-        NewMenuEntry            = BOpt_GetMenuEntry (&DriverMenu, Index2);\r
-        ASSERT (NewMenuEntry != NULL);\r
-        Private->HandleContext  = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-\r
-        CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID, Private);\r
-\r
-        Private->MenuEntry                  = NewMenuEntry;\r
-        Private->LoadContext->FilePathList  = Private->HandleContext->DevicePath;\r
-\r
-        UpdateDriverAddHandleDescPage (Private);\r
-      }\r
-    }\r
-  } else if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
-    if ((Value == NULL) || (ActionRequest == NULL)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    if ((QuestionId >= BOOT_OPTION_DEL_QUESTION_ID) && (QuestionId < BOOT_OPTION_DEL_QUESTION_ID + MAX_MENU_NUMBER)) {\r
-      if (Value->b){\r
-        //\r
-        // Means user try to delete this boot option but not press F10 or "Commit Changes and Exit" menu.\r
-        //\r
-        CurrentFakeNVMap->BootOptionDelMark[QuestionId - BOOT_OPTION_DEL_QUESTION_ID] = TRUE;\r
-      } else {\r
-        //\r
-        // Means user remove the old check status.\r
-        //\r
-        CurrentFakeNVMap->BootOptionDelMark[QuestionId - BOOT_OPTION_DEL_QUESTION_ID] = FALSE;\r
-      }\r
-    } else if ((QuestionId >= DRIVER_OPTION_DEL_QUESTION_ID) && (QuestionId < DRIVER_OPTION_DEL_QUESTION_ID + MAX_MENU_NUMBER)) {\r
-      if (Value->b){\r
-        CurrentFakeNVMap->DriverOptionDelMark[QuestionId - DRIVER_OPTION_DEL_QUESTION_ID] = TRUE;\r
-      } else {\r
-        CurrentFakeNVMap->DriverOptionDelMark[QuestionId - DRIVER_OPTION_DEL_QUESTION_ID] = FALSE;\r
-      }\r
-    } else if ((QuestionId >= LEGACY_FD_QUESTION_ID) && (QuestionId < LEGACY_BEV_QUESTION_ID + MAX_MENU_NUMBER)) {\r
-      //\r
-      // Update Select FD/HD/CD/NET/BEV Order Form\r
-      //\r
-\r
-      DisMap  = Private->BmmOldFakeNVData.DisableMap;\r
-\r
-      if (QuestionId >= LEGACY_FD_QUESTION_ID && QuestionId < LEGACY_FD_QUESTION_ID + MAX_MENU_NUMBER) {\r
-        Number        = (UINT16) LegacyFDMenu.MenuNumber;\r
-        OldLegacyDev  = Private->BmmOldFakeNVData.LegacyFD;\r
-        NewLegacyDev  = CurrentFakeNVMap->LegacyFD;\r
-      } else if (QuestionId >= LEGACY_HD_QUESTION_ID && QuestionId < LEGACY_HD_QUESTION_ID + MAX_MENU_NUMBER) {\r
-        Number        = (UINT16) LegacyHDMenu.MenuNumber;\r
-        OldLegacyDev  = Private->BmmOldFakeNVData.LegacyHD;\r
-        NewLegacyDev  = CurrentFakeNVMap->LegacyHD;\r
-      } else if (QuestionId >= LEGACY_CD_QUESTION_ID && QuestionId < LEGACY_CD_QUESTION_ID + MAX_MENU_NUMBER) {\r
-        Number        = (UINT16) LegacyCDMenu.MenuNumber;\r
-        OldLegacyDev  = Private->BmmOldFakeNVData.LegacyCD;\r
-        NewLegacyDev  = CurrentFakeNVMap->LegacyCD;\r
-      } else if (QuestionId >= LEGACY_NET_QUESTION_ID && QuestionId < LEGACY_NET_QUESTION_ID + MAX_MENU_NUMBER) {\r
-        Number        = (UINT16) LegacyNETMenu.MenuNumber;\r
-        OldLegacyDev  = Private->BmmOldFakeNVData.LegacyNET;\r
-        NewLegacyDev  = CurrentFakeNVMap->LegacyNET;\r
-      } else if (QuestionId >= LEGACY_BEV_QUESTION_ID && QuestionId < LEGACY_BEV_QUESTION_ID + MAX_MENU_NUMBER) {\r
-        Number        = (UINT16) LegacyBEVMenu.MenuNumber;\r
-        OldLegacyDev  = Private->BmmOldFakeNVData.LegacyBEV;\r
-        NewLegacyDev  = CurrentFakeNVMap->LegacyBEV;\r
-      }\r
-      //\r
-      //  First, find the different position\r
-      //  if there is change, it should be only one\r
-      //\r
-      for (Index = 0; Index < Number; Index++) {\r
-        if (OldLegacyDev[Index] != NewLegacyDev[Index]) {\r
-          OldValue  = OldLegacyDev[Index];\r
-          NewValue  = NewLegacyDev[Index];\r
-          break;\r
-        }\r
-      }\r
-\r
-      if (Index != Number) {\r
-        //\r
-        // there is change, now process\r
-        //\r
-        if (0xFF == NewValue) {\r
-          //\r
-          // This item will be disable\r
-          // Just move the items behind this forward to overlap it\r
-          //\r
-          Pos = OldValue / 8;\r
-          Bit = 7 - (OldValue % 8);\r
-          DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit));\r
-          for (Index2 = Index; Index2 < Number - 1; Index2++) {\r
-            NewLegacyDev[Index2] = NewLegacyDev[Index2 + 1];\r
-          }\r
-\r
-          NewLegacyDev[Index2] = 0xFF;\r
-        } else {\r
-          for (Index2 = 0; Index2 < Number; Index2++) {\r
-            if (Index2 == Index) {\r
-              continue;\r
-            }\r
-\r
-            if (OldLegacyDev[Index2] == NewValue) {\r
-              //\r
-              // If NewValue is in OldLegacyDev array\r
-              // remember its old position\r
-              //\r
-              NewValuePos = Index2;\r
-              break;\r
-            }\r
-          }\r
-\r
-          if (Index2 != Number) {\r
-            //\r
-            // We will change current item to an existing item\r
-            // (It's hard to describe here, please read code, it's like a cycle-moving)\r
-            //\r
-            for (Index2 = NewValuePos; Index2 != Index;) {\r
-              if (NewValuePos < Index) {\r
-                NewLegacyDev[Index2] = OldLegacyDev[Index2 + 1];\r
-                Index2++;\r
-              } else {\r
-                NewLegacyDev[Index2] = OldLegacyDev[Index2 - 1];\r
-                Index2--;\r
-              }\r
-            }\r
-          } else {\r
-            //\r
-            // If NewValue is not in OldlegacyDev array, we are changing to a disabled item\r
-            // so we should modify DisMap to reflect the change\r
-            //\r
-            Pos = NewValue / 8;\r
-            Bit = 7 - (NewValue % 8);\r
-            DisMap[Pos] = (UINT8) (DisMap[Pos] & (~ (UINT8) (1 << Bit)));\r
-            if (0xFF != OldValue) {\r
-              //\r
-              // Because NewValue is a item that was disabled before\r
-              // so after changing the OldValue should be disabled\r
-              // actually we are doing a swap of enable-disable states of two items\r
-              //\r
-              Pos = OldValue / 8;\r
-              Bit = 7 - (OldValue % 8);\r
-              DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit));\r
-            }\r
-          }\r
-        }\r
-        //\r
-        // To prevent DISABLE appears in the middle of the list\r
-        // we should perform a re-ordering\r
-        //\r
-        Index3 = Index;\r
-        Index = 0;\r
-        while (Index < Number) {\r
-          if (0xFF != NewLegacyDev[Index]) {\r
-            Index++;\r
-            continue;\r
-          }\r
-\r
-          Index2 = Index;\r
-          Index2++;\r
-          while (Index2 < Number) {\r
-            if (0xFF != NewLegacyDev[Index2]) {\r
-              break;\r
-            }\r
-\r
-            Index2++;\r
-          }\r
-\r
-          if (Index2 < Number) {\r
-            NewLegacyDev[Index]   = NewLegacyDev[Index2];\r
-            NewLegacyDev[Index2]  = 0xFF;\r
-          }\r
-\r
-          Index++;\r
-        }\r
-\r
-        //\r
-        //  Return correct question value.\r
-        //\r
-        Value->u8 = NewLegacyDev[Index3];\r
-      }\r
-    } else {\r
-      switch (QuestionId) {\r
-      case KEY_VALUE_SAVE_AND_EXIT:\r
-        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
-        break;\r
-\r
-      case KEY_VALUE_NO_SAVE_AND_EXIT:\r
-        //\r
-        // Restore local maintain data.\r
-        //\r
-        DiscardChangeHandler (Private, CurrentFakeNVMap);\r
-        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;\r
-        break;\r
-\r
-      case FORM_RESET:\r
-        gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
-        return EFI_UNSUPPORTED;\r
-\r
-      default:\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Pass changed uncommitted data back to Form Browser\r
-  //\r
-  HiiSetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap, NULL);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Discard all changes done to the BMM pages such as Boot Order change,\r
-  Driver order change.\r
-\r
-  @param Private            The BMM context data.\r
-  @param CurrentFakeNVMap   The current Fack NV Map.\r
-\r
-**/\r
-VOID\r
-DiscardChangeHandler (\r
-  IN  BMM_CALLBACK_DATA               *Private,\r
-  IN  BMM_FAKE_NV_DATA                *CurrentFakeNVMap\r
-  )\r
-{\r
-  UINT16  Index;\r
-\r
-  switch (Private->BmmPreviousPageId) {\r
-  case FORM_BOOT_CHG_ID:\r
-    CopyMem (CurrentFakeNVMap->BootOptionOrder, Private->BmmOldFakeNVData.BootOptionOrder, sizeof (CurrentFakeNVMap->BootOptionOrder));\r
-    break;\r
-\r
-  case FORM_DRV_CHG_ID:\r
-    CopyMem (CurrentFakeNVMap->DriverOptionOrder, Private->BmmOldFakeNVData.DriverOptionOrder, sizeof (CurrentFakeNVMap->DriverOptionOrder));\r
-    break;\r
-\r
-  case FORM_BOOT_DEL_ID:\r
-    ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->BootOptionDel) / sizeof (CurrentFakeNVMap->BootOptionDel[0])));\r
-    for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
-      CurrentFakeNVMap->BootOptionDel[Index] = FALSE;\r
-      CurrentFakeNVMap->BootOptionDelMark[Index] = FALSE;\r
-    }\r
-    break;\r
-\r
-  case FORM_DRV_DEL_ID:\r
-    ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->DriverOptionDel) / sizeof (CurrentFakeNVMap->DriverOptionDel[0])));\r
-    for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
-      CurrentFakeNVMap->DriverOptionDel[Index] = FALSE;\r
-      CurrentFakeNVMap->DriverOptionDelMark[Index] = FALSE;\r
-    }\r
-    break;\r
-\r
-  case FORM_BOOT_NEXT_ID:\r
-    CurrentFakeNVMap->BootNext = Private->BmmOldFakeNVData.BootNext;\r
-    break;\r
-\r
-  case FORM_TIME_OUT_ID:\r
-    CurrentFakeNVMap->BootTimeOut = Private->BmmOldFakeNVData.BootTimeOut;\r
-    break;\r
-\r
-  case FORM_DRV_ADD_HANDLE_DESC_ID:\r
-  case FORM_DRV_ADD_FILE_ID:\r
-  case FORM_DRV_ADD_HANDLE_ID:\r
-    CurrentFakeNVMap->DriverAddHandleDesc[0]          = 0x0000;\r
-    CurrentFakeNVMap->DriverAddHandleOptionalData[0]  = 0x0000;\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-}\r
-\r
-/**\r
-  Initialize the Boot Maintenance Utitliy.\r
-\r
-\r
-  @retval  EFI_SUCCESS      utility ended successfully\r
-  @retval  others           contain some errors\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeBM (\r
-  VOID\r
-  )\r
-{\r
-  BMM_CALLBACK_DATA           *BmmCallbackInfo;\r
-  EFI_STATUS                  Status;\r
-  EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;\r
-  UINT32                      Length;\r
-  UINT8                       *Data;\r
-\r
-  Status = EFI_SUCCESS;\r
-  BmmCallbackInfo = mBmmCallbackInfo;\r
-\r
-  BmmCallbackInfo->BmmPreviousPageId             = FORM_MAIN_ID;\r
-  BmmCallbackInfo->BmmCurrentPageId              = FORM_MAIN_ID;\r
-  BmmCallbackInfo->FeCurrentState                = FileExplorerStateInActive;\r
-  BmmCallbackInfo->FeDisplayContext              = FileExplorerDisplayUnknown;\r
-\r
-  //\r
-  // Reinstall String packages to include more new strings.\r
-  //\r
-\r
-  //\r
-  // String package size\r
-  //\r
-  Length = ReadUnaligned32 ((UINT32 *) BdsDxeStrings) - sizeof (UINT32);\r
-\r
-  //\r
-  // Add the length of the Package List Header and the terminating Package Header\r
-  //\r
-  Length += sizeof (EFI_HII_PACKAGE_LIST_HEADER) + sizeof (EFI_HII_PACKAGE_HEADER);\r
-\r
-  //\r
-  // Allocate the storage for the entire Package List\r
-  //\r
-  PackageListHeader = AllocateZeroPool (Length);\r
-\r
-  //\r
-  // If the Package List can not be allocated, then return a NULL HII Handle\r
-  //\r
-  if (PackageListHeader == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Fill in the GUID and Length of the Package List Header\r
-  //\r
-  PackageListHeader->PackageLength = Length;\r
-\r
-  //\r
-  // Copy String Data into Package list.\r
-  //\r
-  Data = (UINT8 *)(PackageListHeader + 1);\r
-  Length = ReadUnaligned32 ((UINT32 *) BdsDxeStrings) - sizeof (UINT32);\r
-  CopyMem (Data, (UINT8 *) BdsDxeStrings + sizeof (UINT32), Length);\r
-\r
-  //\r
-  // Add End type HII package.\r
-  //\r
-  Data += Length;\r
-  ((EFI_HII_PACKAGE_HEADER *) Data)->Type   = EFI_HII_PACKAGE_END;\r
-  ((EFI_HII_PACKAGE_HEADER *) Data)->Length = sizeof (EFI_HII_PACKAGE_HEADER);\r
-\r
-  //\r
-  // Update String package for BM\r
-  //\r
-  CopyGuid (&PackageListHeader->PackageListGuid, &gBootMaintFormSetGuid);\r
-  Status = gHiiDatabase->UpdatePackageList (gHiiDatabase, BmmCallbackInfo->BmmHiiHandle, PackageListHeader);\r
-\r
-  //\r
-  // Update String package for FE.\r
-  //\r
-  CopyGuid (&PackageListHeader->PackageListGuid, &gFileExploreFormSetGuid);\r
-  Status = gHiiDatabase->UpdatePackageList (gHiiDatabase, BmmCallbackInfo->FeHiiHandle, PackageListHeader);\r
-\r
-  FreePool (PackageListHeader);\r
-\r
-  //\r
-  // Init OpCode Handle and Allocate space for creation of Buffer\r
-  //\r
-  mStartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  if (mStartOpCodeHandle == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Exit;\r
-  }\r
-\r
-  mEndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  if (mEndOpCodeHandle == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Exit;\r
-  }\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mStartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the end opcode\r
-  //\r
-  mEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mEndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  mEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  mEndLabel->Number       = LABEL_END;\r
-\r
-  InitializeStringDepository ();\r
-\r
-  InitAllMenu (BmmCallbackInfo);\r
-\r
-  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleInpMenu);\r
-  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleOutMenu);\r
-  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleErrMenu);\r
-  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &BootOptionMenu);\r
-  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &DriverOptionMenu);\r
-  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &TerminalMenu);\r
-  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &DriverMenu);\r
-\r
-  InitializeBmmConfig (BmmCallbackInfo);\r
-\r
-  //\r
-  // Dispatch BMM main formset and File Explorer formset.\r
-  //\r
-  FormSetDispatcher (BmmCallbackInfo);\r
-\r
-  //\r
-  // Clean up.\r
-  //\r
-  CleanUpStringDepository ();\r
-\r
-  FreeAllMenu ();\r
-\r
-Exit:\r
-  if (mStartOpCodeHandle != NULL) {\r
-    HiiFreeOpCodeHandle (mStartOpCodeHandle);\r
-  }\r
-\r
-  if (mEndOpCodeHandle != NULL) {\r
-    HiiFreeOpCodeHandle (mEndOpCodeHandle);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Initialized all Menu Option List.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-InitAllMenu (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  InitializeListHead (&BootOptionMenu.Head);\r
-  InitializeListHead (&DriverOptionMenu.Head);\r
-  BOpt_GetBootOptions (CallbackData);\r
-  BOpt_GetDriverOptions (CallbackData);\r
-  BOpt_GetLegacyOptions ();\r
-  InitializeListHead (&FsOptionMenu.Head);\r
-  BOpt_FindDrivers ();\r
-  InitializeListHead (&DirectoryMenu.Head);\r
-  InitializeListHead (&ConsoleInpMenu.Head);\r
-  InitializeListHead (&ConsoleOutMenu.Head);\r
-  InitializeListHead (&ConsoleErrMenu.Head);\r
-  InitializeListHead (&TerminalMenu.Head);\r
-  LocateSerialIo ();\r
-  GetAllConsoles ();\r
-}\r
-\r
-/**\r
-  Free up all Menu Option list.\r
-\r
-**/\r
-VOID\r
-FreeAllMenu (\r
-  VOID\r
-  )\r
-{\r
-  BOpt_FreeMenu (&DirectoryMenu);\r
-  BOpt_FreeMenu (&FsOptionMenu);\r
-  BOpt_FreeMenu (&BootOptionMenu);\r
-  BOpt_FreeMenu (&DriverOptionMenu);\r
-  BOpt_FreeMenu (&DriverMenu);\r
-  BOpt_FreeLegacyOptions ();\r
-  FreeAllConsoles ();\r
-}\r
-\r
-/**\r
-  Initialize all the string depositories.\r
-\r
-**/\r
-VOID\r
-InitializeStringDepository (\r
-  VOID\r
-  )\r
-{\r
-  STRING_DEPOSITORY *StringDepository;\r
-  StringDepository              = AllocateZeroPool (sizeof (STRING_DEPOSITORY) * STRING_DEPOSITORY_NUMBER);\r
-  FileOptionStrDepository       = StringDepository++;\r
-  ConsoleOptionStrDepository    = StringDepository++;\r
-  BootOptionStrDepository       = StringDepository++;\r
-  BootOptionHelpStrDepository   = StringDepository++;\r
-  DriverOptionStrDepository     = StringDepository++;\r
-  DriverOptionHelpStrDepository = StringDepository++;\r
-  TerminalStrDepository         = StringDepository;\r
-}\r
-\r
-/**\r
-  Fetch a usable string node from the string depository and return the string token.\r
-\r
-  @param CallbackData       The BMM context data.\r
-  @param StringDepository   The string repository.\r
-\r
-  @retval  EFI_STRING_ID           String token.\r
-\r
-**/\r
-EFI_STRING_ID\r
-GetStringTokenFromDepository (\r
-  IN   BMM_CALLBACK_DATA     *CallbackData,\r
-  IN   STRING_DEPOSITORY     *StringDepository\r
-  )\r
-{\r
-  STRING_LIST_NODE  *CurrentListNode;\r
-  STRING_LIST_NODE  *NextListNode;\r
-\r
-  CurrentListNode = StringDepository->CurrentNode;\r
-\r
-  if ((NULL != CurrentListNode) && (NULL != CurrentListNode->Next)) {\r
-    //\r
-    // Fetch one reclaimed node from the list.\r
-    //\r
-    NextListNode = StringDepository->CurrentNode->Next;\r
-  } else {\r
-    //\r
-    // If there is no usable node in the list, update the list.\r
-    //\r
-    NextListNode = AllocateZeroPool (sizeof (STRING_LIST_NODE));\r
-    ASSERT (NextListNode != NULL);\r
-    NextListNode->StringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, L" ", NULL);\r
-    ASSERT (NextListNode->StringToken != 0);\r
-\r
-    StringDepository->TotalNodeNumber++;\r
-\r
-    if (NULL == CurrentListNode) {\r
-      StringDepository->ListHead = NextListNode;\r
-    } else {\r
-      CurrentListNode->Next = NextListNode;\r
-    }\r
-  }\r
-\r
-  StringDepository->CurrentNode = NextListNode;\r
-\r
-  return StringDepository->CurrentNode->StringToken;\r
-}\r
-\r
-/**\r
-  Reclaim string depositories by moving the current node pointer to list head..\r
-\r
-**/\r
-VOID\r
-ReclaimStringDepository (\r
-  VOID\r
-  )\r
-{\r
-  UINTN             DepositoryIndex;\r
-  STRING_DEPOSITORY *StringDepository;\r
-\r
-  StringDepository = FileOptionStrDepository;\r
-  for (DepositoryIndex = 0; DepositoryIndex < STRING_DEPOSITORY_NUMBER; DepositoryIndex++) {\r
-    StringDepository->CurrentNode = StringDepository->ListHead;\r
-    StringDepository++;\r
-  }\r
-}\r
-\r
-/**\r
-  Release resource for all the string depositories.\r
-\r
-**/\r
-VOID\r
-CleanUpStringDepository (\r
-  VOID\r
-  )\r
-{\r
-  UINTN             NodeIndex;\r
-  UINTN             DepositoryIndex;\r
-  STRING_LIST_NODE  *CurrentListNode;\r
-  STRING_LIST_NODE  *NextListNode;\r
-  STRING_DEPOSITORY *StringDepository;\r
-\r
-  //\r
-  // Release string list nodes.\r
-  //\r
-  StringDepository = FileOptionStrDepository;\r
-  for (DepositoryIndex = 0; DepositoryIndex < STRING_DEPOSITORY_NUMBER; DepositoryIndex++) {\r
-    CurrentListNode = StringDepository->ListHead;\r
-    for (NodeIndex = 0; NodeIndex < StringDepository->TotalNodeNumber; NodeIndex++) {\r
-      NextListNode = CurrentListNode->Next;\r
-      FreePool (CurrentListNode);\r
-      CurrentListNode = NextListNode;\r
-    }\r
-\r
-    StringDepository++;\r
-  }\r
-  //\r
-  // Release string depository.\r
-  //\r
-  FreePool (FileOptionStrDepository);\r
-}\r
-\r
-/**\r
-  Start boot maintenance manager\r
-\r
-  @retval EFI_SUCCESS If BMM is invoked successfully.\r
-  @return Other value if BMM return unsuccessfully.\r
-\r
-**/\r
-EFI_STATUS\r
-BdsStartBootMaint (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS      Status;\r
-  LIST_ENTRY      BdsBootOptionList;\r
-\r
-  InitializeListHead (&BdsBootOptionList);\r
-\r
-  //\r
-  // Connect all prior to entering the platform setup menu.\r
-  //\r
-  if (!gConnectAllHappened) {\r
-    BdsLibConnectAllDriversToAllControllers ();\r
-    gConnectAllHappened = TRUE;\r
-  }\r
-  //\r
-  // Have chance to enumerate boot device\r
-  //\r
-  BdsLibEnumerateAllBootOption (&BdsBootOptionList);\r
-\r
-  //\r
-  // Group the legacy boot options for the same device type\r
-  //\r
-  GroupMultipleLegacyBootOption4SameType ();\r
-\r
-  //\r
-  // Init the BMM\r
-  //\r
-  Status = InitializeBM ();\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Dispatch BMM formset and FileExplorer formset.\r
-\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-  @retval EFI_SUCCESS If function complete successfully.\r
-  @return Other value if the Setup Browser process BMM's pages and\r
-           return unsuccessfully.\r
-\r
-**/\r
-EFI_STATUS\r
-FormSetDispatcher (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  EFI_STATUS                 Status;\r
-  EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
-\r
-  while (TRUE) {\r
-    UpdatePageId (CallbackData, FORM_MAIN_ID);\r
-\r
-    ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-    Status = gFormBrowser2->SendForm (\r
-                             gFormBrowser2,\r
-                             &CallbackData->BmmHiiHandle,\r
-                             1,\r
-                             &gBootMaintFormSetGuid,\r
-                             0,\r
-                             NULL,\r
-                             &ActionRequest\r
-                             );\r
-    if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
-      EnableResetRequired ();\r
-    }\r
-\r
-    ReclaimStringDepository ();\r
-\r
-    //\r
-    // When this Formset returns, check if we are going to explore files.\r
-    //\r
-    if (FileExplorerStateInActive != CallbackData->FeCurrentState) {\r
-      UpdateFileExplorer (CallbackData, 0);\r
-\r
-      ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-      Status = gFormBrowser2->SendForm (\r
-                               gFormBrowser2,\r
-                               &CallbackData->FeHiiHandle,\r
-                               1,\r
-                               &gFileExploreFormSetGuid,\r
-                               0,\r
-                               NULL,\r
-                               &ActionRequest\r
-                               );\r
-      if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
-        EnableResetRequired ();\r
-      }\r
-\r
-      CallbackData->FeCurrentState    = FileExplorerStateInActive;\r
-      CallbackData->FeDisplayContext  = FileExplorerDisplayUnknown;\r
-      ReclaimStringDepository ();\r
-    } else {\r
-      break;\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Intall BootMaint and FileExplorer HiiPackages.\r
-\r
-**/\r
-EFI_STATUS\r
-InitBMPackage (\r
-  VOID\r
-  )\r
-{\r
-  BMM_CALLBACK_DATA           *BmmCallbackInfo;\r
-  EFI_STATUS                  Status;\r
-  UINT8                       *Ptr;\r
-\r
-  //\r
-  // Create CallbackData structures for Driver Callback\r
-  //\r
-  BmmCallbackInfo = AllocateZeroPool (sizeof (BMM_CALLBACK_DATA));\r
-  if (BmmCallbackInfo == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Create LoadOption in BmmCallbackInfo for Driver Callback\r
-  //\r
-  Ptr = AllocateZeroPool (sizeof (BM_LOAD_CONTEXT) + sizeof (BM_FILE_CONTEXT) + sizeof (BM_HANDLE_CONTEXT) + sizeof (BM_MENU_ENTRY));\r
-  if (Ptr == NULL) {\r
-    FreePool (BmmCallbackInfo);\r
-    BmmCallbackInfo = NULL;\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Initialize Bmm callback data.\r
-  //\r
-  BmmCallbackInfo->LoadContext = (BM_LOAD_CONTEXT *) Ptr;\r
-  Ptr += sizeof (BM_LOAD_CONTEXT);\r
-\r
-  BmmCallbackInfo->FileContext = (BM_FILE_CONTEXT *) Ptr;\r
-  Ptr += sizeof (BM_FILE_CONTEXT);\r
-\r
-  BmmCallbackInfo->HandleContext = (BM_HANDLE_CONTEXT *) Ptr;\r
-  Ptr += sizeof (BM_HANDLE_CONTEXT);\r
-\r
-  BmmCallbackInfo->MenuEntry      = (BM_MENU_ENTRY *) Ptr;\r
-\r
-  BmmCallbackInfo->Signature                     = BMM_CALLBACK_DATA_SIGNATURE;\r
-  BmmCallbackInfo->BmmConfigAccess.ExtractConfig = BootMaintExtractConfig;\r
-  BmmCallbackInfo->BmmConfigAccess.RouteConfig   = BootMaintRouteConfig;\r
-  BmmCallbackInfo->BmmConfigAccess.Callback      = BootMaintCallback;\r
-  BmmCallbackInfo->FeConfigAccess.ExtractConfig  = FakeExtractConfig;\r
-  BmmCallbackInfo->FeConfigAccess.RouteConfig    = FileExplorerRouteConfig;\r
-  BmmCallbackInfo->FeConfigAccess.Callback       = FileExplorerCallback;\r
-\r
-  //\r
-  // Install Device Path Protocol and Config Access protocol to driver handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &BmmCallbackInfo->BmmDriverHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  &mBmmHiiVendorDevicePath,\r
-                  &gEfiHiiConfigAccessProtocolGuid,\r
-                  &BmmCallbackInfo->BmmConfigAccess,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Install Device Path Protocol and Config Access protocol to driver handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &BmmCallbackInfo->FeDriverHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  &mFeHiiVendorDevicePath,\r
-                  &gEfiHiiConfigAccessProtocolGuid,\r
-                  &BmmCallbackInfo->FeConfigAccess,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Post our Boot Maint VFR binary to the HII database.\r
-  //\r
-  BmmCallbackInfo->BmmHiiHandle = HiiAddPackages (\r
-                                    &gBootMaintFormSetGuid,\r
-                                    BmmCallbackInfo->BmmDriverHandle,\r
-                                    BmBin,\r
-                                    BdsDxeStrings,\r
-                                    NULL\r
-                                    );\r
-  ASSERT (BmmCallbackInfo->BmmHiiHandle != NULL);\r
-\r
-  //\r
-  // Post our File Explorer VFR binary to the HII database.\r
-  //\r
-  BmmCallbackInfo->FeHiiHandle = HiiAddPackages (\r
-                                   &gFileExploreFormSetGuid,\r
-                                   BmmCallbackInfo->FeDriverHandle,\r
-                                   FEBin,\r
-                                   BdsDxeStrings,\r
-                                   NULL\r
-                                   );\r
-  ASSERT (BmmCallbackInfo->FeHiiHandle != NULL);\r
-\r
-  mBmmCallbackInfo = BmmCallbackInfo;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Remvoe the intalled BootMaint and FileExplorer HiiPackages.\r
-\r
-**/\r
-VOID\r
-FreeBMPackage (\r
-  VOID\r
-  )\r
-{\r
-  BMM_CALLBACK_DATA           *BmmCallbackInfo;\r
-\r
-  BmmCallbackInfo = mBmmCallbackInfo;\r
-\r
-  //\r
-  // Remove our IFR data from HII database\r
-  //\r
-  HiiRemovePackages (BmmCallbackInfo->BmmHiiHandle);\r
-  HiiRemovePackages (BmmCallbackInfo->FeHiiHandle);\r
-\r
-  if (BmmCallbackInfo->FeDriverHandle != NULL) {\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-           BmmCallbackInfo->FeDriverHandle,\r
-           &gEfiDevicePathProtocolGuid,\r
-           &mFeHiiVendorDevicePath,\r
-           &gEfiHiiConfigAccessProtocolGuid,\r
-           &BmmCallbackInfo->FeConfigAccess,\r
-           NULL\r
-           );\r
-  }\r
-\r
-  if (BmmCallbackInfo->BmmDriverHandle != NULL) {\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-           BmmCallbackInfo->BmmDriverHandle,\r
-           &gEfiDevicePathProtocolGuid,\r
-           &mBmmHiiVendorDevicePath,\r
-           &gEfiHiiConfigAccessProtocolGuid,\r
-           &BmmCallbackInfo->BmmConfigAccess,\r
-           NULL\r
-           );\r
-  }\r
-\r
-  FreePool (BmmCallbackInfo->LoadContext);\r
-  FreePool (BmmCallbackInfo);\r
-\r
-  mBmmCallbackInfo = NULL;\r
-\r
-  return;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.h b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.h
deleted file mode 100644 (file)
index c5926fb..0000000
+++ /dev/null
@@ -1,1620 +0,0 @@
-/** @file\r
-  Header file for boot maintenance module.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _BOOT_MAINT_H_\r
-#define _BOOT_MAINT_H_\r
-\r
-#include "Bds.h"\r
-#include "BBSsupport.h"\r
-#include "FormGuid.h"\r
-#include "FrontPage.h"\r
-\r
-//\r
-// Constants which are variable names used to access variables\r
-//\r
-#define VAR_CON_OUT_MODE L"ConOutMode"\r
-\r
-//\r
-// String Contant\r
-//\r
-#define STR_FLOPPY       L"Floppy Drive #%02x"\r
-#define STR_HARDDISK     L"HardDisk Drive #%02x"\r
-#define STR_CDROM        L"ATAPI CDROM Drive #%02x"\r
-#define STR_NET          L"NET Drive #%02x"\r
-#define STR_BEV          L"BEV Drive #%02x"\r
-#define STR_FLOPPY_HELP   L"Select Floppy Drive #%02x"\r
-#define STR_HARDDISK_HELP L"Select HardDisk Drive #%02x"\r
-#define STR_CDROM_HELP    L"Select ATAPI CDROM Drive #%02x"\r
-#define STR_NET_HELP      L"NET Drive #%02x"\r
-#define STR_BEV_HELP      L"BEV Drive #%02x"\r
-\r
-extern CHAR16   mFileExplorerStorageName[];\r
-extern CHAR16   mBootMaintStorageName[];\r
-//\r
-// These are the VFR compiler generated data representing our VFR data.\r
-//\r
-extern UINT8    BmBin[];\r
-extern UINT8    FEBin[];\r
-\r
-//\r
-// Below are the number of options in Baudrate, Databits,\r
-// Parity and Stopbits selection for serial ports.\r
-//\r
-#define BM_COM_ATTR_BUADRATE  19\r
-#define BM_COM_ATTR_DATABITS  4\r
-#define BM_COM_ATTR_PARITY    5\r
-#define BM_COM_ATTR_STOPBITS  3\r
-\r
-//\r
-// Callback function helper\r
-//\r
-#define BMM_CALLBACK_DATA_SIGNATURE     SIGNATURE_32 ('C', 'b', 'c', 'k')\r
-#define BMM_CALLBACK_DATA_FROM_THIS(a)  CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)\r
-\r
-#define FE_CALLBACK_DATA_FROM_THIS(a)   CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)\r
-\r
-//\r
-// Enumeration type definition\r
-//\r
-typedef enum _TYPE_OF_TERMINAL {\r
-  TerminalTypePcAnsi                             = 0,\r
-  TerminalTypeVt100,\r
-  TerminalTypeVt100Plus,\r
-  TerminalTypeVtUtf8\r
-} TYPE_OF_TERMINAL;\r
-\r
-typedef enum _FILE_EXPLORER_STATE {\r
-  FileExplorerStateInActive                      = 0,\r
-  FileExplorerStateBootFromFile,\r
-  FileExplorerStateAddBootOption,\r
-  FileExplorerStateAddDriverOptionState,\r
-  FileExplorerStateUnknown\r
-} FILE_EXPLORER_STATE;\r
-\r
-typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT {\r
-  FileExplorerDisplayFileSystem,\r
-  FileExplorerDisplayDirectory,\r
-  FileExplorerDisplayUnknown\r
-} FILE_EXPLORER_DISPLAY_CONTEXT;\r
-\r
-//\r
-// All of the signatures that will be used in list structure\r
-//\r
-#define BM_MENU_OPTION_SIGNATURE      SIGNATURE_32 ('m', 'e', 'n', 'u')\r
-#define BM_LOAD_OPTION_SIGNATURE      SIGNATURE_32 ('l', 'o', 'a', 'd')\r
-#define BM_CONSOLE_OPTION_SIGNATURE   SIGNATURE_32 ('c', 'n', 's', 'l')\r
-#define BM_FILE_OPTION_SIGNATURE      SIGNATURE_32 ('f', 'i', 'l', 'e')\r
-#define BM_HANDLE_OPTION_SIGNATURE    SIGNATURE_32 ('h', 'n', 'd', 'l')\r
-#define BM_TERMINAL_OPTION_SIGNATURE  SIGNATURE_32 ('t', 'r', 'm', 'l')\r
-#define BM_MENU_ENTRY_SIGNATURE       SIGNATURE_32 ('e', 'n', 't', 'r')\r
-\r
-#define BM_LOAD_CONTEXT_SELECT        0x0\r
-#define BM_CONSOLE_CONTEXT_SELECT     0x1\r
-#define BM_FILE_CONTEXT_SELECT        0x2\r
-#define BM_HANDLE_CONTEXT_SELECT      0x3\r
-#define BM_TERMINAL_CONTEXT_SELECT    0x5\r
-\r
-#define BM_CONSOLE_IN_CONTEXT_SELECT  0x6\r
-#define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7\r
-#define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8\r
-#define BM_LEGACY_DEV_CONTEXT_SELECT  0x9\r
-\r
-//\r
-// Buffer size for update data\r
-//\r
-#define UPDATE_DATA_SIZE        0x100000\r
-\r
-//\r
-// Namespace of callback keys used in display and file system navigation\r
-//\r
-#define MAX_BBS_OFFSET          0xE000\r
-#define NET_OPTION_OFFSET       0xD800\r
-#define BEV_OPTION_OFFSET       0xD000\r
-#define FD_OPTION_OFFSET        0xC000\r
-#define HD_OPTION_OFFSET        0xB000\r
-#define CD_OPTION_OFFSET        0xA000\r
-#define FILE_OPTION_GOTO_OFFSET 0xC000\r
-#define FILE_OPTION_OFFSET      0x8000\r
-#define FILE_OPTION_MASK        0x3FFF\r
-#define HANDLE_OPTION_OFFSET    0x7000\r
-#define CONSOLE_OPTION_OFFSET   0x6000\r
-#define TERMINAL_OPTION_OFFSET  0x5000\r
-#define CONFIG_OPTION_OFFSET    0x1200\r
-#define KEY_VALUE_OFFSET        0x1100\r
-#define FORM_ID_OFFSET          0x1000\r
-\r
-//\r
-// VarOffset that will be used to create question\r
-// all these values are computed from the structure\r
-// defined below\r
-//\r
-#define VAR_OFFSET(Field)              ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))\r
-\r
-//\r
-// Question Id of Zero is invalid, so add an offset to it\r
-//\r
-#define QUESTION_ID(Field)             (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)\r
-\r
-#define BOOT_TIME_OUT_VAR_OFFSET        VAR_OFFSET (BootTimeOut)\r
-#define BOOT_NEXT_VAR_OFFSET            VAR_OFFSET (BootNext)\r
-#define COM1_BAUD_RATE_VAR_OFFSET       VAR_OFFSET (COM1BaudRate)\r
-#define COM1_DATA_RATE_VAR_OFFSET       VAR_OFFSET (COM1DataRate)\r
-#define COM1_STOP_BITS_VAR_OFFSET       VAR_OFFSET (COM1StopBits)\r
-#define COM1_PARITY_VAR_OFFSET          VAR_OFFSET (COM1Parity)\r
-#define COM1_TERMINAL_VAR_OFFSET        VAR_OFFSET (COM2TerminalType)\r
-#define COM2_BAUD_RATE_VAR_OFFSET       VAR_OFFSET (COM2BaudRate)\r
-#define COM2_DATA_RATE_VAR_OFFSET       VAR_OFFSET (COM2DataRate)\r
-#define COM2_STOP_BITS_VAR_OFFSET       VAR_OFFSET (COM2StopBits)\r
-#define COM2_PARITY_VAR_OFFSET          VAR_OFFSET (COM2Parity)\r
-#define COM2_TERMINAL_VAR_OFFSET        VAR_OFFSET (COM2TerminalType)\r
-#define DRV_ADD_HANDLE_DESC_VAR_OFFSET  VAR_OFFSET (DriverAddHandleDesc)\r
-#define DRV_ADD_ACTIVE_VAR_OFFSET       VAR_OFFSET (DriverAddActive)\r
-#define DRV_ADD_RECON_VAR_OFFSET        VAR_OFFSET (DriverAddForceReconnect)\r
-#define CON_IN_COM1_VAR_OFFSET          VAR_OFFSET (ConsoleInputCOM1)\r
-#define CON_IN_COM2_VAR_OFFSET          VAR_OFFSET (ConsoleInputCOM2)\r
-#define CON_OUT_COM1_VAR_OFFSET         VAR_OFFSET (ConsoleOutputCOM1)\r
-#define CON_OUT_COM2_VAR_OFFSET         VAR_OFFSET (ConsoleOutputCOM2)\r
-#define CON_ERR_COM1_VAR_OFFSET         VAR_OFFSET (ConsoleErrorCOM1)\r
-#define CON_ERR_COM2_VAR_OFFSET         VAR_OFFSET (ConsoleErrorCOM2)\r
-#define CON_MODE_VAR_OFFSET             VAR_OFFSET (ConsoleOutMode)\r
-#define CON_IN_DEVICE_VAR_OFFSET        VAR_OFFSET (ConsoleInCheck)\r
-#define CON_OUT_DEVICE_VAR_OFFSET       VAR_OFFSET (ConsoleOutCheck)\r
-#define CON_ERR_DEVICE_VAR_OFFSET       VAR_OFFSET (ConsoleErrCheck)\r
-#define BOOT_OPTION_ORDER_VAR_OFFSET    VAR_OFFSET (BootOptionOrder)\r
-#define DRIVER_OPTION_ORDER_VAR_OFFSET  VAR_OFFSET (DriverOptionOrder)\r
-#define BOOT_OPTION_DEL_VAR_OFFSET      VAR_OFFSET (BootOptionDel)\r
-#define DRIVER_OPTION_DEL_VAR_OFFSET    VAR_OFFSET (DriverOptionDel)\r
-#define DRIVER_ADD_OPTION_VAR_OFFSET    VAR_OFFSET (DriverAddHandleOptionalData)\r
-#define COM_BAUD_RATE_VAR_OFFSET        VAR_OFFSET (COMBaudRate)\r
-#define COM_DATA_RATE_VAR_OFFSET        VAR_OFFSET (COMDataRate)\r
-#define COM_STOP_BITS_VAR_OFFSET        VAR_OFFSET (COMStopBits)\r
-#define COM_PARITY_VAR_OFFSET           VAR_OFFSET (COMParity)\r
-#define COM_TERMINAL_VAR_OFFSET         VAR_OFFSET (COMTerminalType)\r
-#define COM_FLOWCONTROL_VAR_OFFSET      VAR_OFFSET (COMFlowControl)\r
-#define LEGACY_FD_VAR_OFFSET            VAR_OFFSET (LegacyFD)\r
-#define LEGACY_HD_VAR_OFFSET            VAR_OFFSET (LegacyHD)\r
-#define LEGACY_CD_VAR_OFFSET            VAR_OFFSET (LegacyCD)\r
-#define LEGACY_NET_VAR_OFFSET           VAR_OFFSET (LegacyNET)\r
-#define LEGACY_BEV_VAR_OFFSET           VAR_OFFSET (LegacyBEV)\r
-\r
-#define BOOT_TIME_OUT_QUESTION_ID       QUESTION_ID (BootTimeOut)\r
-#define BOOT_NEXT_QUESTION_ID           QUESTION_ID (BootNext)\r
-#define COM1_BAUD_RATE_QUESTION_ID      QUESTION_ID (COM1BaudRate)\r
-#define COM1_DATA_RATE_QUESTION_ID      QUESTION_ID (COM1DataRate)\r
-#define COM1_STOP_BITS_QUESTION_ID      QUESTION_ID (COM1StopBits)\r
-#define COM1_PARITY_QUESTION_ID         QUESTION_ID (COM1Parity)\r
-#define COM1_TERMINAL_QUESTION_ID       QUESTION_ID (COM2TerminalType)\r
-#define COM2_BAUD_RATE_QUESTION_ID      QUESTION_ID (COM2BaudRate)\r
-#define COM2_DATA_RATE_QUESTION_ID      QUESTION_ID (COM2DataRate)\r
-#define COM2_STOP_BITS_QUESTION_ID      QUESTION_ID (COM2StopBits)\r
-#define COM2_PARITY_QUESTION_ID         QUESTION_ID (COM2Parity)\r
-#define COM2_TERMINAL_QUESTION_ID       QUESTION_ID (COM2TerminalType)\r
-#define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)\r
-#define DRV_ADD_ACTIVE_QUESTION_ID      QUESTION_ID (DriverAddActive)\r
-#define DRV_ADD_RECON_QUESTION_ID       QUESTION_ID (DriverAddForceReconnect)\r
-#define CON_IN_COM1_QUESTION_ID         QUESTION_ID (ConsoleInputCOM1)\r
-#define CON_IN_COM2_QUESTION_ID         QUESTION_ID (ConsoleInputCOM2)\r
-#define CON_OUT_COM1_QUESTION_ID        QUESTION_ID (ConsoleOutputCOM1)\r
-#define CON_OUT_COM2_QUESTION_ID        QUESTION_ID (ConsoleOutputCOM2)\r
-#define CON_ERR_COM1_QUESTION_ID        QUESTION_ID (ConsoleErrorCOM1)\r
-#define CON_ERR_COM2_QUESTION_ID        QUESTION_ID (ConsoleErrorCOM2)\r
-#define CON_MODE_QUESTION_ID            QUESTION_ID (ConsoleOutMode)\r
-#define CON_IN_DEVICE_QUESTION_ID       QUESTION_ID (ConsoleInCheck)\r
-#define CON_OUT_DEVICE_QUESTION_ID      QUESTION_ID (ConsoleOutCheck)\r
-#define CON_ERR_DEVICE_QUESTION_ID      QUESTION_ID (ConsoleErrCheck)\r
-#define BOOT_OPTION_ORDER_QUESTION_ID   QUESTION_ID (BootOptionOrder)\r
-#define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)\r
-#define BOOT_OPTION_DEL_QUESTION_ID     QUESTION_ID (BootOptionDel)\r
-#define DRIVER_OPTION_DEL_QUESTION_ID   QUESTION_ID (DriverOptionDel)\r
-#define DRIVER_ADD_OPTION_QUESTION_ID   QUESTION_ID (DriverAddHandleOptionalData)\r
-#define COM_BAUD_RATE_QUESTION_ID       QUESTION_ID (COMBaudRate)\r
-#define COM_DATA_RATE_QUESTION_ID       QUESTION_ID (COMDataRate)\r
-#define COM_STOP_BITS_QUESTION_ID       QUESTION_ID (COMStopBits)\r
-#define COM_PARITY_QUESTION_ID          QUESTION_ID (COMParity)\r
-#define COM_TERMINAL_QUESTION_ID        QUESTION_ID (COMTerminalType)\r
-#define COM_FLOWCONTROL_QUESTION_ID     QUESTION_ID (COMFlowControl)\r
-#define LEGACY_FD_QUESTION_ID           QUESTION_ID (LegacyFD)\r
-#define LEGACY_HD_QUESTION_ID           QUESTION_ID (LegacyHD)\r
-#define LEGACY_CD_QUESTION_ID           QUESTION_ID (LegacyCD)\r
-#define LEGACY_NET_QUESTION_ID          QUESTION_ID (LegacyNET)\r
-#define LEGACY_BEV_QUESTION_ID          QUESTION_ID (LegacyBEV)\r
-\r
-#define STRING_DEPOSITORY_NUMBER        8\r
-\r
-///\r
-/// Serial Ports attributes, first one is the value for\r
-/// return from callback function, stringtoken is used to\r
-/// display the value properly\r
-///\r
-typedef struct {\r
-  UINTN   Value;\r
-  UINT16  StringToken;\r
-} COM_ATTR;\r
-\r
-typedef struct {\r
-  UINT64                    BaudRate;\r
-  UINT8                     DataBits;\r
-  UINT8                     Parity;\r
-  UINT8                     StopBits;\r
-\r
-  UINT8                     BaudRateIndex;\r
-  UINT8                     DataBitsIndex;\r
-  UINT8                     ParityIndex;\r
-  UINT8                     StopBitsIndex;\r
-\r
-  UINT8                     FlowControl;\r
-\r
-  UINT8                     IsConIn;\r
-  UINT8                     IsConOut;\r
-  UINT8                     IsStdErr;\r
-  UINT8                     TerminalType;\r
-\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-} BM_TERMINAL_CONTEXT;\r
-\r
-typedef struct {\r
-  BOOLEAN                   IsBootNext;\r
-  BOOLEAN                   LoadOptionModified;\r
-  BOOLEAN                   Deleted;\r
-\r
-  BOOLEAN                   IsLegacy;\r
-  BOOLEAN                   IsActive;\r
-  BOOLEAN                   ForceReconnect;\r
-  UINTN                     OptionalDataSize;\r
-\r
-  UINTN                     LoadOptionSize;\r
-  UINT8                     *LoadOption;\r
-\r
-  UINT32                    Attributes;\r
-  UINT16                    FilePathListLength;\r
-  UINT16                    *Description;\r
-  EFI_DEVICE_PATH_PROTOCOL  *FilePathList;\r
-  UINT8                     *OptionalData;\r
-\r
-  UINT16                    BbsIndex;\r
-} BM_LOAD_CONTEXT;\r
-\r
-typedef struct {\r
-  BBS_TABLE *BbsEntry;\r
-  UINT16    BbsIndex;\r
-  UINT16    BbsCount;\r
-  CHAR16    *Description;\r
-} BM_LEGACY_DEVICE_CONTEXT;\r
-\r
-typedef struct {\r
-\r
-  BOOLEAN                   IsActive;\r
-\r
-  BOOLEAN                   IsTerminal;\r
-\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-} BM_CONSOLE_CONTEXT;\r
-\r
-typedef struct {\r
-  UINTN   Column;\r
-  UINTN   Row;\r
-} CONSOLE_OUT_MODE;\r
-\r
-typedef struct {\r
-  EFI_HANDLE                        Handle;\r
-  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;\r
-  EFI_FILE_HANDLE                   FHandle;\r
-  UINT16                            *FileName;\r
-  EFI_FILE_SYSTEM_VOLUME_LABEL      *Info;\r
-\r
-  BOOLEAN                           IsRoot;\r
-  BOOLEAN                           IsDir;\r
-  BOOLEAN                           IsRemovableMedia;\r
-  BOOLEAN                           IsLoadFile;\r
-  BOOLEAN                           IsBootLegacy;\r
-} BM_FILE_CONTEXT;\r
-\r
-typedef struct {\r
-  EFI_HANDLE                Handle;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-} BM_HANDLE_CONTEXT;\r
-\r
-typedef struct {\r
-  UINTN           Signature;\r
-  LIST_ENTRY      Head;\r
-  UINTN           MenuNumber;\r
-} BM_MENU_OPTION;\r
-\r
-typedef struct {\r
-  UINTN           Signature;\r
-  LIST_ENTRY      Link;\r
-  UINTN           OptionNumber;\r
-  UINT16          *DisplayString;\r
-  UINT16          *HelpString;\r
-  EFI_STRING_ID   DisplayStringToken;\r
-  EFI_STRING_ID   HelpStringToken;\r
-  UINTN           ContextSelection;\r
-  VOID            *VariableContext;\r
-} BM_MENU_ENTRY;\r
-\r
-typedef struct {\r
-  //\r
-  // Shared callback data.\r
-  //\r
-  UINTN                          Signature;\r
-\r
-  BM_MENU_ENTRY                  *MenuEntry;\r
-  BM_HANDLE_CONTEXT              *HandleContext;\r
-  BM_FILE_CONTEXT                *FileContext;\r
-  BM_LOAD_CONTEXT                *LoadContext;\r
-  BM_TERMINAL_CONTEXT            *TerminalContext;\r
-  UINTN                          CurrentTerminal;\r
-  BBS_TYPE                       BbsType;\r
-\r
-  //\r
-  // BMM main formset callback data.\r
-  //\r
-  EFI_HII_HANDLE                 BmmHiiHandle;\r
-  EFI_HANDLE                     BmmDriverHandle;\r
-  EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess;\r
-  EFI_FORM_ID                    BmmCurrentPageId;\r
-  EFI_FORM_ID                    BmmPreviousPageId;\r
-  BOOLEAN                        BmmAskSaveOrNot;\r
-  BMM_FAKE_NV_DATA               BmmFakeNvData;\r
-  BMM_FAKE_NV_DATA               BmmOldFakeNVData;\r
-\r
-  //\r
-  // File explorer formset callback data.\r
-  //\r
-  EFI_HII_HANDLE                 FeHiiHandle;\r
-  EFI_HANDLE                     FeDriverHandle;\r
-  EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess;\r
-  FILE_EXPLORER_STATE            FeCurrentState;\r
-  FILE_EXPLORER_DISPLAY_CONTEXT  FeDisplayContext;\r
-  FILE_EXPLORER_NV_DATA          FeFakeNvData;\r
-} BMM_CALLBACK_DATA;\r
-\r
-typedef struct _STRING_LIST_NODE STRING_LIST_NODE;\r
-\r
-struct _STRING_LIST_NODE {\r
-  EFI_STRING_ID             StringToken;\r
-  STRING_LIST_NODE          *Next;\r
-};\r
-\r
-typedef struct _STRING_DEPOSITORY {\r
-  UINTN             TotalNodeNumber;\r
-  STRING_LIST_NODE  *CurrentNode;\r
-  STRING_LIST_NODE  *ListHead;\r
-} STRING_DEPOSITORY;\r
-\r
-//\r
-// #pragma pack()\r
-//\r
-// For initializing File System menu\r
-//\r
-\r
-/**\r
-  This function build the FsOptionMenu list which records all\r
-  available file system in the system. They includes all instances\r
-  of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM\r
-  and all type of legacy boot device.\r
-\r
-  @param CallbackData    BMM context data\r
-\r
-  @retval  EFI_SUCCESS             Success find the file system\r
-  @retval  EFI_OUT_OF_RESOURCES    Can not create menu entry\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_FindFileSystem (\r
-  IN BMM_CALLBACK_DATA          *CallbackData\r
-  );\r
-\r
-/**\r
-  Find files under current directory\r
-  All files and sub-directories in current directory\r
-  will be stored in DirectoryMenu for future use.\r
-\r
-  @param CallbackData  The BMM context data.\r
-  @param MenuEntry     The Menu Entry.\r
-\r
-  @retval EFI_SUCCESS         Get files from current dir successfully.\r
-  @return Other value if can't get files from current dir.\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_FindFiles (\r
-  IN BMM_CALLBACK_DATA          *CallbackData,\r
-  IN BM_MENU_ENTRY              *MenuEntry\r
-  );\r
-\r
-/**\r
-\r
-  Find drivers that will be added as Driver#### variables from handles\r
-  in current system environment\r
-  All valid handles in the system except those consume SimpleFs, LoadFile\r
-  are stored in DriverMenu for future use.\r
-\r
-  @retval EFI_SUCCESS The function complets successfully.\r
-  @return Other value if failed to build the DriverMenu.\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_FindDrivers (\r
-  VOID\r
-  );\r
-\r
-/**\r
-\r
-  Build the BootOptionMenu according to BootOrder Variable.\r
-  This Routine will access the Boot#### to get EFI_LOAD_OPTION.\r
-\r
-  @param CallbackData The BMM context data.\r
-\r
-  @return The number of the Var Boot####.\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_GetBootOptions (\r
-  IN  BMM_CALLBACK_DATA         *CallbackData\r
-  );\r
-\r
-/**\r
-\r
-  Build up all DriverOptionMenu\r
-\r
-  @param CallbackData The BMM context data.\r
-\r
-  @return EFI_SUCESS The functin completes successfully.\r
-  @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.\r
-\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_GetDriverOptions (\r
-  IN  BMM_CALLBACK_DATA         *CallbackData\r
-  );\r
-\r
-\r
-/**\r
-  Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().\r
-\r
-  @retval EFI_SUCCESS The function complete successfully.\r
-  @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_GetLegacyOptions (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Free out resouce allocated from Legacy Boot Options.\r
-\r
-**/\r
-VOID\r
-BOpt_FreeLegacyOptions (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Free resources allocated in Allocate Rountine.\r
-\r
-  @param FreeMenu        Menu to be freed\r
-\r
-**/\r
-VOID\r
-BOpt_FreeMenu (\r
-  BM_MENU_OPTION        *FreeMenu\r
-  );\r
-\r
-\r
-/**\r
-\r
-  Append file name to existing file name.\r
-\r
-  @param Str1  The existing file name\r
-  @param Str2  The file name to be appended\r
-\r
-  @return Allocate a new string to hold the appended result.\r
-          Caller is responsible to free the returned string.\r
-\r
-**/\r
-CHAR16*\r
-BOpt_AppendFileName (\r
-  IN  CHAR16  *Str1,\r
-  IN  CHAR16  *Str2\r
-  );\r
-\r
-/**\r
-\r
-  Check whether current FileName point to a valid\r
-  Efi Image File.\r
-\r
-  @param FileName  File need to be checked.\r
-\r
-  @retval TRUE  Is Efi Image\r
-  @retval FALSE Not a valid Efi Image\r
-\r
-**/\r
-BOOLEAN\r
-BOpt_IsEfiImageName (\r
-  IN UINT16  *FileName\r
-  );\r
-\r
-\r
-/**\r
-\r
-  Get the Option Number that has not been allocated for use.\r
-\r
-  @param Type  The type of Option.\r
-\r
-  @return The available Option Number.\r
-\r
-**/\r
-UINT16\r
-BOpt_GetOptionNumber (\r
-  CHAR16        *Type\r
-  );\r
-\r
-/**\r
-\r
-  Get the Option Number for Boot#### that does not used.\r
-\r
-  @return The available Option Number.\r
-\r
-**/\r
-UINT16\r
-BOpt_GetBootOptionNumber (\r
-  VOID\r
-  );\r
-\r
-/**\r
-\r
-Get the Option Number for Driver#### that does not used.\r
-\r
-@return The unused Option Number.\r
-\r
-**/\r
-UINT16\r
-BOpt_GetDriverOptionNumber (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Create a menu entry give a Menu type.\r
-\r
-  @param MenuType        The Menu type to be created.\r
-\r
-\r
-  @retval NULL           If failed to create the menu.\r
-  @return                The menu.\r
-\r
-**/\r
-BM_MENU_ENTRY                     *\r
-BOpt_CreateMenuEntry (\r
-  UINTN           MenuType\r
-  );\r
-\r
-/**\r
-  Free up all resource allocated for a BM_MENU_ENTRY.\r
-\r
-  @param MenuEntry   A pointer to BM_MENU_ENTRY.\r
-\r
-**/\r
-VOID\r
-BOpt_DestroyMenuEntry (\r
-  BM_MENU_ENTRY         *MenuEntry\r
-  );\r
-\r
-/**\r
-  Get the Menu Entry from the list in Menu Entry List.\r
-\r
-  If MenuNumber is great or equal to the number of Menu\r
-  Entry in the list, then ASSERT.\r
-\r
-  @param MenuOption      The Menu Entry List to read the menu entry.\r
-  @param MenuNumber      The index of Menu Entry.\r
-\r
-  @return The Menu Entry.\r
-\r
-**/\r
-BM_MENU_ENTRY                     *\r
-BOpt_GetMenuEntry (\r
-  BM_MENU_OPTION      *MenuOption,\r
-  UINTN               MenuNumber\r
-  );\r
-\r
-//\r
-// Locate all serial io devices for console\r
-//\r
-/**\r
-  Build a list containing all serial devices.\r
-\r
-  @retval EFI_SUCCESS The function complete successfully.\r
-  @retval EFI_UNSUPPORTED No serial ports present.\r
-\r
-**/\r
-EFI_STATUS\r
-LocateSerialIo (\r
-  VOID\r
-  );\r
-\r
-//\r
-// Initializing Console menu\r
-//\r
-/**\r
-  Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu\r
-\r
-  @retval EFI_SUCCESS    The function always complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-GetAllConsoles(\r
-  VOID\r
-  );\r
-\r
-//\r
-// Get current mode information\r
-//\r
-/**\r
-  Get mode number according to column and row\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-GetConsoleOutMode (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-//\r
-// Cleaning up console menu\r
-//\r
-/**\r
-  Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu\r
-\r
-  @retval EFI_SUCCESS    The function always complete successfully.\r
-**/\r
-EFI_STATUS\r
-FreeAllConsoles (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Update the multi-instance device path of Terminal Device based on\r
-  the global TerminalMenu. If ChangeTernimal is TRUE, the terminal\r
-  device path in the Terminal Device in TerminalMenu is also updated.\r
-\r
-  @param DevicePath      The multi-instance device path.\r
-  @param ChangeTerminal  TRUE, then device path in the Terminal Device\r
-                         in TerminalMenu is also updated; FALSE, no update.\r
-\r
-  @return EFI_SUCCESS    The function completes successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ChangeTerminalDevicePath (\r
-  IN OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePath,\r
-  IN BOOLEAN                   ChangeTerminal\r
-  );\r
-\r
-//\r
-// Variable operation by menu selection\r
-//\r
-/**\r
-  This function create a currently loaded Boot Option from\r
-  the BMM. It then appends this Boot Option to the end of\r
-  the "BootOrder" list. It also append this Boot Opotion to the end\r
-  of BootOptionMenu.\r
-\r
-  @param CallbackData           The BMM context data.\r
-  @param NvRamMap               The file explorer formset internal state.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  If not enought memory to complete the operation.\r
-  @retval EFI_SUCCESS           If function completes successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateBootOption (\r
-  IN  BMM_CALLBACK_DATA                   *CallbackData,\r
-  IN  FILE_EXPLORER_NV_DATA               *NvRamMap\r
-  );\r
-\r
-/**\r
-  Delete Boot Option that represent a Deleted state in BootOptionMenu.\r
-  After deleting this boot option, call Var_ChangeBootOrder to\r
-  make sure BootOrder is in valid state.\r
-\r
-  @retval EFI_SUCCESS   If all boot load option EFI Variables corresponding to\r
-                        BM_LOAD_CONTEXT marked for deletion is deleted\r
-  @return Others        If failed to update the "BootOrder" variable after deletion.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_DelBootOption (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  After any operation on Boot####, there will be a discrepancy in BootOrder.\r
-  Since some are missing but in BootOrder, while some are present but are\r
-  not reflected by BootOrder. Then a function rebuild BootOrder from\r
-  scratch by content from BootOptionMenu is needed.\r
-\r
-  @retval  EFI_SUCCESS  The boot order is updated successfully.\r
-  @return  other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_ChangeBootOrder (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function create a currently loaded Drive Option from\r
-  the BMM. It then appends this Driver Option to the end of\r
-  the "DriverOrder" list. It append this Driver Opotion to the end\r
-  of DriverOptionMenu.\r
-\r
-  @param CallbackData    The BMM context data.\r
-  @param HiiHandle       The HII handle associated with the BMM formset.\r
-  @param DescriptionData The description of this driver option.\r
-  @param OptionalData    The optional load option.\r
-  @param ForceReconnect  If to force reconnect.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.\r
-  @retval EFI_SUCCESS          If function completes successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateDriverOption (\r
-  IN  BMM_CALLBACK_DATA         *CallbackData,\r
-  IN  EFI_HII_HANDLE            HiiHandle,\r
-  IN  UINT16                    *DescriptionData,\r
-  IN  UINT16                    *OptionalData,\r
-  IN  UINT8                     ForceReconnect\r
-  );\r
-\r
-/**\r
-  Delete Load Option that represent a Deleted state in BootOptionMenu.\r
-  After deleting this Driver option, call Var_ChangeDriverOrder to\r
-  make sure DriverOrder is in valid state.\r
-\r
-  @retval EFI_SUCCESS Load Option is successfully updated.\r
-  @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI\r
-          Variable.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_DelDriverOption (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  After any operation on Driver####, there will be a discrepancy in\r
-  DriverOrder. Since some are missing but in DriverOrder, while some\r
-  are present but are not reflected by DriverOrder. Then a function\r
-  rebuild DriverOrder from scratch by content from DriverOptionMenu is\r
-  needed.\r
-\r
-  @retval  EFI_SUCCESS  The driver order is updated successfully.\r
-  @return  other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_ChangeDriverOrder (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function delete and build multi-instance device path ConIn\r
-  console device.\r
-\r
-  @retval EFI_SUCCESS    The function complete successfully.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-**/\r
-EFI_STATUS\r
-Var_UpdateConsoleInpOption (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function delete and build multi-instance device path ConOut console device.\r
-\r
-  @retval EFI_SUCCESS    The function complete successfully.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-**/\r
-EFI_STATUS\r
-Var_UpdateConsoleOutOption (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function delete and build multi-instance device path ErrOut console device.\r
-\r
-  @retval EFI_SUCCESS    The function complete successfully.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-**/\r
-EFI_STATUS\r
-Var_UpdateErrorOutOption (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,\r
-  this EFI Variable is deleted.\r
-  It also update the BMM context data specified the "BootNext" value.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-  @retval EFI_SUCCESS    The function complete successfully.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateBootNext (\r
-  IN BMM_CALLBACK_DATA            *CallbackData\r
-  );\r
-\r
-/**\r
-  This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh\r
-  BootOptionMenu with the new "BootOrder" list.\r
-\r
-  @param CallbackData           The BMM context data.\r
-\r
-  @retval EFI_SUCCESS           The function complete successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  Not enough memory to complete the function.\r
-  @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateBootOrder (\r
-  IN BMM_CALLBACK_DATA            *CallbackData\r
-  );\r
-\r
-/**\r
-  This function update the "DriverOrder" EFI Variable based on\r
-  BMM Formset's NV map. It then refresh DriverOptionMenu\r
-  with the new "DriverOrder" list.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-  @retval EFI_SUCCESS           The function complete successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  Not enough memory to complete the function.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateDriverOrder (\r
-  IN BMM_CALLBACK_DATA            *CallbackData\r
-  );\r
-\r
-/**\r
-  Update the legacy BBS boot option. VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable\r
-  is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid\r
-  is also updated.\r
-\r
-  @param CallbackData    The context data for BMM.\r
-  @param FormId          The form id.\r
-\r
-  @return EFI_SUCCESS    The function completed successfully.\r
-  @retval EFI_NOT_FOUND  If VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable can not be found.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateBBSOption (\r
-  IN BMM_CALLBACK_DATA            *CallbackData,\r
-  IN EFI_FORM_ID                  FormId\r
-  );\r
-\r
-/**\r
-  Update the Text Mode of Console.\r
-\r
-  @param CallbackData  The context data for BMM.\r
-\r
-  @retval EFI_SUCCSS If the Text Mode of Console is updated.\r
-  @return Other value if the Text Mode of Console is not updated.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateConMode (\r
-  IN BMM_CALLBACK_DATA            *CallbackData\r
-  );\r
-\r
-//\r
-// Following are page create and refresh functions\r
-//\r
-/**\r
-  Refresh the global UpdateData structure.\r
-\r
-**/\r
-VOID\r
-RefreshUpdateData (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Clean up the dynamic opcode at label and form specified by\r
-  both LabelId.\r
-\r
-  @param LabelId         It is both the Form ID and Label ID for\r
-                         opcode deletion.\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-CleanUpPage (\r
-  IN UINT16                           LabelId,\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Create a lit of boot option from global BootOptionMenu. It\r
-  allow user to delete the boot option.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateBootDelPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Create a lit of driver option from global DriverMenu.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateDrvAddHandlePage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Create a lit of driver option from global DriverOptionMenu. It\r
-  allow user to delete the driver option.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateDrvDelPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Prepare the page to allow user to add description for a Driver Option.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateDriverAddHandleDescPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Dispatch the correct update page function to call based on the UpdatePageId.\r
-\r
-  @param UpdatePageId    The form ID.\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdatePageBody (\r
-  IN UINT16                           UpdatePageId,\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Create the dynamic page to allow user to set the "BootNext" vaule.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateBootNextPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Create the dynamic page to allow user to set the "TimeOut" vaule.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateTimeOutPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,\r
-  Parity, Stop Bits, Terminal Type.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateTerminalPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Refresh the text mode page\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateConModePage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Create a list of Goto Opcode for all terminal devices logged\r
-  by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateConCOMPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-/**\r
-  Create a dynamic page so that Legacy Device boot order\r
-  can be set for specified device type.\r
-\r
-  @param UpdatePageId    The form ID. It also spefies the legacy device type.\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateSetLegacyDeviceOrderPage (\r
-  IN UINT16                           UpdatePageId,\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  );\r
-\r
-\r
-/**\r
-  Function opens and returns a file handle to the root directory of a volume.\r
-\r
-  @param DeviceHandle    A handle for a device\r
-  @return A valid file handle or NULL is returned\r
-**/\r
-EFI_FILE_HANDLE\r
-EfiLibOpenRoot (\r
-  IN EFI_HANDLE       DeviceHandle\r
-  );\r
-\r
-/**\r
-  Function gets the file system information from an open file descriptor,\r
-  and stores it in a buffer allocated from pool.\r
-\r
-  @param FHand           The file handle.\r
-\r
-  @return                A pointer to a buffer with file information.\r
-                         NULL is returned if failed to get Vaolume Label Info.\r
-**/\r
-EFI_FILE_SYSTEM_VOLUME_LABEL *\r
-EfiLibFileSystemVolumeLabelInfo (\r
-  IN EFI_FILE_HANDLE      FHand\r
-  );\r
-\r
-/**\r
-\r
-  Function gets the file information from an open file descriptor, and stores it\r
-  in a buffer allocated from pool.\r
-\r
-  @param FHand           File Handle.\r
-\r
-  @return                A pointer to a buffer with file information or NULL is returned\r
-\r
-**/\r
-EFI_FILE_INFO *\r
-EfiLibFileInfo (\r
-  IN EFI_FILE_HANDLE      FHand\r
-  );\r
-\r
-\r
-/**\r
-  Function deletes the variable specified by VarName and VarGuid.\r
-\r
-\r
-  @param VarName            A Null-terminated Unicode string that is\r
-                            the name of the vendor's variable.\r
-\r
-  @param VarGuid            A unique identifier for the vendor.\r
-\r
-  @retval  EFI_SUCCESS           The variable was found and removed\r
-  @retval  EFI_UNSUPPORTED       The variable store was inaccessible\r
-  @retval  EFI_OUT_OF_RESOURCES  The temporary buffer was not available\r
-  @retval  EFI_NOT_FOUND         The variable was not found\r
-\r
-**/\r
-EFI_STATUS\r
-EfiLibDeleteVariable (\r
-  IN CHAR16   *VarName,\r
-  IN EFI_GUID *VarGuid\r
-  );\r
-\r
-/**\r
-  Duplicate a string.\r
-\r
-  @param Src             The source.\r
-\r
-  @return A new string which is duplicated copy of the source.\r
-  @retval NULL If there is not enough memory.\r
-\r
-**/\r
-CHAR16                            *\r
-EfiStrDuplicate (\r
-  IN CHAR16   *Src\r
-  );\r
-\r
-/**\r
-  Function is used to determine the number of device path instances\r
-  that exist in a device path.\r
-\r
-\r
-  @param DevicePath      A pointer to a device path data structure.\r
-\r
-  @return This function counts and returns the number of device path instances\r
-          in DevicePath.\r
-\r
-**/\r
-UINTN\r
-EfiDevicePathInstanceCount (\r
-  IN EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
-  );\r
-\r
-/**\r
-  Create string tokens for a menu from its help strings and display strings\r
-\r
-\r
-  @param CallbackData    The BMM context data.\r
-  @param HiiHandle       Hii Handle of the package to be updated.\r
-  @param MenuOption      The Menu whose string tokens need to be created\r
-\r
-  @retval  EFI_SUCCESS      string tokens created successfully\r
-  @retval  others           contain some errors\r
-\r
-**/\r
-EFI_STATUS\r
-CreateMenuStringToken (\r
-  IN BMM_CALLBACK_DATA                *CallbackData,\r
-  IN EFI_HII_HANDLE                   HiiHandle,\r
-  IN BM_MENU_OPTION                   *MenuOption\r
-  );\r
-\r
-/**\r
-  Get a string from the Data Hub record based on\r
-  a device path.\r
-\r
-  @param DevPath         The device Path.\r
-\r
-  @return A string located from the Data Hub records based on\r
-          the device path.\r
-  @retval NULL  If failed to get the String from Data Hub.\r
-\r
-**/\r
-UINT16 *\r
-EfiLibStrFromDatahub (\r
-  IN EFI_DEVICE_PATH_PROTOCOL                 *DevPath\r
-  );\r
-\r
-/**\r
-  Initialize the Boot Maintenance Utitliy.\r
-\r
-  @retval  EFI_SUCCESS      utility ended successfully.\r
-  @retval  others           contain some errors.\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeBM (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Start boot maintenance manager\r
-\r
-  @retval EFI_SUCCESS If BMM is invoked successfully.\r
-  @return Other value if BMM return unsuccessfully.\r
-\r
-**/\r
-EFI_STATUS\r
-BdsStartBootMaint (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Intialize all the string depositories.\r
-\r
-**/\r
-VOID\r
-InitializeStringDepository (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Fetch a usable string node from the string depository and return the string token.\r
-\r
-\r
-  @param CallbackData       The BMM context data.\r
-  @param StringDepository   Pointer of the string depository.\r
-\r
-  @retval  EFI_STRING_ID    String token.\r
-\r
-**/\r
-EFI_STRING_ID\r
-GetStringTokenFromDepository (\r
-  IN   BMM_CALLBACK_DATA     *CallbackData,\r
-  IN   STRING_DEPOSITORY     *StringDepository\r
-  );\r
-\r
-/**\r
-  Reclaim string depositories by moving the current node pointer to list head..\r
-**/\r
-VOID\r
-ReclaimStringDepository (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Release resource for all the string depositories.\r
-\r
-**/\r
-VOID\r
-CleanUpStringDepository (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Function handling request to apply changes for BMM pages.\r
-\r
-  @param Private            Pointer to callback data buffer.\r
-  @param CurrentFakeNVMap   Pointer to buffer holding data of various values used by BMM\r
-  @param FormId             ID of the form which has sent the request to apply change.\r
-\r
-  @retval  EFI_SUCCESS      Change successfully applied.\r
-  @retval  Other            Error occurs while trying to apply changes.\r
-\r
-**/\r
-EFI_STATUS\r
-ApplyChangeHandler (\r
-  IN  BMM_CALLBACK_DATA               *Private,\r
-  IN  BMM_FAKE_NV_DATA                *CurrentFakeNVMap,\r
-  IN  EFI_FORM_ID                     FormId\r
-  );\r
-\r
-/**\r
-  Discard all changes done to the BMM pages such as Boot Order change,\r
-  Driver order change.\r
-\r
-  @param Private         The BMM context data.\r
-  @param CurrentFakeNVMap The current Fack NV Map.\r
-\r
-**/\r
-VOID\r
-DiscardChangeHandler (\r
-  IN  BMM_CALLBACK_DATA               *Private,\r
-  IN  BMM_FAKE_NV_DATA                *CurrentFakeNVMap\r
-  );\r
-\r
-/**\r
-  Dispatch the display to the next page based on NewPageId.\r
-\r
-  @param Private         The BMM context data.\r
-  @param NewPageId       The original page ID.\r
-\r
-**/\r
-VOID\r
-UpdatePageId (\r
-  BMM_CALLBACK_DATA              *Private,\r
-  UINT16                         NewPageId\r
-  );\r
-\r
-/**\r
-  Boot a file selected by user at File Expoloer of BMM.\r
-\r
-  @param FileContext     The file context data, which contains the device path\r
-                         of the file to be boot from.\r
-\r
-  @retval EFI_SUCCESS    The function completed successfull.\r
-  @return                 Other value if the boot from the file fails.\r
-\r
-**/\r
-EFI_STATUS\r
-BootThisFile (\r
-  IN BM_FILE_CONTEXT                   *FileContext\r
-  );\r
-\r
-/**\r
-  Update the file explower page with the refershed file system.\r
-\r
-\r
-  @param CallbackData    BMM context data\r
-  @param KeyValue        Key value to identify the type of data to expect.\r
-\r
-  @retval  TRUE           Inform the caller to create a callback packet to exit file explorer.\r
-  @retval  FALSE          Indicate that there is no need to exit file explorer.\r
-\r
-**/\r
-BOOLEAN\r
-UpdateFileExplorer (\r
-  IN BMM_CALLBACK_DATA            *CallbackData,\r
-  IN UINT16                       KeyValue\r
-  );\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-  When user select a interactive opcode, this callback will be triggered.\r
-  Based on the Question(QuestionId) that triggers the callback, the corresponding\r
-  actions is performed. It handles:\r
-\r
-  1) the addition of boot option.\r
-  2) the addition of driver option.\r
-  3) exit from file browser\r
-  4) update of file content if a dir is selected.\r
-  5) boot the file if a file is selected in "boot from file"\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_OUT_OF_RESOURCES  Not enough storage is available to hold the variable and its data.\r
-  @retval  EFI_DEVICE_ERROR      The variable could not be saved.\r
-  @retval  EFI_UNSUPPORTED       The specified Action is not supported by the callback.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileExplorerCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  );\r
-\r
-/**\r
-  This function applies changes in a driver's configuration.\r
-  Input is a Configuration, which has the routing data for this\r
-  driver followed by name / value configuration pairs. The driver\r
-  must apply those pairs to its configurable storage. If the\r
-  driver's configuration is stored in a linear block of data\r
-  and the driver's name / value pairs are in <BlockConfig>\r
-  format, it may use the ConfigToBlock helper function (above) to\r
-  simplify the job. Currently not implemented.\r
-\r
-  @param[in]  This                Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param[in]  Configuration       A null-terminated Unicode string in\r
-                                  <ConfigString> format.\r
-  @param[out] Progress            A pointer to a string filled in with the\r
-                                  offset of the most recent '&' before the\r
-                                  first failing name / value pair (or the\r
-                                  beginn ing of the string if the failure\r
-                                  is in the first name / value pair) or\r
-                                  the terminating NULL if all was\r
-                                  successful.\r
-\r
-  @retval EFI_SUCCESS             The results have been distributed or are\r
-                                  awaiting distribution.\r
-  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the\r
-                                  parts of the results that must be\r
-                                  stored awaiting possible future\r
-                                  protocols.\r
-  @retval EFI_INVALID_PARAMETERS  Passing in a NULL for the\r
-                                  Results parameter would result\r
-                                  in this type of error.\r
-  @retval EFI_NOT_FOUND           Target for the specified routing data\r
-                                  was not found.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileExplorerRouteConfig (\r
-  IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
-  IN CONST EFI_STRING                     Configuration,\r
-  OUT EFI_STRING                          *Progress\r
-  );\r
-\r
-/**\r
-  Dispatch BMM formset and FileExplorer formset.\r
-\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-  @retval EFI_SUCCESS If function complete successfully.\r
-  @return Other value if the Setup Browser process BMM's pages and\r
-           return unsuccessfully.\r
-\r
-**/\r
-EFI_STATUS\r
-FormSetDispatcher (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-/**\r
-  Function returns the value of the specified variable.\r
-\r
-  @param Name            A Null-terminated Unicode string that is\r
-                         the name of the vendor's variable.\r
-  @param VendorGuid      A unique identifier for the vendor.\r
-\r
-  @return               The payload of the variable.\r
-  @retval NULL          If the variable can't be read.\r
-\r
-**/\r
-VOID *\r
-EfiLibGetVariable (\r
-  IN CHAR16               *Name,\r
-  IN EFI_GUID             *VendorGuid\r
-  );\r
-\r
-/**\r
-  Get option number according to Boot#### and BootOrder variable.\r
-  The value is saved as #### + 1.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-GetBootOrder (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-/**\r
-  Get driver option order from globalc DriverOptionMenu.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetDriverOrder (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-/**\r
-  Intall BootMaint and FileExplorer HiiPackages.\r
-\r
-**/\r
-EFI_STATUS\r
-InitBMPackage (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Remvoe the intalled BootMaint and FileExplorer HiiPackages.\r
-\r
-**/\r
-VOID\r
-FreeBMPackage (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  According to LegacyDevOrder variable to get legacy FD\HD\CD\NET\BEV\r
-  devices list .\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-GetLegacyDeviceOrder (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-/**\r
-\r
-  Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]\r
-  in BMM_FAKE_NV_DATA structure.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetConsoleInCheck (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-/**\r
-\r
-  Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]\r
-  in BMM_FAKE_NV_DATA structure.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetConsoleOutCheck (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-/**\r
-\r
-  Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]\r
-  in BMM_FAKE_NV_DATA structure.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetConsoleErrCheck (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-/**\r
-\r
-  Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)\r
-  to BMM_FAKE_NV_DATA structure.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetTerminalAttribute (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  );\r
-\r
-/**\r
-\r
-  Find the first instance of this Protocol\r
-  in the system and return it's interface.\r
-\r
-\r
-  @param ProtocolGuid    Provides the protocol to search for\r
-  @param Interface       On return, a pointer to the first interface\r
-                         that matches ProtocolGuid\r
-\r
-  @retval  EFI_SUCCESS      A protocol instance matching ProtocolGuid was found\r
-  @retval  EFI_NOT_FOUND    No protocol instances were found that match ProtocolGuid\r
-\r
-**/\r
-EFI_STATUS\r
-EfiLibLocateProtocol (\r
-  IN  EFI_GUID    *ProtocolGuid,\r
-  OUT VOID        **Interface\r
-  );\r
-\r
-//\r
-// Global variable in this program (defined in data.c)\r
-//\r
-extern BM_MENU_OPTION             BootOptionMenu;\r
-extern BM_MENU_OPTION             DriverOptionMenu;\r
-extern BM_MENU_OPTION             FsOptionMenu;\r
-extern BM_MENU_OPTION             ConsoleInpMenu;\r
-extern BM_MENU_OPTION             ConsoleOutMenu;\r
-extern BM_MENU_OPTION             ConsoleErrMenu;\r
-extern BM_MENU_OPTION             DirectoryMenu;\r
-extern BM_MENU_OPTION             DriverMenu;\r
-extern BM_MENU_OPTION             TerminalMenu;\r
-extern BM_MENU_OPTION             LegacyFDMenu;\r
-extern BM_MENU_OPTION             LegacyHDMenu;\r
-extern BM_MENU_OPTION             LegacyCDMenu;\r
-extern BM_MENU_OPTION             LegacyNETMenu;\r
-extern BM_MENU_OPTION             LegacyBEVMenu;\r
-extern UINT16                     TerminalType[];\r
-extern COM_ATTR                   BaudRateList[19];\r
-extern COM_ATTR                   DataBitsList[4];\r
-extern COM_ATTR                   ParityList[5];\r
-extern COM_ATTR                   StopBitsList[3];\r
-extern EFI_GUID                   TerminalTypeGuid[4];\r
-extern STRING_DEPOSITORY          *FileOptionStrDepository;\r
-extern STRING_DEPOSITORY          *ConsoleOptionStrDepository;\r
-extern STRING_DEPOSITORY          *BootOptionStrDepository;\r
-extern STRING_DEPOSITORY          *BootOptionHelpStrDepository;\r
-extern STRING_DEPOSITORY          *DriverOptionStrDepository;\r
-extern STRING_DEPOSITORY          *DriverOptionHelpStrDepository;\r
-extern STRING_DEPOSITORY          *TerminalStrDepository;\r
-extern EFI_DEVICE_PATH_PROTOCOL   EndDevicePath[];\r
-extern UINT16                     mFlowControlType[2];\r
-extern UINT32                     mFlowControlValue[2];\r
-//\r
-// Shared IFR form update data\r
-//\r
-extern VOID                        *mStartOpCodeHandle;\r
-extern VOID                        *mEndOpCodeHandle;\r
-extern EFI_IFR_GUID_LABEL          *mStartLabel;\r
-extern EFI_IFR_GUID_LABEL          *mEndLabel;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
deleted file mode 100644 (file)
index 96fe935..0000000
+++ /dev/null
@@ -1,1755 +0,0 @@
-/** @file\r
-  Provide boot option support for Application "BootMaint"\r
-\r
-  Include file system navigation, system handle selection\r
-\r
-  Boot option manipulation\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BootMaint.h"\r
-#include "BBSsupport.h"\r
-\r
-/**\r
-  Create a menu entry by given menu type.\r
-\r
-  @param MenuType        The Menu type to be created.\r
-\r
-  @retval NULL           If failed to create the menu.\r
-  @return the new menu entry.\r
-\r
-**/\r
-BM_MENU_ENTRY *\r
-BOpt_CreateMenuEntry (\r
-  UINTN           MenuType\r
-  )\r
-{\r
-  BM_MENU_ENTRY *MenuEntry;\r
-  UINTN         ContextSize;\r
-\r
-  //\r
-  // Get context size according to menu type\r
-  //\r
-  switch (MenuType) {\r
-  case BM_LOAD_CONTEXT_SELECT:\r
-    ContextSize = sizeof (BM_LOAD_CONTEXT);\r
-    break;\r
-\r
-  case BM_FILE_CONTEXT_SELECT:\r
-    ContextSize = sizeof (BM_FILE_CONTEXT);\r
-    break;\r
-\r
-  case BM_CONSOLE_CONTEXT_SELECT:\r
-    ContextSize = sizeof (BM_CONSOLE_CONTEXT);\r
-    break;\r
-\r
-  case BM_TERMINAL_CONTEXT_SELECT:\r
-    ContextSize = sizeof (BM_TERMINAL_CONTEXT);\r
-    break;\r
-\r
-  case BM_HANDLE_CONTEXT_SELECT:\r
-    ContextSize = sizeof (BM_HANDLE_CONTEXT);\r
-    break;\r
-\r
-  case BM_LEGACY_DEV_CONTEXT_SELECT:\r
-    ContextSize = sizeof (BM_LEGACY_DEVICE_CONTEXT);\r
-    break;\r
-\r
-  default:\r
-    ContextSize = 0;\r
-    break;\r
-  }\r
-\r
-  if (ContextSize == 0) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Create new menu entry\r
-  //\r
-  MenuEntry = AllocateZeroPool (sizeof (BM_MENU_ENTRY));\r
-  if (MenuEntry == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  MenuEntry->VariableContext = AllocateZeroPool (ContextSize);\r
-  if (MenuEntry->VariableContext == NULL) {\r
-    FreePool (MenuEntry);\r
-    return NULL;\r
-  }\r
-\r
-  MenuEntry->Signature        = BM_MENU_ENTRY_SIGNATURE;\r
-  MenuEntry->ContextSelection = MenuType;\r
-  return MenuEntry;\r
-}\r
-\r
-/**\r
-  Free up all resource allocated for a BM_MENU_ENTRY.\r
-\r
-  @param MenuEntry   A pointer to BM_MENU_ENTRY.\r
-\r
-**/\r
-VOID\r
-BOpt_DestroyMenuEntry (\r
-  BM_MENU_ENTRY         *MenuEntry\r
-  )\r
-{\r
-  BM_LOAD_CONTEXT           *LoadContext;\r
-  BM_FILE_CONTEXT           *FileContext;\r
-  BM_CONSOLE_CONTEXT        *ConsoleContext;\r
-  BM_TERMINAL_CONTEXT       *TerminalContext;\r
-  BM_HANDLE_CONTEXT         *HandleContext;\r
-  BM_LEGACY_DEVICE_CONTEXT  *LegacyDevContext;\r
-\r
-  //\r
-  //  Select by the type in Menu entry for current context type\r
-  //\r
-  switch (MenuEntry->ContextSelection) {\r
-  case BM_LOAD_CONTEXT_SELECT:\r
-    LoadContext = (BM_LOAD_CONTEXT *) MenuEntry->VariableContext;\r
-    FreePool (LoadContext->FilePathList);\r
-    FreePool (LoadContext->LoadOption);\r
-    if (LoadContext->OptionalData != NULL) {\r
-      FreePool (LoadContext->OptionalData);\r
-    }\r
-    FreePool (LoadContext);\r
-    break;\r
-\r
-  case BM_FILE_CONTEXT_SELECT:\r
-    FileContext = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
-\r
-    if (!FileContext->IsRoot) {\r
-      FreePool (FileContext->DevicePath);\r
-    } else {\r
-      if (FileContext->FHandle != NULL) {\r
-        FileContext->FHandle->Close (FileContext->FHandle);\r
-      }\r
-    }\r
-\r
-    if (FileContext->FileName != NULL) {\r
-      FreePool (FileContext->FileName);\r
-    }\r
-    if (FileContext->Info != NULL) {\r
-      FreePool (FileContext->Info);\r
-    }\r
-    FreePool (FileContext);\r
-    break;\r
-\r
-  case BM_CONSOLE_CONTEXT_SELECT:\r
-    ConsoleContext = (BM_CONSOLE_CONTEXT *) MenuEntry->VariableContext;\r
-    FreePool (ConsoleContext->DevicePath);\r
-    FreePool (ConsoleContext);\r
-    break;\r
-\r
-  case BM_TERMINAL_CONTEXT_SELECT:\r
-    TerminalContext = (BM_TERMINAL_CONTEXT *) MenuEntry->VariableContext;\r
-    FreePool (TerminalContext->DevicePath);\r
-    FreePool (TerminalContext);\r
-    break;\r
-\r
-  case BM_HANDLE_CONTEXT_SELECT:\r
-    HandleContext = (BM_HANDLE_CONTEXT *) MenuEntry->VariableContext;\r
-    FreePool (HandleContext);\r
-    break;\r
-\r
-  case BM_LEGACY_DEV_CONTEXT_SELECT:\r
-    LegacyDevContext = (BM_LEGACY_DEVICE_CONTEXT *) MenuEntry->VariableContext;\r
-    FreePool (LegacyDevContext);\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  FreePool (MenuEntry->DisplayString);\r
-  if (MenuEntry->HelpString != NULL) {\r
-    FreePool (MenuEntry->HelpString);\r
-  }\r
-\r
-  FreePool (MenuEntry);\r
-}\r
-\r
-/**\r
-  Get the Menu Entry from the list in Menu Entry List.\r
-\r
-  If MenuNumber is great or equal to the number of Menu\r
-  Entry in the list, then ASSERT.\r
-\r
-  @param MenuOption      The Menu Entry List to read the menu entry.\r
-  @param MenuNumber      The index of Menu Entry.\r
-\r
-  @return The Menu Entry.\r
-\r
-**/\r
-BM_MENU_ENTRY *\r
-BOpt_GetMenuEntry (\r
-  BM_MENU_OPTION      *MenuOption,\r
-  UINTN               MenuNumber\r
-  )\r
-{\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  UINTN           Index;\r
-  LIST_ENTRY      *List;\r
-\r
-  ASSERT (MenuNumber < MenuOption->MenuNumber);\r
-\r
-  List = MenuOption->Head.ForwardLink;\r
-  for (Index = 0; Index < MenuNumber; Index++) {\r
-    List = List->ForwardLink;\r
-  }\r
-\r
-  NewMenuEntry = CR (List, BM_MENU_ENTRY, Link, BM_MENU_ENTRY_SIGNATURE);\r
-\r
-  return NewMenuEntry;\r
-}\r
-\r
-/**\r
-  This function build the FsOptionMenu list which records all\r
-  available file system in the system. They includes all instances\r
-  of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM\r
-  and all type of legacy boot device.\r
-\r
-  @param CallbackData    BMM context data\r
-\r
-  @retval  EFI_SUCCESS             Success find the file system\r
-  @retval  EFI_OUT_OF_RESOURCES    Can not create menu entry\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_FindFileSystem (\r
-  IN BMM_CALLBACK_DATA          *CallbackData\r
-  )\r
-{\r
-  UINTN                     NoBlkIoHandles;\r
-  UINTN                     NoSimpleFsHandles;\r
-  UINTN                     NoLoadFileHandles;\r
-  EFI_HANDLE                *BlkIoHandle;\r
-  EFI_HANDLE                *SimpleFsHandle;\r
-  EFI_HANDLE                *LoadFileHandle;\r
-  UINT16                    *VolumeLabel;\r
-  EFI_BLOCK_IO_PROTOCOL     *BlkIo;\r
-  UINTN                     Index;\r
-  EFI_STATUS                Status;\r
-  BM_MENU_ENTRY             *MenuEntry;\r
-  BM_FILE_CONTEXT           *FileContext;\r
-  UINT16                    *TempStr;\r
-  UINTN                     OptionNumber;\r
-  VOID                      *Buffer;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  UINT16                    DeviceType;\r
-  BBS_BBS_DEVICE_PATH       BbsDevicePathNode;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  BOOLEAN                   RemovableMedia;\r
-\r
-\r
-  NoSimpleFsHandles = 0;\r
-  NoLoadFileHandles = 0;\r
-  OptionNumber      = 0;\r
-  InitializeListHead (&FsOptionMenu.Head);\r
-\r
-  //\r
-  // Locate Handles that support BlockIo protocol\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  NULL,\r
-                  &NoBlkIoHandles,\r
-                  &BlkIoHandle\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-\r
-    for (Index = 0; Index < NoBlkIoHandles; Index++) {\r
-      Status = gBS->HandleProtocol (\r
-                      BlkIoHandle[Index],\r
-                      &gEfiBlockIoProtocolGuid,\r
-                      (VOID **) &BlkIo\r
-                      );\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        continue;\r
-      }\r
-\r
-      //\r
-      // Issue a dummy read to trigger reinstall of BlockIo protocol for removable media\r
-      //\r
-      if (BlkIo->Media->RemovableMedia) {\r
-        Buffer = AllocateZeroPool (BlkIo->Media->BlockSize);\r
-        if (NULL == Buffer) {\r
-          FreePool (BlkIoHandle);\r
-          return EFI_OUT_OF_RESOURCES;\r
-        }\r
-\r
-        BlkIo->ReadBlocks (\r
-                BlkIo,\r
-                BlkIo->Media->MediaId,\r
-                0,\r
-                BlkIo->Media->BlockSize,\r
-                Buffer\r
-                );\r
-        FreePool (Buffer);\r
-      }\r
-    }\r
-    FreePool (BlkIoHandle);\r
-  }\r
-\r
-  //\r
-  // Locate Handles that support Simple File System protocol\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  NULL,\r
-                  &NoSimpleFsHandles,\r
-                  &SimpleFsHandle\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Find all the instances of the File System prototocol\r
-    //\r
-    for (Index = 0; Index < NoSimpleFsHandles; Index++) {\r
-      Status = gBS->HandleProtocol (\r
-                      SimpleFsHandle[Index],\r
-                      &gEfiBlockIoProtocolGuid,\r
-                      (VOID **) &BlkIo\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // If no block IO exists assume it's NOT a removable media\r
-        //\r
-        RemovableMedia = FALSE;\r
-      } else {\r
-        //\r
-        // If block IO exists check to see if it's remobable media\r
-        //\r
-        RemovableMedia = BlkIo->Media->RemovableMedia;\r
-      }\r
-\r
-      //\r
-      // Allocate pool for this load option\r
-      //\r
-      MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
-      if (NULL == MenuEntry) {\r
-        FreePool (SimpleFsHandle);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      FileContext = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
-\r
-      FileContext->Handle     = SimpleFsHandle[Index];\r
-      MenuEntry->OptionNumber = Index;\r
-      FileContext->FHandle    = EfiLibOpenRoot (FileContext->Handle);\r
-      if (FileContext->FHandle == NULL) {\r
-        BOpt_DestroyMenuEntry (MenuEntry);\r
-        continue;\r
-      }\r
-\r
-      MenuEntry->HelpString = DevicePathToStr (DevicePathFromHandle (FileContext->Handle));\r
-      FileContext->Info = EfiLibFileSystemVolumeLabelInfo (FileContext->FHandle);\r
-      FileContext->FileName = EfiStrDuplicate (L"\\");\r
-      FileContext->DevicePath = FileDevicePath (\r
-                                  FileContext->Handle,\r
-                                  FileContext->FileName\r
-                                  );\r
-      FileContext->IsDir            = TRUE;\r
-      FileContext->IsRoot           = TRUE;\r
-      FileContext->IsRemovableMedia = RemovableMedia;\r
-      FileContext->IsLoadFile       = FALSE;\r
-\r
-      //\r
-      // Get current file system's Volume Label\r
-      //\r
-      if (FileContext->Info == NULL) {\r
-        VolumeLabel = L"NO FILE SYSTEM INFO";\r
-      } else {\r
-        VolumeLabel = FileContext->Info->VolumeLabel;\r
-        if (*VolumeLabel == 0x0000) {\r
-          VolumeLabel = L"NO VOLUME LABEL";\r
-        }\r
-      }\r
-\r
-      TempStr                   = MenuEntry->HelpString;\r
-      MenuEntry->DisplayString  = AllocateZeroPool (MAX_CHAR);\r
-      ASSERT (MenuEntry->DisplayString != NULL);\r
-      UnicodeSPrint (\r
-        MenuEntry->DisplayString,\r
-        MAX_CHAR,\r
-        L"%s, [%s]",\r
-        VolumeLabel,\r
-        TempStr\r
-        );\r
-      OptionNumber++;\r
-      InsertTailList (&FsOptionMenu.Head, &MenuEntry->Link);\r
-    }\r
-  }\r
-\r
-  if (NoSimpleFsHandles != 0) {\r
-    FreePool (SimpleFsHandle);\r
-  }\r
-  //\r
-  // Searching for handles that support Load File protocol\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiLoadFileProtocolGuid,\r
-                  NULL,\r
-                  &NoLoadFileHandles,\r
-                  &LoadFileHandle\r
-                  );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    for (Index = 0; Index < NoLoadFileHandles; Index++) {\r
-      MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
-      if (NULL == MenuEntry) {\r
-        FreePool (LoadFileHandle);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      FileContext                   = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
-      FileContext->IsRemovableMedia = FALSE;\r
-      FileContext->IsLoadFile       = TRUE;\r
-      FileContext->Handle           = LoadFileHandle[Index];\r
-      FileContext->IsRoot           = TRUE;\r
-\r
-      FileContext->DevicePath       = DevicePathFromHandle (FileContext->Handle);\r
-      FileContext->FileName         = DevicePathToStr (FileContext->DevicePath);\r
-\r
-      MenuEntry->HelpString     = DevicePathToStr (FileContext->DevicePath);\r
-\r
-      TempStr                   = MenuEntry->HelpString;\r
-      MenuEntry->DisplayString  = AllocateZeroPool (MAX_CHAR);\r
-      ASSERT (MenuEntry->DisplayString != NULL);\r
-      UnicodeSPrint (\r
-        MenuEntry->DisplayString,\r
-        MAX_CHAR,\r
-        L"Load File [%s]",\r
-        TempStr\r
-        );\r
-\r
-      MenuEntry->OptionNumber = OptionNumber;\r
-      OptionNumber++;\r
-      InsertTailList (&FsOptionMenu.Head, &MenuEntry->Link);\r
-    }\r
-  }\r
-\r
-  if (NoLoadFileHandles != 0) {\r
-    FreePool (LoadFileHandle);\r
-  }\r
-\r
-  //\r
-  // Add Legacy Boot Option Support Here\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiLegacyBiosProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &LegacyBios\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-\r
-    for (Index = BBS_TYPE_FLOPPY; Index <= BBS_TYPE_EMBEDDED_NETWORK; Index++) {\r
-      MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
-      if (NULL == MenuEntry) {\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      FileContext                       = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
-\r
-      FileContext->IsRemovableMedia     = FALSE;\r
-      FileContext->IsLoadFile           = TRUE;\r
-      FileContext->IsBootLegacy         = TRUE;\r
-      DeviceType                        = (UINT16) Index;\r
-      BbsDevicePathNode.Header.Type     = BBS_DEVICE_PATH;\r
-      BbsDevicePathNode.Header.SubType  = BBS_BBS_DP;\r
-      SetDevicePathNodeLength (\r
-        &BbsDevicePathNode.Header,\r
-        sizeof (BBS_BBS_DEVICE_PATH)\r
-        );\r
-      BbsDevicePathNode.DeviceType  = DeviceType;\r
-      BbsDevicePathNode.StatusFlag  = 0;\r
-      BbsDevicePathNode.String[0]   = 0;\r
-      DevicePath = AppendDevicePathNode (\r
-                    EndDevicePath,\r
-                    (EFI_DEVICE_PATH_PROTOCOL *) &BbsDevicePathNode\r
-                    );\r
-\r
-      FileContext->DevicePath   = DevicePath;\r
-      MenuEntry->HelpString     = DevicePathToStr (FileContext->DevicePath);\r
-\r
-      TempStr                   = MenuEntry->HelpString;\r
-      MenuEntry->DisplayString  = AllocateZeroPool (MAX_CHAR);\r
-      ASSERT (MenuEntry->DisplayString != NULL);\r
-      UnicodeSPrint (\r
-        MenuEntry->DisplayString,\r
-        MAX_CHAR,\r
-        L"Boot Legacy [%s]",\r
-        TempStr\r
-        );\r
-      MenuEntry->OptionNumber = OptionNumber;\r
-      OptionNumber++;\r
-      InsertTailList (&FsOptionMenu.Head, &MenuEntry->Link);\r
-    }\r
-  }\r
-  //\r
-  // Remember how many file system options are here\r
-  //\r
-  FsOptionMenu.MenuNumber = OptionNumber;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Free resources allocated in Allocate Rountine.\r
-\r
-  @param FreeMenu        Menu to be freed\r
-**/\r
-VOID\r
-BOpt_FreeMenu (\r
-  BM_MENU_OPTION        *FreeMenu\r
-  )\r
-{\r
-  BM_MENU_ENTRY *MenuEntry;\r
-  while (!IsListEmpty (&FreeMenu->Head)) {\r
-    MenuEntry = CR (\r
-                  FreeMenu->Head.ForwardLink,\r
-                  BM_MENU_ENTRY,\r
-                  Link,\r
-                  BM_MENU_ENTRY_SIGNATURE\r
-                  );\r
-    RemoveEntryList (&MenuEntry->Link);\r
-    BOpt_DestroyMenuEntry (MenuEntry);\r
-  }\r
-  FreeMenu->MenuNumber = 0;\r
-}\r
-\r
-/**\r
-  Find files under current directory\r
-  All files and sub-directories in current directory\r
-  will be stored in DirectoryMenu for future use.\r
-\r
-  @param CallbackData  The BMM context data.\r
-  @param MenuEntry     The Menu Entry.\r
-\r
-  @retval EFI_SUCCESS         Get files from current dir successfully.\r
-  @return Other value if can't get files from current dir.\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_FindFiles (\r
-  IN BMM_CALLBACK_DATA          *CallbackData,\r
-  IN BM_MENU_ENTRY              *MenuEntry\r
-  )\r
-{\r
-  EFI_FILE_HANDLE NewDir;\r
-  EFI_FILE_HANDLE Dir;\r
-  EFI_FILE_INFO   *DirInfo;\r
-  UINTN           BufferSize;\r
-  UINTN           DirBufferSize;\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_FILE_CONTEXT *FileContext;\r
-  BM_FILE_CONTEXT *NewFileContext;\r
-  UINTN           Pass;\r
-  EFI_STATUS      Status;\r
-  UINTN           OptionNumber;\r
-\r
-  FileContext   = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
-  Dir           = FileContext->FHandle;\r
-  OptionNumber  = 0;\r
-  //\r
-  // Open current directory to get files from it\r
-  //\r
-  Status = Dir->Open (\r
-                  Dir,\r
-                  &NewDir,\r
-                  FileContext->FileName,\r
-                  EFI_FILE_READ_ONLY,\r
-                  0\r
-                  );\r
-  if (!FileContext->IsRoot) {\r
-    Dir->Close (Dir);\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  DirInfo = EfiLibFileInfo (NewDir);\r
-  if (DirInfo == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  FileContext->DevicePath = FileDevicePath (\r
-                              FileContext->Handle,\r
-                              FileContext->FileName\r
-                              );\r
-\r
-  DirBufferSize = sizeof (EFI_FILE_INFO) + 1024;\r
-  DirInfo       = AllocateZeroPool (DirBufferSize);\r
-  if (DirInfo == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Get all files in current directory\r
-  // Pass 1 to get Directories\r
-  // Pass 2 to get files that are EFI images\r
-  //\r
-  for (Pass = 1; Pass <= 2; Pass++) {\r
-    NewDir->SetPosition (NewDir, 0);\r
-    for (;;) {\r
-      BufferSize  = DirBufferSize;\r
-      Status      = NewDir->Read (NewDir, &BufferSize, DirInfo);\r
-      if (EFI_ERROR (Status) || BufferSize == 0) {\r
-        break;\r
-      }\r
-\r
-      if (((DirInfo->Attribute & EFI_FILE_DIRECTORY) != 0 && Pass == 2) ||\r
-          ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == 0 && Pass == 1)\r
-          ) {\r
-        //\r
-        // Pass 1 is for Directories\r
-        // Pass 2 is for file names\r
-        //\r
-        continue;\r
-      }\r
-\r
-      if (!(BOpt_IsEfiImageName (DirInfo->FileName) || (DirInfo->Attribute & EFI_FILE_DIRECTORY) != 0)) {\r
-        //\r
-        // Slip file unless it is a directory entry or a .EFI file\r
-        //\r
-        continue;\r
-      }\r
-\r
-      NewMenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
-      if (NULL == NewMenuEntry) {\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      NewFileContext          = (BM_FILE_CONTEXT *) NewMenuEntry->VariableContext;\r
-      NewFileContext->Handle  = FileContext->Handle;\r
-      NewFileContext->FileName = BOpt_AppendFileName (\r
-                                  FileContext->FileName,\r
-                                  DirInfo->FileName\r
-                                  );\r
-      NewFileContext->FHandle = NewDir;\r
-      NewFileContext->DevicePath = FileDevicePath (\r
-                                    NewFileContext->Handle,\r
-                                    NewFileContext->FileName\r
-                                    );\r
-      NewMenuEntry->HelpString = NULL;\r
-\r
-      MenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
-                                        CallbackData,\r
-                                        FileOptionStrDepository\r
-                                        );\r
-\r
-      NewFileContext->IsDir = (BOOLEAN) ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY);\r
-\r
-      if (NewFileContext->IsDir) {\r
-        BufferSize                  = StrLen (DirInfo->FileName) * 2 + 6;\r
-        NewMenuEntry->DisplayString = AllocateZeroPool (BufferSize);\r
-\r
-        UnicodeSPrint (\r
-          NewMenuEntry->DisplayString,\r
-          BufferSize,\r
-          L"<%s>",\r
-          DirInfo->FileName\r
-          );\r
-\r
-      } else {\r
-        NewMenuEntry->DisplayString = EfiStrDuplicate (DirInfo->FileName);\r
-      }\r
-\r
-      NewFileContext->IsRoot            = FALSE;\r
-      NewFileContext->IsLoadFile        = FALSE;\r
-      NewFileContext->IsRemovableMedia  = FALSE;\r
-\r
-      NewMenuEntry->OptionNumber        = OptionNumber;\r
-      OptionNumber++;\r
-      InsertTailList (&DirectoryMenu.Head, &NewMenuEntry->Link);\r
-    }\r
-  }\r
-\r
-  DirectoryMenu.MenuNumber = OptionNumber;\r
-  FreePool (DirInfo);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().\r
-\r
-  @retval EFI_SUCCESS The function complete successfully.\r
-  @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_GetLegacyOptions (\r
-  VOID\r
-  )\r
-{\r
-  BM_MENU_ENTRY             *NewMenuEntry;\r
-  BM_LEGACY_DEVICE_CONTEXT  *NewLegacyDevContext;\r
-  EFI_STATUS                Status;\r
-  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
-  UINT16                    HddCount;\r
-  HDD_INFO                  *HddInfo;\r
-  UINT16                    BbsCount;\r
-  BBS_TABLE                 *BbsTable;\r
-  UINT16                    Index;\r
-  CHAR16                    DescString[100];\r
-  UINTN                     FDNum;\r
-  UINTN                     HDNum;\r
-  UINTN                     CDNum;\r
-  UINTN                     NETNum;\r
-  UINTN                     BEVNum;\r
-\r
-  NewMenuEntry  = NULL;\r
-  HddInfo       = NULL;\r
-  BbsTable      = NULL;\r
-  BbsCount      = 0;\r
-\r
-  //\r
-  // Initialize Bbs Table Context from BBS info data\r
-  //\r
-  InitializeListHead (&LegacyFDMenu.Head);\r
-  InitializeListHead (&LegacyHDMenu.Head);\r
-  InitializeListHead (&LegacyCDMenu.Head);\r
-  InitializeListHead (&LegacyNETMenu.Head);\r
-  InitializeListHead (&LegacyBEVMenu.Head);\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiLegacyBiosProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &LegacyBios\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = LegacyBios->GetBbsInfo (\r
-                          LegacyBios,\r
-                          &HddCount,\r
-                          &HddInfo,\r
-                          &BbsCount,\r
-                          &BbsTable\r
-                          );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  FDNum   = 0;\r
-  HDNum   = 0;\r
-  CDNum   = 0;\r
-  NETNum  = 0;\r
-  BEVNum  = 0;\r
-\r
-  for (Index = 0; Index < BbsCount; Index++) {\r
-    if ((BBS_IGNORE_ENTRY == BbsTable[Index].BootPriority) ||\r
-        (BBS_DO_NOT_BOOT_FROM == BbsTable[Index].BootPriority)\r
-        ) {\r
-      continue;\r
-    }\r
-\r
-    NewMenuEntry = BOpt_CreateMenuEntry (BM_LEGACY_DEV_CONTEXT_SELECT);\r
-    if (NULL == NewMenuEntry) {\r
-      break;\r
-    }\r
-\r
-    NewLegacyDevContext           = (BM_LEGACY_DEVICE_CONTEXT *) NewMenuEntry->VariableContext;\r
-    NewLegacyDevContext->BbsEntry = &BbsTable[Index];\r
-    NewLegacyDevContext->BbsIndex = Index;\r
-    NewLegacyDevContext->BbsCount = BbsCount;\r
-    BdsBuildLegacyDevNameString (\r
-      &BbsTable[Index],\r
-      Index,\r
-      sizeof (DescString),\r
-      DescString\r
-      );\r
-    NewLegacyDevContext->Description = AllocateCopyPool (StrSize (DescString), DescString);\r
-    if (NULL == NewLegacyDevContext->Description) {\r
-      break;\r
-    }\r
-\r
-    NewMenuEntry->DisplayString = NewLegacyDevContext->Description;\r
-    NewMenuEntry->HelpString    = NULL;\r
-\r
-    switch (BbsTable[Index].DeviceType) {\r
-    case BBS_FLOPPY:\r
-      InsertTailList (&LegacyFDMenu.Head, &NewMenuEntry->Link);\r
-      FDNum++;\r
-      break;\r
-\r
-    case BBS_HARDDISK:\r
-      InsertTailList (&LegacyHDMenu.Head, &NewMenuEntry->Link);\r
-      HDNum++;\r
-      break;\r
-\r
-    case BBS_CDROM:\r
-      InsertTailList (&LegacyCDMenu.Head, &NewMenuEntry->Link);\r
-      CDNum++;\r
-      break;\r
-\r
-    case BBS_EMBED_NETWORK:\r
-      InsertTailList (&LegacyNETMenu.Head, &NewMenuEntry->Link);\r
-      NETNum++;\r
-      break;\r
-\r
-    case BBS_BEV_DEVICE:\r
-      InsertTailList (&LegacyBEVMenu.Head, &NewMenuEntry->Link);\r
-      BEVNum++;\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (Index != BbsCount) {\r
-    BOpt_FreeLegacyOptions ();\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  LegacyFDMenu.MenuNumber   = FDNum;\r
-  LegacyHDMenu.MenuNumber   = HDNum;\r
-  LegacyCDMenu.MenuNumber   = CDNum;\r
-  LegacyNETMenu.MenuNumber  = NETNum;\r
-  LegacyBEVMenu.MenuNumber  = BEVNum;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Free out resouce allocated from Legacy Boot Options.\r
-\r
-**/\r
-VOID\r
-BOpt_FreeLegacyOptions (\r
-  VOID\r
-  )\r
-{\r
-  BOpt_FreeMenu (&LegacyFDMenu);\r
-  BOpt_FreeMenu (&LegacyHDMenu);\r
-  BOpt_FreeMenu (&LegacyCDMenu);\r
-  BOpt_FreeMenu (&LegacyNETMenu);\r
-  BOpt_FreeMenu (&LegacyBEVMenu);\r
-}\r
-\r
-/**\r
-\r
-  Build the BootOptionMenu according to BootOrder Variable.\r
-  This Routine will access the Boot#### to get EFI_LOAD_OPTION.\r
-\r
-  @param CallbackData The BMM context data.\r
-\r
-  @return EFI_NOT_FOUND Fail to find "BootOrder" variable.\r
-  @return EFI_SUCESS    Success build boot option menu.\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_GetBootOptions (\r
-  IN  BMM_CALLBACK_DATA         *CallbackData\r
-  )\r
-{\r
-  UINTN                     Index;\r
-  UINT16                    BootString[10];\r
-  UINT8                     *LoadOptionFromVar;\r
-  UINT8                     *LoadOption;\r
-  UINTN                     BootOptionSize;\r
-  BOOLEAN                   BootNextFlag;\r
-  UINT16                    *BootOrderList;\r
-  UINTN                     BootOrderListSize;\r
-  UINT16                    *BootNext;\r
-  UINTN                     BootNextSize;\r
-  BM_MENU_ENTRY             *NewMenuEntry;\r
-  BM_LOAD_CONTEXT           *NewLoadContext;\r
-  UINT8                     *LoadOptionPtr;\r
-  UINTN                     StringSize;\r
-  UINTN                     OptionalDataSize;\r
-  UINT8                     *LoadOptionEnd;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  UINTN                     MenuCount;\r
-  UINT8                     *Ptr;\r
-\r
-  MenuCount         = 0;\r
-  BootOrderListSize = 0;\r
-  BootNextSize      = 0;\r
-  BootOrderList     = NULL;\r
-  BootNext          = NULL;\r
-  LoadOptionFromVar = NULL;\r
-  BOpt_FreeMenu (&BootOptionMenu);\r
-  InitializeListHead (&BootOptionMenu.Head);\r
-\r
-  //\r
-  // Get the BootOrder from the Var\r
-  //\r
-  BootOrderList = BdsLibGetVariableAndSize (\r
-                    L"BootOrder",\r
-                    &gEfiGlobalVariableGuid,\r
-                    &BootOrderListSize\r
-                    );\r
-  if (BootOrderList == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Get the BootNext from the Var\r
-  //\r
-  BootNext = BdsLibGetVariableAndSize (\r
-              L"BootNext",\r
-              &gEfiGlobalVariableGuid,\r
-              &BootNextSize\r
-              );\r
-\r
-  if (BootNext != NULL) {\r
-    if (BootNextSize != sizeof (UINT16)) {\r
-      FreePool (BootNext);\r
-      BootNext = NULL;\r
-    }\r
-  }\r
-\r
-  for (Index = 0; Index < BootOrderListSize / sizeof (UINT16); Index++) {\r
-    UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", BootOrderList[Index]);\r
-    //\r
-    //  Get all loadoptions from the VAR\r
-    //\r
-    LoadOptionFromVar = BdsLibGetVariableAndSize (\r
-                          BootString,\r
-                          &gEfiGlobalVariableGuid,\r
-                          &BootOptionSize\r
-                          );\r
-    if (LoadOptionFromVar == NULL) {\r
-      continue;\r
-    }\r
-\r
-    LoadOption = AllocateZeroPool (BootOptionSize);\r
-    if (LoadOption == NULL) {\r
-      continue;\r
-    }\r
-\r
-    CopyMem (LoadOption, LoadOptionFromVar, BootOptionSize);\r
-    FreePool (LoadOptionFromVar);\r
-\r
-    if (BootNext != NULL) {\r
-      BootNextFlag = (BOOLEAN) (*BootNext == BootOrderList[Index]);\r
-    } else {\r
-      BootNextFlag = FALSE;\r
-    }\r
-\r
-    if (0 == (*((UINT32 *) LoadOption) & LOAD_OPTION_ACTIVE)) {\r
-      FreePool (LoadOption);\r
-      continue;\r
-    }\r
-    //\r
-    // BUGBUG: could not return EFI_OUT_OF_RESOURCES here directly.\r
-    // the buffer allocated already should be freed before returning.\r
-    //\r
-    NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
-    if (NULL == NewMenuEntry) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    NewLoadContext                      = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-\r
-    LoadOptionPtr                       = LoadOption;\r
-    LoadOptionEnd                       = LoadOption + BootOptionSize;\r
-\r
-    NewMenuEntry->OptionNumber          = BootOrderList[Index];\r
-    NewLoadContext->LoadOptionModified  = FALSE;\r
-    NewLoadContext->Deleted             = FALSE;\r
-    NewLoadContext->IsBootNext          = BootNextFlag;\r
-\r
-    //\r
-    // Is a Legacy Device?\r
-    //\r
-    Ptr = (UINT8 *) LoadOption;\r
-\r
-    //\r
-    // Attribute = *(UINT32 *)Ptr;\r
-    //\r
-    Ptr += sizeof (UINT32);\r
-\r
-    //\r
-    // FilePathSize = *(UINT16 *)Ptr;\r
-    //\r
-    Ptr += sizeof (UINT16);\r
-\r
-    //\r
-    // Description = (CHAR16 *)Ptr;\r
-    //\r
-    Ptr += StrSize ((CHAR16 *) Ptr);\r
-\r
-    //\r
-    // Now Ptr point to Device Path\r
-    //\r
-    DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
-    if ((BBS_DEVICE_PATH == DevicePath->Type) && (BBS_BBS_DP == DevicePath->SubType)) {\r
-      NewLoadContext->IsLegacy = TRUE;\r
-    } else {\r
-      NewLoadContext->IsLegacy = FALSE;\r
-    }\r
-    //\r
-    // LoadOption is a pointer type of UINT8\r
-    // for easy use with following LOAD_OPTION\r
-    // embedded in this struct\r
-    //\r
-    NewLoadContext->LoadOption      = LoadOption;\r
-    NewLoadContext->LoadOptionSize  = BootOptionSize;\r
-\r
-    NewLoadContext->Attributes      = *(UINT32 *) LoadOptionPtr;\r
-    NewLoadContext->IsActive        = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_ACTIVE);\r
-\r
-    NewLoadContext->ForceReconnect  = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);\r
-\r
-    LoadOptionPtr += sizeof (UINT32);\r
-\r
-    NewLoadContext->FilePathListLength = *(UINT16 *) LoadOptionPtr;\r
-    LoadOptionPtr += sizeof (UINT16);\r
-\r
-    StringSize = StrSize((UINT16*)LoadOptionPtr);\r
-\r
-    NewLoadContext->Description = AllocateCopyPool (StrSize((UINT16*)LoadOptionPtr), LoadOptionPtr);\r
-    ASSERT (NewLoadContext->Description != NULL);\r
-\r
-    NewMenuEntry->DisplayString = NewLoadContext->Description;\r
-\r
-    LoadOptionPtr += StringSize;\r
-\r
-    NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);\r
-    ASSERT (NewLoadContext->FilePathList != NULL);\r
-    CopyMem (\r
-      NewLoadContext->FilePathList,\r
-      (EFI_DEVICE_PATH_PROTOCOL *) LoadOptionPtr,\r
-      NewLoadContext->FilePathListLength\r
-      );\r
-\r
-    NewMenuEntry->HelpString = DevicePathToStr (NewLoadContext->FilePathList);\r
-    NewMenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
-                                        CallbackData,\r
-                                        BootOptionStrDepository\r
-                                        );\r
-    NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
-                                      CallbackData,\r
-                                      BootOptionHelpStrDepository\r
-                                      );\r
-    LoadOptionPtr += NewLoadContext->FilePathListLength;\r
-\r
-    if (LoadOptionPtr < LoadOptionEnd) {\r
-      OptionalDataSize = BootOptionSize -\r
-        sizeof (UINT32) -\r
-        sizeof (UINT16) -\r
-        StringSize -\r
-        NewLoadContext->FilePathListLength;\r
-\r
-      NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);\r
-      ASSERT (NewLoadContext->OptionalData != NULL);\r
-      CopyMem (\r
-        NewLoadContext->OptionalData,\r
-        LoadOptionPtr,\r
-        OptionalDataSize\r
-        );\r
-\r
-      NewLoadContext->OptionalDataSize = OptionalDataSize;\r
-    }\r
-\r
-    InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);\r
-    MenuCount++;\r
-  }\r
-\r
-  if (BootNext != NULL) {\r
-    FreePool (BootNext);\r
-  }\r
-  if (BootOrderList != NULL) {\r
-    FreePool (BootOrderList);\r
-  }\r
-  BootOptionMenu.MenuNumber = MenuCount;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  Append file name to existing file name.\r
-\r
-  @param Str1  The existing file name\r
-  @param Str2  The file name to be appended\r
-\r
-  @return Allocate a new string to hold the appended result.\r
-          Caller is responsible to free the returned string.\r
-\r
-**/\r
-CHAR16 *\r
-BOpt_AppendFileName (\r
-  IN  CHAR16  *Str1,\r
-  IN  CHAR16  *Str2\r
-  )\r
-{\r
-  UINTN   Size1;\r
-  UINTN   Size2;\r
-  UINTN   MaxLen;\r
-  CHAR16  *Str;\r
-  CHAR16  *TmpStr;\r
-  CHAR16  *Ptr;\r
-  CHAR16  *LastSlash;\r
-\r
-  Size1 = StrSize (Str1);\r
-  Size2 = StrSize (Str2);\r
-  MaxLen = (Size1 + Size2 + sizeof (CHAR16)) / sizeof (CHAR16);\r
-  Str   = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
-  ASSERT (Str != NULL);\r
-\r
-  TmpStr = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
-  ASSERT (TmpStr != NULL);\r
-\r
-  StrCatS (Str, MaxLen, Str1);\r
-  if (!((*Str == '\\') && (*(Str + 1) == 0))) {\r
-    StrCatS (Str, MaxLen, L"\\");\r
-  }\r
-\r
-  StrCatS (Str, MaxLen, Str2);\r
-\r
-  Ptr       = Str;\r
-  LastSlash = Str;\r
-  while (*Ptr != 0) {\r
-    if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '.' && *(Ptr + 3) == L'\\') {\r
-      //\r
-      // Convert "\Name\..\" to "\"\r
-      // DO NOT convert the .. if it is at the end of the string. This will\r
-      // break the .. behavior in changing directories.\r
-      //\r
-\r
-      //\r
-      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings\r
-      // that overlap.\r
-      //\r
-      StrCpyS (TmpStr, MaxLen, Ptr + 3);\r
-      StrCpyS (LastSlash, MaxLen - ((UINTN) LastSlash - (UINTN) Str) / sizeof (CHAR16), TmpStr);\r
-      Ptr = LastSlash;\r
-    } else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {\r
-      //\r
-      // Convert a "\.\" to a "\"\r
-      //\r
-\r
-      //\r
-      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings\r
-      // that overlap.\r
-      //\r
-      StrCpyS (TmpStr, MaxLen, Ptr + 2);\r
-      StrCpyS (Ptr, MaxLen - ((UINTN) Ptr - (UINTN) Str) / sizeof (CHAR16), TmpStr);\r
-      Ptr = LastSlash;\r
-    } else if (*Ptr == '\\') {\r
-      LastSlash = Ptr;\r
-    }\r
-\r
-    Ptr++;\r
-  }\r
-\r
-  FreePool (TmpStr);\r
-\r
-  return Str;\r
-}\r
-\r
-/**\r
-\r
-  Check whether current FileName point to a valid\r
-  Efi Image File.\r
-\r
-  @param FileName  File need to be checked.\r
-\r
-  @retval TRUE  Is Efi Image\r
-  @retval FALSE Not a valid Efi Image\r
-\r
-**/\r
-BOOLEAN\r
-BOpt_IsEfiImageName (\r
-  IN UINT16  *FileName\r
-  )\r
-{\r
-  //\r
-  // Search for ".efi" extension\r
-  //\r
-  while (*FileName != L'\0') {\r
-    if (FileName[0] == '.') {\r
-      if (FileName[1] == 'e' || FileName[1] == 'E') {\r
-        if (FileName[2] == 'f' || FileName[2] == 'F') {\r
-          if (FileName[3] == 'i' || FileName[3] == 'I') {\r
-            return TRUE;\r
-          } else if (FileName[3] == 0x0000) {\r
-            return FALSE;\r
-          }\r
-        } else if (FileName[2] == 0x0000) {\r
-          return FALSE;\r
-        }\r
-      } else if (FileName[1] == 0x0000) {\r
-        return FALSE;\r
-      }\r
-    }\r
-\r
-    FileName += 1;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-\r
-\r
-/**\r
-\r
-  Find drivers that will be added as Driver#### variables from handles\r
-  in current system environment\r
-  All valid handles in the system except those consume SimpleFs, LoadFile\r
-  are stored in DriverMenu for future use.\r
-\r
-  @retval EFI_SUCCESS The function complets successfully.\r
-  @return Other value if failed to build the DriverMenu.\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_FindDrivers (\r
-  VOID\r
-  )\r
-{\r
-  UINTN                           NoDevicePathHandles;\r
-  EFI_HANDLE                      *DevicePathHandle;\r
-  UINTN                           Index;\r
-  EFI_STATUS                      Status;\r
-  BM_MENU_ENTRY                   *NewMenuEntry;\r
-  BM_HANDLE_CONTEXT               *NewHandleContext;\r
-  EFI_HANDLE                      CurHandle;\r
-  UINTN                           OptionNumber;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;\r
-  EFI_LOAD_FILE_PROTOCOL          *LoadFile;\r
-\r
-  SimpleFs  = NULL;\r
-  LoadFile  = NULL;\r
-\r
-  InitializeListHead (&DriverMenu.Head);\r
-\r
-  //\r
-  // At first, get all handles that support Device Path\r
-  // protocol which is the basic requirement for\r
-  // Driver####\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  NULL,\r
-                  &NoDevicePathHandles,\r
-                  &DevicePathHandle\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  OptionNumber = 0;\r
-  for (Index = 0; Index < NoDevicePathHandles; Index++) {\r
-    CurHandle = DevicePathHandle[Index];\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    CurHandle,\r
-                    &gEfiSimpleFileSystemProtocolGuid,\r
-                    (VOID **) &SimpleFs\r
-                    );\r
-    if (Status == EFI_SUCCESS) {\r
-      continue;\r
-    }\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    CurHandle,\r
-                    &gEfiLoadFileProtocolGuid,\r
-                    (VOID **) &LoadFile\r
-                    );\r
-    if (Status == EFI_SUCCESS) {\r
-      continue;\r
-    }\r
-\r
-    NewMenuEntry = BOpt_CreateMenuEntry (BM_HANDLE_CONTEXT_SELECT);\r
-    if (NULL == NewMenuEntry) {\r
-      FreePool (DevicePathHandle);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    NewHandleContext              = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-    NewHandleContext->Handle      = CurHandle;\r
-    NewHandleContext->DevicePath  = DevicePathFromHandle (CurHandle);\r
-    NewMenuEntry->DisplayString = DevicePathToStr (NewHandleContext->DevicePath);\r
-    NewMenuEntry->HelpString    = NULL;\r
-    NewMenuEntry->OptionNumber  = OptionNumber;\r
-    OptionNumber++;\r
-    InsertTailList (&DriverMenu.Head, &NewMenuEntry->Link);\r
-\r
-  }\r
-\r
-  if (DevicePathHandle != NULL) {\r
-    FreePool (DevicePathHandle);\r
-  }\r
-\r
-  DriverMenu.MenuNumber = OptionNumber;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  Get the Option Number that has not been allocated for use.\r
-\r
-  @param Type  The type of Option.\r
-\r
-  @return The available Option Number.\r
-\r
-**/\r
-UINT16\r
-BOpt_GetOptionNumber (\r
-  CHAR16        *Type\r
-  )\r
-{\r
-  UINT16        *OrderList;\r
-  UINTN         OrderListSize;\r
-  UINTN         Index;\r
-  CHAR16        StrTemp[20];\r
-  UINT16        *OptionBuffer;\r
-  UINT16        OptionNumber;\r
-  UINTN         OptionSize;\r
-\r
-  OrderListSize = 0;\r
-  OrderList     = NULL;\r
-  OptionNumber  = 0;\r
-  Index         = 0;\r
-\r
-  UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%sOrder", Type);\r
-\r
-  OrderList = BdsLibGetVariableAndSize (\r
-                          StrTemp,\r
-                          &gEfiGlobalVariableGuid,\r
-                          &OrderListSize\r
-                          );\r
-\r
-  for (OptionNumber = 0; ; OptionNumber++) {\r
-    if (OrderList != NULL) {\r
-      for (Index = 0; Index < OrderListSize / sizeof (UINT16); Index++) {\r
-        if (OptionNumber == OrderList[Index]) {\r
-          break;\r
-        }\r
-      }\r
-    }\r
-\r
-    if (Index < OrderListSize / sizeof (UINT16)) {\r
-      //\r
-      // The OptionNumber occurs in the OrderList, continue to use next one\r
-      //\r
-      continue;\r
-    }\r
-    UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%s%04x", Type, (UINTN) OptionNumber);\r
-    DEBUG((EFI_D_ERROR,"Option = %s\n", StrTemp));\r
-    OptionBuffer = BdsLibGetVariableAndSize (\r
-                       StrTemp,\r
-                       &gEfiGlobalVariableGuid,\r
-                       &OptionSize\r
-                       );\r
-    if (NULL == OptionBuffer) {\r
-      //\r
-      // The Boot[OptionNumber] / Driver[OptionNumber] NOT occurs, we found it\r
-      //\r
-      break;\r
-    }\r
-  }\r
-\r
-  return OptionNumber;\r
-}\r
-\r
-/**\r
-\r
-  Get the Option Number for Boot#### that does not used.\r
-\r
-  @return The available Option Number.\r
-\r
-**/\r
-UINT16\r
-BOpt_GetBootOptionNumber (\r
-  VOID\r
-  )\r
-{\r
-  return BOpt_GetOptionNumber (L"Boot");\r
-}\r
-\r
-/**\r
-\r
-  Get the Option Number for Driver#### that does not used.\r
-\r
-  @return The unused Option Number.\r
-\r
-**/\r
-UINT16\r
-BOpt_GetDriverOptionNumber (\r
-  VOID\r
-  )\r
-{\r
-  return BOpt_GetOptionNumber (L"Driver");\r
-}\r
-\r
-/**\r
-\r
-  Build up all DriverOptionMenu\r
-\r
-  @param CallbackData The BMM context data.\r
-\r
-  @retval EFI_SUCESS           The functin completes successfully.\r
-  @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.\r
-  @retval EFI_NOT_FOUND        Fail to get "DriverOrder" variable.\r
-\r
-**/\r
-EFI_STATUS\r
-BOpt_GetDriverOptions (\r
-  IN  BMM_CALLBACK_DATA         *CallbackData\r
-  )\r
-{\r
-  UINTN           Index;\r
-  UINT16          DriverString[12];\r
-  UINT8           *LoadOptionFromVar;\r
-  UINT8           *LoadOption;\r
-  UINTN           DriverOptionSize;\r
-\r
-  UINT16          *DriverOrderList;\r
-  UINTN           DriverOrderListSize;\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT *NewLoadContext;\r
-  UINT8           *LoadOptionPtr;\r
-  UINTN           StringSize;\r
-  UINTN           OptionalDataSize;\r
-  UINT8           *LoadOptionEnd;\r
-\r
-  DriverOrderListSize = 0;\r
-  DriverOrderList     = NULL;\r
-  DriverOptionSize    = 0;\r
-  LoadOptionFromVar   = NULL;\r
-  BOpt_FreeMenu (&DriverOptionMenu);\r
-  InitializeListHead (&DriverOptionMenu.Head);\r
-  //\r
-  // Get the DriverOrder from the Var\r
-  //\r
-  DriverOrderList = BdsLibGetVariableAndSize (\r
-                      L"DriverOrder",\r
-                      &gEfiGlobalVariableGuid,\r
-                      &DriverOrderListSize\r
-                      );\r
-  if (DriverOrderList == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  for (Index = 0; Index < DriverOrderListSize / sizeof (UINT16); Index++) {\r
-    UnicodeSPrint (\r
-      DriverString,\r
-      sizeof (DriverString),\r
-      L"Driver%04x",\r
-      DriverOrderList[Index]\r
-      );\r
-    //\r
-    //  Get all loadoptions from the VAR\r
-    //\r
-    LoadOptionFromVar = BdsLibGetVariableAndSize (\r
-                          DriverString,\r
-                          &gEfiGlobalVariableGuid,\r
-                          &DriverOptionSize\r
-                          );\r
-    if (LoadOptionFromVar == NULL) {\r
-      continue;\r
-    }\r
-\r
-    LoadOption = AllocateZeroPool (DriverOptionSize);\r
-    if (LoadOption == NULL) {\r
-      continue;\r
-    }\r
-\r
-    CopyMem (LoadOption, LoadOptionFromVar, DriverOptionSize);\r
-    FreePool (LoadOptionFromVar);\r
-\r
-    NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
-    if (NULL == NewMenuEntry) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    NewLoadContext                      = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-    LoadOptionPtr                       = LoadOption;\r
-    LoadOptionEnd                       = LoadOption + DriverOptionSize;\r
-    NewMenuEntry->OptionNumber          = DriverOrderList[Index];\r
-    NewLoadContext->LoadOptionModified  = FALSE;\r
-    NewLoadContext->Deleted             = FALSE;\r
-    NewLoadContext->IsLegacy            = FALSE;\r
-\r
-    //\r
-    // LoadOption is a pointer type of UINT8\r
-    // for easy use with following LOAD_OPTION\r
-    // embedded in this struct\r
-    //\r
-    NewLoadContext->LoadOption      = LoadOption;\r
-    NewLoadContext->LoadOptionSize  = DriverOptionSize;\r
-\r
-    NewLoadContext->Attributes      = *(UINT32 *) LoadOptionPtr;\r
-    NewLoadContext->IsActive        = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_ACTIVE);\r
-\r
-    NewLoadContext->ForceReconnect  = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);\r
-\r
-    LoadOptionPtr += sizeof (UINT32);\r
-\r
-    NewLoadContext->FilePathListLength = *(UINT16 *) LoadOptionPtr;\r
-    LoadOptionPtr += sizeof (UINT16);\r
-\r
-    StringSize                  = StrSize ((UINT16 *) LoadOptionPtr);\r
-    NewLoadContext->Description = AllocateZeroPool (StringSize);\r
-    ASSERT (NewLoadContext->Description != NULL);\r
-    CopyMem (\r
-      NewLoadContext->Description,\r
-      (UINT16 *) LoadOptionPtr,\r
-      StringSize\r
-      );\r
-    NewMenuEntry->DisplayString = NewLoadContext->Description;\r
-\r
-    LoadOptionPtr += StringSize;\r
-\r
-    NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);\r
-    ASSERT (NewLoadContext->FilePathList != NULL);\r
-    CopyMem (\r
-      NewLoadContext->FilePathList,\r
-      (EFI_DEVICE_PATH_PROTOCOL *) LoadOptionPtr,\r
-      NewLoadContext->FilePathListLength\r
-      );\r
-\r
-    NewMenuEntry->HelpString = DevicePathToStr (NewLoadContext->FilePathList);\r
-    NewMenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
-                                        CallbackData,\r
-                                        DriverOptionStrDepository\r
-                                        );\r
-    NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
-                                      CallbackData,\r
-                                      DriverOptionHelpStrDepository\r
-                                      );\r
-    LoadOptionPtr += NewLoadContext->FilePathListLength;\r
-\r
-    if (LoadOptionPtr < LoadOptionEnd) {\r
-      OptionalDataSize = DriverOptionSize -\r
-        sizeof (UINT32) -\r
-        sizeof (UINT16) -\r
-        StringSize -\r
-        NewLoadContext->FilePathListLength;\r
-\r
-      NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);\r
-      ASSERT (NewLoadContext->OptionalData != NULL);\r
-      CopyMem (\r
-        NewLoadContext->OptionalData,\r
-        LoadOptionPtr,\r
-        OptionalDataSize\r
-        );\r
-\r
-      NewLoadContext->OptionalDataSize = OptionalDataSize;\r
-    }\r
-\r
-    InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);\r
-\r
-  }\r
-\r
-  if (DriverOrderList != NULL) {\r
-    FreePool (DriverOrderList);\r
-  }\r
-  DriverOptionMenu.MenuNumber = Index;\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-/**\r
-  Get option number according to Boot#### and BootOrder variable.\r
-  The value is saved as #### + 1.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-GetBootOrder (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  BMM_FAKE_NV_DATA          *BmmConfig;\r
-  UINT16                    Index;\r
-  UINT16                    OptionOrderIndex;\r
-  UINTN                     DeviceType;\r
-  BM_MENU_ENTRY             *NewMenuEntry;\r
-  BM_LOAD_CONTEXT           *NewLoadContext;\r
-\r
-  ASSERT (CallbackData != NULL);\r
-\r
-  DeviceType = (UINTN) -1;\r
-  BmmConfig  = &CallbackData->BmmFakeNvData;\r
-  ZeroMem (BmmConfig->BootOptionOrder, sizeof (BmmConfig->BootOptionOrder));\r
-\r
-  for (Index = 0, OptionOrderIndex = 0; ((Index < BootOptionMenu.MenuNumber) &&\r
-       (OptionOrderIndex < (sizeof (BmmConfig->BootOptionOrder) / sizeof (BmmConfig->BootOptionOrder[0]))));\r
-       Index++) {\r
-    NewMenuEntry   = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
-    NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-\r
-    if (NewLoadContext->IsLegacy) {\r
-      if (((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType != DeviceType) {\r
-        DeviceType = ((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType;\r
-      } else {\r
-        //\r
-        // Only show one legacy boot option for the same device type\r
-        // assuming the boot options are grouped by the device type\r
-        //\r
-        continue;\r
-      }\r
-    }\r
-    BmmConfig->BootOptionOrder[OptionOrderIndex++] = (UINT32) (NewMenuEntry->OptionNumber + 1);\r
-  }\r
-}\r
-\r
-/**\r
-  According to LegacyDevOrder variable to get legacy FD\HD\CD\NET\BEV\r
-  devices list .\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-GetLegacyDeviceOrder (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  UINTN                     Index;\r
-  UINTN                     OptionIndex;\r
-  UINT16                    PageIdList[5];\r
-  UINTN                     PageNum;\r
-  UINTN                     VarSize;\r
-  UINT8                     *VarData;\r
-  UINT8                     *WorkingVarData;\r
-  LEGACY_DEV_ORDER_ENTRY    *DevOrder;\r
-  UINT16                    VarDevOrder;\r
-  UINT8                     *DisMap;\r
-  BM_MENU_OPTION            *OptionMenu;\r
-  BBS_TYPE                  BbsType;\r
-  UINT8                     *LegacyOrder;\r
-  UINT8                     *OldData;\r
-  UINTN                     Pos;\r
-  UINTN                     Bit;\r
-\r
-  ASSERT (CallbackData != NULL);\r
-\r
-  PageIdList[0] = FORM_SET_FD_ORDER_ID;\r
-  PageIdList[1] = FORM_SET_HD_ORDER_ID;\r
-  PageIdList[2] = FORM_SET_CD_ORDER_ID;\r
-  PageIdList[3] = FORM_SET_NET_ORDER_ID;\r
-  PageIdList[4] = FORM_SET_BEV_ORDER_ID;\r
-  OptionMenu  = NULL;\r
-  BbsType     = 0;\r
-  LegacyOrder = NULL;\r
-  OldData     = NULL;\r
-  DisMap      = ZeroMem (CallbackData->BmmFakeNvData.DisableMap, sizeof (CallbackData->BmmFakeNvData.DisableMap));\r
-  PageNum     = ARRAY_SIZE (PageIdList);\r
-  VarData     = BdsLibGetVariableAndSize (\r
-                  VAR_LEGACY_DEV_ORDER,\r
-                  &gEfiLegacyDevOrderVariableGuid,\r
-                  &VarSize\r
-                  );\r
-\r
-  for (Index = 0; Index < PageNum; Index++) {\r
-    switch (PageIdList[Index]) {\r
-\r
-    case FORM_SET_FD_ORDER_ID:\r
-      OptionMenu  = (BM_MENU_OPTION *) &LegacyFDMenu;\r
-      BbsType     = BBS_FLOPPY;\r
-      LegacyOrder = CallbackData->BmmFakeNvData.LegacyFD;\r
-      OldData     = CallbackData->BmmOldFakeNVData.LegacyFD;\r
-      break;\r
-\r
-    case FORM_SET_HD_ORDER_ID:\r
-      OptionMenu  = (BM_MENU_OPTION *) &LegacyHDMenu;\r
-      BbsType     = BBS_HARDDISK;\r
-      LegacyOrder = CallbackData->BmmFakeNvData.LegacyHD;\r
-      OldData     = CallbackData->BmmOldFakeNVData.LegacyHD;\r
-      break;\r
-\r
-    case FORM_SET_CD_ORDER_ID:\r
-      OptionMenu  = (BM_MENU_OPTION *) &LegacyCDMenu;\r
-      BbsType     = BBS_CDROM;\r
-      LegacyOrder = CallbackData->BmmFakeNvData.LegacyCD;\r
-      OldData     = CallbackData->BmmOldFakeNVData.LegacyCD;\r
-      break;\r
-\r
-    case FORM_SET_NET_ORDER_ID:\r
-      OptionMenu  = (BM_MENU_OPTION *) &LegacyNETMenu;\r
-      BbsType     = BBS_EMBED_NETWORK;\r
-      LegacyOrder = CallbackData->BmmFakeNvData.LegacyNET;\r
-      OldData     = CallbackData->BmmOldFakeNVData.LegacyNET;\r
-      break;\r
-\r
-    default:\r
-      ASSERT (PageIdList[Index] == FORM_SET_BEV_ORDER_ID);\r
-      OptionMenu  = (BM_MENU_OPTION *) &LegacyBEVMenu;\r
-      BbsType     = BBS_BEV_DEVICE;\r
-      LegacyOrder = CallbackData->BmmFakeNvData.LegacyBEV;\r
-      OldData     = CallbackData->BmmOldFakeNVData.LegacyBEV;\r
-      break;\r
-    }\r
-\r
-    if (NULL != VarData) {\r
-      WorkingVarData = VarData;\r
-      DevOrder    = (LEGACY_DEV_ORDER_ENTRY *) WorkingVarData;\r
-      while (WorkingVarData < VarData + VarSize) {\r
-        if (DevOrder->BbsType == BbsType) {\r
-          break;\r
-        }\r
-\r
-        WorkingVarData  = (UINT8 *)((UINTN)WorkingVarData + sizeof (BBS_TYPE));\r
-        WorkingVarData += *(UINT16 *) WorkingVarData;\r
-        DevOrder = (LEGACY_DEV_ORDER_ENTRY *) WorkingVarData;\r
-      }\r
-      for (OptionIndex = 0; OptionIndex < OptionMenu->MenuNumber; OptionIndex++) {\r
-        VarDevOrder = *(UINT16 *) ((UINTN) DevOrder + sizeof (BBS_TYPE) + sizeof (UINT16) + OptionIndex * sizeof (UINT16));\r
-         if (0xFF00 == (VarDevOrder & 0xFF00)) {\r
-          LegacyOrder[OptionIndex]  = 0xFF;\r
-          Pos                       = (VarDevOrder & 0xFF) / 8;\r
-          Bit                       = 7 - ((VarDevOrder & 0xFF) % 8);\r
-          DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit));\r
-        } else {\r
-          LegacyOrder[OptionIndex] = (UINT8) (VarDevOrder & 0xFF);\r
-        }\r
-      }\r
-      CopyMem (OldData, LegacyOrder, 100);\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Get driver option order from globalc DriverOptionMenu.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetDriverOrder (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  BMM_FAKE_NV_DATA          *BmmConfig;\r
-  UINT16                    Index;\r
-  UINT16                    OptionOrderIndex;\r
-  UINTN                     DeviceType;\r
-  BM_MENU_ENTRY             *NewMenuEntry;\r
-  BM_LOAD_CONTEXT           *NewLoadContext;\r
-\r
-  ASSERT (CallbackData != NULL);\r
-\r
-  DeviceType = (UINTN) -1;\r
-  BmmConfig  = &CallbackData->BmmFakeNvData;\r
-  ZeroMem (BmmConfig->DriverOptionOrder, sizeof (BmmConfig->DriverOptionOrder));\r
-\r
-  for (Index = 0, OptionOrderIndex = 0; ((Index < DriverOptionMenu.MenuNumber) &&\r
-       (OptionOrderIndex < (sizeof (BmmConfig->DriverOptionOrder) / sizeof (BmmConfig->DriverOptionOrder[0]))));\r
-       Index++) {\r
-    NewMenuEntry   = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
-    NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-\r
-    if (NewLoadContext->IsLegacy) {\r
-      if (((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType != DeviceType) {\r
-        DeviceType = ((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType;\r
-      } else {\r
-        //\r
-        // Only show one legacy boot option for the same device type\r
-        // assuming the boot options are grouped by the device type\r
-        //\r
-        continue;\r
-      }\r
-    }\r
-    BmmConfig->DriverOptionOrder[OptionOrderIndex++] = (UINT32) (NewMenuEntry->OptionNumber + 1);\r
-  }\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
deleted file mode 100644 (file)
index 846ea99..0000000
+++ /dev/null
@@ -1,1128 +0,0 @@
-/** @file\r
-  handles console redirection from boot manager\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BootMaint.h"\r
-\r
-UART_FLOW_CONTROL_DEVICE_PATH mFlowControlDevicePath =\r
-{\r
-  {\r
-    MESSAGING_DEVICE_PATH,\r
-    MSG_VENDOR_DP,\r
-    {\r
-      (UINT8)(sizeof(UART_FLOW_CONTROL_DEVICE_PATH)),\r
-      (UINT8)((sizeof(UART_FLOW_CONTROL_DEVICE_PATH)) >> 8)\r
-    }\r
-  },\r
-  DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL,\r
-  UART_FLOW_CONTROL_HARDWARE\r
-};\r
-\r
-/**\r
-  Check the device path node whether it's the Flow Control node or not.\r
-\r
-  @param[in] FlowControl    The device path node to be checked.\r
-\r
-  @retval TRUE              It's the Flow Control node.\r
-  @retval FALSE             It's not.\r
-\r
-**/\r
-BOOLEAN\r
-IsUartFlowControlNode (\r
-  IN UART_FLOW_CONTROL_DEVICE_PATH *FlowControl\r
-  )\r
-{\r
-  return (BOOLEAN) (\r
-           (DevicePathType (FlowControl) == MESSAGING_DEVICE_PATH) &&\r
-           (DevicePathSubType (FlowControl) == MSG_VENDOR_DP) &&\r
-           (CompareGuid (&FlowControl->Guid, &gEfiUartDevicePathGuid))\r
-           );\r
-}\r
-\r
-/**\r
-  Check whether the device path node is ISA Serial Node.\r
-\r
-  @param Acpi           Device path node to be checked\r
-\r
-  @retval TRUE          It's ISA Serial Node.\r
-  @retval FALSE         It's NOT ISA Serial Node.\r
-\r
-**/\r
-BOOLEAN\r
-IsIsaSerialNode (\r
-  IN ACPI_HID_DEVICE_PATH *Acpi\r
-  )\r
-{\r
-  return (BOOLEAN) (\r
-      (DevicePathType (Acpi) == ACPI_DEVICE_PATH) &&\r
-      (DevicePathSubType (Acpi) == ACPI_DP) &&\r
-      (ReadUnaligned32 (&Acpi->HID) == EISA_PNP_ID (0x0501))\r
-      );\r
-}\r
-\r
-/**\r
-  Update Com Ports attributes from DevicePath\r
-\r
-  @param DevicePath      DevicePath that contains Com ports\r
-\r
-  @retval EFI_SUCCESS   The update is successful.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateComAttributeFromVariable (\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  );\r
-\r
-/**\r
-  Update the multi-instance device path of Terminal Device based on\r
-  the global TerminalMenu. If ChangeTernimal is TRUE, the terminal\r
-  device path in the Terminal Device in TerminalMenu is also updated.\r
-\r
-  @param DevicePath      The multi-instance device path.\r
-  @param ChangeTerminal  TRUE, then device path in the Terminal Device\r
-                         in TerminalMenu is also updated; FALSE, no update.\r
-\r
-  @return EFI_SUCCESS    The function completes successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ChangeTerminalDevicePath (\r
-  IN OUT    EFI_DEVICE_PATH_PROTOCOL  **DevicePath,\r
-  IN        BOOLEAN                   ChangeTerminal\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Node1;\r
-  ACPI_HID_DEVICE_PATH      *Acpi;\r
-  UART_DEVICE_PATH          *Uart;\r
-  UART_DEVICE_PATH          *Uart1;\r
-  UINTN                     Com;\r
-  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
-  BM_MENU_ENTRY             *NewMenuEntry;\r
-  UART_FLOW_CONTROL_DEVICE_PATH *FlowControlNode;\r
-\r
-  Node  = *DevicePath;\r
-  Node  = NextDevicePathNode (Node);\r
-  Com   = 0;\r
-  while (!IsDevicePathEnd (Node)) {\r
-    Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r
-    if (IsIsaSerialNode (Acpi)) {\r
-      CopyMem (&Com, &Acpi->UID, sizeof (UINT32));\r
-    }\r
-\r
-    NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Com);\r
-\r
-    NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
-    if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r
-      Uart = (UART_DEVICE_PATH *) Node;\r
-      CopyMem (\r
-        &Uart->BaudRate,\r
-        &NewTerminalContext->BaudRate,\r
-        sizeof (UINT64)\r
-        );\r
-\r
-      CopyMem (\r
-        &Uart->DataBits,\r
-        &NewTerminalContext->DataBits,\r
-        sizeof (UINT8)\r
-        );\r
-\r
-      CopyMem (\r
-        &Uart->Parity,\r
-        &NewTerminalContext->Parity,\r
-        sizeof (UINT8)\r
-        );\r
-\r
-      CopyMem (\r
-        &Uart->StopBits,\r
-        &NewTerminalContext->StopBits,\r
-        sizeof (UINT8)\r
-        );\r
-\r
-      FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Node);\r
-      if (IsUartFlowControlNode (FlowControlNode)) {\r
-        FlowControlNode->FlowControlMap = NewTerminalContext->FlowControl;\r
-      } else {\r
-        //\r
-        // Append the Flow control device node when user enable flow control.\r
-        //\r
-        if (NewTerminalContext->FlowControl != 0) {\r
-          mFlowControlDevicePath.FlowControlMap = NewTerminalContext->FlowControl;\r
-          *DevicePath = AppendDevicePathNode (\r
-                                       *DevicePath,\r
-                                       (EFI_DEVICE_PATH_PROTOCOL *) (&mFlowControlDevicePath)\r
-                                       );\r
-        }\r
-      }\r
-\r
-      //\r
-      // Change the device path in the ComPort\r
-      //\r
-      if (ChangeTerminal) {\r
-        Node1 = NewTerminalContext->DevicePath;\r
-        Node1 = NextDevicePathNode (Node1);\r
-        while (!IsDevicePathEnd (Node1)) {\r
-          if ((DevicePathType (Node1) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node1) == MSG_UART_DP)) {\r
-            Uart1 = (UART_DEVICE_PATH *) Node1;\r
-            CopyMem (\r
-              &Uart1->BaudRate,\r
-              &NewTerminalContext->BaudRate,\r
-              sizeof (UINT64)\r
-              );\r
-\r
-            CopyMem (\r
-              &Uart1->DataBits,\r
-              &NewTerminalContext->DataBits,\r
-              sizeof (UINT8)\r
-              );\r
-\r
-            CopyMem (\r
-              &Uart1->Parity,\r
-              &NewTerminalContext->Parity,\r
-              sizeof (UINT8)\r
-              );\r
-\r
-            CopyMem (\r
-              &Uart1->StopBits,\r
-              &NewTerminalContext->StopBits,\r
-              sizeof (UINT8)\r
-              );\r
-            break;\r
-          }\r
-          //\r
-          // end if\r
-          //\r
-          Node1 = NextDevicePathNode (Node1);\r
-        }\r
-        //\r
-        // end while\r
-        //\r
-        break;\r
-      }\r
-    }\r
-\r
-    Node = NextDevicePathNode (Node);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-\r
-\r
-/**\r
-  Retrieve ACPI UID of UART from device path\r
-\r
-  @param Handle          The handle for the UART device.\r
-  @param AcpiUid         The ACPI UID on output.\r
-\r
-  @retval  TRUE   Find valid UID from device path\r
-  @retval  FALSE  Can't find\r
-\r
-**/\r
-BOOLEAN\r
-RetrieveUartUid (\r
-  IN EFI_HANDLE   Handle,\r
-  IN OUT UINT32   *AcpiUid\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  ACPI_HID_DEVICE_PATH      *Acpi;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-\r
-  Acpi = NULL;\r
-  for (; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {\r
-    if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (DevicePath) == MSG_UART_DP)) {\r
-      break;\r
-    }\r
-    //\r
-    // Acpi points to the node before the Uart node\r
-    //\r
-    Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;\r
-  }\r
-\r
-  if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {\r
-    if (AcpiUid != NULL) {\r
-      CopyMem (AcpiUid, &Acpi->UID, sizeof (UINT32));\r
-    }\r
-    return TRUE;\r
-  } else {\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-/**\r
-  Sort Uart handles array with Acpi->UID from low to high.\r
-\r
-  @param Handles         EFI_SERIAL_IO_PROTOCOL handle buffer\r
-  @param NoHandles       EFI_SERIAL_IO_PROTOCOL handle count\r
-**/\r
-VOID\r
-SortedUartHandle (\r
-  IN  EFI_HANDLE *Handles,\r
-  IN  UINTN      NoHandles\r
-  )\r
-{\r
-  UINTN       Index1;\r
-  UINTN       Index2;\r
-  UINTN       Position;\r
-  UINT32      AcpiUid1;\r
-  UINT32      AcpiUid2;\r
-  UINT32      TempAcpiUid;\r
-  EFI_HANDLE  TempHandle;\r
-\r
-  for (Index1 = 0; Index1 < NoHandles-1; Index1++) {\r
-    if (!RetrieveUartUid (Handles[Index1], &AcpiUid1)) {\r
-      continue;\r
-    }\r
-    TempHandle  = Handles[Index1];\r
-    Position    = Index1;\r
-    TempAcpiUid = AcpiUid1;\r
-\r
-    for (Index2 = Index1+1; Index2 < NoHandles; Index2++) {\r
-      if (!RetrieveUartUid (Handles[Index2], &AcpiUid2)) {\r
-        continue;\r
-      }\r
-      if (AcpiUid2 < TempAcpiUid) {\r
-        TempAcpiUid = AcpiUid2;\r
-        TempHandle  = Handles[Index2];\r
-        Position    = Index2;\r
-      }\r
-    }\r
-    Handles[Position] = Handles[Index1];\r
-    Handles[Index1]   = TempHandle;\r
-  }\r
-}\r
-\r
-/**\r
-  Test whether DevicePath is a valid Terminal\r
-\r
-\r
-  @param DevicePath      DevicePath to be checked\r
-  @param Termi           If DevicePath is valid Terminal, terminal type is returned.\r
-  @param Com             If DevicePath is valid Terminal, Com Port type is returned.\r
-\r
-  @retval  TRUE         If DevicePath point to a Terminal.\r
-  @retval  FALSE        If DevicePath does not point to a Terminal.\r
-\r
-**/\r
-BOOLEAN\r
-IsTerminalDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  OUT TYPE_OF_TERMINAL         *Termi,\r
-  OUT UINTN                    *Com\r
-  );\r
-\r
-/**\r
-  Build a list containing all serial devices.\r
-\r
-\r
-  @retval EFI_SUCCESS The function complete successfully.\r
-  @retval EFI_UNSUPPORTED No serial ports present.\r
-\r
-**/\r
-EFI_STATUS\r
-LocateSerialIo (\r
-  VOID\r
-  )\r
-{\r
-  UINTN                     Index;\r
-  UINTN                     Index2;\r
-  UINTN                     NoHandles;\r
-  EFI_HANDLE                *Handles;\r
-  EFI_STATUS                Status;\r
-  ACPI_HID_DEVICE_PATH      *Acpi;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_SERIAL_IO_PROTOCOL    *SerialIo;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
-  EFI_DEVICE_PATH_PROTOCOL  *OutDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *InpDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ErrDevicePath;\r
-  BM_MENU_ENTRY             *NewMenuEntry;\r
-  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
-  VENDOR_DEVICE_PATH        Vendor;\r
-  UINT32                    FlowControl;\r
-  //\r
-  // Get all handles that have SerialIo protocol installed\r
-  //\r
-  InitializeListHead (&TerminalMenu.Head);\r
-  TerminalMenu.MenuNumber = 0;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiSerialIoProtocolGuid,\r
-                  NULL,\r
-                  &NoHandles,\r
-                  &Handles\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // No serial ports present\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Sort Uart handles array with Acpi->UID from low to high\r
-  // then Terminal menu can be built from low Acpi->UID to high Acpi->UID\r
-  //\r
-  SortedUartHandle (Handles, NoHandles);\r
-\r
-  for (Index = 0; Index < NoHandles; Index++) {\r
-    //\r
-    // Check to see whether the handle has DevicePath Protocol installed\r
-    //\r
-    gBS->HandleProtocol (\r
-          Handles[Index],\r
-          &gEfiDevicePathProtocolGuid,\r
-          (VOID **) &DevicePath\r
-          );\r
-\r
-    Acpi = NULL;\r
-    for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {\r
-      if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r
-        break;\r
-      }\r
-      //\r
-      // Acpi points to the node before Uart node\r
-      //\r
-      Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r
-    }\r
-\r
-    if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {\r
-      NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT);\r
-      if (NewMenuEntry == NULL) {\r
-        FreePool (Handles);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
-      CopyMem (&NewMenuEntry->OptionNumber, &Acpi->UID, sizeof (UINT32));\r
-      NewTerminalContext->DevicePath = DuplicateDevicePath (DevicePath);\r
-      //\r
-      // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!\r
-      // coz' the misc data for each platform is not correct, actually it's the device path stored in\r
-      // datahub which is not completed, so a searching for end of device path will enter a\r
-      // dead-loop.\r
-      //\r
-      NewMenuEntry->DisplayString = EfiLibStrFromDatahub (DevicePath);\r
-      if (NULL == NewMenuEntry->DisplayString) {\r
-        NewMenuEntry->DisplayString = DevicePathToStr (DevicePath);\r
-      }\r
-\r
-      NewMenuEntry->HelpString = NULL;\r
-\r
-      gBS->HandleProtocol (\r
-            Handles[Index],\r
-            &gEfiSerialIoProtocolGuid,\r
-            (VOID **) &SerialIo\r
-            );\r
-\r
-      CopyMem (\r
-        &NewTerminalContext->BaudRate,\r
-        &SerialIo->Mode->BaudRate,\r
-        sizeof (UINT64)\r
-        );\r
-\r
-      CopyMem (\r
-        &NewTerminalContext->DataBits,\r
-        &SerialIo->Mode->DataBits,\r
-        sizeof (UINT8)\r
-        );\r
-\r
-      CopyMem (\r
-        &NewTerminalContext->Parity,\r
-        &SerialIo->Mode->Parity,\r
-        sizeof (UINT8)\r
-        );\r
-\r
-      CopyMem (\r
-        &NewTerminalContext->StopBits,\r
-        &SerialIo->Mode->StopBits,\r
-        sizeof (UINT8)\r
-        );\r
-\r
-      NewTerminalContext->FlowControl = 0;\r
-      SerialIo->GetControl(SerialIo, &FlowControl);\r
-      if ((FlowControl & EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) != 0) {\r
-        NewTerminalContext->FlowControl = UART_FLOW_CONTROL_HARDWARE;\r
-      }\r
-\r
-      InsertTailList (&TerminalMenu.Head, &NewMenuEntry->Link);\r
-      TerminalMenu.MenuNumber++;\r
-    }\r
-  }\r
-  if (Handles != NULL) {\r
-    FreePool (Handles);\r
-  }\r
-\r
-  //\r
-  // Get L"ConOut", L"ConIn" and L"ErrOut" from the Var\r
-  //\r
-  OutDevicePath = EfiLibGetVariable (L"ConOut", &gEfiGlobalVariableGuid);\r
-  InpDevicePath = EfiLibGetVariable (L"ConIn", &gEfiGlobalVariableGuid);\r
-  ErrDevicePath = EfiLibGetVariable (L"ErrOut", &gEfiGlobalVariableGuid);\r
-  if (OutDevicePath != NULL) {\r
-    UpdateComAttributeFromVariable (OutDevicePath);\r
-  }\r
-\r
-  if (InpDevicePath != NULL) {\r
-    UpdateComAttributeFromVariable (InpDevicePath);\r
-  }\r
-\r
-  if (ErrDevicePath != NULL) {\r
-    UpdateComAttributeFromVariable (ErrDevicePath);\r
-  }\r
-\r
-  for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
-    NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
-    if (NULL == NewMenuEntry) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    NewTerminalContext                = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
-\r
-    NewTerminalContext->TerminalType  = 0;\r
-    NewTerminalContext->IsConIn       = FALSE;\r
-    NewTerminalContext->IsConOut      = FALSE;\r
-    NewTerminalContext->IsStdErr      = FALSE;\r
-\r
-    Vendor.Header.Type                = MESSAGING_DEVICE_PATH;\r
-    Vendor.Header.SubType             = MSG_VENDOR_DP;\r
-\r
-    for (Index2 = 0; Index2 < 4; Index2++) {\r
-      CopyMem (&Vendor.Guid, &TerminalTypeGuid[Index2], sizeof (EFI_GUID));\r
-      SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));\r
-      NewDevicePath = AppendDevicePathNode (\r
-                        NewTerminalContext->DevicePath,\r
-                        (EFI_DEVICE_PATH_PROTOCOL *) &Vendor\r
-                        );\r
-      if (NewMenuEntry->HelpString != NULL) {\r
-        FreePool (NewMenuEntry->HelpString);\r
-      }\r
-      //\r
-      // NewMenuEntry->HelpString = DevicePathToStr (NewDevicePath);\r
-      // NewMenuEntry->DisplayString = NewMenuEntry->HelpString;\r
-      //\r
-      NewMenuEntry->HelpString = NULL;\r
-\r
-      if (BdsLibMatchDevicePaths (OutDevicePath, NewDevicePath)) {\r
-        NewTerminalContext->IsConOut      = TRUE;\r
-        NewTerminalContext->TerminalType  = (UINT8) Index2;\r
-      }\r
-\r
-      if (BdsLibMatchDevicePaths (InpDevicePath, NewDevicePath)) {\r
-        NewTerminalContext->IsConIn       = TRUE;\r
-        NewTerminalContext->TerminalType  = (UINT8) Index2;\r
-      }\r
-\r
-      if (BdsLibMatchDevicePaths (ErrDevicePath, NewDevicePath)) {\r
-        NewTerminalContext->IsStdErr      = TRUE;\r
-        NewTerminalContext->TerminalType  = (UINT8) Index2;\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Update Com Ports attributes from DevicePath\r
-\r
-  @param DevicePath      DevicePath that contains Com ports\r
-\r
-  @retval EFI_SUCCESS   The update is successful.\r
-  @retval EFI_NOT_FOUND Can not find specific menu entry\r
-**/\r
-EFI_STATUS\r
-UpdateComAttributeFromVariable (\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
-  EFI_DEVICE_PATH_PROTOCOL  *SerialNode;\r
-  ACPI_HID_DEVICE_PATH      *Acpi;\r
-  UART_DEVICE_PATH          *Uart;\r
-  UART_DEVICE_PATH          *Uart1;\r
-  UINTN                     TerminalNumber;\r
-  BM_MENU_ENTRY             *NewMenuEntry;\r
-  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
-  UINTN                     Index;\r
-  UART_FLOW_CONTROL_DEVICE_PATH *FlowControlNode;\r
-  BOOLEAN                   HasFlowControlNode;\r
-\r
-  HasFlowControlNode = FALSE;\r
-  Node            = DevicePath;\r
-  Node            = NextDevicePathNode (Node);\r
-  TerminalNumber  = 0;\r
-  for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
-    while (!IsDevicePathEnd (Node)) {\r
-      Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r
-      if (IsIsaSerialNode (Acpi)) {\r
-        CopyMem (&TerminalNumber, &Acpi->UID, sizeof (UINT32));\r
-      }\r
-\r
-      if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r
-        Uart          = (UART_DEVICE_PATH *) Node;\r
-        NewMenuEntry  = BOpt_GetMenuEntry (&TerminalMenu, TerminalNumber);\r
-        if (NULL == NewMenuEntry) {\r
-          return EFI_NOT_FOUND;\r
-        }\r
-\r
-        NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
-        CopyMem (\r
-          &NewTerminalContext->BaudRate,\r
-          &Uart->BaudRate,\r
-          sizeof (UINT64)\r
-          );\r
-\r
-        CopyMem (\r
-          &NewTerminalContext->DataBits,\r
-          &Uart->DataBits,\r
-          sizeof (UINT8)\r
-          );\r
-\r
-        CopyMem (\r
-          &NewTerminalContext->Parity,\r
-          &Uart->Parity,\r
-          sizeof (UINT8)\r
-          );\r
-\r
-        CopyMem (\r
-          &NewTerminalContext->StopBits,\r
-          &Uart->StopBits,\r
-          sizeof (UINT8)\r
-          );\r
-\r
-        FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Node);\r
-        if (IsUartFlowControlNode (FlowControlNode)) {\r
-          HasFlowControlNode = TRUE;\r
-          NewTerminalContext->FlowControl = (UINT8) ReadUnaligned32 (&FlowControlNode->FlowControlMap);\r
-        } else if (NewTerminalContext->FlowControl != 0) {\r
-          //\r
-          // No Flow Control device path node, assumption no Flow control\r
-          //\r
-          NewTerminalContext->FlowControl = 0;\r
-        }\r
-\r
-        SerialNode  = NewTerminalContext->DevicePath;\r
-        SerialNode  = NextDevicePathNode (SerialNode);\r
-        while (!IsDevicePathEnd (SerialNode)) {\r
-          if ((DevicePathType (SerialNode) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (SerialNode) == MSG_UART_DP)) {\r
-            //\r
-            // Update following device paths according to\r
-            // previous acquired uart attributes\r
-            //\r
-            Uart1 = (UART_DEVICE_PATH *) SerialNode;\r
-            CopyMem (\r
-              &Uart1->BaudRate,\r
-              &NewTerminalContext->BaudRate,\r
-              sizeof (UINT64)\r
-              );\r
-\r
-            CopyMem (\r
-              &Uart1->DataBits,\r
-              &NewTerminalContext->DataBits,\r
-              sizeof (UINT8)\r
-              );\r
-            CopyMem (\r
-              &Uart1->Parity,\r
-              &NewTerminalContext->Parity,\r
-              sizeof (UINT8)\r
-              );\r
-            CopyMem (\r
-              &Uart1->StopBits,\r
-              &NewTerminalContext->StopBits,\r
-              sizeof (UINT8)\r
-              );\r
-\r
-            FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (SerialNode);\r
-            if (IsUartFlowControlNode (FlowControlNode)) {\r
-              FlowControlNode->FlowControlMap = NewTerminalContext->FlowControl;\r
-            } else {\r
-              if (HasFlowControlNode) {\r
-                mFlowControlDevicePath.FlowControlMap = NewTerminalContext->FlowControl;\r
-                NewTerminalContext->DevicePath = AppendDevicePathNode (\r
-                                             NewTerminalContext->DevicePath,\r
-                                             (EFI_DEVICE_PATH_PROTOCOL *) (&mFlowControlDevicePath)\r
-                                             );\r
-              }\r
-            }\r
-            break;\r
-          }\r
-\r
-          SerialNode = NextDevicePathNode (SerialNode);\r
-        }\r
-        //\r
-        // end while\r
-        //\r
-      }\r
-\r
-      Node = NextDevicePathNode (Node);\r
-    }\r
-    //\r
-    // end while\r
-    //\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Build up Console Menu based on types passed in. The type can\r
-  be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT\r
-  and BM_CONSOLE_ERR_CONTEXT_SELECT.\r
-\r
-  @param ConsoleMenuType Can be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT\r
-                         and BM_CONSOLE_ERR_CONTEXT_SELECT.\r
-\r
-  @retval EFI_UNSUPPORTED The type passed in is not in the 3 types defined.\r
-  @retval EFI_NOT_FOUND   If the EFI Variable defined in UEFI spec with name "ConOutDev",\r
-                          "ConInDev" or "ConErrDev" doesn't exists.\r
-  @retval EFI_OUT_OF_RESOURCES Not enough resource to complete the operations.\r
-  @retval EFI_SUCCESS          Function completes successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-GetConsoleMenu (\r
-  IN UINTN              ConsoleMenuType\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *AllDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *MultiDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
-  UINTN                     Size;\r
-  UINTN                     AllCount;\r
-  UINTN                     Index;\r
-  UINTN                     Index2;\r
-  BM_MENU_ENTRY             *NewMenuEntry;\r
-  BM_CONSOLE_CONTEXT        *NewConsoleContext;\r
-  TYPE_OF_TERMINAL          Terminal;\r
-  UINTN                     Com;\r
-  BM_MENU_OPTION            *ConsoleMenu;\r
-\r
-  DevicePath    = NULL;\r
-  AllDevicePath = NULL;\r
-  AllCount      = 0;\r
-  switch (ConsoleMenuType) {\r
-  case BM_CONSOLE_IN_CONTEXT_SELECT:\r
-    ConsoleMenu = &ConsoleInpMenu;\r
-    DevicePath = EfiLibGetVariable (\r
-                  L"ConIn",\r
-                  &gEfiGlobalVariableGuid\r
-                  );\r
-\r
-    AllDevicePath = EfiLibGetVariable (\r
-                      L"ConInDev",\r
-                      &gEfiGlobalVariableGuid\r
-                      );\r
-    break;\r
-\r
-  case BM_CONSOLE_OUT_CONTEXT_SELECT:\r
-    ConsoleMenu = &ConsoleOutMenu;\r
-    DevicePath = EfiLibGetVariable (\r
-                  L"ConOut",\r
-                  &gEfiGlobalVariableGuid\r
-                  );\r
-\r
-    AllDevicePath = EfiLibGetVariable (\r
-                      L"ConOutDev",\r
-                      &gEfiGlobalVariableGuid\r
-                      );\r
-    break;\r
-\r
-  case BM_CONSOLE_ERR_CONTEXT_SELECT:\r
-    ConsoleMenu = &ConsoleErrMenu;\r
-    DevicePath = EfiLibGetVariable (\r
-                  L"ErrOut",\r
-                  &gEfiGlobalVariableGuid\r
-                  );\r
-\r
-    AllDevicePath = EfiLibGetVariable (\r
-                      L"ErrOutDev",\r
-                      &gEfiGlobalVariableGuid\r
-                      );\r
-    break;\r
-\r
-  default:\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (NULL == AllDevicePath) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  InitializeListHead (&ConsoleMenu->Head);\r
-\r
-  AllCount                = EfiDevicePathInstanceCount (AllDevicePath);\r
-  ConsoleMenu->MenuNumber = 0;\r
-  //\r
-  // Following is menu building up for Console Devices selected.\r
-  //\r
-  MultiDevicePath = AllDevicePath;\r
-  Index2          = 0;\r
-  for (Index = 0; Index < AllCount; Index++) {\r
-    DevicePathInst  = GetNextDevicePathInstance (&MultiDevicePath, &Size);\r
-\r
-    NewMenuEntry    = BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT);\r
-    if (NULL == NewMenuEntry) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    NewConsoleContext             = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-    NewMenuEntry->OptionNumber    = Index2;\r
-\r
-    NewConsoleContext->DevicePath = DuplicateDevicePath (DevicePathInst);\r
-    ASSERT (NewConsoleContext->DevicePath != NULL);\r
-    NewMenuEntry->DisplayString   = EfiLibStrFromDatahub (NewConsoleContext->DevicePath);\r
-    if (NULL == NewMenuEntry->DisplayString) {\r
-      NewMenuEntry->DisplayString = DevicePathToStr (NewConsoleContext->DevicePath);\r
-    }\r
-\r
-    NewConsoleContext->IsTerminal = IsTerminalDevicePath (\r
-                                      NewConsoleContext->DevicePath,\r
-                                      &Terminal,\r
-                                      &Com\r
-                                      );\r
-\r
-    NewConsoleContext->IsActive = BdsLibMatchDevicePaths (\r
-                                    DevicePath,\r
-                                    NewConsoleContext->DevicePath\r
-                                    );\r
-\r
-    if (NewConsoleContext->IsTerminal) {\r
-      BOpt_DestroyMenuEntry (NewMenuEntry);\r
-    } else {\r
-      Index2++;\r
-      ConsoleMenu->MenuNumber++;\r
-      InsertTailList (&ConsoleMenu->Head, &NewMenuEntry->Link);\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu\r
-\r
-  @retval EFI_SUCCESS    The function always complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-GetAllConsoles (\r
-  VOID\r
-  )\r
-{\r
-  GetConsoleMenu (BM_CONSOLE_IN_CONTEXT_SELECT);\r
-  GetConsoleMenu (BM_CONSOLE_OUT_CONTEXT_SELECT);\r
-  GetConsoleMenu (BM_CONSOLE_ERR_CONTEXT_SELECT);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu\r
-\r
-  @retval EFI_SUCCESS    The function always complete successfully.\r
-**/\r
-EFI_STATUS\r
-FreeAllConsoles (\r
-  VOID\r
-  )\r
-{\r
-  BOpt_FreeMenu (&ConsoleOutMenu);\r
-  BOpt_FreeMenu (&ConsoleInpMenu);\r
-  BOpt_FreeMenu (&ConsoleErrMenu);\r
-  BOpt_FreeMenu (&TerminalMenu);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Test whether DevicePath is a valid Terminal\r
-\r
-\r
-  @param DevicePath      DevicePath to be checked\r
-  @param Termi           If DevicePath is valid Terminal, terminal type is returned.\r
-  @param Com             If DevicePath is valid Terminal, Com Port type is returned.\r
-\r
-  @retval  TRUE         If DevicePath point to a Terminal.\r
-  @retval  FALSE        If DevicePath does not point to a Terminal.\r
-\r
-**/\r
-BOOLEAN\r
-IsTerminalDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  OUT TYPE_OF_TERMINAL         *Termi,\r
-  OUT UINTN                    *Com\r
-  )\r
-{\r
-  BOOLEAN                   IsTerminal;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
-  VENDOR_DEVICE_PATH        *Vendor;\r
-  UART_DEVICE_PATH          *Uart;\r
-  ACPI_HID_DEVICE_PATH      *Acpi;\r
-\r
-  IsTerminal = FALSE;\r
-\r
-  Uart   = NULL;\r
-  Vendor = NULL;\r
-  Acpi   = NULL;\r
-  for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {\r
-    //\r
-    // Vendor points to the node before the End node\r
-    //\r
-    Vendor = (VENDOR_DEVICE_PATH *) Node;\r
-\r
-    if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r
-      Uart = (UART_DEVICE_PATH *) Node;\r
-    }\r
-\r
-    if (Uart == NULL) {\r
-      //\r
-      // Acpi points to the node before the UART node\r
-      //\r
-      Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r
-    }\r
-  }\r
-\r
-  if (Vendor == NULL ||\r
-      DevicePathType (Vendor) != MESSAGING_DEVICE_PATH ||\r
-      DevicePathSubType (Vendor) != MSG_VENDOR_DP ||\r
-      Uart == NULL) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // There are four kinds of Terminal types\r
-  // check to see whether this devicepath\r
-  // is one of that type\r
-  //\r
-  if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[0])) {\r
-    *Termi      = TerminalTypePcAnsi;\r
-    IsTerminal  = TRUE;\r
-  } else {\r
-    if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[1])) {\r
-      *Termi      = TerminalTypeVt100;\r
-      IsTerminal  = TRUE;\r
-    } else {\r
-      if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[2])) {\r
-        *Termi      = TerminalTypeVt100Plus;\r
-        IsTerminal  = TRUE;\r
-      } else {\r
-        if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[3])) {\r
-          *Termi      = TerminalTypeVtUtf8;\r
-          IsTerminal  = TRUE;\r
-        } else {\r
-          IsTerminal = FALSE;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  if (!IsTerminal) {\r
-    return FALSE;\r
-  }\r
-\r
-  if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {\r
-    CopyMem (Com, &Acpi->UID, sizeof (UINT32));\r
-  } else {\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Get mode number according to column and row\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-GetConsoleOutMode (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  UINTN                         Col;\r
-  UINTN                         Row;\r
-  UINTN                         CurrentCol;\r
-  UINTN                         CurrentRow;\r
-  UINTN                         Mode;\r
-  UINTN                         MaxMode;\r
-  EFI_STATUS                    Status;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *ConOut;\r
-\r
-  ConOut   = gST->ConOut;\r
-  MaxMode  = (UINTN) (ConOut->Mode->MaxMode);\r
-\r
-  CurrentCol = PcdGet32 (PcdSetupConOutColumn);\r
-  CurrentRow = PcdGet32 (PcdSetupConOutRow);\r
-  for (Mode = 0; Mode < MaxMode; Mode++) {\r
-    Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);\r
-    if (!EFI_ERROR(Status)) {\r
-      if (CurrentCol == Col && CurrentRow == Row) {\r
-        CallbackData->BmmFakeNvData.ConsoleOutMode = (UINT16) Mode;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]\r
-  in BMM_FAKE_NV_DATA structure.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetConsoleInCheck (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  UINT16              Index;\r
-  BM_MENU_ENTRY       *NewMenuEntry;\r
-  UINT8               *ConInCheck;\r
-  BM_CONSOLE_CONTEXT  *NewConsoleContext;\r
-\r
-  ASSERT (CallbackData != NULL);\r
-\r
-  ConInCheck = &CallbackData->BmmFakeNvData.ConsoleInCheck[0];\r
-  for (Index = 0; ((Index < ConsoleInpMenu.MenuNumber) && \\r
-       (Index < MAX_MENU_NUMBER)) ; Index++) {\r
-    NewMenuEntry      = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);\r
-    NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-    ConInCheck[Index] = NewConsoleContext->IsActive;\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]\r
-  in BMM_FAKE_NV_DATA structure.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetConsoleOutCheck (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  UINT16              Index;\r
-  BM_MENU_ENTRY       *NewMenuEntry;\r
-  UINT8               *ConOutCheck;\r
-  BM_CONSOLE_CONTEXT  *NewConsoleContext;\r
-\r
-  ASSERT (CallbackData != NULL);\r
-  ConOutCheck = &CallbackData->BmmFakeNvData.ConsoleOutCheck[0];\r
-  for (Index = 0; ((Index < ConsoleOutMenu.MenuNumber) && \\r
-       (Index < MAX_MENU_NUMBER)) ; Index++) {\r
-    NewMenuEntry      = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);\r
-    NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-    ConOutCheck[Index] = NewConsoleContext->IsActive;\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]\r
-  in BMM_FAKE_NV_DATA structure.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetConsoleErrCheck (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  UINT16              Index;\r
-  BM_MENU_ENTRY       *NewMenuEntry;\r
-  UINT8               *ConErrCheck;\r
-  BM_CONSOLE_CONTEXT  *NewConsoleContext;\r
-\r
-  ASSERT (CallbackData != NULL);\r
-  ConErrCheck = &CallbackData->BmmFakeNvData.ConsoleErrCheck[0];\r
-  for (Index = 0; ((Index < ConsoleErrMenu.MenuNumber) && \\r
-       (Index < MAX_MENU_NUMBER)) ; Index++) {\r
-    NewMenuEntry      = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);\r
-    NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-    ConErrCheck[Index] = NewConsoleContext->IsActive;\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)\r
-  to BMM_FAKE_NV_DATA structure.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-GetTerminalAttribute (\r
-  IN  BMM_CALLBACK_DATA    *CallbackData\r
-  )\r
-{\r
-  BMM_FAKE_NV_DATA     *CurrentFakeNVMap;\r
-  BM_MENU_ENTRY        *NewMenuEntry;\r
-  BM_TERMINAL_CONTEXT  *NewTerminalContext;\r
-  UINT16               TerminalIndex;\r
-  UINT8                AttributeIndex;\r
-\r
-  ASSERT (CallbackData != NULL);\r
-\r
-  CurrentFakeNVMap = &CallbackData->BmmFakeNvData;\r
-  for (TerminalIndex = 0; ((TerminalIndex < TerminalMenu.MenuNumber) && \\r
-       (TerminalIndex < MAX_MENU_NUMBER)); TerminalIndex++) {\r
-    NewMenuEntry        = BOpt_GetMenuEntry (&TerminalMenu, TerminalIndex);\r
-    NewTerminalContext  = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
-    for (AttributeIndex = 0; AttributeIndex < sizeof (BaudRateList) / sizeof (BaudRateList [0]); AttributeIndex++) {\r
-      if (NewTerminalContext->BaudRate == (UINT64) (BaudRateList[AttributeIndex].Value)) {\r
-        NewTerminalContext->BaudRateIndex = AttributeIndex;\r
-        break;\r
-      }\r
-    }\r
-    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (DataBitsList); AttributeIndex++) {\r
-      if (NewTerminalContext->DataBits == (UINT64) (DataBitsList[AttributeIndex].Value)) {\r
-        NewTerminalContext->DataBitsIndex = AttributeIndex;\r
-        break;\r
-      }\r
-    }\r
-\r
-    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (ParityList); AttributeIndex++) {\r
-      if (NewTerminalContext->Parity == (UINT64) (ParityList[AttributeIndex].Value)) {\r
-        NewTerminalContext->ParityIndex = AttributeIndex;\r
-        break;\r
-      }\r
-    }\r
-\r
-    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (StopBitsList); AttributeIndex++) {\r
-      if (NewTerminalContext->StopBits == (UINT64) (StopBitsList[AttributeIndex].Value)) {\r
-        NewTerminalContext->StopBitsIndex = AttributeIndex;\r
-        break;\r
-      }\r
-    }\r
-    CurrentFakeNVMap->COMBaudRate[TerminalIndex]     = NewTerminalContext->BaudRateIndex;\r
-    CurrentFakeNVMap->COMDataRate[TerminalIndex]     = NewTerminalContext->DataBitsIndex;\r
-    CurrentFakeNVMap->COMStopBits[TerminalIndex]     = NewTerminalContext->StopBitsIndex;\r
-    CurrentFakeNVMap->COMParity[TerminalIndex]       = NewTerminalContext->ParityIndex;\r
-    CurrentFakeNVMap->COMTerminalType[TerminalIndex] = NewTerminalContext->TerminalType;\r
-    CurrentFakeNVMap->COMFlowControl[TerminalIndex]  = NewTerminalContext->FlowControl;\r
-  }\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Data.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Data.c
deleted file mode 100644 (file)
index 1698f0b..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/** @file\r
-  Define some data used for Boot Maint\r
-\r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BootMaint.h"\r
-\r
-VOID                *mStartOpCodeHandle = NULL;\r
-VOID                *mEndOpCodeHandle = NULL;\r
-EFI_IFR_GUID_LABEL  *mStartLabel = NULL;\r
-EFI_IFR_GUID_LABEL  *mEndLabel = NULL;\r
-\r
-STRING_DEPOSITORY   *FileOptionStrDepository;\r
-STRING_DEPOSITORY   *ConsoleOptionStrDepository;\r
-STRING_DEPOSITORY   *BootOptionStrDepository;\r
-STRING_DEPOSITORY   *BootOptionHelpStrDepository;\r
-STRING_DEPOSITORY   *DriverOptionStrDepository;\r
-STRING_DEPOSITORY   *DriverOptionHelpStrDepository;\r
-STRING_DEPOSITORY   *TerminalStrDepository;\r
-\r
-///\r
-/// Terminal type string token storage\r
-///\r
-UINT16              TerminalType[] = {\r
-  STRING_TOKEN(STR_COM_TYPE_0),\r
-  STRING_TOKEN(STR_COM_TYPE_1),\r
-  STRING_TOKEN(STR_COM_TYPE_2),\r
-  STRING_TOKEN(STR_COM_TYPE_3),\r
-};\r
-\r
-///\r
-/// Flow Control type string token storage\r
-///\r
-UINT16              mFlowControlType[2] = {\r
-  STRING_TOKEN(STR_NONE_FLOW_CONTROL),\r
-  STRING_TOKEN(STR_HARDWARE_FLOW_CONTROL)\r
-};\r
-\r
-UINT32              mFlowControlValue[2] = {\r
-  0,\r
-  UART_FLOW_CONTROL_HARDWARE\r
-};\r
-\r
-///\r
-/// File system selection menu\r
-///\r
-BM_MENU_OPTION      FsOptionMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Console Input Device Selection Menu\r
-///\r
-BM_MENU_OPTION      ConsoleInpMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Console Output Device Selection Menu\r
-///\r
-BM_MENU_OPTION      ConsoleOutMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Error Output Device Selection Menu\r
-///\r
-BM_MENU_OPTION      ConsoleErrMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Boot Option from variable Menu\r
-///\r
-BM_MENU_OPTION      BootOptionMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Driver Option from variable menu\r
-///\r
-BM_MENU_OPTION      DriverOptionMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Legacy FD Info from LegacyBios.GetBbsInfo()\r
-///\r
-BM_MENU_OPTION      LegacyFDMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Legacy HD Info from LegacyBios.GetBbsInfo()\r
-///\r
-BM_MENU_OPTION      LegacyHDMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Legacy CD Info from LegacyBios.GetBbsInfo()\r
-///\r
-BM_MENU_OPTION      LegacyCDMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Legacy NET Info from LegacyBios.GetBbsInfo()\r
-///\r
-BM_MENU_OPTION      LegacyNETMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Legacy NET Info from LegacyBios.GetBbsInfo()\r
-///\r
-BM_MENU_OPTION      LegacyBEVMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Files and sub-directories in current directory menu\r
-///\r
-BM_MENU_OPTION      DirectoryMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Handles in current system selection menu\r
-///\r
-BM_MENU_OPTION      DriverMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-BM_MENU_OPTION      TerminalMenu = {\r
-  BM_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Value and string token correspondency for BaudRate\r
-///\r
-COM_ATTR            BaudRateList[19] = {\r
-  {\r
-    115200,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_0)\r
-  },\r
-  {\r
-    57600,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_1)\r
-  },\r
-  {\r
-    38400,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_2)\r
-  },\r
-  {\r
-    19200,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_3)\r
-  },\r
-  {\r
-    9600,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_4)\r
-  },\r
-  {\r
-    7200,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_5)\r
-  },\r
-  {\r
-    4800,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_6)\r
-  },\r
-  {\r
-    3600,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_7)\r
-  },\r
-  {\r
-    2400,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_8)\r
-  },\r
-  {\r
-    2000,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_9)\r
-  },\r
-  {\r
-    1800,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_10)\r
-  },\r
-  {\r
-    1200,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_11)\r
-  },\r
-  {\r
-    600,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_12)\r
-  },\r
-  {\r
-    300,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_13)\r
-  },\r
-  {\r
-    150,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_14)\r
-  },\r
-  {\r
-    134,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_15)\r
-  },\r
-  {\r
-    110,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_16)\r
-  },\r
-  {\r
-    75,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_17)\r
-  },\r
-  {\r
-    50,\r
-    STRING_TOKEN(STR_COM_BAUD_RATE_18)\r
-  }\r
-};\r
-\r
-///\r
-/// Value and string token correspondency for DataBits\r
-///\r
-COM_ATTR            DataBitsList[4] = {\r
-  {\r
-    5,\r
-    STRING_TOKEN(STR_COM_DATA_BITS_0)\r
-  },\r
-  {\r
-    6,\r
-    STRING_TOKEN(STR_COM_DATA_BITS_1)\r
-  },\r
-  {\r
-    7,\r
-    STRING_TOKEN(STR_COM_DATA_BITS_2)\r
-  },\r
-  {\r
-    8,\r
-    STRING_TOKEN(STR_COM_DATA_BITS_3)\r
-  }\r
-};\r
-\r
-///\r
-/// Value and string token correspondency for Parity\r
-///\r
-COM_ATTR            ParityList[5] = {\r
-  {\r
-    NoParity,\r
-    STRING_TOKEN(STR_COM_PAR_0)\r
-  },\r
-  {\r
-    EvenParity,\r
-    STRING_TOKEN(STR_COM_PAR_1)\r
-  },\r
-  {\r
-    OddParity,\r
-    STRING_TOKEN(STR_COM_PAR_2)\r
-  },\r
-  {\r
-    MarkParity,\r
-    STRING_TOKEN(STR_COM_PAR_3)\r
-  },\r
-  {\r
-    SpaceParity,\r
-    STRING_TOKEN(STR_COM_PAR_4)\r
-  }\r
-};\r
-\r
-///\r
-/// Value and string token correspondency for Baudreate\r
-///\r
-COM_ATTR            StopBitsList[3] = {\r
-  {\r
-    OneStopBit,\r
-    STRING_TOKEN(STR_COM_STOP_BITS_0)\r
-  },\r
-  {\r
-    OneFiveStopBits,\r
-    STRING_TOKEN(STR_COM_STOP_BITS_1)\r
-  },\r
-  {\r
-    TwoStopBits,\r
-    STRING_TOKEN(STR_COM_STOP_BITS_2)\r
-  }\r
-};\r
-\r
-///\r
-/// Guid for messaging path, used in Serial port setting.\r
-///\r
-EFI_GUID            TerminalTypeGuid[4] = {\r
-  DEVICE_PATH_MESSAGING_PC_ANSI,\r
-  DEVICE_PATH_MESSAGING_VT_100,\r
-  DEVICE_PATH_MESSAGING_VT_100_PLUS,\r
-  DEVICE_PATH_MESSAGING_VT_UTF8\r
-};\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FE.vfr b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FE.vfr
deleted file mode 100644 (file)
index 8e013c6..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-///** @file\r
-//\r
-//    File Explorer Formset\r
-//\r
-//  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-//**/\r
-\r
-#include "FormGuid.h"\r
-\r
-formset\r
-  guid = FILE_EXPLORE_FORMSET_GUID,\r
-  title = STRING_TOKEN(STR_FILE_EXPLORER_TITLE),\r
-  help = STRING_TOKEN(STR_NULL_STRING),\r
-  classguid = FILE_EXPLORE_FORMSET_GUID,\r
-\r
-  varstore FILE_EXPLORER_NV_DATA,\r
-    varid = VARSTORE_ID_BOOT_MAINT,\r
-    name = FeData,\r
-    guid = FILE_EXPLORE_FORMSET_GUID;\r
-\r
-  form formid = FORM_FILE_EXPLORER_ID,\r
-       title = STRING_TOKEN(STR_FILE_EXPLORER_TITLE);\r
-\r
-       label FORM_FILE_EXPLORER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  form formid = FORM_BOOT_ADD_DESCRIPTION_ID,\r
-       title = STRING_TOKEN(STR_FORM_BOOT_ADD_DESC_TITLE);\r
-\r
-       label FORM_BOOT_ADD_DESCRIPTION_ID;\r
-       label LABEL_END;\r
-\r
-       subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
-       string    varid    = FeData.BootDescriptionData,\r
-                 questionid = KEY_VALUE_BOOT_DESCRIPTION,\r
-                 prompt   = STRING_TOKEN(STR_LOAD_OPTION_DESC),\r
-                 help     = STRING_TOKEN(STR_NULL_STRING),\r
-                 flags    = INTERACTIVE,\r
-                 minsize  = 6,\r
-                 maxsize  = 75,\r
-       endstring;\r
-\r
-       string    varid    = FeData.BootOptionalData,\r
-                 questionid = KEY_VALUE_BOOT_OPTION,\r
-                 prompt   = STRING_TOKEN(STR_OPTIONAL_DATA),\r
-                 help     = STRING_TOKEN(STR_NULL_STRING),\r
-                 flags    = INTERACTIVE,\r
-                 minsize  = 0,\r
-                 maxsize  = 120,\r
-       endstring;\r
-\r
-       subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
-       text\r
-         help   = STRING_TOKEN(STR_SAVE_AND_EXIT),\r
-         text   = STRING_TOKEN(STR_SAVE_AND_EXIT),\r
-         flags  = INTERACTIVE,\r
-         key    = KEY_VALUE_SAVE_AND_EXIT_BOOT;\r
-\r
-       text\r
-         help   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),\r
-         text   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),\r
-         flags  = INTERACTIVE,\r
-         key    = KEY_VALUE_NO_SAVE_AND_EXIT_BOOT;\r
-\r
-  endform;\r
-\r
-  form formid = FORM_DRIVER_ADD_FILE_DESCRIPTION_ID,\r
-       title = STRING_TOKEN(STR_FORM_DRV_ADD_DESC_TITLE);\r
-\r
-       label FORM_DRIVER_ADD_FILE_DESCRIPTION_ID;\r
-       label LABEL_END;\r
-\r
-       subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
-       string    varid    = FeData.DriverDescriptionData,\r
-                 questionid = KEY_VALUE_DRIVER_DESCRIPTION,\r
-                 prompt   = STRING_TOKEN(STR_LOAD_OPTION_DESC),\r
-                 help     = STRING_TOKEN(STR_NULL_STRING),\r
-                 flags    = INTERACTIVE,\r
-                 minsize  = 6,\r
-                 maxsize  = 75,\r
-       endstring;\r
-\r
-       string    varid    = FeData.DriverOptionalData,\r
-                 questionid = KEY_VALUE_DRIVER_OPTION,\r
-                 prompt   = STRING_TOKEN(STR_OPTIONAL_DATA),\r
-                 help     = STRING_TOKEN(STR_NULL_STRING),\r
-                 flags    = INTERACTIVE,\r
-                 minsize  = 0,\r
-                 maxsize  = 120,\r
-       endstring;\r
-\r
-       checkbox varid    = FeData.ForceReconnect,\r
-               prompt   = STRING_TOKEN(STR_LOAD_OPTION_FORCE_RECON),\r
-               help     = STRING_TOKEN(STR_LOAD_OPTION_FORCE_RECON),\r
-               flags    = CHECKBOX_DEFAULT,\r
-               key      = 0,\r
-       endcheckbox;\r
-\r
-       subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
-       text\r
-         help   = STRING_TOKEN(STR_SAVE_AND_EXIT),\r
-         text   = STRING_TOKEN(STR_SAVE_AND_EXIT),\r
-         flags  = INTERACTIVE,\r
-         key    = KEY_VALUE_SAVE_AND_EXIT_DRIVER;  //BUGBUB: allow duplicate key in one formset???\r
-\r
-       text\r
-         help   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),\r
-         text   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),\r
-         flags  = INTERACTIVE,\r
-         key    = KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER;\r
-\r
-  endform;\r
-\r
-endformset;\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FileExplorer.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FileExplorer.c
deleted file mode 100644 (file)
index d67c9b5..0000000
+++ /dev/null
@@ -1,463 +0,0 @@
-/** @file\r
-  File explorer related functions.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BootMaint.h"\r
-\r
-/**\r
-  Update the File Explore page.\r
-\r
-  @param CallbackData    The BMM context data.\r
-  @param MenuOption      Pointer to menu options to display.\r
-\r
-**/\r
-VOID\r
-UpdateFileExplorePage (\r
-  IN BMM_CALLBACK_DATA            *CallbackData,\r
-  BM_MENU_OPTION                  *MenuOption\r
-  )\r
-{\r
-  UINTN           Index;\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_FILE_CONTEXT *NewFileContext;\r
-  EFI_FORM_ID     FormId;\r
-\r
-  NewMenuEntry    = NULL;\r
-  NewFileContext  = NULL;\r
-  FormId          = 0;\r
-\r
-  RefreshUpdateData ();\r
-  mStartLabel->Number = FORM_FILE_EXPLORER_ID;\r
-\r
-  for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r
-    NewMenuEntry    = BOpt_GetMenuEntry (MenuOption, Index);\r
-    NewFileContext  = (BM_FILE_CONTEXT *) NewMenuEntry->VariableContext;\r
-\r
-    if (NewFileContext->IsBootLegacy) {\r
-      continue;\r
-    }\r
-\r
-    if ((NewFileContext->IsDir) || (FileExplorerStateBootFromFile == CallbackData->FeCurrentState)) {\r
-      //\r
-      // Create Text opcode for directory, also create Text opcode for file in FileExplorerStateBootFromFile.\r
-      //\r
-      HiiCreateActionOpCode (\r
-        mStartOpCodeHandle,\r
-        (UINT16) (FILE_OPTION_OFFSET + Index),\r
-        NewMenuEntry->DisplayStringToken,\r
-        STRING_TOKEN (STR_NULL_STRING),\r
-        EFI_IFR_FLAG_CALLBACK,\r
-        0\r
-        );\r
-    } else {\r
-      //\r
-      // Create Goto opcode for file in FileExplorerStateAddBootOption or FileExplorerStateAddDriverOptionState.\r
-      //\r
-      if (FileExplorerStateAddBootOption == CallbackData->FeCurrentState) {\r
-        FormId = FORM_BOOT_ADD_DESCRIPTION_ID;\r
-      } else if (FileExplorerStateAddDriverOptionState == CallbackData->FeCurrentState) {\r
-        FormId = FORM_DRIVER_ADD_FILE_DESCRIPTION_ID;\r
-      }\r
-\r
-      HiiCreateGotoOpCode (\r
-        mStartOpCodeHandle,\r
-        FormId,\r
-        NewMenuEntry->DisplayStringToken,\r
-        STRING_TOKEN (STR_NULL_STRING),\r
-        EFI_IFR_FLAG_CALLBACK,\r
-        (UINT16) (FILE_OPTION_GOTO_OFFSET + Index)\r
-        );\r
-    }\r
-  }\r
-\r
-  HiiUpdateForm (\r
-    CallbackData->FeHiiHandle,\r
-    &gFileExploreFormSetGuid,\r
-    FORM_FILE_EXPLORER_ID,\r
-    mStartOpCodeHandle, // Label FORM_FILE_EXPLORER_ID\r
-    mEndOpCodeHandle    // LABEL_END\r
-    );\r
-}\r
-\r
-/**\r
-  Update the file explower page with the refershed file system.\r
-\r
-\r
-  @param CallbackData    BMM context data\r
-  @param KeyValue        Key value to identify the type of data to expect.\r
-\r
-  @retval  TRUE           Inform the caller to create a callback packet to exit file explorer.\r
-  @retval  FALSE          Indicate that there is no need to exit file explorer.\r
-\r
-**/\r
-BOOLEAN\r
-UpdateFileExplorer (\r
-  IN BMM_CALLBACK_DATA            *CallbackData,\r
-  IN UINT16                       KeyValue\r
-  )\r
-{\r
-  UINT16          FileOptionMask;\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_FILE_CONTEXT *NewFileContext;\r
-  EFI_FORM_ID     FormId;\r
-  BOOLEAN         ExitFileExplorer;\r
-  EFI_STATUS      Status;\r
-\r
-  NewMenuEntry      = NULL;\r
-  NewFileContext    = NULL;\r
-  ExitFileExplorer  = FALSE;\r
-\r
-  FileOptionMask    = (UINT16) (FILE_OPTION_MASK & KeyValue);\r
-\r
-  if (FileExplorerDisplayUnknown == CallbackData->FeDisplayContext) {\r
-    //\r
-    // First in, display file system.\r
-    //\r
-    BOpt_FreeMenu (&FsOptionMenu);\r
-    BOpt_FindFileSystem (CallbackData);\r
-    CreateMenuStringToken (CallbackData, CallbackData->FeHiiHandle, &FsOptionMenu);\r
-\r
-    UpdateFileExplorePage (CallbackData, &FsOptionMenu);\r
-\r
-    CallbackData->FeDisplayContext = FileExplorerDisplayFileSystem;\r
-  } else {\r
-    if (FileExplorerDisplayFileSystem == CallbackData->FeDisplayContext) {\r
-      NewMenuEntry = BOpt_GetMenuEntry (&FsOptionMenu, FileOptionMask);\r
-    } else if (FileExplorerDisplayDirectory == CallbackData->FeDisplayContext) {\r
-      NewMenuEntry = BOpt_GetMenuEntry (&DirectoryMenu, FileOptionMask);\r
-    }\r
-\r
-    NewFileContext                  = (BM_FILE_CONTEXT *) NewMenuEntry->VariableContext;\r
-\r
-    if (NewFileContext->IsDir ) {\r
-      CallbackData->FeDisplayContext = FileExplorerDisplayDirectory;\r
-\r
-      RemoveEntryList (&NewMenuEntry->Link);\r
-      BOpt_FreeMenu (&DirectoryMenu);\r
-      Status = BOpt_FindFiles (CallbackData, NewMenuEntry);\r
-       if (EFI_ERROR (Status)) {\r
-         ExitFileExplorer = TRUE;\r
-         goto exit;\r
-       }\r
-      CreateMenuStringToken (CallbackData, CallbackData->FeHiiHandle, &DirectoryMenu);\r
-      BOpt_DestroyMenuEntry (NewMenuEntry);\r
-\r
-      UpdateFileExplorePage (CallbackData, &DirectoryMenu);\r
-\r
-    } else {\r
-      switch (CallbackData->FeCurrentState) {\r
-      case FileExplorerStateBootFromFile:\r
-        //\r
-        // Restore to original mode before  launching boot option.\r
-        //\r
-        BdsSetConsoleMode (FALSE);\r
-\r
-        //\r
-        // Here boot from file\r
-        //\r
-        BootThisFile (NewFileContext);\r
-        //\r
-        // Set proper video resolution and text mode for setup.\r
-        //\r
-        BdsSetConsoleMode (TRUE);\r
-        ExitFileExplorer = TRUE;\r
-        break;\r
-\r
-      case FileExplorerStateAddBootOption:\r
-      case FileExplorerStateAddDriverOptionState:\r
-        if (FileExplorerStateAddBootOption == CallbackData->FeCurrentState) {\r
-          FormId = FORM_BOOT_ADD_DESCRIPTION_ID;\r
-          if (!CallbackData->FeFakeNvData.BootOptionChanged) {\r
-            ZeroMem (CallbackData->FeFakeNvData.BootOptionalData, sizeof (CallbackData->FeFakeNvData.BootOptionalData));\r
-            ZeroMem (CallbackData->FeFakeNvData.BootDescriptionData, sizeof (CallbackData->FeFakeNvData.BootDescriptionData));\r
-          }\r
-        } else {\r
-          FormId = FORM_DRIVER_ADD_FILE_DESCRIPTION_ID;\r
-          if (!CallbackData->FeFakeNvData.DriverOptionChanged) {\r
-            ZeroMem (CallbackData->FeFakeNvData.DriverOptionalData, sizeof (CallbackData->FeFakeNvData.DriverOptionalData));\r
-            ZeroMem (CallbackData->FeFakeNvData.DriverDescriptionData, sizeof (CallbackData->FeFakeNvData.DriverDescriptionData));\r
-          }\r
-        }\r
-\r
-        CallbackData->MenuEntry = NewMenuEntry;\r
-        CallbackData->LoadContext->FilePathList = ((BM_FILE_CONTEXT *) (CallbackData->MenuEntry->VariableContext))->DevicePath;\r
-\r
-        //\r
-        // Create Subtitle op-code for the display string of the option.\r
-        //\r
-        RefreshUpdateData ();\r
-        mStartLabel->Number = FormId;\r
-\r
-        HiiCreateSubTitleOpCode (\r
-          mStartOpCodeHandle,\r
-          NewMenuEntry->DisplayStringToken,\r
-          0,\r
-          0,\r
-          0\r
-          );\r
-\r
-        HiiUpdateForm (\r
-          CallbackData->FeHiiHandle,\r
-          &gFileExploreFormSetGuid,\r
-          FormId,\r
-          mStartOpCodeHandle, // Label FormId\r
-          mEndOpCodeHandle    // LABEL_END\r
-          );\r
-        break;\r
-\r
-      default:\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  exit:\r
-  return ExitFileExplorer;\r
-}\r
-\r
-/**\r
-  This function applies changes in a driver's configuration.\r
-  Input is a Configuration, which has the routing data for this\r
-  driver followed by name / value configuration pairs. The driver\r
-  must apply those pairs to its configurable storage. If the\r
-  driver's configuration is stored in a linear block of data\r
-  and the driver's name / value pairs are in <BlockConfig>\r
-  format, it may use the ConfigToBlock helper function (above) to\r
-  simplify the job. Currently not implemented.\r
-\r
-  @param[in]  This                Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param[in]  Configuration       A null-terminated Unicode string in\r
-                                  <ConfigString> format.\r
-  @param[out] Progress            A pointer to a string filled in with the\r
-                                  offset of the most recent '&' before the\r
-                                  first failing name / value pair (or the\r
-                                  beginn ing of the string if the failure\r
-                                  is in the first name / value pair) or\r
-                                  the terminating NULL if all was\r
-                                  successful.\r
-\r
-  @retval EFI_SUCCESS             The results have been distributed or are\r
-                                  awaiting distribution.\r
-  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the\r
-                                  parts of the results that must be\r
-                                  stored awaiting possible future\r
-                                  protocols.\r
-  @retval EFI_INVALID_PARAMETERS  Passing in a NULL for the\r
-                                  Results parameter would result\r
-                                  in this type of error.\r
-  @retval EFI_NOT_FOUND           Target for the specified routing data\r
-                                  was not found.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileExplorerRouteConfig (\r
-  IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
-  IN CONST EFI_STRING                     Configuration,\r
-  OUT EFI_STRING                          *Progress\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  UINTN                           BufferSize;\r
-  EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;\r
-  FILE_EXPLORER_NV_DATA           *FeData;\r
-  BMM_CALLBACK_DATA               *Private;\r
-\r
-  if (Progress == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  *Progress = Configuration;\r
-\r
-  if (Configuration == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Check routing data in <ConfigHdr>.\r
-  // Note: there is no name for Name/Value storage, only GUID will be checked\r
-  //\r
-  if (!HiiIsConfigHdrMatch (Configuration, &gFileExploreFormSetGuid, mFileExplorerStorageName)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiHiiConfigRoutingProtocolGuid,\r
-                  NULL,\r
-                  (VOID**) &ConfigRouting\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Private = FE_CALLBACK_DATA_FROM_THIS (This);\r
-  //\r
-  // Get Buffer Storage data from EFI variable\r
-  //\r
-  BufferSize = sizeof (FILE_EXPLORER_NV_DATA );\r
-  FeData = &Private->FeFakeNvData;\r
-\r
-  //\r
-  // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()\r
-  //\r
-  Status = ConfigRouting->ConfigToBlock (\r
-                            ConfigRouting,\r
-                            Configuration,\r
-                            (UINT8 *) FeData,\r
-                            &BufferSize,\r
-                            Progress\r
-                            );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  if (FeData->BootDescriptionData[0] != 0x00 || FeData->BootOptionalData[0] != 0x00) {\r
-    Status = Var_UpdateBootOption (Private, FeData);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    BOpt_GetBootOptions (Private);\r
-    CreateMenuStringToken (Private, Private->FeHiiHandle, &BootOptionMenu);\r
-  }\r
-\r
-  if (FeData->DriverDescriptionData[0] != 0x00 || FeData->DriverOptionalData[0] != 0x00) {\r
-    Status = Var_UpdateDriverOption (\r
-              Private,\r
-              Private->FeHiiHandle,\r
-              FeData->DriverDescriptionData,\r
-              FeData->DriverOptionalData,\r
-              FeData->ForceReconnect\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    BOpt_GetDriverOptions (Private);\r
-    CreateMenuStringToken (Private, Private->FeHiiHandle, &DriverOptionMenu);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-  When user select a interactive opcode, this callback will be triggered.\r
-  Based on the Question(QuestionId) that triggers the callback, the corresponding\r
-  actions is performed. It handles:\r
-\r
-  1) the addition of boot option.\r
-  2) the addition of driver option.\r
-  3) exit from file browser\r
-  4) update of file content if a dir is selected.\r
-  5) boot the file if a file is selected in "boot from file"\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_OUT_OF_RESOURCES  Not enough storage is available to hold the variable and its data.\r
-  @retval  EFI_DEVICE_ERROR      The variable could not be saved.\r
-  @retval  EFI_UNSUPPORTED       The specified Action is not supported by the callback.\r
-  @retval  EFI_INVALID_PARAMETER If parameter Value or ActionRequest is NULL.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileExplorerCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  )\r
-{\r
-  BMM_CALLBACK_DATA     *Private;\r
-  FILE_EXPLORER_NV_DATA *NvRamMap;\r
-  EFI_STATUS            Status;\r
-\r
-  if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {\r
-    //\r
-    // All other action return unsupported.\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status         = EFI_SUCCESS;\r
-  Private        = FE_CALLBACK_DATA_FROM_THIS (This);\r
-\r
-  //\r
-  // Retrieve uncommitted data from Form Browser\r
-  //\r
-  NvRamMap = &Private->FeFakeNvData;\r
-  HiiGetBrowserData (&gFileExploreFormSetGuid, mFileExplorerStorageName, sizeof (FILE_EXPLORER_NV_DATA), (UINT8 *) NvRamMap);\r
-\r
-  if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
-    if ((Value == NULL) || (ActionRequest == NULL)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_BOOT) {\r
-      NvRamMap->BootOptionChanged = FALSE;\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
-    } else if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_DRIVER) {\r
-      NvRamMap->DriverOptionChanged = FALSE;\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
-    } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER) {\r
-      //\r
-      // Discard changes and exit formset\r
-      //\r
-      NvRamMap->DriverOptionalData[0]     = 0x0000;\r
-      NvRamMap->DriverDescriptionData[0]  = 0x0000;\r
-      NvRamMap->DriverOptionChanged = FALSE;\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-    } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_BOOT) {\r
-      //\r
-      // Discard changes and exit formset\r
-      //\r
-      NvRamMap->BootOptionalData[0]     = 0x0000;\r
-      NvRamMap->BootDescriptionData[0]  = 0x0000;\r
-      NvRamMap->BootOptionChanged = FALSE;\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-    } else if (QuestionId == KEY_VALUE_BOOT_DESCRIPTION || QuestionId == KEY_VALUE_BOOT_OPTION) {\r
-      NvRamMap->BootOptionChanged = TRUE;\r
-    } else if (QuestionId == KEY_VALUE_DRIVER_DESCRIPTION || QuestionId == KEY_VALUE_DRIVER_OPTION) {\r
-      NvRamMap->DriverOptionChanged = TRUE;\r
-    } else if (QuestionId < FILE_OPTION_OFFSET) {\r
-      //\r
-      // Exit File Explorer formset\r
-      //\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-    } else if (QuestionId >= FILE_OPTION_OFFSET && QuestionId < FILE_OPTION_GOTO_OFFSET) {\r
-      //\r
-      // Update forms may return TRUE or FALSE, need to check here.\r
-      //\r
-      if (UpdateFileExplorer (Private, QuestionId)) {\r
-        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-      }\r
-    }\r
-  } else if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
-    if (Value == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (QuestionId >= FILE_OPTION_GOTO_OFFSET) {\r
-      //\r
-      // function will always return FALSE, no need to check here.\r
-      //\r
-      UpdateFileExplorer (Private, QuestionId);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Pass changed uncommitted data back to Form Browser\r
-  //\r
-  HiiSetBrowserData (&gFileExploreFormSetGuid, mFileExplorerStorageName, sizeof (FILE_EXPLORER_NV_DATA), (UINT8 *) NvRamMap, NULL);\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FormGuid.h b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FormGuid.h
deleted file mode 100644 (file)
index 3305710..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/** @file\r
-  Formset guids, form id and VarStore data structure for Boot Maintenance Manager.\r
-\r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-#ifndef _FORM_GUID_H_\r
-#define _FORM_GUID_H_\r
-\r
-#include <Guid/BdsHii.h>\r
-\r
-#define FORM_MAIN_ID                         0x1001\r
-#define FORM_BOOT_ADD_ID                     0x1002\r
-#define FORM_BOOT_DEL_ID                     0x1003\r
-#define FORM_BOOT_CHG_ID                     0x1004\r
-#define FORM_DRV_ADD_ID                      0x1005\r
-#define FORM_DRV_DEL_ID                      0x1006\r
-#define FORM_DRV_CHG_ID                      0x1007\r
-#define FORM_CON_MAIN_ID                     0x1008\r
-#define FORM_CON_IN_ID                       0x1009\r
-#define FORM_CON_OUT_ID                      0x100A\r
-#define FORM_CON_ERR_ID                      0x100B\r
-#define FORM_FILE_SEEK_ID                    0x100C\r
-#define FORM_FILE_NEW_SEEK_ID                0x100D\r
-#define FORM_DRV_ADD_FILE_ID                 0x100E\r
-#define FORM_DRV_ADD_HANDLE_ID               0x100F\r
-#define FORM_DRV_ADD_HANDLE_DESC_ID          0x1010\r
-#define FORM_BOOT_NEXT_ID                    0x1011\r
-#define FORM_TIME_OUT_ID                     0x1012\r
-#define FORM_RESET                           0x1013\r
-#define FORM_BOOT_SETUP_ID                   0x1014\r
-#define FORM_DRIVER_SETUP_ID                 0x1015\r
-#define FORM_BOOT_LEGACY_DEVICE_ID           0x1016\r
-#define FORM_CON_COM_ID                      0x1017\r
-#define FORM_CON_COM_SETUP_ID                0x1018\r
-#define FORM_SET_FD_ORDER_ID                 0x1019\r
-#define FORM_SET_HD_ORDER_ID                 0x101A\r
-#define FORM_SET_CD_ORDER_ID                 0x101B\r
-#define FORM_SET_NET_ORDER_ID                0x101C\r
-#define FORM_SET_BEV_ORDER_ID                0x101D\r
-#define FORM_FILE_EXPLORER_ID                0x101E\r
-#define FORM_BOOT_ADD_DESCRIPTION_ID         0x101F\r
-#define FORM_DRIVER_ADD_FILE_DESCRIPTION_ID  0x1020\r
-#define FORM_CON_MODE_ID                     0x1021\r
-#define FORM_BOOT_FROM_FILE_ID               0x1022\r
-\r
-#define MAXIMUM_FORM_ID                      0x10FF\r
-\r
-#define KEY_VALUE_COM_SET_BAUD_RATE          0x1101\r
-#define KEY_VALUE_COM_SET_DATA_BITS          0x1102\r
-#define KEY_VALUE_COM_SET_STOP_BITS          0x1103\r
-#define KEY_VALUE_COM_SET_PARITY             0x1104\r
-#define KEY_VALUE_COM_SET_TERMI_TYPE         0x1105\r
-#define KEY_VALUE_MAIN_BOOT_NEXT             0x1106\r
-#define KEY_VALUE_BOOT_ADD_DESC_DATA         0x1107\r
-#define KEY_VALUE_BOOT_ADD_OPT_DATA          0x1108\r
-#define KEY_VALUE_DRIVER_ADD_DESC_DATA       0x1109\r
-#define KEY_VALUE_DRIVER_ADD_OPT_DATA        0x110A\r
-#define KEY_VALUE_SAVE_AND_EXIT              0x110B\r
-#define KEY_VALUE_NO_SAVE_AND_EXIT           0x110C\r
-#define KEY_VALUE_BOOT_FROM_FILE             0x110D\r
-#define KEY_VALUE_BOOT_DESCRIPTION           0x110E\r
-#define KEY_VALUE_BOOT_OPTION                0x110F\r
-#define KEY_VALUE_DRIVER_DESCRIPTION         0x1110\r
-#define KEY_VALUE_DRIVER_OPTION              0x1111\r
-\r
-#define MAXIMUM_NORMAL_KEY_VALUE             0x11FF\r
-\r
-//\r
-// Varstore ID defined for Buffer Storage\r
-//\r
-#define VARSTORE_ID_BOOT_MAINT               0x1000\r
-#define VARSTORE_ID_FILE_EXPLORER            0x1001\r
-\r
-//\r
-// End Label\r
-//\r
-#define LABEL_END   0xffff\r
-#define MAX_MENU_NUMBER 100\r
-\r
-///\r
-/// This is the structure that will be used to store the\r
-/// question's current value. Use it at initialize time to\r
-/// set default value for each question. When using at run\r
-/// time, this map is returned by the callback function,\r
-/// so dynamically changing the question's value will be\r
-/// possible through this mechanism\r
-///\r
-typedef struct {\r
-  //\r
-  // Three questions displayed at the main page\r
-  // for Timeout, BootNext Variables respectively\r
-  //\r
-  UINT16  BootTimeOut;\r
-  UINT16  BootNext;\r
-\r
-  //\r
-  // This is the COM1 Attributes value storage\r
-  //\r
-  UINT8   COM1BaudRate;\r
-  UINT8   COM1DataRate;\r
-  UINT8   COM1StopBits;\r
-  UINT8   COM1Parity;\r
-  UINT8   COM1TerminalType;\r
-\r
-  //\r
-  // This is the COM2 Attributes value storage\r
-  //\r
-  UINT8   COM2BaudRate;\r
-  UINT8   COM2DataRate;\r
-  UINT8   COM2StopBits;\r
-  UINT8   COM2Parity;\r
-  UINT8   COM2TerminalType;\r
-\r
-  //\r
-  // Driver Option Add Handle page storage\r
-  //\r
-  UINT16  DriverAddHandleDesc[MAX_MENU_NUMBER];\r
-  UINT16  DriverAddHandleOptionalData[MAX_MENU_NUMBER];\r
-  UINT8   DriverAddActive;\r
-  UINT8   DriverAddForceReconnect;\r
-\r
-  //\r
-  // Console Input/Output/Errorout using COM port check storage\r
-  //\r
-  UINT8   ConsoleInputCOM1;\r
-  UINT8   ConsoleInputCOM2;\r
-  UINT8   ConsoleOutputCOM1;\r
-  UINT8   ConsoleOutputCOM2;\r
-  UINT8   ConsoleErrorCOM1;\r
-  UINT8   ConsoleErrorCOM2;\r
-\r
-  //\r
-  // At most 100 input/output/errorout device for console storage\r
-  //\r
-  UINT8   ConsoleCheck[MAX_MENU_NUMBER];\r
-  //\r
-  // At most 100 input/output/errorout device for console storage\r
-  //\r
-  UINT8   ConsoleInCheck[MAX_MENU_NUMBER];\r
-  UINT8   ConsoleOutCheck[MAX_MENU_NUMBER];\r
-  UINT8   ConsoleErrCheck[MAX_MENU_NUMBER];\r
-\r
-  //\r
-  // Boot Option Order storage\r
-  // The value is the OptionNumber+1 because the order list value cannot be 0\r
-  // Use UINT32 to hold the potential value 0xFFFF+1=0x10000\r
-  //\r
-  UINT32  BootOptionOrder[MAX_MENU_NUMBER];\r
-\r
-  //\r
-  // Driver Option Order storage\r
-  // The value is the OptionNumber+1 because the order list value cannot be 0\r
-  // Use UINT32 to hold the potential value 0xFFFF+1=0x10000\r
-  //\r
-  UINT32  DriverOptionOrder[MAX_MENU_NUMBER];\r
-\r
-  //\r
-  // Boot Option Delete storage\r
-  //\r
-  BOOLEAN BootOptionDel[MAX_MENU_NUMBER];\r
-  BOOLEAN BootOptionDelMark[MAX_MENU_NUMBER];\r
-\r
-  //\r
-  // Driver Option Delete storage\r
-  //\r
-  BOOLEAN DriverOptionDel[MAX_MENU_NUMBER];\r
-  BOOLEAN DriverOptionDelMark[MAX_MENU_NUMBER];\r
-\r
-  //\r
-  // This is the Terminal Attributes value storage\r
-  //\r
-  UINT8   COMBaudRate[MAX_MENU_NUMBER];\r
-  UINT8   COMDataRate[MAX_MENU_NUMBER];\r
-  UINT8   COMStopBits[MAX_MENU_NUMBER];\r
-  UINT8   COMParity[MAX_MENU_NUMBER];\r
-  UINT8   COMTerminalType[MAX_MENU_NUMBER];\r
-  UINT8   COMFlowControl[MAX_MENU_NUMBER];\r
-\r
-  //\r
-  // Legacy Device Order Selection Storage\r
-  //\r
-  UINT8   LegacyFD[MAX_MENU_NUMBER];\r
-  UINT8   LegacyHD[MAX_MENU_NUMBER];\r
-  UINT8   LegacyCD[MAX_MENU_NUMBER];\r
-  UINT8   LegacyNET[MAX_MENU_NUMBER];\r
-  UINT8   LegacyBEV[MAX_MENU_NUMBER];\r
-\r
-  //\r
-  // We use DisableMap array to record the enable/disable state of each boot device\r
-  // It should be taken as a bit array, from left to right there are totally 256 bits\r
-  // the most left one stands for BBS table item 0, and the most right one stands for item 256\r
-  // If the bit is 1, it means the boot device has been disabled.\r
-  //\r
-  UINT8   DisableMap[32];\r
-\r
-  //\r
-  // Console Output Text Mode\r
-  //\r
-  UINT16  ConsoleOutMode;\r
-\r
-  //\r
-  //  UINT16                    PadArea[10];\r
-  //\r
-} BMM_FAKE_NV_DATA;\r
-\r
-//\r
-// Key used by File Explorer forms\r
-//\r
-#define KEY_VALUE_SAVE_AND_EXIT_BOOT           0x1000\r
-#define KEY_VALUE_NO_SAVE_AND_EXIT_BOOT        0x1001\r
-#define KEY_VALUE_SAVE_AND_EXIT_DRIVER         0x1002\r
-#define KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER      0x1003\r
-\r
-//\r
-// Description data and optional data size\r
-//\r
-#define DESCRIPTION_DATA_SIZE                  75\r
-#define OPTIONAL_DATA_SIZE                     127\r
-\r
-///\r
-/// This is the data structure used by File Explorer formset\r
-///\r
-typedef struct {\r
-  UINT16  BootDescriptionData[DESCRIPTION_DATA_SIZE];\r
-  UINT16  BootOptionalData[OPTIONAL_DATA_SIZE];\r
-  UINT16  DriverDescriptionData[DESCRIPTION_DATA_SIZE];\r
-  UINT16  DriverOptionalData[OPTIONAL_DATA_SIZE];\r
-  BOOLEAN BootOptionChanged;\r
-  BOOLEAN DriverOptionChanged;\r
-  UINT8   Active;\r
-  UINT8   ForceReconnect;\r
-} FILE_EXPLORER_NV_DATA;\r
-\r
-#endif\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
deleted file mode 100644 (file)
index e37c2db..0000000
+++ /dev/null
@@ -1,1407 +0,0 @@
-/** @file\r
-Dynamically update the pages.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BootMaint.h"\r
-\r
-/**\r
-  Refresh the global UpdateData structure.\r
-\r
-**/\r
-VOID\r
-RefreshUpdateData (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Free current updated date\r
-  //\r
-  if (mStartOpCodeHandle != NULL) {\r
-    HiiFreeOpCodeHandle (mStartOpCodeHandle);\r
-  }\r
-\r
-  //\r
-  // Create new OpCode Handle\r
-  //\r
-  mStartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mStartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-\r
-}\r
-\r
-/**\r
-  Add a "Go back to main page" tag in front of the form when there are no\r
-  "Apply changes" and "Discard changes" tags in the end of the form.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdatePageStart (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  RefreshUpdateData ();\r
-  mStartLabel->Number = CallbackData->BmmCurrentPageId;\r
-\r
-  if (!(CallbackData->BmmAskSaveOrNot)) {\r
-    //\r
-    // Add a "Go back to main page" tag in front of the form when there are no\r
-    // "Apply changes" and "Discard changes" tags in the end of the form.\r
-    //\r
-    HiiCreateGotoOpCode (\r
-      mStartOpCodeHandle,\r
-      FORM_MAIN_ID,\r
-      STRING_TOKEN (STR_FORM_GOTO_MAIN),\r
-      STRING_TOKEN (STR_FORM_GOTO_MAIN),\r
-      0,\r
-      FORM_MAIN_ID\r
-      );\r
-  }\r
-\r
-}\r
-\r
-/**\r
-  Create the "Apply changes" and "Discard changes" tags. And\r
-  ensure user can return to the main page.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdatePageEnd (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  //\r
-  // Create the "Apply changes" and "Discard changes" tags.\r
-  //\r
-  if (CallbackData->BmmAskSaveOrNot) {\r
-    HiiCreateSubTitleOpCode (\r
-      mStartOpCodeHandle,\r
-      STRING_TOKEN (STR_NULL_STRING),\r
-      0,\r
-      0,\r
-      0\r
-      );\r
-\r
-    HiiCreateActionOpCode (\r
-      mStartOpCodeHandle,\r
-      KEY_VALUE_SAVE_AND_EXIT,\r
-      STRING_TOKEN (STR_SAVE_AND_EXIT),\r
-      STRING_TOKEN (STR_NULL_STRING),\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      0\r
-      );\r
-  }\r
-\r
-  //\r
-  // Ensure user can return to the main page.\r
-  //\r
-  HiiCreateActionOpCode (\r
-    mStartOpCodeHandle,\r
-    KEY_VALUE_NO_SAVE_AND_EXIT,\r
-    STRING_TOKEN (STR_NO_SAVE_AND_EXIT),\r
-    STRING_TOKEN (STR_NULL_STRING),\r
-    EFI_IFR_FLAG_CALLBACK,\r
-    0\r
-    );\r
-\r
-  HiiUpdateForm (\r
-    CallbackData->BmmHiiHandle,\r
-    &gBootMaintFormSetGuid,\r
-    CallbackData->BmmCurrentPageId,\r
-    mStartOpCodeHandle, // Label CallbackData->BmmCurrentPageId\r
-    mEndOpCodeHandle    // LABEL_END\r
-    );\r
-}\r
-\r
-/**\r
-  Clean up the dynamic opcode at label and form specified by both LabelId.\r
-\r
-  @param LabelId         It is both the Form ID and Label ID for opcode deletion.\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-CleanUpPage (\r
-  IN UINT16                           LabelId,\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  RefreshUpdateData ();\r
-\r
-  //\r
-  // Remove all op-codes from dynamic page\r
-  //\r
-  mStartLabel->Number = LabelId;\r
-  HiiUpdateForm (\r
-    CallbackData->BmmHiiHandle,\r
-    &gBootMaintFormSetGuid,\r
-    LabelId,\r
-    mStartOpCodeHandle, // Label LabelId\r
-    mEndOpCodeHandle    // LABEL_END\r
-    );\r
-}\r
-\r
-/**\r
-  Boot a file selected by user at File Expoloer of BMM.\r
-\r
-  @param FileContext     The file context data, which contains the device path\r
-                         of the file to be boot from.\r
-\r
-  @retval EFI_SUCCESS    The function completed successfull.\r
-  @return Other value if the boot from the file fails.\r
-\r
-**/\r
-EFI_STATUS\r
-BootThisFile (\r
-  IN BM_FILE_CONTEXT                   *FileContext\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  UINTN             ExitDataSize;\r
-  CHAR16            *ExitData;\r
-  BDS_COMMON_OPTION *Option;\r
-\r
-  Option = (BDS_COMMON_OPTION *) AllocatePool (sizeof (BDS_COMMON_OPTION));\r
-  ASSERT (Option != NULL);\r
-  Option->Description     = (CHAR16 *) AllocateCopyPool (StrSize (FileContext->FileName), FileContext->FileName);\r
-  Option->DevicePath      = FileContext->DevicePath;\r
-  Option->LoadOptionsSize = 0;\r
-  Option->LoadOptions     = NULL;\r
-\r
-  //\r
-  // Since current no boot from removable media directly is allowed */\r
-  //\r
-  gST->ConOut->ClearScreen (gST->ConOut);\r
-\r
-  ExitDataSize  = 0;\r
-\r
-  Status        = BdsLibBootViaBootOption (Option, Option->DevicePath, &ExitDataSize, &ExitData);\r
-\r
-  return Status;\r
-\r
-}\r
-\r
-/**\r
-  Create a list of Goto Opcode for all terminal devices logged\r
-  by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.\r
-\r
-  @param CallbackData    The BMM context data.\r
-**/\r
-VOID\r
-UpdateConCOMPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY *NewMenuEntry;\r
-  UINT16        Index;\r
-\r
-  CallbackData->BmmAskSaveOrNot = FALSE;\r
-\r
-  UpdatePageStart (CallbackData);\r
-\r
-\r
-  for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
-    NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
-\r
-    HiiCreateGotoOpCode (\r
-      mStartOpCodeHandle,\r
-      FORM_CON_COM_SETUP_ID,\r
-      NewMenuEntry->DisplayStringToken,\r
-      STRING_TOKEN (STR_NULL_STRING),\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      (UINT16) (TERMINAL_OPTION_OFFSET + Index)\r
-      );\r
-  }\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Create a lit of boot option from global BootOptionMenu. It\r
-  allow user to delete the boot option.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateBootDelPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT *NewLoadContext;\r
-  UINT16          Index;\r
-\r
-  CallbackData->BmmAskSaveOrNot = TRUE;\r
-\r
-  UpdatePageStart (CallbackData);\r
-  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &BootOptionMenu);\r
-\r
-  ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.BootOptionDel) / sizeof (CallbackData->BmmFakeNvData.BootOptionDel[0])));\r
-  for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
-    NewMenuEntry    = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
-    NewLoadContext  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-    if (NewLoadContext->IsLegacy) {\r
-      continue;\r
-    }\r
-\r
-    NewLoadContext->Deleted = FALSE;\r
-\r
-    if (CallbackData->BmmFakeNvData.BootOptionDel[Index] && !CallbackData->BmmFakeNvData.BootOptionDelMark[Index]) {\r
-      //\r
-      // CallbackData->BmmFakeNvData.BootOptionDel[Index] == TRUE means browser knows this boot option is selected\r
-      // CallbackData->BmmFakeNvData.BootOptionDelMark[Index] = FALSE means BDS knows the selected boot option has\r
-      // deleted, browser maintains old useless info. So clear this info here, and later update this info to browser\r
-      // through HiiSetBrowserData function.\r
-      //\r
-      CallbackData->BmmFakeNvData.BootOptionDel[Index] = FALSE;\r
-    }\r
-\r
-    HiiCreateCheckBoxOpCode (\r
-      mStartOpCodeHandle,\r
-      (EFI_QUESTION_ID) (BOOT_OPTION_DEL_QUESTION_ID + Index),\r
-      VARSTORE_ID_BOOT_MAINT,\r
-      (UINT16) (BOOT_OPTION_DEL_VAR_OFFSET + Index),\r
-      NewMenuEntry->DisplayStringToken,\r
-      NewMenuEntry->HelpStringToken,\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      0,\r
-      NULL\r
-      );\r
-  }\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Create a lit of driver option from global DriverMenu.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateDrvAddHandlePage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY *NewMenuEntry;\r
-  UINT16        Index;\r
-\r
-  CallbackData->BmmAskSaveOrNot = FALSE;\r
-\r
-  UpdatePageStart (CallbackData);\r
-\r
-  for (Index = 0; Index < DriverMenu.MenuNumber; Index++) {\r
-    NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index);\r
-\r
-    HiiCreateGotoOpCode (\r
-      mStartOpCodeHandle,\r
-      FORM_DRV_ADD_HANDLE_DESC_ID,\r
-      NewMenuEntry->DisplayStringToken,\r
-      STRING_TOKEN (STR_NULL_STRING),\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      (UINT16) (HANDLE_OPTION_OFFSET + Index)\r
-      );\r
-  }\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Create a lit of driver option from global DriverOptionMenu. It\r
-  allow user to delete the driver option.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateDrvDelPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT *NewLoadContext;\r
-  UINT16          Index;\r
-\r
-  CallbackData->BmmAskSaveOrNot = TRUE;\r
-\r
-  UpdatePageStart (CallbackData);\r
-\r
-  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &DriverOptionMenu);\r
-\r
-  ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.DriverOptionDel) / sizeof (CallbackData->BmmFakeNvData.DriverOptionDel[0])));\r
-  for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
-    NewMenuEntry            = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
-\r
-    NewLoadContext          = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-    NewLoadContext->Deleted = FALSE;\r
-\r
-    if (CallbackData->BmmFakeNvData.DriverOptionDel[Index] && !CallbackData->BmmFakeNvData.DriverOptionDelMark[Index]) {\r
-      //\r
-      // CallbackData->BmmFakeNvData.BootOptionDel[Index] == TRUE means browser knows this boot option is selected\r
-      // CallbackData->BmmFakeNvData.BootOptionDelMark[Index] = FALSE means BDS knows the selected boot option has\r
-      // deleted, browser maintains old useless info. So clear this info here, and later update this info to browser\r
-      // through HiiSetBrowserData function.\r
-      //\r
-      CallbackData->BmmFakeNvData.DriverOptionDel[Index] = FALSE;\r
-    }\r
-\r
-    HiiCreateCheckBoxOpCode (\r
-      mStartOpCodeHandle,\r
-      (EFI_QUESTION_ID) (DRIVER_OPTION_DEL_QUESTION_ID + Index),\r
-      VARSTORE_ID_BOOT_MAINT,\r
-      (UINT16) (DRIVER_OPTION_DEL_VAR_OFFSET + Index),\r
-      NewMenuEntry->DisplayStringToken,\r
-      NewMenuEntry->HelpStringToken,\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      0,\r
-      NULL\r
-      );\r
-  }\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Prepare the page to allow user to add description for\r
-  a Driver Option.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateDriverAddHandleDescPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY *NewMenuEntry;\r
-\r
-  CallbackData->BmmFakeNvData.DriverAddActive          = 0x01;\r
-  CallbackData->BmmFakeNvData.DriverAddForceReconnect  = 0x00;\r
-  CallbackData->BmmAskSaveOrNot                        = TRUE;\r
-  NewMenuEntry = CallbackData->MenuEntry;\r
-\r
-  UpdatePageStart (CallbackData);\r
-\r
-  HiiCreateSubTitleOpCode (\r
-    mStartOpCodeHandle,\r
-    NewMenuEntry->DisplayStringToken,\r
-    0,\r
-    0,\r
-    0\r
-    );\r
-\r
-  HiiCreateStringOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) DRV_ADD_HANDLE_DESC_QUESTION_ID,\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    DRV_ADD_HANDLE_DESC_VAR_OFFSET,\r
-    STRING_TOKEN (STR_LOAD_OPTION_DESC),\r
-    STRING_TOKEN (STR_NULL_STRING),\r
-    0,\r
-    0,\r
-    6,\r
-    75,\r
-    NULL\r
-    );\r
-\r
-  HiiCreateCheckBoxOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) DRV_ADD_RECON_QUESTION_ID,\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    DRV_ADD_RECON_VAR_OFFSET,\r
-    STRING_TOKEN (STR_LOAD_OPTION_FORCE_RECON),\r
-    STRING_TOKEN (STR_LOAD_OPTION_FORCE_RECON),\r
-    0,\r
-    0,\r
-    NULL\r
-    );\r
-\r
-  HiiCreateStringOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) DRIVER_ADD_OPTION_QUESTION_ID,\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    DRIVER_ADD_OPTION_VAR_OFFSET,\r
-    STRING_TOKEN (STR_OPTIONAL_DATA),\r
-    STRING_TOKEN (STR_NULL_STRING),\r
-    0,\r
-    0,\r
-    6,\r
-    75,\r
-    NULL\r
-    );\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Update console page.\r
-\r
-  @param UpdatePageId    The form ID to be updated.\r
-  @param ConsoleMenu     The console menu list.\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateConsolePage (\r
-  IN UINT16                           UpdatePageId,\r
-  IN BM_MENU_OPTION                   *ConsoleMenu,\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY       *NewMenuEntry;\r
-  UINT16              Index;\r
-  UINT8               CheckFlags;\r
-  UINT8               *ConsoleCheck;\r
-  EFI_QUESTION_ID     QuestionIdBase;\r
-  UINT16              VariableOffsetBase;\r
-\r
-  UpdatePageStart (CallbackData);\r
-\r
-  ConsoleCheck       = NULL;\r
-  QuestionIdBase     = 0;\r
-  VariableOffsetBase = 0;\r
-\r
-  switch (UpdatePageId) {\r
-  case FORM_CON_IN_ID:\r
-    ConsoleCheck       = &CallbackData->BmmFakeNvData.ConsoleInCheck[0];\r
-    QuestionIdBase     = CON_IN_DEVICE_QUESTION_ID;\r
-    VariableOffsetBase = CON_IN_DEVICE_VAR_OFFSET;\r
-    break;\r
-\r
-  case FORM_CON_OUT_ID:\r
-    ConsoleCheck       = &CallbackData->BmmFakeNvData.ConsoleOutCheck[0];\r
-    QuestionIdBase     = CON_OUT_DEVICE_QUESTION_ID;\r
-    VariableOffsetBase = CON_OUT_DEVICE_VAR_OFFSET;\r
-    break;\r
-\r
-  case FORM_CON_ERR_ID:\r
-    ConsoleCheck       = &CallbackData->BmmFakeNvData.ConsoleErrCheck[0];\r
-    QuestionIdBase     = CON_ERR_DEVICE_QUESTION_ID;\r
-    VariableOffsetBase = CON_ERR_DEVICE_VAR_OFFSET;\r
-    break;\r
-  }\r
-  ASSERT (ConsoleCheck != NULL);\r
-\r
-  for (Index = 0; ((Index < ConsoleMenu->MenuNumber) && \\r
-       (Index < MAX_MENU_NUMBER)) ; Index++) {\r
-    CheckFlags = 0;\r
-    if (UpdatePageId != FORM_CON_ERR_ID) {\r
-      CheckFlags |= EFI_IFR_CHECKBOX_DEFAULT;\r
-    }\r
-    NewMenuEntry = BOpt_GetMenuEntry (ConsoleMenu, Index);\r
-    HiiCreateCheckBoxOpCode (\r
-      mStartOpCodeHandle,\r
-      (EFI_QUESTION_ID) (QuestionIdBase + Index),\r
-      VARSTORE_ID_BOOT_MAINT,\r
-      (UINT16) (VariableOffsetBase + Index),\r
-      NewMenuEntry->DisplayStringToken,\r
-      NewMenuEntry->HelpStringToken,\r
-      0,\r
-      CheckFlags,\r
-      NULL\r
-      );\r
-  }\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Update the page's NV Map if user has changed the order\r
-  a list. This list can be Boot Order or Driver Order.\r
-\r
-  @param UpdatePageId    The form ID to be updated.\r
-  @param OptionMenu      The new list.\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateOrderPage (\r
-  IN UINT16                           UpdatePageId,\r
-  IN BM_MENU_OPTION                   *OptionMenu,\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY     *NewMenuEntry;\r
-  UINT16            Index;\r
-  UINT16            OptionIndex;\r
-  VOID              *OptionsOpCodeHandle;\r
-  BOOLEAN           BootOptionFound;\r
-  UINT32            *OptionOrder;\r
-  EFI_QUESTION_ID   QuestionId;\r
-  UINT16            VarOffset;\r
-\r
-\r
-  UpdatePageStart (CallbackData);\r
-\r
-  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, OptionMenu);\r
-\r
-  OptionOrder = NULL;\r
-  QuestionId = 0;\r
-  VarOffset = 0;\r
-  switch (UpdatePageId) {\r
-\r
-  case FORM_BOOT_CHG_ID:\r
-    //\r
-    // If the BootOptionOrder in the BmmFakeNvData are same with the date in the BmmOldFakeNVData,\r
-    // means all Boot Options has been save in BootOptionMenu, we can get the date from the menu.\r
-    // else means browser maintains some uncommitted date which are not saved in BootOptionMenu,\r
-    // so we should not get the data from BootOptionMenu to show it.\r
-    //\r
-    if (CompareMem (CallbackData->BmmFakeNvData.BootOptionOrder, CallbackData->BmmOldFakeNVData.BootOptionOrder, sizeof (CallbackData->BmmFakeNvData.BootOptionOrder)) == 0) {\r
-      GetBootOrder (CallbackData);\r
-    }\r
-    OptionOrder = CallbackData->BmmFakeNvData.BootOptionOrder;\r
-    QuestionId = BOOT_OPTION_ORDER_QUESTION_ID;\r
-    VarOffset = BOOT_OPTION_ORDER_VAR_OFFSET;\r
-    break;\r
-\r
-  case FORM_DRV_CHG_ID:\r
-    //\r
-    // If the DriverOptionOrder in the BmmFakeNvData are same with the date in the BmmOldFakeNVData,\r
-    // means all Driver Options has been save in DriverOptionMenu, we can get the DriverOptionOrder from the menu.\r
-    // else means browser maintains some uncommitted date which are not saved in DriverOptionMenu,\r
-    // so we should not get the data from DriverOptionMenu to show it.\r
-    //\r
-    if (CompareMem (CallbackData->BmmFakeNvData.DriverOptionOrder, CallbackData->BmmOldFakeNVData.DriverOptionOrder, sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder)) == 0) {\r
-      GetDriverOrder (CallbackData);\r
-    }\r
-    OptionOrder = CallbackData->BmmFakeNvData.DriverOptionOrder;\r
-    QuestionId = DRIVER_OPTION_ORDER_QUESTION_ID;\r
-    VarOffset = DRIVER_OPTION_ORDER_VAR_OFFSET;\r
-    break;\r
-  }\r
-  ASSERT (OptionOrder != NULL);\r
-\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-  NewMenuEntry = NULL;\r
-  for (OptionIndex = 0; (OptionIndex < MAX_MENU_NUMBER && OptionOrder[OptionIndex] != 0); OptionIndex++) {\r
-    BootOptionFound = FALSE;\r
-    for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
-      NewMenuEntry   = BOpt_GetMenuEntry (OptionMenu, Index);\r
-      if ((UINT32) (NewMenuEntry->OptionNumber + 1) == OptionOrder[OptionIndex]) {\r
-        BootOptionFound = TRUE;\r
-        break;\r
-      }\r
-    }\r
-    if (BootOptionFound) {\r
-      HiiCreateOneOfOptionOpCode (\r
-        OptionsOpCodeHandle,\r
-        NewMenuEntry->DisplayStringToken,\r
-        0,\r
-        EFI_IFR_TYPE_NUM_SIZE_32,\r
-        OptionOrder[OptionIndex]\r
-        );\r
-    }\r
-  }\r
-\r
-  if (OptionMenu->MenuNumber > 0) {\r
-    HiiCreateOrderedListOpCode (\r
-      mStartOpCodeHandle,                          // Container for dynamic created opcodes\r
-      QuestionId,                                  // Question ID\r
-      VARSTORE_ID_BOOT_MAINT,                      // VarStore ID\r
-      VarOffset,                                   // Offset in Buffer Storage\r
-      STRING_TOKEN (STR_CHANGE_ORDER),             // Question prompt text\r
-      STRING_TOKEN (STR_CHANGE_ORDER),             // Question help text\r
-      0,                                           // Question flag\r
-      0,                                           // Ordered list flag, e.g. EFI_IFR_UNIQUE_SET\r
-      EFI_IFR_TYPE_NUM_SIZE_32,                    // Data type of Question value\r
-      100,                                         // Maximum container\r
-      OptionsOpCodeHandle,                         // Option Opcode list\r
-      NULL                                         // Default Opcode is NULL\r
-      );\r
-  }\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Create the dynamic page to allow user to set\r
-  the "BootNext" value.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateBootNextPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT *NewLoadContext;\r
-  UINTN           NumberOfOptions;\r
-  UINT16          Index;\r
-  VOID            *OptionsOpCodeHandle;\r
-\r
-  NumberOfOptions               = BootOptionMenu.MenuNumber;\r
-  CallbackData->BmmAskSaveOrNot = TRUE;\r
-\r
-  UpdatePageStart (CallbackData);\r
-  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &BootOptionMenu);\r
-\r
-  if (NumberOfOptions > 0) {\r
-    OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-    ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-    //CallbackData->BmmFakeNvData.BootNext = (UINT16) (BootOptionMenu.MenuNumber);\r
-\r
-    for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
-      NewMenuEntry    = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
-      NewLoadContext  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-\r
-      if (NewLoadContext->IsBootNext) {\r
-        HiiCreateOneOfOptionOpCode (\r
-          OptionsOpCodeHandle,\r
-          NewMenuEntry->DisplayStringToken,\r
-          EFI_IFR_OPTION_DEFAULT,\r
-          EFI_IFR_TYPE_NUM_SIZE_16,\r
-          Index\r
-          );\r
-        //CallbackData->BmmFakeNvData.BootNext = Index;\r
-      } else {\r
-        HiiCreateOneOfOptionOpCode (\r
-          OptionsOpCodeHandle,\r
-          NewMenuEntry->DisplayStringToken,\r
-          0,\r
-          EFI_IFR_TYPE_NUM_SIZE_16,\r
-          Index\r
-          );\r
-      }\r
-    }\r
-\r
-    if (CallbackData->BmmFakeNvData.BootNext == Index) {\r
-      HiiCreateOneOfOptionOpCode (\r
-        OptionsOpCodeHandle,\r
-        STRING_TOKEN (STR_NONE),\r
-        EFI_IFR_OPTION_DEFAULT,\r
-        EFI_IFR_TYPE_NUM_SIZE_16,\r
-        Index\r
-        );\r
-    } else {\r
-      HiiCreateOneOfOptionOpCode (\r
-        OptionsOpCodeHandle,\r
-        STRING_TOKEN (STR_NONE),\r
-        0,\r
-        EFI_IFR_TYPE_NUM_SIZE_16,\r
-        Index\r
-        );\r
-    }\r
-\r
-    HiiCreateOneOfOpCode (\r
-      mStartOpCodeHandle,\r
-      (EFI_QUESTION_ID) BOOT_NEXT_QUESTION_ID,\r
-      VARSTORE_ID_BOOT_MAINT,\r
-      BOOT_NEXT_VAR_OFFSET,\r
-      STRING_TOKEN (STR_BOOT_NEXT),\r
-      STRING_TOKEN (STR_BOOT_NEXT_HELP),\r
-      0,\r
-      EFI_IFR_NUMERIC_SIZE_2,\r
-      OptionsOpCodeHandle,\r
-      NULL\r
-      );\r
-\r
-    HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-  }\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Create the dynamic page to allow user to set the "TimeOut" value.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateTimeOutPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  UINT16  BootTimeOut;\r
-  VOID    *DefaultOpCodeHandle;\r
-\r
-  CallbackData->BmmAskSaveOrNot = TRUE;\r
-\r
-  UpdatePageStart (CallbackData);\r
-\r
-  BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);\r
-\r
-  DefaultOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (DefaultOpCodeHandle != NULL);\r
-  HiiCreateDefaultOpCode (DefaultOpCodeHandle, EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_NUM_SIZE_16, BootTimeOut);\r
-\r
-  HiiCreateNumericOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) BOOT_TIME_OUT_QUESTION_ID,\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    BOOT_TIME_OUT_VAR_OFFSET,\r
-    STRING_TOKEN (STR_NUM_AUTO_BOOT),\r
-    STRING_TOKEN (STR_HLP_AUTO_BOOT),\r
-    0,\r
-    EFI_IFR_NUMERIC_SIZE_2 | EFI_IFR_DISPLAY_UINT_DEC,\r
-    0,\r
-    65535,\r
-    0,\r
-    DefaultOpCodeHandle\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (DefaultOpCodeHandle);\r
-\r
-  //CallbackData->BmmFakeNvData.BootTimeOut = BootTimeOut;\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Refresh the text mode page.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateConModePage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  UINTN                         Mode;\r
-  UINTN                         Index;\r
-  UINTN                         Col;\r
-  UINTN                         Row;\r
-  CHAR16                        ModeString[50];\r
-  CHAR16                        *PStr;\r
-  UINTN                         MaxMode;\r
-  UINTN                         ValidMode;\r
-  EFI_STRING_ID                 *ModeToken;\r
-  EFI_STATUS                    Status;\r
-  VOID                          *OptionsOpCodeHandle;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *ConOut;\r
-\r
-  ConOut    = gST->ConOut;\r
-  Index     = 0;\r
-  ValidMode = 0;\r
-  MaxMode   = (UINTN) (ConOut->Mode->MaxMode);\r
-\r
-  CallbackData->BmmAskSaveOrNot = TRUE;\r
-\r
-  UpdatePageStart (CallbackData);\r
-\r
-  //\r
-  // Check valid mode\r
-  //\r
-  for (Mode = 0; Mode < MaxMode; Mode++) {\r
-    Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-    ValidMode++;\r
-  }\r
-\r
-  if (ValidMode == 0) {\r
-    return;\r
-  }\r
-\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-  ModeToken           = AllocateZeroPool (sizeof (EFI_STRING_ID) * ValidMode);\r
-  ASSERT(ModeToken != NULL);\r
-\r
-  //\r
-  // Determin which mode should be the first entry in menu\r
-  //\r
-  // GetConsoleOutMode (CallbackData);\r
-\r
-  //\r
-  // Build text mode options\r
-  //\r
-  for (Mode = 0; Mode < MaxMode; Mode++) {\r
-    Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Build mode string Column x Row\r
-    //\r
-    UnicodeValueToStringS (ModeString, sizeof (ModeString), 0, Col, 0);\r
-    PStr = &ModeString[0];\r
-    StrCatS (PStr, ARRAY_SIZE (ModeString), L" x ");\r
-    PStr = PStr + StrLen (PStr);\r
-    UnicodeValueToStringS (\r
-      PStr,\r
-      sizeof (ModeString) - ((UINTN)PStr - (UINTN)&ModeString[0]),\r
-      0,\r
-      Row,\r
-      0\r
-      );\r
-\r
-    ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);\r
-\r
-    if (Mode == CallbackData->BmmFakeNvData.ConsoleOutMode) {\r
-      HiiCreateOneOfOptionOpCode (\r
-        OptionsOpCodeHandle,\r
-        ModeToken[Index],\r
-        EFI_IFR_OPTION_DEFAULT,\r
-        EFI_IFR_TYPE_NUM_SIZE_16,\r
-        (UINT16) Mode\r
-        );\r
-    } else {\r
-      HiiCreateOneOfOptionOpCode (\r
-        OptionsOpCodeHandle,\r
-        ModeToken[Index],\r
-        0,\r
-        EFI_IFR_TYPE_NUM_SIZE_16,\r
-        (UINT16) Mode\r
-        );\r
-    }\r
-    Index++;\r
-  }\r
-\r
-  HiiCreateOneOfOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) CON_MODE_QUESTION_ID,\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    CON_MODE_VAR_OFFSET,\r
-    STRING_TOKEN (STR_CON_MODE_SETUP),\r
-    STRING_TOKEN (STR_CON_MODE_SETUP),\r
-    EFI_IFR_FLAG_RESET_REQUIRED,\r
-    EFI_IFR_NUMERIC_SIZE_2,\r
-    OptionsOpCodeHandle,\r
-    NULL\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-  FreePool (ModeToken);\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,\r
-  Parity, Stop Bits, Terminal Type.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdateTerminalPage (\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  UINT8               Index;\r
-  UINT8               CheckFlags;\r
-  BM_MENU_ENTRY       *NewMenuEntry;\r
-  VOID                *OptionsOpCodeHandle;\r
-  UINTN               CurrentTerminal;\r
-\r
-  UpdatePageStart (CallbackData);\r
-\r
-  CurrentTerminal = CallbackData->CurrentTerminal;\r
-  NewMenuEntry = BOpt_GetMenuEntry (\r
-                  &TerminalMenu,\r
-                  CurrentTerminal\r
-                  );\r
-\r
-  if (NewMenuEntry == NULL) {\r
-    return ;\r
-  }\r
-\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-  for (Index = 0; Index < sizeof (BaudRateList) / sizeof (BaudRateList [0]); Index++) {\r
-    CheckFlags = 0;\r
-    if (BaudRateList[Index].Value == 115200) {\r
-      CheckFlags |= EFI_IFR_OPTION_DEFAULT;\r
-    }\r
-    HiiCreateOneOfOptionOpCode (\r
-      OptionsOpCodeHandle,\r
-      BaudRateList[Index].StringToken,\r
-      CheckFlags,\r
-      EFI_IFR_TYPE_NUM_SIZE_8,\r
-      Index\r
-      );\r
-  }\r
-\r
-  HiiCreateOneOfOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) (COM_BAUD_RATE_QUESTION_ID + CurrentTerminal),\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    (UINT16) (COM_BAUD_RATE_VAR_OFFSET + CurrentTerminal),\r
-    STRING_TOKEN (STR_COM_BAUD_RATE),\r
-    STRING_TOKEN (STR_COM_BAUD_RATE),\r
-    0,\r
-    EFI_IFR_NUMERIC_SIZE_1,\r
-    OptionsOpCodeHandle,\r
-    NULL\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-  for (Index = 0; Index < ARRAY_SIZE (DataBitsList); Index++) {\r
-    CheckFlags = 0;\r
-\r
-    if (DataBitsList[Index].Value == 8) {\r
-      CheckFlags |= EFI_IFR_OPTION_DEFAULT;\r
-    }\r
-\r
-    HiiCreateOneOfOptionOpCode (\r
-      OptionsOpCodeHandle,\r
-      DataBitsList[Index].StringToken,\r
-      CheckFlags,\r
-      EFI_IFR_TYPE_NUM_SIZE_8,\r
-      Index\r
-      );\r
-  }\r
-\r
-  HiiCreateOneOfOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) (COM_DATA_RATE_QUESTION_ID + CurrentTerminal),\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    (UINT16) (COM_DATA_RATE_VAR_OFFSET + CurrentTerminal),\r
-    STRING_TOKEN (STR_COM_DATA_BITS),\r
-    STRING_TOKEN (STR_COM_DATA_BITS),\r
-    0,\r
-    EFI_IFR_NUMERIC_SIZE_1,\r
-    OptionsOpCodeHandle,\r
-    NULL\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-  for (Index = 0; Index < ARRAY_SIZE (ParityList); Index++) {\r
-    CheckFlags = 0;\r
-    if (ParityList[Index].Value ==  NoParity) {\r
-      CheckFlags |= EFI_IFR_OPTION_DEFAULT;\r
-    }\r
-\r
-    HiiCreateOneOfOptionOpCode (\r
-      OptionsOpCodeHandle,\r
-      ParityList[Index].StringToken,\r
-      CheckFlags,\r
-      EFI_IFR_TYPE_NUM_SIZE_8,\r
-      Index\r
-      );\r
-  }\r
-\r
-  HiiCreateOneOfOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) (COM_PARITY_QUESTION_ID + CurrentTerminal),\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    (UINT16) (COM_PARITY_VAR_OFFSET + CurrentTerminal),\r
-    STRING_TOKEN (STR_COM_PARITY),\r
-    STRING_TOKEN (STR_COM_PARITY),\r
-    0,\r
-    EFI_IFR_NUMERIC_SIZE_1,\r
-    OptionsOpCodeHandle,\r
-    NULL\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-  for (Index = 0; Index < ARRAY_SIZE (StopBitsList); Index++) {\r
-    CheckFlags = 0;\r
-    if (StopBitsList[Index].Value == OneStopBit) {\r
-      CheckFlags |= EFI_IFR_OPTION_DEFAULT;\r
-    }\r
-\r
-    HiiCreateOneOfOptionOpCode (\r
-      OptionsOpCodeHandle,\r
-      StopBitsList[Index].StringToken,\r
-      CheckFlags,\r
-      EFI_IFR_TYPE_NUM_SIZE_8,\r
-      Index\r
-      );\r
-  }\r
-\r
-  HiiCreateOneOfOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) (COM_STOP_BITS_QUESTION_ID + CurrentTerminal),\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    (UINT16) (COM_STOP_BITS_VAR_OFFSET + CurrentTerminal),\r
-    STRING_TOKEN (STR_COM_STOP_BITS),\r
-    STRING_TOKEN (STR_COM_STOP_BITS),\r
-    0,\r
-    EFI_IFR_NUMERIC_SIZE_1,\r
-    OptionsOpCodeHandle,\r
-    NULL\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-  for (Index = 0; Index < 4; Index++) {\r
-    CheckFlags = 0;\r
-    if (Index == 0) {\r
-      CheckFlags |= EFI_IFR_OPTION_DEFAULT;\r
-    }\r
-\r
-    HiiCreateOneOfOptionOpCode (\r
-      OptionsOpCodeHandle,\r
-      (EFI_STRING_ID) TerminalType[Index],\r
-      CheckFlags,\r
-      EFI_IFR_TYPE_NUM_SIZE_8,\r
-      Index\r
-      );\r
-  }\r
-\r
-  HiiCreateOneOfOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) (COM_TERMINAL_QUESTION_ID + CurrentTerminal),\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    (UINT16) (COM_TERMINAL_VAR_OFFSET + CurrentTerminal),\r
-    STRING_TOKEN (STR_COM_TERMI_TYPE),\r
-    STRING_TOKEN (STR_COM_TERMI_TYPE),\r
-    0,\r
-    EFI_IFR_NUMERIC_SIZE_1,\r
-    OptionsOpCodeHandle,\r
-    NULL\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-  for (Index = 0; Index < ARRAY_SIZE (mFlowControlType); Index++) {\r
-  CheckFlags = 0;\r
-    if (Index == 0) {\r
-      CheckFlags |= EFI_IFR_OPTION_DEFAULT;\r
-    }\r
-    HiiCreateOneOfOptionOpCode (\r
-      OptionsOpCodeHandle,\r
-      (EFI_STRING_ID) mFlowControlType[Index],\r
-      CheckFlags,\r
-      EFI_IFR_TYPE_NUM_SIZE_8,\r
-      mFlowControlValue[Index]\r
-      );\r
-  }\r
-\r
-  HiiCreateOneOfOpCode (\r
-    mStartOpCodeHandle,\r
-    (EFI_QUESTION_ID) (COM_FLOWCONTROL_QUESTION_ID + CurrentTerminal),\r
-    VARSTORE_ID_BOOT_MAINT,\r
-    (UINT16) (COM_FLOWCONTROL_VAR_OFFSET + CurrentTerminal),\r
-    STRING_TOKEN (STR_COM_FLOW_CONTROL),\r
-    STRING_TOKEN (STR_COM_FLOW_CONTROL),\r
-    0,\r
-    EFI_IFR_NUMERIC_SIZE_1,\r
-    OptionsOpCodeHandle,\r
-    NULL\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-/**\r
-  Dispatch the correct update page function to call based on\r
-  the UpdatePageId.\r
-\r
-  @param UpdatePageId    The form ID.\r
-  @param CallbackData    The BMM context data.\r
-\r
-**/\r
-VOID\r
-UpdatePageBody (\r
-  IN UINT16                           UpdatePageId,\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  CleanUpPage (UpdatePageId, CallbackData);\r
-  switch (UpdatePageId) {\r
-  case FORM_CON_IN_ID:\r
-    UpdateConsolePage (UpdatePageId, &ConsoleInpMenu, CallbackData);\r
-    break;\r
-\r
-  case FORM_CON_OUT_ID:\r
-    UpdateConsolePage (UpdatePageId, &ConsoleOutMenu, CallbackData);\r
-    break;\r
-\r
-  case FORM_CON_ERR_ID:\r
-    UpdateConsolePage (UpdatePageId, &ConsoleErrMenu, CallbackData);\r
-    break;\r
-\r
-  case FORM_BOOT_CHG_ID:\r
-    UpdateOrderPage (UpdatePageId, &BootOptionMenu, CallbackData);\r
-    break;\r
-\r
-  case FORM_DRV_CHG_ID:\r
-    UpdateOrderPage (UpdatePageId, &DriverOptionMenu, CallbackData);\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-}\r
-\r
-/**\r
-  Create a dynamic page so that Legacy Device boot order\r
-  can be set for specified device type.\r
-\r
-  @param UpdatePageId    The form ID. It also spefies the legacy device type.\r
-  @param CallbackData    The BMM context data.\r
-\r
-\r
-**/\r
-VOID\r
-UpdateSetLegacyDeviceOrderPage (\r
-  IN UINT16                           UpdatePageId,\r
-  IN BMM_CALLBACK_DATA                *CallbackData\r
-  )\r
-{\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  BM_MENU_OPTION              *OptionMenu;\r
-  BM_MENU_ENTRY               *NewMenuEntry;\r
-  EFI_STRING_ID               StrRef;\r
-  EFI_STRING_ID               StrRefHelp;\r
-  BBS_TYPE                    BbsType;\r
-  UINTN                       VarSize;\r
-  UINTN                       Pos;\r
-  UINTN                       Bit;\r
-  UINT16                      Index;\r
-  UINT16                      Key;\r
-  CHAR16                      String[100];\r
-  CHAR16                      *TypeStr;\r
-  CHAR16                      *TypeStrHelp;\r
-  UINT16                      VarDevOrder;\r
-  UINT8                       *VarData;\r
-  UINT8                       *LegacyOrder;\r
-  UINT8                       *OldData;\r
-  UINT8                       *DisMap;\r
-  VOID                        *OptionsOpCodeHandle;\r
-\r
-  OptionMenu = NULL;\r
-  Key = 0;\r
-  StrRef = 0;\r
-  StrRefHelp = 0;\r
-  TypeStr = NULL;\r
-  TypeStrHelp = NULL;\r
-  BbsType = BBS_FLOPPY;\r
-  LegacyOrder = NULL;\r
-  OldData = NULL;\r
-  DisMap = NULL;\r
-\r
-  CallbackData->BmmAskSaveOrNot = TRUE;\r
-  UpdatePageStart (CallbackData);\r
-\r
-  DisMap = ZeroMem (CallbackData->BmmOldFakeNVData.DisableMap, sizeof (CallbackData->BmmOldFakeNVData.DisableMap));\r
-\r
-  //\r
-  // Create oneof option list\r
-  //\r
-  switch (UpdatePageId) {\r
-  case FORM_SET_FD_ORDER_ID:\r
-    OptionMenu  = (BM_MENU_OPTION *) &LegacyFDMenu;\r
-    Key         = (UINT16) LEGACY_FD_QUESTION_ID;\r
-    TypeStr     = STR_FLOPPY;\r
-    TypeStrHelp = STR_FLOPPY_HELP;\r
-    BbsType     = BBS_FLOPPY;\r
-    LegacyOrder = CallbackData->BmmFakeNvData.LegacyFD;\r
-    OldData     = CallbackData->BmmOldFakeNVData.LegacyFD;\r
-    break;\r
-\r
-  case FORM_SET_HD_ORDER_ID:\r
-    OptionMenu  = (BM_MENU_OPTION *) &LegacyHDMenu;\r
-    Key         = (UINT16) LEGACY_HD_QUESTION_ID;\r
-    TypeStr     = STR_HARDDISK;\r
-    TypeStrHelp = STR_HARDDISK_HELP;\r
-    BbsType     = BBS_HARDDISK;\r
-    LegacyOrder = CallbackData->BmmFakeNvData.LegacyHD;\r
-    OldData     = CallbackData->BmmOldFakeNVData.LegacyHD;\r
-    break;\r
-\r
-  case FORM_SET_CD_ORDER_ID:\r
-    OptionMenu  = (BM_MENU_OPTION *) &LegacyCDMenu;\r
-    Key         = (UINT16) LEGACY_CD_QUESTION_ID;\r
-    TypeStr     = STR_CDROM;\r
-    TypeStrHelp = STR_CDROM_HELP;\r
-    BbsType     = BBS_CDROM;\r
-    LegacyOrder = CallbackData->BmmFakeNvData.LegacyCD;\r
-    OldData     = CallbackData->BmmOldFakeNVData.LegacyCD;\r
-    break;\r
-\r
-  case FORM_SET_NET_ORDER_ID:\r
-    OptionMenu  = (BM_MENU_OPTION *) &LegacyNETMenu;\r
-    Key         = (UINT16) LEGACY_NET_QUESTION_ID;\r
-    TypeStr     = STR_NET;\r
-    TypeStrHelp = STR_NET_HELP;\r
-    BbsType     = BBS_EMBED_NETWORK;\r
-    LegacyOrder = CallbackData->BmmFakeNvData.LegacyNET;\r
-    OldData     = CallbackData->BmmOldFakeNVData.LegacyNET;\r
-    break;\r
-\r
-  case FORM_SET_BEV_ORDER_ID:\r
-    OptionMenu  = (BM_MENU_OPTION *) &LegacyBEVMenu;\r
-    Key         = (UINT16) LEGACY_BEV_QUESTION_ID;\r
-    TypeStr     = STR_BEV;\r
-    TypeStrHelp = STR_BEV_HELP;\r
-    BbsType     = BBS_BEV_DEVICE;\r
-    LegacyOrder = CallbackData->BmmFakeNvData.LegacyBEV;\r
-    OldData     = CallbackData->BmmOldFakeNVData.LegacyBEV;\r
-    break;\r
-\r
-  default:\r
-    DEBUG ((EFI_D_ERROR, "Invalid command ID for updating page!\n"));\r
-    return;\r
-  }\r
-\r
-  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, OptionMenu);\r
-\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
-  for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
-    NewMenuEntry                = BOpt_GetMenuEntry (OptionMenu, Index);\r
-    //\r
-    // Create OneOf for each legacy device\r
-    //\r
-    HiiCreateOneOfOptionOpCode (\r
-      OptionsOpCodeHandle,\r
-      NewMenuEntry->DisplayStringToken,\r
-      0,\r
-      EFI_IFR_TYPE_NUM_SIZE_8,\r
-      (UINT8) ((BM_LEGACY_DEVICE_CONTEXT *) NewMenuEntry->VariableContext)->BbsIndex\r
-      );\r
-  }\r
-\r
-  //\r
-  // Create OneOf for item "Disabled"\r
-  //\r
-  HiiCreateOneOfOptionOpCode (\r
-    OptionsOpCodeHandle,\r
-    STRING_TOKEN (STR_DISABLE_LEGACY_DEVICE),\r
-    0,\r
-    EFI_IFR_TYPE_NUM_SIZE_8,\r
-    0xFF\r
-    );\r
-\r
-  //\r
-  // Get Device Order from variable\r
-  //\r
-  VarData = BdsLibGetVariableAndSize (\r
-              VAR_LEGACY_DEV_ORDER,\r
-              &gEfiLegacyDevOrderVariableGuid,\r
-              &VarSize\r
-              );\r
-\r
-  if (NULL != VarData) {\r
-    DevOrder    = (LEGACY_DEV_ORDER_ENTRY *) VarData;\r
-    while (VarData < VarData + VarSize) {\r
-      if (DevOrder->BbsType == BbsType) {\r
-        break;\r
-      }\r
-\r
-      VarData  = (UINT8 *)((UINTN)VarData + sizeof (BBS_TYPE));\r
-      VarData += *(UINT16 *) VarData;\r
-      DevOrder = (LEGACY_DEV_ORDER_ENTRY *) VarData;\r
-    }\r
-    //\r
-    // Create oneof tag here for FD/HD/CD #1 #2\r
-    //\r
-    for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
-      //\r
-      // Create the string for oneof tag\r
-      //\r
-      UnicodeSPrint (String, sizeof (String), TypeStr, Index);\r
-      StrRef = HiiSetString (CallbackData->BmmHiiHandle, 0, String, NULL);\r
-\r
-      UnicodeSPrint (String, sizeof (String), TypeStrHelp, Index);\r
-      StrRefHelp = HiiSetString (CallbackData->BmmHiiHandle, 0, String, NULL);\r
-\r
-      HiiCreateOneOfOpCode (\r
-        mStartOpCodeHandle,\r
-        (EFI_QUESTION_ID) (Key + Index),\r
-        VARSTORE_ID_BOOT_MAINT,\r
-        (UINT16) (Key + Index - CONFIG_OPTION_OFFSET),\r
-        StrRef,\r
-        StrRefHelp,\r
-        EFI_IFR_FLAG_CALLBACK,\r
-        EFI_IFR_NUMERIC_SIZE_1,\r
-        OptionsOpCodeHandle,\r
-        NULL\r
-        );\r
-\r
-      VarDevOrder = *(UINT16 *) ((UINTN) DevOrder + sizeof (BBS_TYPE) + sizeof (UINT16) + Index * sizeof (UINT16));\r
-\r
-      if (0xFF00 == (VarDevOrder & 0xFF00)) {\r
-        LegacyOrder[Index]  = 0xFF;\r
-        Pos                 = (VarDevOrder & 0xFF) / 8;\r
-        Bit                 = 7 - ((VarDevOrder & 0xFF) % 8);\r
-        DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit));\r
-      } else {\r
-        LegacyOrder[Index] = (UINT8) (VarDevOrder & 0xFF);\r
-      }\r
-    }\r
-  }\r
-\r
-  CopyMem (OldData, LegacyOrder, 100);\r
-\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-\r
-  UpdatePageEnd (CallbackData);\r
-}\r
-\r
-\r
-/**\r
-  Dispatch the display to the next page based on NewPageId.\r
-\r
-  @param Private         The BMM context data.\r
-  @param NewPageId       The original page ID.\r
-\r
-**/\r
-VOID\r
-UpdatePageId (\r
-  BMM_CALLBACK_DATA              *Private,\r
-  UINT16                         NewPageId\r
-  )\r
-{\r
-  //\r
-  // For the question don't impact the page update, just ignore it.\r
-  //\r
-  if (((NewPageId >= BOOT_OPTION_DEL_QUESTION_ID) && (NewPageId < BOOT_OPTION_DEL_QUESTION_ID + MAX_MENU_NUMBER)) ||\r
-      ((NewPageId >= DRIVER_OPTION_DEL_QUESTION_ID) && (NewPageId < DRIVER_OPTION_DEL_QUESTION_ID + MAX_MENU_NUMBER))) {\r
-    return;\r
-  }\r
-\r
-  if ((NewPageId < FILE_OPTION_OFFSET) && (NewPageId >= HANDLE_OPTION_OFFSET)) {\r
-    //\r
-    // If we select a handle to add driver option, advance to the add handle description page.\r
-    //\r
-    NewPageId = FORM_DRV_ADD_HANDLE_DESC_ID;\r
-  } else if ((NewPageId == KEY_VALUE_SAVE_AND_EXIT) || (NewPageId == KEY_VALUE_NO_SAVE_AND_EXIT)) {\r
-    //\r
-    // Return to main page after "Save Changes" or "Discard Changes".\r
-    //\r
-    NewPageId = FORM_MAIN_ID;\r
-  } else if ((NewPageId >= TERMINAL_OPTION_OFFSET) && (NewPageId < CONSOLE_OPTION_OFFSET)) {\r
-    NewPageId = FORM_CON_COM_SETUP_ID;\r
-  }\r
-\r
-  if ((NewPageId > 0) && (NewPageId < MAXIMUM_FORM_ID)) {\r
-    Private->BmmPreviousPageId  = Private->BmmCurrentPageId;\r
-    Private->BmmCurrentPageId   = NewPageId;\r
-  }\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
deleted file mode 100644 (file)
index 3220c28..0000000
+++ /dev/null
@@ -1,1311 +0,0 @@
-/** @file\r
-  Variable operation that will be used by bootmaint\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BootMaint.h"\r
-\r
-/**\r
-  Delete Boot Option that represent a Deleted state in BootOptionMenu.\r
-  After deleting this boot option, call Var_ChangeBootOrder to\r
-  make sure BootOrder is in valid state.\r
-\r
-  @retval EFI_SUCCESS   If all boot load option EFI Variables corresponding to\r
-                        BM_LOAD_CONTEXT marked for deletion is deleted.\r
-  @retval EFI_NOT_FOUND If can not find the boot option want to be deleted.\r
-  @return Others        If failed to update the "BootOrder" variable after deletion.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_DelBootOption (\r
-  VOID\r
-  )\r
-{\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT *NewLoadContext;\r
-  UINT16          BootString[10];\r
-  EFI_STATUS      Status;\r
-  UINTN           Index;\r
-  UINTN           Index2;\r
-\r
-  Status  = EFI_SUCCESS;\r
-  Index2  = 0;\r
-  for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
-    NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, (Index - Index2));\r
-    if (NULL == NewMenuEntry) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-    if (!NewLoadContext->Deleted) {\r
-      continue;\r
-    }\r
-\r
-    UnicodeSPrint (\r
-      BootString,\r
-      sizeof (BootString),\r
-      L"Boot%04x",\r
-      NewMenuEntry->OptionNumber\r
-      );\r
-\r
-    EfiLibDeleteVariable (BootString, &gEfiGlobalVariableGuid);\r
-    Index2++;\r
-    //\r
-    // If current Load Option is the same as BootNext,\r
-    // must delete BootNext in order to make sure\r
-    // there will be no panic on next boot\r
-    //\r
-    if (NewLoadContext->IsBootNext) {\r
-      EfiLibDeleteVariable (L"BootNext", &gEfiGlobalVariableGuid);\r
-    }\r
-\r
-    RemoveEntryList (&NewMenuEntry->Link);\r
-    BOpt_DestroyMenuEntry (NewMenuEntry);\r
-    NewMenuEntry = NULL;\r
-  }\r
-\r
-  BootOptionMenu.MenuNumber -= Index2;\r
-\r
-  Status = Var_ChangeBootOrder ();\r
-  return Status;\r
-}\r
-\r
-/**\r
-  After any operation on Boot####, there will be a discrepancy in BootOrder.\r
-  Since some are missing but in BootOrder, while some are present but are\r
-  not reflected by BootOrder. Then a function rebuild BootOrder from\r
-  scratch by content from BootOptionMenu is needed.\r
-\r
-\r
-\r
-\r
-  @retval  EFI_SUCCESS  The boot order is updated successfully.\r
-  @return               EFI_STATUS other than EFI_SUCCESS if failed to\r
-                        Set the "BootOrder" EFI Variable.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_ChangeBootOrder (\r
-  VOID\r
-  )\r
-{\r
-\r
-  EFI_STATUS    Status;\r
-  BM_MENU_ENTRY *NewMenuEntry;\r
-  UINT16        *BootOrderList;\r
-  UINT16        *BootOrderListPtr;\r
-  UINTN         BootOrderListSize;\r
-  UINTN         Index;\r
-\r
-  BootOrderList     = NULL;\r
-  BootOrderListSize = 0;\r
-\r
-  //\r
-  // First check whether BootOrder is present in current configuration\r
-  //\r
-  BootOrderList = BdsLibGetVariableAndSize (\r
-                    L"BootOrder",\r
-                    &gEfiGlobalVariableGuid,\r
-                    &BootOrderListSize\r
-                    );\r
-\r
-  //\r
-  // If exists, delete it to hold new BootOrder\r
-  //\r
-  if (BootOrderList != NULL) {\r
-    EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);\r
-    FreePool (BootOrderList);\r
-    BootOrderList = NULL;\r
-  }\r
-  //\r
-  // Maybe here should be some check method to ensure that\r
-  // no new added boot options will be added\r
-  // but the setup engine now will give only one callback\r
-  // that is to say, user are granted only one chance to\r
-  // decide whether the boot option will be added or not\r
-  // there should be no indictor to show whether this\r
-  // is a "new" boot option\r
-  //\r
-  BootOrderListSize = BootOptionMenu.MenuNumber;\r
-\r
-  if (BootOrderListSize > 0) {\r
-    BootOrderList = AllocateZeroPool (BootOrderListSize * sizeof (UINT16));\r
-    ASSERT (BootOrderList != NULL);\r
-    BootOrderListPtr = BootOrderList;\r
-\r
-    //\r
-    // Get all current used Boot#### from BootOptionMenu.\r
-    // OptionNumber in each BM_LOAD_OPTION is really its\r
-    // #### value.\r
-    //\r
-    for (Index = 0; Index < BootOrderListSize; Index++) {\r
-      NewMenuEntry    = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
-      *BootOrderList  = (UINT16) NewMenuEntry->OptionNumber;\r
-      BootOrderList++;\r
-    }\r
-\r
-    BootOrderList = BootOrderListPtr;\r
-\r
-    //\r
-    // After building the BootOrderList, write it back\r
-    //\r
-    Status = gRT->SetVariable (\r
-                    L"BootOrder",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    BootOrderListSize * sizeof (UINT16),\r
-                    BootOrderList\r
-                    );\r
-    //\r
-    // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Delete Load Option that represent a Deleted state in BootOptionMenu.\r
-  After deleting this Driver option, call Var_ChangeDriverOrder to\r
-  make sure DriverOrder is in valid state.\r
-\r
-  @retval EFI_SUCCESS       Load Option is successfully updated.\r
-  @retval EFI_NOT_FOUND     Fail to find the driver option want to be deleted.\r
-  @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI\r
-          Variable.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_DelDriverOption (\r
-  VOID\r
-  )\r
-{\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT *NewLoadContext;\r
-  UINT16          DriverString[12];\r
-  EFI_STATUS      Status;\r
-  UINTN           Index;\r
-  UINTN           Index2;\r
-\r
-  Status  = EFI_SUCCESS;\r
-  Index2  = 0;\r
-  for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
-    NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, (Index - Index2));\r
-    if (NULL == NewMenuEntry) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-    if (!NewLoadContext->Deleted) {\r
-      continue;\r
-    }\r
-\r
-    UnicodeSPrint (\r
-      DriverString,\r
-      sizeof (DriverString),\r
-      L"Driver%04x",\r
-      NewMenuEntry->OptionNumber\r
-      );\r
-\r
-    EfiLibDeleteVariable (DriverString, &gEfiGlobalVariableGuid);\r
-    Index2++;\r
-\r
-    RemoveEntryList (&NewMenuEntry->Link);\r
-    BOpt_DestroyMenuEntry (NewMenuEntry);\r
-    NewMenuEntry = NULL;\r
-  }\r
-\r
-  DriverOptionMenu.MenuNumber -= Index2;\r
-\r
-  Status = Var_ChangeDriverOrder ();\r
-  return Status;\r
-}\r
-\r
-/**\r
-  After any operation on Driver####, there will be a discrepancy in\r
-  DriverOrder. Since some are missing but in DriverOrder, while some\r
-  are present but are not reflected by DriverOrder. Then a function\r
-  rebuild DriverOrder from scratch by content from DriverOptionMenu is\r
-  needed.\r
-\r
-  @retval  EFI_SUCCESS  The driver order is updated successfully.\r
-  @return  Other status than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_ChangeDriverOrder (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  BM_MENU_ENTRY *NewMenuEntry;\r
-  UINT16        *DriverOrderList;\r
-  UINT16        *DriverOrderListPtr;\r
-  UINTN         DriverOrderListSize;\r
-  UINTN         Index;\r
-\r
-  DriverOrderList     = NULL;\r
-  DriverOrderListSize = 0;\r
-\r
-  //\r
-  // First check whether DriverOrder is present in current configuration\r
-  //\r
-  DriverOrderList = BdsLibGetVariableAndSize (\r
-                      L"DriverOrder",\r
-                      &gEfiGlobalVariableGuid,\r
-                      &DriverOrderListSize\r
-                      );\r
-\r
-  //\r
-  // If exists, delete it to hold new DriverOrder\r
-  //\r
-  if (DriverOrderList != NULL) {\r
-    EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
-    FreePool (DriverOrderList);\r
-    DriverOrderList = NULL;\r
-  }\r
-\r
-  DriverOrderListSize = DriverOptionMenu.MenuNumber;\r
-\r
-  if (DriverOrderListSize > 0) {\r
-    DriverOrderList = AllocateZeroPool (DriverOrderListSize * sizeof (UINT16));\r
-    ASSERT (DriverOrderList != NULL);\r
-    DriverOrderListPtr = DriverOrderList;\r
-\r
-    //\r
-    // Get all current used Driver#### from DriverOptionMenu.\r
-    // OptionNumber in each BM_LOAD_OPTION is really its\r
-    // #### value.\r
-    //\r
-    for (Index = 0; Index < DriverOrderListSize; Index++) {\r
-      NewMenuEntry      = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
-      *DriverOrderList  = (UINT16) NewMenuEntry->OptionNumber;\r
-      DriverOrderList++;\r
-    }\r
-\r
-    DriverOrderList = DriverOrderListPtr;\r
-\r
-    //\r
-    // After building the DriverOrderList, write it back\r
-    //\r
-    Status = gRT->SetVariable (\r
-                    L"DriverOrder",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    DriverOrderListSize * sizeof (UINT16),\r
-                    DriverOrderList\r
-                    );\r
-    //\r
-    // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-/**\r
-  This function delete and build multi-instance device path for\r
-  specified type of console device.\r
-\r
-  This function clear the EFI variable defined by ConsoleName and\r
-  gEfiGlobalVariableGuid. It then build the multi-instance device\r
-  path by appending the device path of the Console (In/Out/Err) instance\r
-  in ConsoleMenu. Then it scan all corresponding console device by\r
-  scanning Terminal (built from device supporting Serial I/O instances)\r
-  devices in TerminalMenu. At last, it save a EFI variable specifed\r
-  by ConsoleName and gEfiGlobalVariableGuid.\r
-\r
-  @param ConsoleName     The name for the console device type. They are\r
-                         usually "ConIn", "ConOut" and "ErrOut".\r
-  @param ConsoleMenu     The console memu which is a list of console devices.\r
-  @param UpdatePageId    The flag specifying which type of console device\r
-                         to be processed.\r
-\r
-  @retval EFI_SUCCESS    The function complete successfully.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateConsoleOption (\r
-  IN UINT16                     *ConsoleName,\r
-  IN BM_MENU_OPTION             *ConsoleMenu,\r
-  IN UINT16                     UpdatePageId\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *ConDevicePath;\r
-  BM_MENU_ENTRY             *NewMenuEntry;\r
-  BM_CONSOLE_CONTEXT        *NewConsoleContext;\r
-  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
-  EFI_STATUS                Status;\r
-  VENDOR_DEVICE_PATH        Vendor;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TerminalDevicePath;\r
-  UINTN                     Index;\r
-\r
-  ConDevicePath = EfiLibGetVariable (ConsoleName, &gEfiGlobalVariableGuid);\r
-  if (ConDevicePath != NULL) {\r
-    EfiLibDeleteVariable (ConsoleName, &gEfiGlobalVariableGuid);\r
-    FreePool (ConDevicePath);\r
-    ConDevicePath = NULL;\r
-  };\r
-\r
-  //\r
-  // First add all console input device from console input menu\r
-  //\r
-  for (Index = 0; Index < ConsoleMenu->MenuNumber; Index++) {\r
-    NewMenuEntry = BOpt_GetMenuEntry (ConsoleMenu, Index);\r
-\r
-    NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
-    if (NewConsoleContext->IsActive) {\r
-      ConDevicePath = AppendDevicePathInstance (\r
-                        ConDevicePath,\r
-                        NewConsoleContext->DevicePath\r
-                        );\r
-    }\r
-  }\r
-\r
-  for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
-    NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
-\r
-    NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
-    if (((NewTerminalContext->IsConIn != 0) && (UpdatePageId == FORM_CON_IN_ID)) ||\r
-        ((NewTerminalContext->IsConOut != 0)  && (UpdatePageId == FORM_CON_OUT_ID)) ||\r
-        ((NewTerminalContext->IsStdErr  != 0) && (UpdatePageId == FORM_CON_ERR_ID))\r
-        ) {\r
-      Vendor.Header.Type    = MESSAGING_DEVICE_PATH;\r
-      Vendor.Header.SubType = MSG_VENDOR_DP;\r
-\r
-      ASSERT (NewTerminalContext->TerminalType < (ARRAY_SIZE (TerminalTypeGuid)));\r
-      CopyMem (\r
-        &Vendor.Guid,\r
-        &TerminalTypeGuid[NewTerminalContext->TerminalType],\r
-        sizeof (EFI_GUID)\r
-        );\r
-      SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));\r
-      TerminalDevicePath = AppendDevicePathNode (\r
-                            NewTerminalContext->DevicePath,\r
-                            (EFI_DEVICE_PATH_PROTOCOL *) &Vendor\r
-                            );\r
-      ASSERT (TerminalDevicePath != NULL);\r
-      ChangeTerminalDevicePath (&TerminalDevicePath, TRUE);\r
-      ConDevicePath = AppendDevicePathInstance (\r
-                        ConDevicePath,\r
-                        TerminalDevicePath\r
-                        );\r
-    }\r
-  }\r
-\r
-  if (ConDevicePath != NULL) {\r
-    Status = gRT->SetVariable (\r
-                    ConsoleName,\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    GetDevicePathSize (ConDevicePath),\r
-                    ConDevicePath\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-/**\r
-  This function delete and build multi-instance device path ConIn\r
-  console device.\r
-\r
-  @retval EFI_SUCCESS    The function complete successfully.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-**/\r
-EFI_STATUS\r
-Var_UpdateConsoleInpOption (\r
-  VOID\r
-  )\r
-{\r
-  return Var_UpdateConsoleOption (L"ConIn", &ConsoleInpMenu, FORM_CON_IN_ID);\r
-}\r
-\r
-/**\r
-  This function delete and build multi-instance device path ConOut\r
-  console device.\r
-\r
-  @retval EFI_SUCCESS    The function complete successfully.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-**/\r
-EFI_STATUS\r
-Var_UpdateConsoleOutOption (\r
-  VOID\r
-  )\r
-{\r
-  return Var_UpdateConsoleOption (L"ConOut", &ConsoleOutMenu, FORM_CON_OUT_ID);\r
-}\r
-\r
-/**\r
-  This function delete and build multi-instance device path ErrOut\r
-  console device.\r
-\r
-  @retval EFI_SUCCESS    The function complete successfully.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-**/\r
-EFI_STATUS\r
-Var_UpdateErrorOutOption (\r
-  VOID\r
-  )\r
-{\r
-  return Var_UpdateConsoleOption (L"ErrOut", &ConsoleErrMenu, FORM_CON_ERR_ID);\r
-}\r
-\r
-/**\r
-  This function create a currently loaded Drive Option from\r
-  the BMM. It then appends this Driver Option to the end of\r
-  the "DriverOrder" list. It append this Driver Opotion to the end\r
-  of DriverOptionMenu.\r
-\r
-  @param CallbackData    The BMM context data.\r
-  @param HiiHandle       The HII handle associated with the BMM formset.\r
-  @param DescriptionData The description of this driver option.\r
-  @param OptionalData    The optional load option.\r
-  @param ForceReconnect  If to force reconnect.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.\r
-  @retval EFI_SUCCESS          If function completes successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateDriverOption (\r
-  IN  BMM_CALLBACK_DATA         *CallbackData,\r
-  IN  EFI_HII_HANDLE            HiiHandle,\r
-  IN  UINT16                    *DescriptionData,\r
-  IN  UINT16                    *OptionalData,\r
-  IN  UINT8                     ForceReconnect\r
-  )\r
-{\r
-  UINT16          Index;\r
-  UINT16          *DriverOrderList;\r
-  UINT16          *NewDriverOrderList;\r
-  UINT16          DriverString[12];\r
-  UINTN           DriverOrderListSize;\r
-  VOID            *Buffer;\r
-  UINTN           BufferSize;\r
-  UINT8           *Ptr;\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT *NewLoadContext;\r
-  BOOLEAN         OptionalDataExist;\r
-  EFI_STATUS      Status;\r
-\r
-  OptionalDataExist = FALSE;\r
-\r
-  Index             = BOpt_GetDriverOptionNumber ();\r
-  UnicodeSPrint (\r
-    DriverString,\r
-    sizeof (DriverString),\r
-    L"Driver%04x",\r
-    Index\r
-    );\r
-\r
-  if (*DescriptionData == 0x0000) {\r
-    StrCpyS (DescriptionData, DESCRIPTION_DATA_SIZE, DriverString);\r
-  }\r
-\r
-  BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescriptionData);\r
-  BufferSize += GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
-\r
-  if (*OptionalData != 0x0000) {\r
-    OptionalDataExist = TRUE;\r
-    BufferSize += StrSize (OptionalData);\r
-  }\r
-\r
-  Buffer = AllocateZeroPool (BufferSize);\r
-  if (NULL == Buffer) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
-  if (NULL == NewMenuEntry) {\r
-    FreePool (Buffer);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  NewLoadContext                  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-  NewLoadContext->Deleted         = FALSE;\r
-  NewLoadContext->LoadOptionSize  = BufferSize;\r
-  Ptr = (UINT8 *) Buffer;\r
-  NewLoadContext->LoadOption = Ptr;\r
-  *((UINT32 *) Ptr) = LOAD_OPTION_ACTIVE | (ForceReconnect << 1);\r
-  NewLoadContext->Attributes = *((UINT32 *) Ptr);\r
-  NewLoadContext->IsActive = TRUE;\r
-  NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);\r
-\r
-  Ptr += sizeof (UINT32);\r
-  *((UINT16 *) Ptr) = (UINT16) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
-  NewLoadContext->FilePathListLength = *((UINT16 *) Ptr);\r
-\r
-  Ptr += sizeof (UINT16);\r
-  CopyMem (\r
-    Ptr,\r
-    DescriptionData,\r
-    StrSize (DescriptionData)\r
-    );\r
-\r
-  NewLoadContext->Description = AllocateZeroPool (StrSize (DescriptionData));\r
-  ASSERT (NewLoadContext->Description != NULL);\r
-  NewMenuEntry->DisplayString = NewLoadContext->Description;\r
-  CopyMem (\r
-    NewLoadContext->Description,\r
-    (VOID *) Ptr,\r
-    StrSize (DescriptionData)\r
-    );\r
-\r
-  Ptr += StrSize (DescriptionData);\r
-  CopyMem (\r
-    Ptr,\r
-    CallbackData->LoadContext->FilePathList,\r
-    GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
-    );\r
-\r
-  NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));\r
-  ASSERT (NewLoadContext->FilePathList != NULL);\r
-\r
-  CopyMem (\r
-    NewLoadContext->FilePathList,\r
-    (VOID *) Ptr,\r
-    GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
-    );\r
-\r
-  NewMenuEntry->HelpString    = DevicePathToStr (NewLoadContext->FilePathList);\r
-  NewMenuEntry->OptionNumber  = Index;\r
-  NewMenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
-                                      CallbackData,\r
-                                      DriverOptionStrDepository\r
-                                      );\r
-  NewMenuEntry->DisplayStringToken = HiiSetString (HiiHandle, 0, NewMenuEntry->DisplayString, NULL);\r
-\r
-  NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
-                                    CallbackData,\r
-                                    DriverOptionHelpStrDepository\r
-                                    );\r
-  NewMenuEntry->HelpStringToken = HiiSetString (HiiHandle, 0, NewMenuEntry->HelpString, NULL);\r
-\r
-  if (OptionalDataExist) {\r
-    Ptr += (UINT8) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
-\r
-    CopyMem (\r
-      Ptr,\r
-      OptionalData,\r
-      StrSize (OptionalData)\r
-      );\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  DriverString,\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  BufferSize,\r
-                  Buffer\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    DriverOrderList = BdsLibGetVariableAndSize (\r
-                        L"DriverOrder",\r
-                        &gEfiGlobalVariableGuid,\r
-                        &DriverOrderListSize\r
-                        );\r
-    NewDriverOrderList = AllocateZeroPool (DriverOrderListSize + sizeof (UINT16));\r
-    ASSERT (NewDriverOrderList != NULL);\r
-    if (DriverOrderList != NULL) {\r
-      CopyMem (NewDriverOrderList, DriverOrderList, DriverOrderListSize);\r
-      EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
-    }\r
-    NewDriverOrderList[DriverOrderListSize / sizeof (UINT16)] = Index;\r
-\r
-    Status = gRT->SetVariable (\r
-                    L"DriverOrder",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    DriverOrderListSize + sizeof (UINT16),\r
-                    NewDriverOrderList\r
-                    );\r
-    if (DriverOrderList != NULL) {\r
-      FreePool (DriverOrderList);\r
-    }\r
-    DriverOrderList = NULL;\r
-    FreePool (NewDriverOrderList);\r
-    if (!EFI_ERROR (Status)) {\r
-      InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);\r
-      DriverOptionMenu.MenuNumber++;\r
-\r
-      //\r
-      // Update "change boot order" page used data, append the new add boot\r
-      // option at the end.\r
-      //\r
-      Index = 0;\r
-      while (CallbackData->BmmFakeNvData.DriverOptionOrder[Index] != 0) {\r
-        Index++;\r
-      }\r
-      CallbackData->BmmFakeNvData.DriverOptionOrder[Index] = (UINT32) (NewMenuEntry->OptionNumber + 1);\r
-\r
-      *DescriptionData  = 0x0000;\r
-      *OptionalData     = 0x0000;\r
-    }\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function create a currently loaded Boot Option from\r
-  the BMM. It then appends this Boot Option to the end of\r
-  the "BootOrder" list. It also append this Boot Opotion to the end\r
-  of BootOptionMenu.\r
-\r
-  @param CallbackData    The BMM context data.\r
-  @param NvRamMap        The file explorer formset internal state.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.\r
-  @retval EFI_SUCCESS          If function completes successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateBootOption (\r
-  IN  BMM_CALLBACK_DATA                   *CallbackData,\r
-  IN  FILE_EXPLORER_NV_DATA               *NvRamMap\r
-  )\r
-{\r
-  UINT16          *BootOrderList;\r
-  UINT16          *NewBootOrderList;\r
-  UINTN           BootOrderListSize;\r
-  UINT16          BootString[10];\r
-  VOID            *Buffer;\r
-  UINTN           BufferSize;\r
-  UINT8           *Ptr;\r
-  UINT16          Index;\r
-  BM_MENU_ENTRY   *NewMenuEntry;\r
-  BM_LOAD_CONTEXT *NewLoadContext;\r
-  BOOLEAN         OptionalDataExist;\r
-  EFI_STATUS      Status;\r
-\r
-  OptionalDataExist = FALSE;\r
-\r
-  Index = BOpt_GetBootOptionNumber () ;\r
-  UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", Index);\r
-\r
-  if (NvRamMap->BootDescriptionData[0] == 0x0000) {\r
-    StrCpyS (\r
-      NvRamMap->BootDescriptionData,\r
-      sizeof (NvRamMap->BootDescriptionData) / sizeof (NvRamMap->BootDescriptionData[0]),\r
-      BootString\r
-      );\r
-  }\r
-\r
-  BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (NvRamMap->BootDescriptionData);\r
-  BufferSize += GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
-\r
-  if (NvRamMap->BootOptionalData[0] != 0x0000) {\r
-    OptionalDataExist = TRUE;\r
-    BufferSize += StrSize (NvRamMap->BootOptionalData);\r
-  }\r
-\r
-  Buffer = AllocateZeroPool (BufferSize);\r
-  if (NULL == Buffer) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
-  if (NULL == NewMenuEntry) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  NewLoadContext                  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-  NewLoadContext->Deleted         = FALSE;\r
-  NewLoadContext->LoadOptionSize  = BufferSize;\r
-  Ptr = (UINT8 *) Buffer;\r
-  NewLoadContext->LoadOption = Ptr;\r
-  *((UINT32 *) Ptr) = LOAD_OPTION_ACTIVE;\r
-  NewLoadContext->Attributes = *((UINT32 *) Ptr);\r
-  NewLoadContext->IsActive = TRUE;\r
-  NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);\r
-\r
-  Ptr += sizeof (UINT32);\r
-  *((UINT16 *) Ptr) = (UINT16) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
-  NewLoadContext->FilePathListLength = *((UINT16 *) Ptr);\r
-  Ptr += sizeof (UINT16);\r
-\r
-  CopyMem (\r
-    Ptr,\r
-    NvRamMap->BootDescriptionData,\r
-    StrSize (NvRamMap->BootDescriptionData)\r
-    );\r
-\r
-  NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->BootDescriptionData));\r
-  ASSERT (NewLoadContext->Description != NULL);\r
-\r
-  NewMenuEntry->DisplayString = NewLoadContext->Description;\r
-  CopyMem (\r
-    NewLoadContext->Description,\r
-    (VOID *) Ptr,\r
-    StrSize (NvRamMap->BootDescriptionData)\r
-    );\r
-\r
-  Ptr += StrSize (NvRamMap->BootDescriptionData);\r
-  CopyMem (\r
-    Ptr,\r
-    CallbackData->LoadContext->FilePathList,\r
-    GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
-    );\r
-\r
-  NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));\r
-  ASSERT (NewLoadContext->FilePathList != NULL);\r
-\r
-  CopyMem (\r
-    NewLoadContext->FilePathList,\r
-    (VOID *) Ptr,\r
-    GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
-    );\r
-\r
-  NewMenuEntry->HelpString    = DevicePathToStr (NewLoadContext->FilePathList);\r
-  NewMenuEntry->OptionNumber  = Index;\r
-  NewMenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
-                                      CallbackData,\r
-                                      BootOptionStrDepository\r
-                                      );\r
-  NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->FeHiiHandle, 0, NewMenuEntry->DisplayString, NULL);\r
-\r
-  NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
-                                    CallbackData,\r
-                                    BootOptionHelpStrDepository\r
-                                    );\r
-  NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->FeHiiHandle, 0, NewMenuEntry->HelpString, NULL);\r
-\r
-  if (OptionalDataExist) {\r
-    Ptr += (UINT8) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
-\r
-    CopyMem (Ptr, NvRamMap->BootOptionalData, StrSize (NvRamMap->BootOptionalData));\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  BootString,\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  BufferSize,\r
-                  Buffer\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-\r
-    BootOrderList = BdsLibGetVariableAndSize (\r
-                      L"BootOrder",\r
-                      &gEfiGlobalVariableGuid,\r
-                      &BootOrderListSize\r
-                      );\r
-    ASSERT (BootOrderList != NULL);\r
-    NewBootOrderList = AllocateZeroPool (BootOrderListSize + sizeof (UINT16));\r
-    ASSERT (NewBootOrderList != NULL);\r
-    CopyMem (NewBootOrderList, BootOrderList, BootOrderListSize);\r
-    NewBootOrderList[BootOrderListSize / sizeof (UINT16)] = Index;\r
-\r
-    if (BootOrderList != NULL) {\r
-      FreePool (BootOrderList);\r
-    }\r
-\r
-    Status = gRT->SetVariable (\r
-                    L"BootOrder",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    BootOrderListSize + sizeof (UINT16),\r
-                    NewBootOrderList\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-\r
-      FreePool (NewBootOrderList);\r
-      NewBootOrderList = NULL;\r
-      InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);\r
-      BootOptionMenu.MenuNumber++;\r
-\r
-      //\r
-      // Update "change driver order" page used data, append the new add driver\r
-      // option at the end.\r
-      //\r
-      Index = 0;\r
-      while (CallbackData->BmmFakeNvData.BootOptionOrder[Index] != 0) {\r
-        Index++;\r
-      }\r
-      CallbackData->BmmFakeNvData.BootOptionOrder[Index] = (UINT32) (NewMenuEntry->OptionNumber + 1);\r
-\r
-      NvRamMap->BootDescriptionData[0]  = 0x0000;\r
-      NvRamMap->BootOptionalData[0]     = 0x0000;\r
-    }\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function update the "BootNext" EFI Variable. If there is\r
-  no "BootNext" specified in BMM, this EFI Variable is deleted.\r
-  It also update the BMM context data specified the "BootNext"\r
-  vaule.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-  @retval EFI_SUCCESS    The function complete successfully.\r
-  @return                The EFI variable can be saved. See gRT->SetVariable\r
-                         for detail return information.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateBootNext (\r
-  IN BMM_CALLBACK_DATA            *CallbackData\r
-  )\r
-{\r
-  BM_MENU_ENTRY     *NewMenuEntry;\r
-  BM_LOAD_CONTEXT   *NewLoadContext;\r
-  BMM_FAKE_NV_DATA  *CurrentFakeNVMap;\r
-  UINT16            Index;\r
-  EFI_STATUS        Status;\r
-\r
-  Status            = EFI_SUCCESS;\r
-  CurrentFakeNVMap  = &CallbackData->BmmFakeNvData;\r
-  for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
-    NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
-    ASSERT (NULL != NewMenuEntry);\r
-\r
-    NewLoadContext              = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-    NewLoadContext->IsBootNext  = FALSE;\r
-  }\r
-\r
-  if (CurrentFakeNVMap->BootNext == BootOptionMenu.MenuNumber) {\r
-    EfiLibDeleteVariable (L"BootNext", &gEfiGlobalVariableGuid);\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  NewMenuEntry = BOpt_GetMenuEntry (\r
-                  &BootOptionMenu,\r
-                  CurrentFakeNVMap->BootNext\r
-                  );\r
-  ASSERT (NewMenuEntry != NULL);\r
-\r
-  NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-  Status = gRT->SetVariable (\r
-                  L"BootNext",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  sizeof (UINT16),\r
-                  &NewMenuEntry->OptionNumber\r
-                  );\r
-  NewLoadContext->IsBootNext              = TRUE;\r
-  CallbackData->BmmOldFakeNVData.BootNext = CurrentFakeNVMap->BootNext;\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function update the "BootOrder" EFI Variable based on\r
-  BMM Formset's NV map. It then refresh BootOptionMenu\r
-  with the new "BootOrder" list.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-  @retval EFI_SUCCESS             The function complete successfully.\r
-  @retval EFI_OUT_OF_RESOURCES    Not enough memory to complete the function.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateBootOrder (\r
-  IN BMM_CALLBACK_DATA            *CallbackData\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT16      Index;\r
-  UINT16      OrderIndex;\r
-  UINT16      *BootOrderList;\r
-  UINTN       BootOrderListSize;\r
-  UINT16      OptionNumber;\r
-\r
-  BootOrderList     = NULL;\r
-  BootOrderListSize = 0;\r
-\r
-  //\r
-  // First check whether BootOrder is present in current configuration\r
-  //\r
-  BootOrderList = BdsLibGetVariableAndSize (\r
-                    L"BootOrder",\r
-                    &gEfiGlobalVariableGuid,\r
-                    &BootOrderListSize\r
-                    );\r
-  if (BootOrderList == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.BootOptionOrder) / sizeof (CallbackData->BmmFakeNvData.BootOptionOrder[0])));\r
-\r
-  for (OrderIndex = 0; (OrderIndex < BootOptionMenu.MenuNumber) && (CallbackData->BmmFakeNvData.BootOptionOrder[OrderIndex] != 0); OrderIndex++) {\r
-    for (Index = OrderIndex; Index < BootOrderListSize / sizeof (UINT16); Index++) {\r
-      if ((BootOrderList[Index] == (UINT16) (CallbackData->BmmFakeNvData.BootOptionOrder[OrderIndex] - 1)) && (OrderIndex != Index)) {\r
-        OptionNumber = BootOrderList[Index];\r
-        CopyMem (&BootOrderList[OrderIndex + 1], &BootOrderList[OrderIndex], (Index - OrderIndex) * sizeof (UINT16));\r
-        BootOrderList[OrderIndex] = OptionNumber;\r
-      }\r
-    }\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  L"BootOrder",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  BootOrderListSize,\r
-                  BootOrderList\r
-                  );\r
-  //\r
-  // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
-  //\r
-  ASSERT_EFI_ERROR (Status);\r
-  FreePool (BootOrderList);\r
-\r
-  GroupMultipleLegacyBootOption4SameType ();\r
-\r
-  BOpt_FreeMenu (&BootOptionMenu);\r
-  BOpt_GetBootOptions (CallbackData);\r
-\r
-  return Status;\r
-\r
-}\r
-\r
-/**\r
-  This function update the "DriverOrder" EFI Variable based on\r
-  BMM Formset's NV map. It then refresh DriverOptionMenu\r
-  with the new "DriverOrder" list.\r
-\r
-  @param CallbackData    The BMM context data.\r
-\r
-  @retval EFI_SUCCESS           The function complete successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  Not enough memory to complete the function.\r
-  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateDriverOrder (\r
-  IN BMM_CALLBACK_DATA            *CallbackData\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT16      Index;\r
-  UINT16      *DriverOrderList;\r
-  UINT16      *NewDriverOrderList;\r
-  UINTN       DriverOrderListSize;\r
-\r
-  DriverOrderList     = NULL;\r
-  DriverOrderListSize = 0;\r
-\r
-  //\r
-  // First check whether DriverOrder is present in current configuration\r
-  //\r
-  DriverOrderList = BdsLibGetVariableAndSize (\r
-                      L"DriverOrder",\r
-                      &gEfiGlobalVariableGuid,\r
-                      &DriverOrderListSize\r
-                      );\r
-\r
-  NewDriverOrderList = AllocateZeroPool (DriverOrderListSize);\r
-\r
-  if (NewDriverOrderList == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // If exists, delete it to hold new DriverOrder\r
-  //\r
-  if (DriverOrderList != NULL) {\r
-    EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
-    FreePool (DriverOrderList);\r
-  }\r
-\r
-  ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder) / sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder[0])));\r
-  for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
-    NewDriverOrderList[Index] = (UINT16) (CallbackData->BmmFakeNvData.DriverOptionOrder[Index] - 1);\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  L"DriverOrder",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  DriverOrderListSize,\r
-                  NewDriverOrderList\r
-                  );\r
-  //\r
-  // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
-  //\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  BOpt_FreeMenu (&DriverOptionMenu);\r
-  BOpt_GetDriverOptions (CallbackData);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Update the legacy BBS boot option. VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable\r
-  is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid\r
-  is also updated.\r
-\r
-  @param CallbackData    The context data for BMM.\r
-  @param FormId          The form id.\r
-\r
-  @return EFI_SUCCESS           The function completed successfully.\r
-  @retval EFI_NOT_FOUND         If VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable can be found.\r
-  @retval EFI_OUT_OF_RESOURCES  Fail to allocate memory resource\r
-**/\r
-EFI_STATUS\r
-Var_UpdateBBSOption (\r
-  IN BMM_CALLBACK_DATA            *CallbackData,\r
-  IN EFI_FORM_ID                  FormId\r
-  )\r
-{\r
-  UINTN                       Index;\r
-  UINTN                       Index2;\r
-  VOID                        *BootOptionVar;\r
-  CHAR16                      VarName[100];\r
-  UINTN                       OptionSize;\r
-  EFI_STATUS                  Status;\r
-  UINT32                      *Attribute;\r
-  BM_MENU_OPTION              *OptionMenu;\r
-  UINT8                       *LegacyDev;\r
-  UINT8                       *VarData;\r
-  UINTN                       VarSize;\r
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;\r
-  UINT8                       *OriginalPtr;\r
-  UINT8                       *DisMap;\r
-  UINTN                       Pos;\r
-  UINTN                       Bit;\r
-  UINT16                      *NewOrder;\r
-  UINT16                      Tmp;\r
-  UINT16                      *EnBootOption;\r
-  UINTN                       EnBootOptionCount;\r
-  UINT16                      *DisBootOption;\r
-  UINTN                       DisBootOptionCount;\r
-\r
-  DisMap              = NULL;\r
-  NewOrder            = NULL;\r
-\r
-  switch (FormId) {\r
-    case FORM_SET_FD_ORDER_ID:\r
-      OptionMenu            = (BM_MENU_OPTION *) &LegacyFDMenu;\r
-      LegacyDev             = CallbackData->BmmFakeNvData.LegacyFD;\r
-      CallbackData->BbsType = BBS_FLOPPY;\r
-      break;\r
-\r
-    case FORM_SET_HD_ORDER_ID:\r
-      OptionMenu            = (BM_MENU_OPTION *) &LegacyHDMenu;\r
-      LegacyDev             = CallbackData->BmmFakeNvData.LegacyHD;\r
-      CallbackData->BbsType = BBS_HARDDISK;\r
-      break;\r
-\r
-    case FORM_SET_CD_ORDER_ID:\r
-      OptionMenu            = (BM_MENU_OPTION *) &LegacyCDMenu;\r
-      LegacyDev             = CallbackData->BmmFakeNvData.LegacyCD;\r
-      CallbackData->BbsType = BBS_CDROM;\r
-      break;\r
-\r
-    case FORM_SET_NET_ORDER_ID:\r
-      OptionMenu            = (BM_MENU_OPTION *) &LegacyNETMenu;\r
-      LegacyDev             = CallbackData->BmmFakeNvData.LegacyNET;\r
-      CallbackData->BbsType = BBS_EMBED_NETWORK;\r
-      break;\r
-\r
-    default:\r
-      ASSERT (FORM_SET_BEV_ORDER_ID == CallbackData->BmmPreviousPageId);\r
-      OptionMenu            = (BM_MENU_OPTION *) &LegacyBEVMenu;\r
-      LegacyDev             = CallbackData->BmmFakeNvData.LegacyBEV;\r
-      CallbackData->BbsType = BBS_BEV_DEVICE;\r
-      break;\r
-  }\r
-\r
-  DisMap  = CallbackData->BmmOldFakeNVData.DisableMap;\r
-  Status  = EFI_SUCCESS;\r
-\r
-\r
-  //\r
-  // Update the Variable "LegacyDevOrder"\r
-  //\r
-  VarData = (UINT8 *) BdsLibGetVariableAndSize (\r
-                        VAR_LEGACY_DEV_ORDER,\r
-                        &gEfiLegacyDevOrderVariableGuid,\r
-                        &VarSize\r
-                        );\r
-\r
-  if (VarData == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  OriginalPtr = VarData;\r
-  DevOrder    = (LEGACY_DEV_ORDER_ENTRY *) VarData;\r
-\r
-  while (VarData < OriginalPtr + VarSize) {\r
-    if (DevOrder->BbsType == CallbackData->BbsType) {\r
-      break;\r
-    }\r
-\r
-    VarData += sizeof (BBS_TYPE) + DevOrder->Length;\r
-    DevOrder = (LEGACY_DEV_ORDER_ENTRY *) VarData;\r
-  }\r
-\r
-  if (VarData >= OriginalPtr + VarSize) {\r
-    FreePool (OriginalPtr);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  NewOrder = AllocateZeroPool (DevOrder->Length - sizeof (DevOrder->Length));\r
-  if (NewOrder == NULL) {\r
-    FreePool (OriginalPtr);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
-    if (0xFF == LegacyDev[Index]) {\r
-      break;\r
-    }\r
-\r
-    NewOrder[Index] = LegacyDev[Index];\r
-  }\r
-  //\r
-  // Only the enable/disable state of each boot device with same device type can be changed,\r
-  // so we can count on the index information in DevOrder.\r
-  // DisMap bit array is the only reliable source to check a device's en/dis state,\r
-  // so we use DisMap to set en/dis state of each item in NewOrder array\r
-  //\r
-  for (Index2 = 0; Index2 < OptionMenu->MenuNumber; Index2++) {\r
-    Tmp = (UINT16) (DevOrder->Data[Index2] & 0xFF);\r
-    Pos = Tmp / 8;\r
-    Bit = 7 - (Tmp % 8);\r
-    if ((DisMap[Pos] & (1 << Bit)) != 0) {\r
-      NewOrder[Index] = (UINT16) (0xFF00 | Tmp);\r
-      Index++;\r
-    }\r
-  }\r
-\r
-  CopyMem (\r
-    DevOrder->Data,\r
-    NewOrder,\r
-    DevOrder->Length - sizeof (DevOrder->Length)\r
-    );\r
-  FreePool (NewOrder);\r
-\r
-  Status = gRT->SetVariable (\r
-                  VAR_LEGACY_DEV_ORDER,\r
-                  &gEfiLegacyDevOrderVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                  VarSize,\r
-                  OriginalPtr\r
-                  );\r
-\r
-\r
-  //\r
-  // Update BootOrder and Boot####.Attribute\r
-  //\r
-  // 1. Re-order the Option Number in BootOrder according to Legacy Dev Order\r
-  //\r
-  ASSERT (OptionMenu->MenuNumber == DevOrder->Length / sizeof (UINT16) - 1);\r
-\r
-  OrderLegacyBootOption4SameType (\r
-    DevOrder->Data,\r
-    DevOrder->Length / sizeof (UINT16) - 1,\r
-    &EnBootOption,\r
-    &EnBootOptionCount,\r
-    &DisBootOption,\r
-    &DisBootOptionCount\r
-    );\r
-\r
-  //\r
-  // 2. Deactivate the DisBootOption and activate the EnBootOption\r
-  //\r
-  for (Index = 0; Index < DisBootOptionCount; Index++) {\r
-    UnicodeSPrint (VarName, sizeof (VarName), L"Boot%04x", DisBootOption[Index]);\r
-    BootOptionVar = BdsLibGetVariableAndSize (\r
-                      VarName,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &OptionSize\r
-                      );\r
-    if (BootOptionVar != NULL) {\r
-      Attribute   = (UINT32 *) BootOptionVar;\r
-      *Attribute &= ~LOAD_OPTION_ACTIVE;\r
-\r
-      Status = gRT->SetVariable (\r
-                      VarName,\r
-                      &gEfiGlobalVariableGuid,\r
-                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                      OptionSize,\r
-                      BootOptionVar\r
-                      );\r
-      //\r
-      // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
-      //\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-      FreePool (BootOptionVar);\r
-    }\r
-  }\r
-\r
-  for (Index = 0; Index < EnBootOptionCount; Index++) {\r
-    UnicodeSPrint (VarName, sizeof (VarName), L"Boot%04x", EnBootOption[Index]);\r
-    BootOptionVar = BdsLibGetVariableAndSize (\r
-                      VarName,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &OptionSize\r
-                      );\r
-    if (BootOptionVar != NULL) {\r
-      Attribute   = (UINT32 *) BootOptionVar;\r
-      *Attribute |= LOAD_OPTION_ACTIVE;\r
-\r
-      Status = gRT->SetVariable (\r
-                      VarName,\r
-                      &gEfiGlobalVariableGuid,\r
-                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                      OptionSize,\r
-                      BootOptionVar\r
-                      );\r
-      //\r
-      // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
-      //\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-      FreePool (BootOptionVar);\r
-    }\r
-  }\r
-\r
-  BOpt_GetBootOptions (CallbackData);\r
-\r
-  FreePool (OriginalPtr);\r
-  FreePool (EnBootOption);\r
-  FreePool (DisBootOption);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Update the Text Mode of Console.\r
-\r
-  @param CallbackData  The context data for BMM.\r
-\r
-  @retval EFI_SUCCSS If the Text Mode of Console is updated.\r
-  @return Other value if the Text Mode of Console is not updated.\r
-\r
-**/\r
-EFI_STATUS\r
-Var_UpdateConMode (\r
-  IN BMM_CALLBACK_DATA            *CallbackData\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  UINTN             Mode;\r
-  CONSOLE_OUT_MODE  ModeInfo;\r
-\r
-  Mode = CallbackData->BmmFakeNvData.ConsoleOutMode;\r
-\r
-  Status = gST->ConOut->QueryMode (gST->ConOut, Mode, &(ModeInfo.Column), &(ModeInfo.Row));\r
-  if (!EFI_ERROR(Status)) {\r
-    Status = PcdSet32S (PcdSetupConOutColumn, (UINT32) ModeInfo.Column);\r
-    if (!EFI_ERROR (Status)){\r
-      Status = PcdSet32S (PcdSetupConOutRow, (UINT32) ModeInfo.Row);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
deleted file mode 100644 (file)
index 72f750d..0000000
+++ /dev/null
@@ -1,393 +0,0 @@
-/** @file\r
-  The platform boot manager reference implementation\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BootManager.h"\r
-\r
-UINT16             mKeyInput;\r
-LIST_ENTRY         mBootOptionsList;\r
-BDS_COMMON_OPTION  *gOption;\r
-CHAR16             *mDeviceTypeStr[] = {\r
-  L"Legacy BEV",\r
-  L"Legacy Floppy",\r
-  L"Legacy Hard Drive",\r
-  L"Legacy CD ROM",\r
-  L"Legacy PCMCIA",\r
-  L"Legacy USB",\r
-  L"Legacy Embedded Network",\r
-  L"Legacy Unknown Device"\r
-};\r
-\r
-\r
-HII_VENDOR_DEVICE_PATH  mBootManagerHiiVendorDevicePath = {\r
-  {\r
-    {\r
-      HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,\r
-      {\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    BOOT_MANAGER_FORMSET_GUID\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      (UINT8) (END_DEVICE_PATH_LENGTH),\r
-      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
-    }\r
-  }\r
-};\r
-\r
-BOOT_MANAGER_CALLBACK_DATA  gBootManagerPrivate = {\r
-  BOOT_MANAGER_CALLBACK_DATA_SIGNATURE,\r
-  NULL,\r
-  NULL,\r
-  {\r
-    FakeExtractConfig,\r
-    FakeRouteConfig,\r
-    BootManagerCallback\r
-  }\r
-};\r
-\r
-/**\r
-  This call back function is registered with Boot Manager formset.\r
-  When user selects a boot option, this call back function will\r
-  be triggered. The boot option is saved for later processing.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BootManagerCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  )\r
-{\r
-  BDS_COMMON_OPTION       *Option;\r
-  LIST_ENTRY              *Link;\r
-  UINT16                  KeyCount;\r
-\r
-  if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
-    if ((Value == NULL) || (ActionRequest == NULL)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    //\r
-    // Initialize the key count\r
-    //\r
-    KeyCount = 0;\r
-\r
-    for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) {\r
-      Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
-\r
-      KeyCount++;\r
-\r
-      gOption = Option;\r
-\r
-      //\r
-      // Is this device the one chosen?\r
-      //\r
-      if (KeyCount == QuestionId) {\r
-        //\r
-        // Assigning the returned Key to a global allows the original routine to know what was chosen\r
-        //\r
-        mKeyInput = QuestionId;\r
-\r
-        //\r
-        // Request to exit SendForm(), so that we could boot the selected option\r
-        //\r
-        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-        break;\r
-      }\r
-    }\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // All other action return unsupported.\r
-  //\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-\r
-  Registers HII packages for the Boot Manger to HII Database.\r
-  It also registers the browser call back function.\r
-\r
-  @retval  EFI_SUCCESS           HII packages for the Boot Manager were registered successfully.\r
-  @retval  EFI_OUT_OF_RESOURCES  HII packages for the Boot Manager failed to be registered.\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeBootManager (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-\r
-  //\r
-  // Install Device Path Protocol and Config Access protocol to driver handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &gBootManagerPrivate.DriverHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  &mBootManagerHiiVendorDevicePath,\r
-                  &gEfiHiiConfigAccessProtocolGuid,\r
-                  &gBootManagerPrivate.ConfigAccess,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Publish our HII data\r
-  //\r
-  gBootManagerPrivate.HiiHandle = HiiAddPackages (\r
-                                    &gBootManagerFormSetGuid,\r
-                                    gBootManagerPrivate.DriverHandle,\r
-                                    BootManagerVfrBin,\r
-                                    BdsDxeStrings,\r
-                                    NULL\r
-                                    );\r
-  if (gBootManagerPrivate.HiiHandle == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-  } else {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function invokes Boot Manager. If all devices have not a chance to be connected,\r
-  the connect all will be triggered. It then enumerate all boot options. If\r
-  a boot option from the Boot Manager page is selected, Boot Manager will boot\r
-  from this boot option.\r
-\r
-**/\r
-VOID\r
-CallBootManager (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  BDS_COMMON_OPTION           *Option;\r
-  LIST_ENTRY                  *Link;\r
-  CHAR16                      *ExitData;\r
-  UINTN                       ExitDataSize;\r
-  EFI_STRING_ID               Token;\r
-  EFI_INPUT_KEY               Key;\r
-  CHAR16                      *HelpString;\r
-  UINTN                       HelpSize;\r
-  EFI_STRING_ID               HelpToken;\r
-  UINT16                      *TempStr;\r
-  EFI_HII_HANDLE              HiiHandle;\r
-  EFI_BROWSER_ACTION_REQUEST  ActionRequest;\r
-  VOID                        *StartOpCodeHandle;\r
-  VOID                        *EndOpCodeHandle;\r
-  EFI_IFR_GUID_LABEL          *StartLabel;\r
-  EFI_IFR_GUID_LABEL          *EndLabel;\r
-  UINT16                      DeviceType;\r
-  BOOLEAN                     IsLegacyOption;\r
-  BOOLEAN                     NeedEndOp;\r
-\r
-  DeviceType = (UINT16) -1;\r
-  gOption    = NULL;\r
-  InitializeListHead (&mBootOptionsList);\r
-\r
-  //\r
-  // Connect all prior to entering the platform setup menu.\r
-  //\r
-  if (!gConnectAllHappened) {\r
-    BdsLibConnectAllDriversToAllControllers ();\r
-    gConnectAllHappened = TRUE;\r
-  }\r
-\r
-  BdsLibEnumerateAllBootOption (&mBootOptionsList);\r
-\r
-  //\r
-  // Group the legacy boot options for the same device type\r
-  //\r
-  GroupMultipleLegacyBootOption4SameType ();\r
-\r
-  InitializeListHead (&mBootOptionsList);\r
-  BdsLibBuildOptionFromVar (&mBootOptionsList, L"BootOrder");\r
-\r
-  HiiHandle = gBootManagerPrivate.HiiHandle;\r
-\r
-  //\r
-  // Allocate space for creation of UpdateData Buffer\r
-  //\r
-  StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (StartOpCodeHandle != NULL);\r
-\r
-  EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (EndOpCodeHandle != NULL);\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  StartLabel->Number       = LABEL_BOOT_OPTION;\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the end opcode\r
-  //\r
-  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  EndLabel->Number       = LABEL_BOOT_OPTION_END;\r
-\r
-  mKeyInput = 0;\r
-  NeedEndOp = FALSE;\r
-  for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) {\r
-    Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
-\r
-    //\r
-    // At this stage we are creating a menu entry, thus the Keys are reproduceable\r
-    //\r
-    mKeyInput++;\r
-\r
-    //\r
-    // Don't display the hidden/inactive boot option\r
-    //\r
-    if (((Option->Attribute & LOAD_OPTION_HIDDEN) != 0) || ((Option->Attribute & LOAD_OPTION_ACTIVE) == 0)) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Group the legacy boot option in the sub title created dynamically\r
-    //\r
-    IsLegacyOption = (BOOLEAN) (\r
-                       (DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) &&\r
-                       (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP)\r
-                       );\r
-\r
-    if (!IsLegacyOption && NeedEndOp) {\r
-      NeedEndOp = FALSE;\r
-      HiiCreateEndOpCode (StartOpCodeHandle);\r
-    }\r
-\r
-    if (IsLegacyOption && DeviceType != ((BBS_BBS_DEVICE_PATH *) Option->DevicePath)->DeviceType) {\r
-      if (NeedEndOp) {\r
-        HiiCreateEndOpCode (StartOpCodeHandle);\r
-      }\r
-\r
-      DeviceType = ((BBS_BBS_DEVICE_PATH *) Option->DevicePath)->DeviceType;\r
-      Token      = HiiSetString (\r
-                     HiiHandle,\r
-                     0,\r
-                     mDeviceTypeStr[\r
-                       MIN (DeviceType & 0xF, ARRAY_SIZE (mDeviceTypeStr) - 1)\r
-                       ],\r
-                     NULL\r
-                     );\r
-      HiiCreateSubTitleOpCode (StartOpCodeHandle, Token, 0, 0, 1);\r
-      NeedEndOp = TRUE;\r
-    }\r
-\r
-    ASSERT (Option->Description != NULL);\r
-\r
-    Token = HiiSetString (HiiHandle, 0, Option->Description, NULL);\r
-\r
-    TempStr = DevicePathToStr (Option->DevicePath);\r
-    HelpSize = StrSize (TempStr) + StrSize (L"Device Path : ");\r
-    HelpString = AllocateZeroPool (HelpSize);\r
-    ASSERT (HelpString != NULL);\r
-    StrCatS (HelpString, HelpSize / sizeof (CHAR16), L"Device Path : ");\r
-    StrCatS (HelpString, HelpSize / sizeof (CHAR16), TempStr);\r
-\r
-    HelpToken = HiiSetString (HiiHandle, 0, HelpString, NULL);\r
-\r
-    HiiCreateActionOpCode (\r
-      StartOpCodeHandle,\r
-      mKeyInput,\r
-      Token,\r
-      HelpToken,\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      0\r
-      );\r
-  }\r
-\r
-  if (NeedEndOp) {\r
-    HiiCreateEndOpCode (StartOpCodeHandle);\r
-  }\r
-\r
-  HiiUpdateForm (\r
-    HiiHandle,\r
-    &gBootManagerFormSetGuid,\r
-    BOOT_MANAGER_FORM_ID,\r
-    StartOpCodeHandle,\r
-    EndOpCodeHandle\r
-    );\r
-\r
-  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
-  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-\r
-  ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-  Status = gFormBrowser2->SendForm (\r
-                           gFormBrowser2,\r
-                           &HiiHandle,\r
-                           1,\r
-                           &gBootManagerFormSetGuid,\r
-                           0,\r
-                           NULL,\r
-                           &ActionRequest\r
-                           );\r
-  if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
-    EnableResetRequired ();\r
-  }\r
-\r
-  if (gOption == NULL) {\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Will leave browser, check any reset required change is applied? if yes, reset system\r
-  //\r
-  SetupResetReminder ();\r
-\r
-  //\r
-  // Restore to original mode before launching boot option.\r
-  //\r
-  BdsSetConsoleMode (FALSE);\r
-\r
-  //\r
-  // parse the selected option\r
-  //\r
-  Status = BdsLibBootViaBootOption (gOption, gOption->DevicePath, &ExitDataSize, &ExitData);\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    gOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));\r
-    PlatformBdsBootSuccess (gOption);\r
-  } else {\r
-    gOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));\r
-    PlatformBdsBootFail (gOption, Status, ExitData, ExitDataSize);\r
-    gST->ConOut->OutputString (\r
-                  gST->ConOut,\r
-                  GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE))\r
-                  );\r
-    gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-  }\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.h b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.h
deleted file mode 100644 (file)
index e87e7b0..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @file\r
-  The platform boot manager reference implement\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _EFI_BOOT_MANAGER_H_\r
-#define _EFI_BOOT_MANAGER_H_\r
-\r
-#include "Bds.h"\r
-#include "FrontPage.h"\r
-\r
-#define BOOT_MANAGER_FORM_ID     0x1000\r
-\r
-#define LABEL_BOOT_OPTION        0x00\r
-#define LABEL_BOOT_OPTION_END    0x01\r
-\r
-//\r
-// These are the VFR compiler generated data representing our VFR data.\r
-//\r
-extern UINT8 BootManagerVfrBin[];\r
-\r
-#define BOOT_MANAGER_CALLBACK_DATA_SIGNATURE  SIGNATURE_32 ('B', 'M', 'C', 'B')\r
-\r
-typedef struct {\r
-  UINTN                           Signature;\r
-\r
-  //\r
-  // HII relative handles\r
-  //\r
-  EFI_HII_HANDLE                  HiiHandle;\r
-  EFI_HANDLE                      DriverHandle;\r
-\r
-  //\r
-  // Produced protocols\r
-  //\r
-  EFI_HII_CONFIG_ACCESS_PROTOCOL   ConfigAccess;\r
-} BOOT_MANAGER_CALLBACK_DATA;\r
-\r
-/**\r
-  This call back function is registered with Boot Manager formset.\r
-  When user selects a boot option, this call back function will\r
-  be triggered. The boot option is saved for later processing.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BootManagerCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  );\r
-\r
-/**\r
-\r
-  Registers HII packages for the Boot Manger to HII Database.\r
-  It also registers the browser call back function.\r
-\r
-  @retval  EFI_SUCCESS           HII packages for the Boot Manager were registered successfully.\r
-  @retval  EFI_OUT_OF_RESOURCES  HII packages for the Boot Manager failed to be registered.\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeBootManager (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function invokes Boot Manager. If all devices have not a chance to be connected,\r
-  the connect all will be triggered. It then enumerate all boot options. If\r
-  a boot option from the Boot Manager page is selected, Boot Manager will boot\r
-  from this boot option.\r
-\r
-**/\r
-VOID\r
-CallBootManager (\r
-  VOID\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManagerStrings.uni b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManagerStrings.uni
deleted file mode 100644 (file)
index f8efc67..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-///** @file\r
-//\r
-//    String definitions for BdsPlatform formset.\r
-//\r
-//  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-//**/\r
-\r
-/=#\r
-\r
-#langdef   en-US "English"\r
-#langdef   fr-FR "Français"\r
-\r
-#string STR_BM_BANNER                  #language en-US  "Boot Manager"\r
-                                       #language fr-FR  "Boot Manager"\r
-#string STR_HELP_FOOTER                #language en-US  "↑ and â†“ to change option, ENTER to select an option, ESC to exit"\r
-                                       #language fr-FR  "↑ pour â†“ changer l'option, ENTRER choisir une option, ESC pour sortir"\r
-#string STR_AND                        #language en-US  " and "\r
-                                       #language fr-FR  " et "\r
-#string STR_BOOT_OPTION_BANNER         #language en-US  "Boot Option Menu"\r
-                                       #language fr-FR  "le Menu d'Option de Botte"\r
-#string STR_ANY_KEY_CONTINUE           #language en-US  "Press any key to continue..."\r
-                                       #language fr-FR  "Appuie n'importe quelle pour continuer..."\r
-#string STR_LAST_STRING                #language en-US  ""\r
-                                       #language fr-FR  ""\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManagerVfr.Vfr b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManagerVfr.Vfr
deleted file mode 100644 (file)
index 5d4cf38..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-///** @file\r
-//  \r
-//    Browser formset.\r
-//  \r
-//  Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//  \r
-//**/\r
-\r
-#include <Guid/BdsHii.h>\r
-\r
-#define BOOT_MANAGER_FORM_ID     0x1000\r
-\r
-#define LABEL_BOOT_OPTION        0x00\r
-#define LABEL_BOOT_OPTION_END    0x01\r
-\r
-#define BOOT_MANAGER_CLASS       0x00\r
-#define BOOT_MANAGER_SUBCLASS    0x00\r
-\r
-formset\r
-  guid      = BOOT_MANAGER_FORMSET_GUID,\r
-  title     = STRING_TOKEN(STR_BM_BANNER),\r
-  help      = STRING_TOKEN(STR_LAST_STRING),\r
-  classguid = BOOT_MANAGER_FORMSET_GUID,\r
-\r
-  form formid = BOOT_MANAGER_FORM_ID,\r
-       title  = STRING_TOKEN(STR_BM_BANNER);\r
-\r
-    subtitle text = STRING_TOKEN(STR_LAST_STRING);\r
-    subtitle text = STRING_TOKEN(STR_BOOT_OPTION_BANNER);\r
-    subtitle text = STRING_TOKEN(STR_LAST_STRING);\r
-\r
-    //\r
-    // This is where we will dynamically add choices for the Boot Manager\r
-    //\r
-    label LABEL_BOOT_OPTION;\r
-    label LABEL_BOOT_OPTION_END;\r
-\r
-    subtitle text = STRING_TOKEN(STR_LAST_STRING);\r
-    subtitle text = STRING_TOKEN(STR_HELP_FOOTER);\r
-\r
-  endform;\r
-\r
-endformset;\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c b/IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c
deleted file mode 100644 (file)
index 0be2bae..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/** @file\r
-  BDS routines to handle capsules.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-#include "Bds.h"\r
-\r
-/**\r
-\r
-  This routine is called to see if there are any capsules we need to process.\r
-  If the boot mode is not UPDATE, then we do nothing. Otherwise find the\r
-  capsule HOBS and produce firmware volumes for them via the DXE service.\r
-  Then call the dispatcher to dispatch drivers from them. Finally, check\r
-  the status of the updates.\r
-\r
-  This function should be called by BDS in case we need to do some\r
-  sort of processing even if there is no capsule to process. We\r
-  need to do this if an earlier update went away and we need to\r
-  clear the capsule variable so on the next reset PEI does not see it and\r
-  think there is a capsule available.\r
-\r
-  @param BootMode                 the current boot mode\r
-\r
-  @retval EFI_INVALID_PARAMETER   boot mode is not correct for an update\r
-  @retval EFI_SUCCESS             There is no error when processing capsule\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsProcessCapsules (\r
-  EFI_BOOT_MODE BootMode\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_PEI_HOB_POINTERS        HobPointer;\r
-  EFI_CAPSULE_HEADER          *CapsuleHeader;\r
-  UINT32                      Size;\r
-  UINT32                      CapsuleNumber;\r
-  UINT32                      CapsuleTotalNumber;\r
-  EFI_CAPSULE_TABLE           *CapsuleTable;\r
-  UINT32                      Index;\r
-  UINT32                      CacheIndex;\r
-  UINT32                      CacheNumber;\r
-  VOID                        **CapsulePtr;\r
-  VOID                        **CapsulePtrCache;\r
-  EFI_GUID                    *CapsuleGuidCache;\r
-  BOOLEAN                     NeedReset;\r
-\r
-  CapsuleNumber      = 0;\r
-  CapsuleTotalNumber = 0;\r
-  CacheIndex         = 0;\r
-  CacheNumber        = 0;\r
-  CapsulePtr         = NULL;\r
-  CapsulePtrCache    = NULL;\r
-  CapsuleGuidCache   = NULL;\r
-  NeedReset          = FALSE;\r
-\r
-  //\r
-  // We don't do anything else if the boot mode is not flash-update\r
-  //\r
-  if (BootMode != BOOT_ON_FLASH_UPDATE) {\r
-    DEBUG ((EFI_D_ERROR, "Boot mode is not correct for capsule update.\n"));\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-  //\r
-  // Find all capsule images from hob\r
-  //\r
-  HobPointer.Raw = GetHobList ();\r
-  while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) != NULL) {\r
-    CapsuleTotalNumber ++;\r
-    HobPointer.Raw = GET_NEXT_HOB (HobPointer);\r
-  }\r
-\r
-  if (CapsuleTotalNumber == 0) {\r
-    //\r
-    // We didn't find a hob, so had no errors.\r
-    //\r
-    DEBUG ((EFI_D_ERROR, "We can not find capsule data in capsule update boot mode.\n"));\r
-    DEBUG ((EFI_D_ERROR, "Please check the followings are correct if unexpected capsule update error happens.\n"));\r
-    DEBUG ((EFI_D_ERROR, "1. CapsuleX64 is built as X64 module when PEI is IA32 and DXE is X64\n"));\r
-    DEBUG ((EFI_D_ERROR, "2. Capsule data should persist in memory across a system reset.\n"));\r
-    PlatformBdsLockNonUpdatableFlash ();\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Init temp Capsule Data table.\r
-  //\r
-  CapsulePtr       = (VOID **) AllocateZeroPool (sizeof (VOID *) * CapsuleTotalNumber);\r
-  ASSERT (CapsulePtr != NULL);\r
-  CapsulePtrCache  = (VOID **) AllocateZeroPool (sizeof (VOID *) * CapsuleTotalNumber);\r
-  ASSERT (CapsulePtrCache != NULL);\r
-  CapsuleGuidCache = (EFI_GUID *) AllocateZeroPool (sizeof (EFI_GUID) * CapsuleTotalNumber);\r
-  ASSERT (CapsuleGuidCache != NULL);\r
-\r
-  //\r
-  // Find all capsule images from hob\r
-  //\r
-  HobPointer.Raw = GetHobList ();\r
-  while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) != NULL) {\r
-    CapsulePtr [CapsuleNumber++] = (VOID *) (UINTN) HobPointer.Capsule->BaseAddress;\r
-    HobPointer.Raw = GET_NEXT_HOB (HobPointer);\r
-  }\r
-\r
-  //\r
-  //Check the capsule flags,if contains CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE, install\r
-  //capsuleTable to configure table with EFI_CAPSULE_GUID\r
-  //\r
-\r
-  //\r
-  // Capsules who have CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE always are used for operating\r
-  // System to have information persist across a system reset. EFI System Table must\r
-  // point to an array of capsules that contains the same CapsuleGuid value. And agents\r
-  // searching for this type capsule will look in EFI System Table and search for the\r
-  // capsule's Guid and associated pointer to retrieve the data. Two steps below describes\r
-  // how to sorting the capsules by the unique guid and install the array to EFI System Table.\r
-  // Firstly, Loop for all coalesced capsules, record unique CapsuleGuids and cache them in an\r
-  // array for later sorting capsules by CapsuleGuid.\r
-  //\r
-  for (Index = 0; Index < CapsuleTotalNumber; Index++) {\r
-    CapsuleHeader = (EFI_CAPSULE_HEADER*) CapsulePtr [Index];\r
-    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) {\r
-      //\r
-      // For each capsule, we compare it with known CapsuleGuid in the CacheArray.\r
-      // If already has the Guid, skip it. Whereas, record it in the CacheArray as\r
-      // an additional one.\r
-      //\r
-      CacheIndex = 0;\r
-      while (CacheIndex < CacheNumber) {\r
-        if (CompareGuid(&CapsuleGuidCache[CacheIndex],&CapsuleHeader->CapsuleGuid)) {\r
-          break;\r
-        }\r
-        CacheIndex++;\r
-      }\r
-      if (CacheIndex == CacheNumber) {\r
-        CopyMem(&CapsuleGuidCache[CacheNumber++],&CapsuleHeader->CapsuleGuid,sizeof(EFI_GUID));\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Secondly, for each unique CapsuleGuid in CacheArray, gather all coalesced capsules\r
-  // whose guid is the same as it, and malloc memory for an array which preceding\r
-  // with UINT32. The array fills with entry point of capsules that have the same\r
-  // CapsuleGuid, and UINT32 represents the size of the array of capsules. Then install\r
-  // this array into EFI System Table, so that agents searching for this type capsule\r
-  // will look in EFI System Table and search for the capsule's Guid and associated\r
-  // pointer to retrieve the data.\r
-  //\r
-  CacheIndex = 0;\r
-  while (CacheIndex < CacheNumber) {\r
-    CapsuleNumber = 0;\r
-    for (Index = 0; Index < CapsuleTotalNumber; Index++) {\r
-      CapsuleHeader = (EFI_CAPSULE_HEADER*) CapsulePtr [Index];\r
-      if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) {\r
-        if (CompareGuid (&CapsuleGuidCache[CacheIndex], &CapsuleHeader->CapsuleGuid)) {\r
-          //\r
-          // Cache Caspuleheader to the array, this array is uniqued with certain CapsuleGuid.\r
-          //\r
-          CapsulePtrCache[CapsuleNumber++] = (VOID*)CapsuleHeader;\r
-        }\r
-      }\r
-    }\r
-    if (CapsuleNumber != 0) {\r
-      Size = sizeof(EFI_CAPSULE_TABLE) + (CapsuleNumber - 1) * sizeof(VOID*);\r
-      CapsuleTable = AllocateRuntimePool (Size);\r
-      ASSERT (CapsuleTable != NULL);\r
-      CapsuleTable->CapsuleArrayNumber =  CapsuleNumber;\r
-      CopyMem(&CapsuleTable->CapsulePtr[0], CapsulePtrCache, CapsuleNumber * sizeof(VOID*));\r
-      Status = gBS->InstallConfigurationTable (&CapsuleGuidCache[CacheIndex], (VOID*)CapsuleTable);\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-    CacheIndex++;\r
-  }\r
-\r
-  //\r
-  // Besides ones with CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE flag, all capsules left are\r
-  // recognized by platform with CapsuleGuid. For general platform driver, UpdateFlash\r
-  // type is commonly supported, so here only deal with encapsuled FVs capsule. Additional\r
-  // type capsule transaction could be extended. It depends on platform policy.\r
-  //\r
-  for (Index = 0; Index < CapsuleTotalNumber; Index++) {\r
-    CapsuleHeader = (EFI_CAPSULE_HEADER*) CapsulePtr [Index];\r
-    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {\r
-      //\r
-      // Always reset system after all capsule processed if FMP capsule exist\r
-      //\r
-      if (CompareGuid (&gEfiFmpCapsuleGuid, &CapsuleHeader->CapsuleGuid)){\r
-        NeedReset = TRUE;\r
-      }\r
-\r
-      //\r
-      // Call capsule library to process capsule image.\r
-      //\r
-      ProcessCapsuleImage (CapsuleHeader);\r
-    }\r
-  }\r
-\r
-  if (NeedReset) {\r
-    Print(L"Capsule Request Cold Reboot.\n");\r
-\r
-    for (Index = 5; Index > 0; Index--) {\r
-      Print(L"\rResetting system in %d seconds ...", Index);\r
-      gBS->Stall (1000000);\r
-    }\r
-\r
-    gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
-\r
-    CpuDeadLoop ();\r
-  }\r
-\r
-  PlatformBdsLockNonUpdatableFlash ();\r
-\r
-  //\r
-  // Free the allocated temp memory space.\r
-  //\r
-  FreePool (CapsuleGuidCache);\r
-  FreePool (CapsulePtrCache);\r
-  FreePool (CapsulePtr);\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
deleted file mode 100644 (file)
index 7ae8c73..0000000
+++ /dev/null
@@ -1,2599 +0,0 @@
-/** @file\r
-  The platform device manager reference implementation\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "DeviceManager.h"\r
-\r
-DEVICE_MANAGER_CALLBACK_DATA  gDeviceManagerPrivate = {\r
-  DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE,\r
-  NULL,\r
-  NULL,\r
-  NULL,\r
-  NULL,\r
-  {\r
-    FakeExtractConfig,\r
-    FakeRouteConfig,\r
-    DeviceManagerCallback\r
-  },\r
-  {\r
-    FakeExtractConfig,\r
-    FakeRouteConfig,\r
-    DriverHealthCallback\r
-  }\r
-};\r
-\r
-#define  MAX_MAC_ADDRESS_NODE_LIST_LEN    10\r
-\r
-//\r
-// Which Mac Address string is select\r
-// it will decide what menu need to show in the NETWORK_DEVICE_FORM_ID form.\r
-//\r
-EFI_STRING  mSelectedMacAddrString;\r
-\r
-//\r
-// Which form Id need to be show.\r
-//\r
-EFI_FORM_ID      mNextShowFormId = DEVICE_MANAGER_FORM_ID;\r
-\r
-//\r
-// The Mac Address show in the NETWORK_DEVICE_LIST_FORM_ID\r
-//\r
-MAC_ADDRESS_NODE_LIST  mMacDeviceList;\r
-\r
-DEVICE_MANAGER_MENU_ITEM  mDeviceManagerMenuItemTable[] = {\r
-  { STRING_TOKEN (STR_DISK_DEVICE),     EFI_DISK_DEVICE_CLASS },\r
-  { STRING_TOKEN (STR_VIDEO_DEVICE),    EFI_VIDEO_DEVICE_CLASS },\r
-  { STRING_TOKEN (STR_NETWORK_DEVICE),  EFI_NETWORK_DEVICE_CLASS },\r
-  { STRING_TOKEN (STR_INPUT_DEVICE),    EFI_INPUT_DEVICE_CLASS },\r
-  { STRING_TOKEN (STR_ON_BOARD_DEVICE), EFI_ON_BOARD_DEVICE_CLASS },\r
-  { STRING_TOKEN (STR_OTHER_DEVICE),    EFI_OTHER_DEVICE_CLASS }\r
-};\r
-\r
-HII_VENDOR_DEVICE_PATH  mDeviceManagerHiiVendorDevicePath = {\r
-  {\r
-    {\r
-      HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,\r
-      {\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    DEVICE_MANAGER_FORMSET_GUID\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      (UINT8) (END_DEVICE_PATH_LENGTH),\r
-      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
-    }\r
-  }\r
-};\r
-\r
-HII_VENDOR_DEVICE_PATH  mDriverHealthHiiVendorDevicePath = {\r
-  {\r
-    {\r
-      HARDWARE_DEVICE_PATH,\r
-        HW_VENDOR_DP,\r
-      {\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-          (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    DRIVER_HEALTH_FORMSET_GUID\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-      END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      (UINT8) (END_DEVICE_PATH_LENGTH),\r
-        (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
-    }\r
-  }\r
-};\r
-\r
-/**\r
-  This function is invoked if user selected a interactive opcode from Device Manager's\r
-  Formset. The decision by user is saved to gCallbackKey for later processing. If\r
-  user set VBIOS, the new value is saved to EFI variable.\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceManagerCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  )\r
-{\r
-  UINTN CurIndex;\r
-\r
-  if (Action != EFI_BROWSER_ACTION_CHANGING) {\r
-    //\r
-    // All other action return unsupported.\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (Value == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  gCallbackKey = QuestionId;\r
-  if ((QuestionId < MAX_KEY_SECTION_LEN + NETWORK_DEVICE_LIST_KEY_OFFSET) && (QuestionId >= NETWORK_DEVICE_LIST_KEY_OFFSET)) {\r
-    //\r
-    // If user select the mac address, need to record mac address string to support next form show.\r
-    //\r
-    for (CurIndex = 0; CurIndex < mMacDeviceList.CurListLen; CurIndex ++) {\r
-      if (mMacDeviceList.NodeList[CurIndex].QuestionId == QuestionId) {\r
-         mSelectedMacAddrString = HiiGetString (gDeviceManagerPrivate.HiiHandle, mMacDeviceList.NodeList[CurIndex].PromptId, NULL);\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  This function registers HII packages to HII database.\r
-\r
-  @retval  EFI_SUCCESS           HII packages for the Device Manager were registered successfully.\r
-  @retval  EFI_OUT_OF_RESOURCES  HII packages for the Device Manager failed to be registered.\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeDeviceManager (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-\r
-  //\r
-  // Install Device Path Protocol and Config Access protocol to driver handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &gDeviceManagerPrivate.DriverHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  &mDeviceManagerHiiVendorDevicePath,\r
-                  &gEfiHiiConfigAccessProtocolGuid,\r
-                  &gDeviceManagerPrivate.ConfigAccess,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &gDeviceManagerPrivate.DriverHealthHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  &mDriverHealthHiiVendorDevicePath,\r
-                  &gEfiHiiConfigAccessProtocolGuid,\r
-                  &gDeviceManagerPrivate.DriverHealthConfigAccess,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  mMacDeviceList.CurListLen = 0;\r
-  mMacDeviceList.MaxListLen = 0;\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Extract the displayed formset for given HII handle and class guid.\r
-\r
-  @param Handle          The HII handle.\r
-  @param SetupClassGuid  The class guid specifies which form set will be displayed.\r
-  @param SkipCount       Skip some formsets which has processed before.\r
-  @param FormSetTitle    Formset title string.\r
-  @param FormSetHelp     Formset help string.\r
-  @param FormSetGuid     Return the formset guid for this formset.\r
-\r
-  @retval  TRUE          The formset for given HII handle will be displayed.\r
-  @return  FALSE         The formset for given HII handle will not be displayed.\r
-\r
-**/\r
-BOOLEAN\r
-ExtractDisplayedHiiFormFromHiiHandle (\r
-  IN      EFI_HII_HANDLE      Handle,\r
-  IN      EFI_GUID            *SetupClassGuid,\r
-  IN      UINTN               SkipCount,\r
-  OUT     EFI_STRING_ID       *FormSetTitle,\r
-  OUT     EFI_STRING_ID       *FormSetHelp,\r
-  OUT     EFI_GUID            **FormSetGuid\r
-  )\r
-{\r
-  EFI_STATUS                   Status;\r
-  UINTN                        BufferSize;\r
-  EFI_HII_PACKAGE_LIST_HEADER  *HiiPackageList;\r
-  UINT8                        *Package;\r
-  UINT8                        *OpCodeData;\r
-  UINT32                       Offset;\r
-  UINT32                       Offset2;\r
-  UINT32                       PackageListLength;\r
-  EFI_HII_PACKAGE_HEADER       PackageHeader;\r
-  EFI_GUID                     *ClassGuid;\r
-  UINT8                        ClassGuidNum;\r
-\r
-  ASSERT (Handle != NULL);\r
-  ASSERT (SetupClassGuid != NULL);\r
-  ASSERT (FormSetTitle != NULL);\r
-  ASSERT (FormSetHelp != NULL);\r
-\r
-  *FormSetTitle = 0;\r
-  *FormSetHelp  = 0;\r
-  ClassGuidNum  = 0;\r
-  ClassGuid     = NULL;\r
-\r
-  //\r
-  // Get HII PackageList\r
-  //\r
-  BufferSize = 0;\r
-  HiiPackageList = NULL;\r
-  Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);\r
-  //\r
-  // Handle is a invalid handle. Check if Handle is corrupted.\r
-  //\r
-  ASSERT (Status != EFI_NOT_FOUND);\r
-  //\r
-  // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.\r
-  //\r
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
-\r
-  HiiPackageList = AllocatePool (BufferSize);\r
-  ASSERT (HiiPackageList != NULL);\r
-\r
-  Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Get Form package from this HII package List\r
-  //\r
-  Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
-  Offset2 = 0;\r
-  PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);\r
-\r
-  while (Offset < PackageListLength) {\r
-    Package = ((UINT8 *) HiiPackageList) + Offset;\r
-    CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));\r
-\r
-    if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {\r
-      //\r
-      // Search FormSet Opcode in this Form Package\r
-      //\r
-      Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);\r
-      while (Offset2 < PackageHeader.Length) {\r
-        OpCodeData = Package + Offset2;\r
-        Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;\r
-\r
-        if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {\r
-          if (SkipCount != 0) {\r
-            SkipCount --;\r
-            continue;\r
-          }\r
-\r
-          if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {\r
-            //\r
-            // Find FormSet OpCode\r
-            //\r
-            ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);\r
-            ClassGuid = (EFI_GUID *) (VOID *)(OpCodeData + sizeof (EFI_IFR_FORM_SET));\r
-            while (ClassGuidNum-- > 0) {\r
-              if (CompareGuid (SetupClassGuid, ClassGuid)) {\r
-                CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));\r
-                CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));\r
-                *FormSetGuid = AllocateCopyPool (sizeof (EFI_GUID), &((EFI_IFR_FORM_SET *) OpCodeData)->Guid);\r
-                ASSERT (*FormSetGuid != NULL);\r
-                FreePool (HiiPackageList);\r
-                return TRUE;\r
-              }\r
-              ClassGuid ++;\r
-            }\r
-           } else {\r
-             CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));\r
-             CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));\r
-             *FormSetGuid = AllocateCopyPool (sizeof (EFI_GUID), &((EFI_IFR_FORM_SET *) OpCodeData)->Guid);\r
-             ASSERT (*FormSetGuid != NULL);\r
-             FreePool (HiiPackageList);\r
-             return TRUE;\r
-          }\r
-        }\r
-      }\r
-    }\r
-\r
-    //\r
-    // Go to next package\r
-    //\r
-    Offset += PackageHeader.Length;\r
-  }\r
-\r
-  FreePool (HiiPackageList);\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Get the mac address string from the device path.\r
-  if the device path has the vlan, get the vanid also.\r
-\r
-  @param MacAddressNode              Device path begin with mac address\r
-  @param PBuffer                     Output string buffer contain mac address.\r
-\r
-**/\r
-BOOLEAN\r
-GetMacAddressString(\r
-  IN  MAC_ADDR_DEVICE_PATH   *MacAddressNode,\r
-  OUT CHAR16                 **PBuffer\r
-  )\r
-{\r
-  UINTN                 HwAddressSize;\r
-  UINTN                 Index;\r
-  UINT8                 *HwAddress;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
-  UINT16                VlanId;\r
-  CHAR16                *String;\r
-  UINTN                 BufferLen;\r
-\r
-  VlanId = 0;\r
-  String = NULL;\r
-  ASSERT(MacAddressNode != NULL);\r
-\r
-  HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
-  if (MacAddressNode->IfType == 0x01 || MacAddressNode->IfType == 0x00) {\r
-    HwAddressSize = 6;\r
-  }\r
-\r
-  //\r
-  // The output format is MAC:XX:XX:XX:...\XXXX\r
-  // The size is the Number size + ":" size + Vlan size(\XXXX) + End\r
-  //\r
-  BufferLen = (4 + 2 * HwAddressSize + (HwAddressSize - 1) + 5 + 1) * sizeof (CHAR16);\r
-  String = AllocateZeroPool (BufferLen);\r
-  if (String == NULL) {\r
-    return FALSE;\r
-  }\r
-\r
-  *PBuffer = String;\r
-  StrCpyS (String, BufferLen / sizeof (CHAR16), L"MAC:");\r
-  String += 4;\r
-\r
-  //\r
-  // Convert the MAC address into a unicode string.\r
-  //\r
-  HwAddress = &MacAddressNode->MacAddress.Addr[0];\r
-  for (Index = 0; Index < HwAddressSize; Index++) {\r
-    UnicodeValueToStringS (\r
-      String,\r
-      BufferLen - ((UINTN)String - (UINTN)*PBuffer),\r
-      PREFIX_ZERO | RADIX_HEX,\r
-      *(HwAddress++),\r
-      2\r
-      );\r
-    String += StrnLenS (String, (BufferLen - ((UINTN)String - (UINTN)*PBuffer)) / sizeof (CHAR16));\r
-    if (Index < HwAddressSize - 1) {\r
-      *String++ = L':';\r
-    }\r
-  }\r
-\r
-  //\r
-  // If VLAN is configured, it will need extra 5 characters like "\0005".\r
-  // Plus one unicode character for the null-terminator.\r
-  //\r
-  Node = (EFI_DEVICE_PATH_PROTOCOL  *)MacAddressNode;\r
-  while (!IsDevicePathEnd (Node)) {\r
-    if (Node->Type == MESSAGING_DEVICE_PATH && Node->SubType == MSG_VLAN_DP) {\r
-      VlanId = ((VLAN_DEVICE_PATH *) Node)->VlanId;\r
-    }\r
-    Node = NextDevicePathNode (Node);\r
-  }\r
-\r
-  if (VlanId != 0) {\r
-    *String++ = L'\\';\r
-    UnicodeValueToStringS (\r
-      String,\r
-      BufferLen - ((UINTN)String - (UINTN)*PBuffer),\r
-      PREFIX_ZERO | RADIX_HEX,\r
-      VlanId,\r
-      4\r
-      );\r
-    String += StrnLenS (String, (BufferLen - ((UINTN)String - (UINTN)*PBuffer)) / sizeof (CHAR16));\r
-  }\r
-\r
-  //\r
-  // Null terminate the Unicode string\r
-  //\r
-  *String = L'\0';\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Save question id and prompt id to the mac device list.\r
-  If the same mac address has saved yet, no need to add more.\r
-\r
-  @param MacAddrString               Mac address string.\r
-\r
-  @retval  EFI_SUCCESS               Add the item is successful.\r
-  @return  Other values if failed to Add the item.\r
-**/\r
-BOOLEAN\r
-AddIdToMacDeviceList (\r
-  IN  EFI_STRING        MacAddrString\r
-  )\r
-{\r
-  MENU_INFO_ITEM *TempDeviceList;\r
-  UINTN          Index;\r
-  EFI_STRING     StoredString;\r
-  EFI_STRING_ID  PromptId;\r
-  EFI_HII_HANDLE HiiHandle;\r
-\r
-  HiiHandle =   gDeviceManagerPrivate.HiiHandle;\r
-  TempDeviceList = NULL;\r
-\r
-  for (Index = 0; Index < mMacDeviceList.CurListLen; Index ++) {\r
-    StoredString = HiiGetString (HiiHandle, mMacDeviceList.NodeList[Index].PromptId, NULL);\r
-    if (StoredString == NULL) {\r
-      return FALSE;\r
-    }\r
-\r
-    //\r
-    // Already has save the same mac address to the list.\r
-    //\r
-    if (StrCmp (MacAddrString, StoredString) == 0) {\r
-      return FALSE;\r
-    }\r
-  }\r
-\r
-  PromptId = HiiSetString(HiiHandle, 0, MacAddrString, NULL);\r
-  //\r
-  // If not in the list, save it.\r
-  //\r
-  if (mMacDeviceList.MaxListLen > mMacDeviceList.CurListLen + 1) {\r
-    mMacDeviceList.NodeList[mMacDeviceList.CurListLen].PromptId = PromptId;\r
-    mMacDeviceList.NodeList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) (mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);\r
-  } else {\r
-    mMacDeviceList.MaxListLen += MAX_MAC_ADDRESS_NODE_LIST_LEN;\r
-    if (mMacDeviceList.CurListLen != 0) {\r
-      TempDeviceList = ReallocatePool (\r
-                         sizeof (MENU_INFO_ITEM) * mMacDeviceList.CurListLen,\r
-                         sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen,\r
-                         mMacDeviceList.NodeList\r
-                         );\r
-    } else {\r
-      TempDeviceList = (MENU_INFO_ITEM *)AllocatePool (sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen);\r
-    }\r
-\r
-    if (TempDeviceList == NULL) {\r
-      return FALSE;\r
-    }\r
-    TempDeviceList[mMacDeviceList.CurListLen].PromptId = PromptId;\r
-    TempDeviceList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) (mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);\r
-\r
-    mMacDeviceList.NodeList = TempDeviceList;\r
-  }\r
-  mMacDeviceList.CurListLen ++;\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Check the devcie path, try to find whether it has mac address path.\r
-\r
-  In this function, first need to check whether this path has mac address path.\r
-  second, when the mac address device path has find, also need to deicide whether\r
-  need to add this mac address relate info to the menu.\r
-\r
-  @param    *Node           Input device which need to be check.\r
-  @param    *NeedAddItem    Whether need to add the menu in the network device list.\r
-\r
-  @retval  TRUE             Has mac address device path.\r
-  @retval  FALSE            NOT Has mac address device path.\r
-\r
-**/\r
-BOOLEAN\r
-IsMacAddressDevicePath (\r
-  IN  VOID    *Node,\r
-  OUT BOOLEAN *NeedAddItem\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL   *DevicePath;\r
-  CHAR16                     *Buffer;\r
-  BOOLEAN                    ReturnVal;\r
-\r
-  ASSERT (Node != NULL);\r
-  *NeedAddItem = FALSE;\r
-  ReturnVal    = FALSE;\r
-  Buffer    = NULL;\r
-\r
-  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node;\r
-\r
-  //\r
-  // find the partition device path node\r
-  //\r
-  while (!IsDevicePathEnd (DevicePath)) {\r
-    if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&\r
-       (DevicePathSubType (DevicePath) == MSG_MAC_ADDR_DP)) {\r
-      ReturnVal = TRUE;\r
-\r
-      if (DEVICE_MANAGER_FORM_ID == mNextShowFormId) {\r
-        *NeedAddItem = TRUE;\r
-        break;\r
-      }\r
-\r
-      if (!GetMacAddressString((MAC_ADDR_DEVICE_PATH*)DevicePath, &Buffer)) {\r
-        break;\r
-      }\r
-\r
-      if (NETWORK_DEVICE_FORM_ID == mNextShowFormId) {\r
-        if (StrCmp (Buffer, mSelectedMacAddrString) == 0) {\r
-          *NeedAddItem = TRUE;\r
-        }\r
-        break;\r
-      }\r
-\r
-      if (NETWORK_DEVICE_LIST_FORM_ID == mNextShowFormId) {\r
-        //\r
-        // Same handle may has two network child handle, so the questionid\r
-        // has the offset of SAME_HANDLE_KEY_OFFSET.\r
-        //\r
-        if (AddIdToMacDeviceList (Buffer)) {\r
-          *NeedAddItem = TRUE;\r
-        }\r
-        break;\r
-      }\r
-    }\r
-    DevicePath = NextDevicePathNode (DevicePath);\r
-  }\r
-\r
-  if (Buffer != NULL) {\r
-    FreePool (Buffer);\r
-  }\r
-\r
-  return ReturnVal;\r
-}\r
-\r
-/**\r
-  Check to see if the device path is for the network device.\r
-\r
-  @param Handle          The HII handle which include the mac address device path.\r
-  @param ItemCount       The new add Mac address item count.\r
-\r
-  @retval  TRUE          Need to add new item in the menu.\r
-  @return  FALSE         Do not need to add the menu about the network.\r
-\r
-**/\r
-BOOLEAN\r
-IsNeedAddNetworkMenu (\r
-  IN      EFI_HII_HANDLE      Handle,\r
-  OUT     UINTN               *ItemCount\r
-  )\r
-{\r
-  EFI_STATUS     Status;\r
-  UINTN          EntryCount;\r
-  UINTN          Index;\r
-  EFI_HANDLE     DriverHandle;\r
-  EFI_HANDLE     ControllerHandle;\r
-  EFI_DEVICE_PATH_PROTOCOL   *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL   *TmpDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL   *ChildDevicePath;\r
-  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY   *OpenInfoBuffer;\r
-  BOOLEAN        IsNeedAdd;\r
-\r
-  IsNeedAdd  = FALSE;\r
-  OpenInfoBuffer = NULL;\r
-  if ((Handle == NULL) || (ItemCount == NULL)) {\r
-    return FALSE;\r
-  }\r
-  *ItemCount = 0;\r
-\r
-  Status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, Handle, &DriverHandle);\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-  //\r
-  // Get the device path by the got Driver handle .\r
-  //\r
-  Status = gBS->HandleProtocol (DriverHandle, &gEfiDevicePathProtocolGuid, (VOID **) &DevicePath);\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-  TmpDevicePath = DevicePath;\r
-\r
-  //\r
-  // Check whether this device path include mac address device path.\r
-  // If this path has mac address path, get the value whether need\r
-  // add this info to the menu and return.\r
-  // Else check more about the child handle devcie path.\r
-  //\r
-  if (IsMacAddressDevicePath(TmpDevicePath, &IsNeedAdd)) {\r
-    if ((NETWORK_DEVICE_LIST_FORM_ID == mNextShowFormId) && IsNeedAdd) {\r
-      (*ItemCount) = 1;\r
-    }\r
-    return IsNeedAdd;\r
-  }\r
-\r
-  //\r
-  // Search whether this path is the controller path, not he child handle path.\r
-  // And the child handle has the network devcie connected.\r
-  //\r
-  TmpDevicePath = DevicePath;\r
-  Status = gBS->LocateDevicePath(&gEfiDevicePathProtocolGuid, &TmpDevicePath, &ControllerHandle);\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if (!IsDevicePathEnd (TmpDevicePath)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Retrieve the list of agents that are consuming the specific protocol\r
-  // on ControllerHandle.\r
-  // The buffer point by OpenInfoBuffer need be free at this function.\r
-  //\r
-  Status = gBS->OpenProtocolInformation (\r
-                  ControllerHandle,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  &OpenInfoBuffer,\r
-                  &EntryCount\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Inspect if ChildHandle is one of the agents.\r
-  //\r
-  Status = EFI_UNSUPPORTED;\r
-  for (Index = 0; Index < EntryCount; Index++) {\r
-    //\r
-    // Query all the children created by the controller handle's driver\r
-    //\r
-    if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
-      Status = gBS->OpenProtocol (\r
-                      OpenInfoBuffer[Index].ControllerHandle,\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      (VOID **) &ChildDevicePath,\r
-                      NULL,\r
-                      NULL,\r
-                      EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        continue;\r
-      }\r
-\r
-      //\r
-      // Check whether this device path include mac address device path.\r
-      //\r
-      if (!IsMacAddressDevicePath(ChildDevicePath, &IsNeedAdd)) {\r
-        //\r
-        // If this path not has mac address path, check the other.\r
-        //\r
-        continue;\r
-      } else {\r
-        //\r
-        // If need to update the NETWORK_DEVICE_LIST_FORM, try to get more.\r
-        //\r
-        if ((NETWORK_DEVICE_LIST_FORM_ID == mNextShowFormId)) {\r
-          if (IsNeedAdd) {\r
-            (*ItemCount) += 1;\r
-          }\r
-          continue;\r
-        } else {\r
-          //\r
-          // If need to update other form, return whether need to add to the menu.\r
-          //\r
-          goto Done;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-Done:\r
-  if (OpenInfoBuffer != NULL) {\r
-    FreePool (OpenInfoBuffer);\r
-  }\r
-  return IsNeedAdd;\r
-}\r
-\r
-/**\r
-  Get HiiHandle total number.\r
-\r
-  @param   HiiHandles              The input HiiHandle array.\r
-\r
-  @retval  the Hiihandle count.\r
-\r
-**/\r
-UINTN\r
-GetHiiHandleCount (\r
-  IN EFI_HII_HANDLE              *HiiHandles\r
-  )\r
-{\r
-  UINTN  Index;\r
-\r
-  for (Index = 0; HiiHandles[Index] != NULL; Index++) {\r
-  }\r
-\r
-  return Index;\r
-}\r
-\r
-/**\r
-  Insert the new HiiHandle + FormsetGuid at the NewPair[InsertOffset].\r
-\r
-  @param   HiiHandles              The input HiiHandle array.\r
-  @param   GuidLists               The input form set guid lists.\r
-  @param   ArrayCount              The input array count, new array will be arraycount + 1 size.\r
-  @param   Offset                  The current used HiiHandle's Offset.\r
-  @param   FormSetGuid             The new found formset guid.\r
-\r
-**/\r
-VOID\r
-AdjustArrayData (\r
-  IN OUT EFI_HII_HANDLE              **HiiHandles,\r
-  IN OUT EFI_GUID                    ***GuidLists,\r
-  IN     UINTN                       ArrayCount,\r
-  IN     UINTN                       Offset,\r
-  IN     EFI_GUID                    *FormSetGuid\r
-  )\r
-{\r
-  EFI_HII_HANDLE              *NewHiiHandles;\r
-  EFI_GUID                    **NewGuidLists;\r
-\r
-  //\r
-  // +2 means include the new HiiHandle and the last empty NULL pointer.\r
-  //\r
-  NewHiiHandles = AllocateZeroPool ((ArrayCount + 2) * sizeof (EFI_HII_HANDLE));\r
-  ASSERT (NewHiiHandles != NULL);\r
-\r
-  CopyMem (NewHiiHandles, *HiiHandles, Offset * sizeof (EFI_HII_HANDLE));\r
-  NewHiiHandles[Offset] = NewHiiHandles[Offset - 1];\r
-  CopyMem (NewHiiHandles + Offset + 1, *HiiHandles + Offset, (ArrayCount - Offset) * sizeof (EFI_HII_HANDLE));\r
-\r
-  NewGuidLists = AllocateZeroPool ((ArrayCount + 2) * sizeof (EFI_GUID *));\r
-  ASSERT (NewGuidLists != NULL);\r
-\r
-  CopyMem (NewGuidLists, *GuidLists, Offset * sizeof (EFI_GUID *));\r
-  NewGuidLists[Offset] = FormSetGuid;\r
-\r
-  FreePool (*HiiHandles);\r
-  *HiiHandles = NewHiiHandles;\r
-  FreePool (*GuidLists);\r
-  *GuidLists = NewGuidLists;\r
-}\r
-\r
-/**\r
-  Call the browser and display the device manager to allow user\r
-  to configure the platform.\r
-\r
-  This function create the dynamic content for device manager. It includes\r
-  section header for all class of devices, one-of opcode to set VBIOS.\r
-\r
-  @retval  EFI_SUCCESS             Operation is successful.\r
-  @return  Other values if failed to clean up the dynamic content from HII\r
-           database.\r
-\r
-**/\r
-EFI_STATUS\r
-CallDeviceManager (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  UINTN                       Index;\r
-  EFI_STRING                  String;\r
-  EFI_STRING_ID               Token;\r
-  EFI_STRING_ID               TokenHelp;\r
-  EFI_HII_HANDLE              *HiiHandles;\r
-  EFI_HII_HANDLE              HiiHandle;\r
-  EFI_STRING_ID               FormSetTitle;\r
-  EFI_STRING_ID               FormSetHelp;\r
-  EFI_BROWSER_ACTION_REQUEST  ActionRequest;\r
-  VOID                        *StartOpCodeHandle;\r
-  VOID                        *EndOpCodeHandle;\r
-  EFI_IFR_GUID_LABEL          *StartLabel;\r
-  EFI_IFR_GUID_LABEL          *EndLabel;\r
-  UINTN                       NumHandles;\r
-  EFI_HANDLE                  *DriverHealthHandles;\r
-  BOOLEAN                     AddNetworkMenu;\r
-  UINTN                       AddItemCount;\r
-  UINTN                       NewStringLen;\r
-  EFI_STRING                  NewStringTitle;\r
-  EFI_GUID                    **GuidLists;\r
-  UINTN                       HandleNum;\r
-  UINTN                       SkipCount;\r
-  EFI_GUID                    *FormSetGuid;\r
-\r
-  GuidLists     = NULL;\r
-  HiiHandles    = NULL;\r
-  Status        = EFI_SUCCESS;\r
-  gCallbackKey  = 0;\r
-  NumHandles    = 0;\r
-  DriverHealthHandles = NULL;\r
-  AddNetworkMenu = FALSE;\r
-  AddItemCount   = 0;\r
-  SkipCount      = 0;\r
-  FormSetGuid    = NULL;\r
-\r
-  //\r
-  // Connect all prior to entering the platform setup menu.\r
-  //\r
-  if (!gConnectAllHappened) {\r
-    BdsLibConnectAllDriversToAllControllers ();\r
-    gConnectAllHappened = TRUE;\r
-  }\r
-\r
-  HiiHandle = gDeviceManagerPrivate.HiiHandle;\r
-  if (HiiHandle == NULL) {\r
-    //\r
-    // Publish our HII data.\r
-    //\r
-    HiiHandle = HiiAddPackages (\r
-                  &gDeviceManagerFormSetGuid,\r
-                  gDeviceManagerPrivate.DriverHandle,\r
-                  DeviceManagerVfrBin,\r
-                  BdsDxeStrings,\r
-                  NULL\r
-                  );\r
-    if (HiiHandle == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    gDeviceManagerPrivate.HiiHandle = HiiHandle;\r
-  }\r
-\r
-  //\r
-  // If need show the Network device list form, clear the old save list first.\r
-  //\r
-  if ((mNextShowFormId == NETWORK_DEVICE_LIST_FORM_ID) && (mMacDeviceList.CurListLen > 0)) {\r
-    mMacDeviceList.CurListLen = 0;\r
-  }\r
-\r
-  //\r
-  // Update the network device form titile.\r
-  //\r
-  if (mNextShowFormId == NETWORK_DEVICE_FORM_ID) {\r
-    String = HiiGetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), NULL);\r
-    NewStringLen = StrLen(mSelectedMacAddrString) * 2;\r
-    NewStringLen += (StrLen(String) + 2) * 2;\r
-    NewStringTitle = AllocatePool (NewStringLen);\r
-    UnicodeSPrint (NewStringTitle, NewStringLen, L"%s %s", String, mSelectedMacAddrString);\r
-    HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), NewStringTitle, NULL);\r
-    FreePool (String);\r
-    FreePool (NewStringTitle);\r
-  }\r
-\r
-  //\r
-  // Allocate space for creation of UpdateData Buffer\r
-  //\r
-  StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (StartOpCodeHandle != NULL);\r
-\r
-  EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (EndOpCodeHandle != NULL);\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  //\r
-  // According to the next show Form id(mNextShowFormId) to decide which form need to update.\r
-  //\r
-  StartLabel->Number       = (UINT16) (LABEL_FORM_ID_OFFSET + mNextShowFormId);\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the end opcode\r
-  //\r
-  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  EndLabel->Number       = LABEL_END;\r
-\r
-  //\r
-  // Get all the Hii handles\r
-  //\r
-  HiiHandles = HiiGetHiiHandles (NULL);\r
-  ASSERT (HiiHandles != NULL);\r
-\r
-  HandleNum = GetHiiHandleCount (HiiHandles);\r
-  GuidLists = AllocateZeroPool ((HandleNum + 1) * sizeof (EFI_GUID *));\r
-  ASSERT (GuidLists != NULL);\r
-\r
-  //\r
-  // Search for formset of each class type\r
-  //\r
-  for (Index = 0; HiiHandles[Index] != NULL; Index++) {\r
-    //\r
-    //  The QuestionId in the form which will call the driver form has this asssumption.\r
-    //  QuestionId = Handle Index + NETWORK_DEVICE_LIST_KEY_OFFSET;\r
-    //  Different QuestionId at least has the section of NETWORK_DEVICE_LIST_KEY_OFFSET.\r
-    //\r
-    ASSERT(Index < MAX_KEY_SECTION_LEN);\r
-\r
-    if (!ExtractDisplayedHiiFormFromHiiHandle (HiiHandles[Index], &gEfiHiiPlatformSetupFormsetGuid, SkipCount, &FormSetTitle, &FormSetHelp, &FormSetGuid)) {\r
-      SkipCount = 0;\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // One HiiHandle has more than one formset can be shown,\r
-    // Insert a new pair of HiiHandle + Guid to the HiiHandles and GuidLists list.\r
-    //\r
-    if (SkipCount > 0) {\r
-      AdjustArrayData (&HiiHandles, &GuidLists, HandleNum, Index + 1, FormSetGuid);\r
-      HandleNum ++;\r
-      Index ++;\r
-    }\r
-\r
-    String = HiiGetString (HiiHandles[Index], FormSetTitle, NULL);\r
-    if (String == NULL) {\r
-      String = HiiGetString (HiiHandle, STR_MISSING_STRING, NULL);\r
-      ASSERT (String != NULL);\r
-    }\r
-    Token = HiiSetString (HiiHandle, 0, String, NULL);\r
-    FreePool (String);\r
-\r
-    String = HiiGetString (HiiHandles[Index], FormSetHelp, NULL);\r
-    if (String == NULL) {\r
-      String = HiiGetString (HiiHandle, STR_MISSING_STRING, NULL);\r
-      ASSERT (String != NULL);\r
-    }\r
-    TokenHelp = HiiSetString (HiiHandle, 0, String, NULL);\r
-    FreePool (String);\r
-\r
-    //\r
-    // Network device process\r
-    //\r
-    if (IsNeedAddNetworkMenu (HiiHandles[Index], &AddItemCount)) {\r
-      if (mNextShowFormId == DEVICE_MANAGER_FORM_ID) {\r
-        //\r
-        // Only show one menu item "Network Config" in the device manger form.\r
-        //\r
-        if (!AddNetworkMenu) {\r
-          AddNetworkMenu = TRUE;\r
-          HiiCreateGotoOpCode (\r
-            StartOpCodeHandle,\r
-            INVALID_FORM_ID,\r
-            STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_TITLE),\r
-            STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_HELP),\r
-            EFI_IFR_FLAG_CALLBACK,\r
-            (EFI_QUESTION_ID) QUESTION_NETWORK_DEVICE_ID\r
-            );\r
-        }\r
-      } else if (mNextShowFormId == NETWORK_DEVICE_LIST_FORM_ID) {\r
-        //\r
-        // In network device list form, same mac address device only show one menu.\r
-        //\r
-        while (AddItemCount > 0) {\r
-            HiiCreateGotoOpCode (\r
-              StartOpCodeHandle,\r
-              INVALID_FORM_ID,\r
-              mMacDeviceList.NodeList[mMacDeviceList.CurListLen - AddItemCount].PromptId,\r
-              STRING_TOKEN (STR_NETWORK_DEVICE_HELP),\r
-              EFI_IFR_FLAG_CALLBACK,\r
-              mMacDeviceList.NodeList[mMacDeviceList.CurListLen - AddItemCount].QuestionId\r
-              );\r
-            AddItemCount -= 1;\r
-          }\r
-      } else if (mNextShowFormId == NETWORK_DEVICE_FORM_ID) {\r
-        //\r
-        // In network device form, only the selected mac address device need to be show.\r
-        //\r
-        HiiCreateGotoOpCode (\r
-          StartOpCodeHandle,\r
-          INVALID_FORM_ID,\r
-          Token,\r
-          TokenHelp,\r
-          EFI_IFR_FLAG_CALLBACK,\r
-          (EFI_QUESTION_ID) (Index + DEVICE_KEY_OFFSET)\r
-          );\r
-      }\r
-    } else {\r
-      //\r
-      //\r
-      // Not network device process, only need to show at device manger form.\r
-      //\r
-      if (mNextShowFormId == DEVICE_MANAGER_FORM_ID) {\r
-        HiiCreateGotoOpCode (\r
-          StartOpCodeHandle,\r
-          INVALID_FORM_ID,\r
-          Token,\r
-          TokenHelp,\r
-          EFI_IFR_FLAG_CALLBACK,\r
-          (EFI_QUESTION_ID) (Index + DEVICE_KEY_OFFSET)\r
-          );\r
-      }\r
-    }\r
-\r
-    //\r
-    // Try to find more formset in this HiiHandle.\r
-    //\r
-    SkipCount++;\r
-    Index--;\r
-  }\r
-\r
-  Status = gBS->LocateHandleBuffer (\r
-                ByProtocol,\r
-                &gEfiDriverHealthProtocolGuid,\r
-                NULL,\r
-                &NumHandles,\r
-                &DriverHealthHandles\r
-                );\r
-\r
-  //\r
-  // If there are no drivers installed driver health protocol, do not create driver health entry in UI\r
-  //\r
-  if (NumHandles != 0) {\r
-    //\r
-    // If driver health protocol is installed, create Driver Health subtitle and entry\r
-    //\r
-    HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_DM_DRIVER_HEALTH_TITLE), 0, 0, 0);\r
-    HiiCreateGotoOpCode (\r
-      StartOpCodeHandle,\r
-      DRIVER_HEALTH_FORM_ID,\r
-      STRING_TOKEN(STR_DRIVER_HEALTH_ALL_HEALTHY),      // Prompt text\r
-      STRING_TOKEN(STR_DRIVER_HEALTH_STATUS_HELP),      // Help text\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      DEVICE_MANAGER_KEY_DRIVER_HEALTH                  // Question ID\r
-      );\r
-\r
-    //\r
-    // Check All Driver health status\r
-    //\r
-    if (!PlaformHealthStatusCheck ()) {\r
-      //\r
-      // At least one driver in the platform are not in healthy status\r
-      //\r
-      HiiSetString (HiiHandle, STRING_TOKEN (STR_DRIVER_HEALTH_ALL_HEALTHY), GetStringById (STRING_TOKEN (STR_DRIVER_NOT_HEALTH)), NULL);\r
-    } else {\r
-      //\r
-      // For the string of STR_DRIVER_HEALTH_ALL_HEALTHY previously has been updated and we need to update it while re-entry.\r
-      //\r
-      HiiSetString (HiiHandle, STRING_TOKEN (STR_DRIVER_HEALTH_ALL_HEALTHY), GetStringById (STRING_TOKEN (STR_DRIVER_HEALTH_ALL_HEALTHY)), NULL);\r
-    }\r
-  }\r
-\r
-  HiiUpdateForm (\r
-    HiiHandle,\r
-    &gDeviceManagerFormSetGuid,\r
-    mNextShowFormId,\r
-    StartOpCodeHandle,\r
-    EndOpCodeHandle\r
-    );\r
-\r
-  ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-  Status = gFormBrowser2->SendForm (\r
-                           gFormBrowser2,\r
-                           &HiiHandle,\r
-                           1,\r
-                           &gDeviceManagerFormSetGuid,\r
-                           mNextShowFormId,\r
-                           NULL,\r
-                           &ActionRequest\r
-                           );\r
-  if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
-    EnableResetRequired ();\r
-  }\r
-\r
-  //\r
-  // We will have returned from processing a callback, selected\r
-  // a target to display\r
-  //\r
-  if ((gCallbackKey >= DEVICE_KEY_OFFSET)) {\r
-    ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-    Status = gFormBrowser2->SendForm (\r
-                             gFormBrowser2,\r
-                             &HiiHandles[gCallbackKey - DEVICE_KEY_OFFSET],\r
-                             1,\r
-                             GuidLists[gCallbackKey - DEVICE_KEY_OFFSET],\r
-                             0,\r
-                             NULL,\r
-                             &ActionRequest\r
-                             );\r
-\r
-    if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
-      EnableResetRequired ();\r
-    }\r
-\r
-    //\r
-    // Force return to Device Manager\r
-    //\r
-    gCallbackKey = FRONT_PAGE_KEY_DEVICE_MANAGER;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Driver Health item chose.\r
-  //\r
-  if (gCallbackKey == DEVICE_MANAGER_KEY_DRIVER_HEALTH) {\r
-    CallDriverHealth ();\r
-    //\r
-    // Force return to Device Manager\r
-    //\r
-    gCallbackKey = FRONT_PAGE_KEY_DEVICE_MANAGER;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Enter from device manager and into the network device list.\r
-  //\r
-  if (gCallbackKey == QUESTION_NETWORK_DEVICE_ID) {\r
-    mNextShowFormId = NETWORK_DEVICE_LIST_FORM_ID;\r
-    gCallbackKey = FRONT_PAGE_KEY_DEVICE_MANAGER;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // In this case, go from the network device list to the specify device.\r
-  //\r
-  if ((gCallbackKey < MAX_KEY_SECTION_LEN + NETWORK_DEVICE_LIST_KEY_OFFSET ) && (gCallbackKey >= NETWORK_DEVICE_LIST_KEY_OFFSET)) {\r
-    mNextShowFormId = NETWORK_DEVICE_FORM_ID;\r
-    gCallbackKey = FRONT_PAGE_KEY_DEVICE_MANAGER;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Select the ESC, the gCallbackKey == 0.\r
-  //\r
-  if(mNextShowFormId - 1 < DEVICE_MANAGER_FORM_ID) {\r
-    mNextShowFormId = DEVICE_MANAGER_FORM_ID;\r
-  } else {\r
-    mNextShowFormId = (UINT16) (mNextShowFormId - 1);\r
-    gCallbackKey = FRONT_PAGE_KEY_DEVICE_MANAGER;\r
-  }\r
-\r
-Done:\r
-  //\r
-  // Remove our packagelist from HII database.\r
-  //\r
-  HiiRemovePackages (HiiHandle);\r
-  gDeviceManagerPrivate.HiiHandle = NULL;\r
-\r
-  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
-  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-  FreePool (HiiHandles);\r
-\r
-  for (Index = 0; Index < HandleNum; Index++) {\r
-    if (GuidLists[Index] != NULL) {\r
-      FreePool (GuidLists[Index]);\r
-    }\r
-  }\r
-  FreePool (GuidLists);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function is invoked if user selected a interactive opcode from Driver Health's\r
-  Formset. The decision by user is saved to gCallbackKey for later processing.\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DriverHealthCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  )\r
-{\r
-  if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
-    if ((Value == NULL) || (ActionRequest == NULL)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    gCallbackKey = QuestionId;\r
-\r
-    //\r
-    // Request to exit SendForm(), so as to switch to selected form\r
-    //\r
-    *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // All other action return unsupported.\r
-  //\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Collect and display the platform's driver health relative information, allow user to do interactive\r
-  operation while the platform is unhealthy.\r
-\r
-  This function display a form which divided into two parts. The one list all modules which has installed\r
-  driver health protocol. The list usually contain driver name, controller name, and it's health info.\r
-  While the driver name can't be retrieved, will use device path as backup. The other part of the form provide\r
-  a choice to the user to repair all platform.\r
-\r
-**/\r
-VOID\r
-CallDriverHealth (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_HII_HANDLE              HiiHandle;\r
-  EFI_BROWSER_ACTION_REQUEST  ActionRequest;\r
-  EFI_IFR_GUID_LABEL          *StartLabel;\r
-  EFI_IFR_GUID_LABEL          *StartLabelRepair;\r
-  EFI_IFR_GUID_LABEL          *EndLabel;\r
-  EFI_IFR_GUID_LABEL          *EndLabelRepair;\r
-  VOID                        *StartOpCodeHandle;\r
-  VOID                        *EndOpCodeHandle;\r
-  VOID                        *StartOpCodeHandleRepair;\r
-  VOID                        *EndOpCodeHandleRepair;\r
-  UINTN                       Index;\r
-  EFI_STRING_ID               Token;\r
-  EFI_STRING_ID               TokenHelp;\r
-  EFI_STRING                  String;\r
-  EFI_STRING                  TmpString;\r
-  EFI_STRING                  DriverName;\r
-  EFI_STRING                  ControllerName;\r
-  LIST_ENTRY                  DriverHealthList;\r
-  DRIVER_HEALTH_INFO          *DriverHealthInfo;\r
-  LIST_ENTRY                  *Link;\r
-  EFI_DEVICE_PATH_PROTOCOL    *DriverDevicePath;\r
-  BOOLEAN                     RebootRequired;\r
-  BOOLEAN                     IsControllerNameEmpty;\r
-  UINTN                       StringSize;\r
-\r
-  Index               = 0;\r
-  DriverHealthInfo    = NULL;\r
-  DriverDevicePath    = NULL;\r
-  IsControllerNameEmpty = FALSE;\r
-  InitializeListHead (&DriverHealthList);\r
-\r
-  HiiHandle = gDeviceManagerPrivate.DriverHealthHiiHandle;\r
-  if (HiiHandle == NULL) {\r
-    //\r
-    // Publish Driver Health HII data.\r
-    //\r
-    HiiHandle = HiiAddPackages (\r
-                  &gDeviceManagerFormSetGuid,\r
-                  gDeviceManagerPrivate.DriverHealthHandle,\r
-                  DriverHealthVfrBin,\r
-                  BdsDxeStrings,\r
-                  NULL\r
-                  );\r
-    if (HiiHandle == NULL) {\r
-      return;\r
-    }\r
-\r
-    gDeviceManagerPrivate.DriverHealthHiiHandle = HiiHandle;\r
-  }\r
-\r
-  //\r
-  // Allocate space for creation of UpdateData Buffer\r
-  //\r
-  StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (StartOpCodeHandle != NULL);\r
-\r
-  EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (EndOpCodeHandle != NULL);\r
-\r
-  StartOpCodeHandleRepair = HiiAllocateOpCodeHandle ();\r
-  ASSERT (StartOpCodeHandleRepair != NULL);\r
-\r
-  EndOpCodeHandleRepair = HiiAllocateOpCodeHandle ();\r
-  ASSERT (EndOpCodeHandleRepair != NULL);\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  StartLabel->Number       = LABEL_DRIVER_HEALTH;\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  StartLabelRepair = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandleRepair, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  StartLabelRepair->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  StartLabelRepair->Number       = LABEL_DRIVER_HEALTH_REAPIR_ALL;\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the end opcode\r
-  //\r
-  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  EndLabel->Number       = LABEL_DRIVER_HEALTH_END;\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the end opcode\r
-  //\r
-  EndLabelRepair = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandleRepair, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  EndLabelRepair->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  EndLabelRepair->Number       = LABEL_DRIVER_HEALTH_REAPIR_ALL_END;\r
-\r
-  HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_DH_STATUS_LIST), 0, 0, 1);\r
-\r
-  Status = GetAllControllersHealthStatus (&DriverHealthList);\r
-  ASSERT (Status != EFI_OUT_OF_RESOURCES);\r
-\r
-  Link = GetFirstNode (&DriverHealthList);\r
-\r
-  while (!IsNull (&DriverHealthList, Link)) {\r
-    DriverHealthInfo = DEVICE_MANAGER_HEALTH_INFO_FROM_LINK (Link);\r
-\r
-    Status = DriverHealthGetDriverName (DriverHealthInfo->DriverHandle, &DriverName);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Can not get the Driver name, so use the Device path\r
-      //\r
-      DriverDevicePath = DevicePathFromHandle (DriverHealthInfo->DriverHandle);\r
-      DriverName       = DevicePathToStr (DriverDevicePath);\r
-    }\r
-    StringSize = StrSize (DriverName);\r
-\r
-    Status = DriverHealthGetControllerName (\r
-               DriverHealthInfo->DriverHandle,\r
-               DriverHealthInfo->ControllerHandle,\r
-               DriverHealthInfo->ChildHandle,\r
-               &ControllerName\r
-               );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      IsControllerNameEmpty = FALSE;\r
-      StringSize += StrLen (L"    ") * sizeof(CHAR16);\r
-      StringSize += StrLen (ControllerName) * sizeof(CHAR16);\r
-    } else {\r
-      IsControllerNameEmpty = TRUE;\r
-    }\r
-\r
-    //\r
-    // Add the message of the Module itself provided after the string item.\r
-    //\r
-    if ((DriverHealthInfo->MessageList != NULL) && (DriverHealthInfo->MessageList->StringId != 0)) {\r
-       TmpString = HiiGetString (\r
-                     DriverHealthInfo->MessageList->HiiHandle,\r
-                     DriverHealthInfo->MessageList->StringId,\r
-                     NULL\r
-                     );\r
-       ASSERT (TmpString != NULL);\r
-\r
-       StringSize += StrLen (L"    ") * sizeof(CHAR16);\r
-       StringSize += StrLen (TmpString) * sizeof(CHAR16);\r
-\r
-       String = (EFI_STRING) AllocateZeroPool (StringSize);\r
-       ASSERT (String != NULL);\r
-\r
-       StrCpyS (String, StringSize / sizeof(CHAR16), DriverName);\r
-       if (!IsControllerNameEmpty) {\r
-        StrCatS (String, StringSize / sizeof(CHAR16), L"    ");\r
-        StrCatS (String, StringSize / sizeof(CHAR16), ControllerName);\r
-       }\r
-\r
-       StrCatS (String, StringSize / sizeof(CHAR16), L"    ");\r
-       StrCatS (String, StringSize / sizeof(CHAR16), TmpString);\r
-\r
-    } else {\r
-      //\r
-      // Update the string will be displayed base on the driver's health status\r
-      //\r
-      switch(DriverHealthInfo->HealthStatus) {\r
-      case EfiDriverHealthStatusRepairRequired:\r
-        TmpString = GetStringById (STRING_TOKEN (STR_REPAIR_REQUIRED));\r
-        break;\r
-      case EfiDriverHealthStatusConfigurationRequired:\r
-        TmpString = GetStringById (STRING_TOKEN (STR_CONFIGURATION_REQUIRED));\r
-        break;\r
-      case EfiDriverHealthStatusFailed:\r
-        TmpString = GetStringById (STRING_TOKEN (STR_OPERATION_FAILED));\r
-        break;\r
-      case EfiDriverHealthStatusReconnectRequired:\r
-        TmpString = GetStringById (STRING_TOKEN (STR_RECONNECT_REQUIRED));\r
-        break;\r
-      case EfiDriverHealthStatusRebootRequired:\r
-        TmpString = GetStringById (STRING_TOKEN (STR_REBOOT_REQUIRED));\r
-        break;\r
-      default:\r
-        TmpString = GetStringById (STRING_TOKEN (STR_DRIVER_HEALTH_HEALTHY));\r
-        break;\r
-      }\r
-      ASSERT (TmpString != NULL);\r
-\r
-      StringSize += StrLen (TmpString) * sizeof(CHAR16);\r
-\r
-      String = (EFI_STRING) AllocateZeroPool (StringSize);\r
-      ASSERT (String != NULL);\r
-\r
-      StrCpyS (String, StringSize / sizeof (CHAR16), DriverName);\r
-      if (!IsControllerNameEmpty) {\r
-        StrCatS (String, StringSize / sizeof (CHAR16), L"    ");\r
-        StrCatS (String, StringSize / sizeof (CHAR16), ControllerName);\r
-      }\r
-\r
-      StrCatS (String, StringSize / sizeof (CHAR16), TmpString);\r
-    }\r
-\r
-    FreePool (TmpString);\r
-\r
-    Token = HiiSetString (HiiHandle, 0, String, NULL);\r
-    FreePool (String);\r
-\r
-    TokenHelp = HiiSetString (HiiHandle, 0, GetStringById( STRING_TOKEN (STR_DH_REPAIR_SINGLE_HELP)), NULL);\r
-\r
-    HiiCreateActionOpCode (\r
-      StartOpCodeHandle,\r
-      (EFI_QUESTION_ID) (Index + DRIVER_HEALTH_KEY_OFFSET),\r
-      Token,\r
-      TokenHelp,\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      0\r
-      );\r
-    Index++;\r
-    Link = GetNextNode (&DriverHealthList, Link);\r
-  }\r
-\r
-  //\r
-  // Add End Opcode for Subtitle\r
-  //\r
-  HiiCreateEndOpCode (StartOpCodeHandle);\r
-\r
-  HiiCreateSubTitleOpCode (StartOpCodeHandleRepair, STRING_TOKEN (STR_DRIVER_HEALTH_REPAIR_ALL), 0, 0, 1);\r
-  TokenHelp = HiiSetString (HiiHandle, 0, GetStringById( STRING_TOKEN (STR_DH_REPAIR_ALL_HELP)), NULL);\r
-\r
-  if (PlaformHealthStatusCheck ()) {\r
-    //\r
-    // No action need to do for the platform\r
-    //\r
-    Token = HiiSetString (HiiHandle, 0, GetStringById( STRING_TOKEN (STR_DRIVER_HEALTH_ALL_HEALTHY)), NULL);\r
-    HiiCreateActionOpCode (\r
-      StartOpCodeHandleRepair,\r
-      0,\r
-      Token,\r
-      TokenHelp,\r
-      EFI_IFR_FLAG_READ_ONLY,\r
-      0\r
-      );\r
-  } else {\r
-    //\r
-    // Create ActionOpCode only while the platform need to do health related operation.\r
-    //\r
-    Token = HiiSetString (HiiHandle, 0, GetStringById( STRING_TOKEN (STR_DH_REPAIR_ALL_TITLE)), NULL);\r
-    HiiCreateActionOpCode (\r
-      StartOpCodeHandleRepair,\r
-      (EFI_QUESTION_ID) DRIVER_HEALTH_REPAIR_ALL_KEY,\r
-      Token,\r
-      TokenHelp,\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      0\r
-      );\r
-  }\r
-\r
-  HiiCreateEndOpCode (StartOpCodeHandleRepair);\r
-\r
-  Status = HiiUpdateForm (\r
-             HiiHandle,\r
-             &gDriverHealthFormSetGuid,\r
-             DRIVER_HEALTH_FORM_ID,\r
-             StartOpCodeHandle,\r
-             EndOpCodeHandle\r
-             );\r
-  ASSERT (Status != EFI_NOT_FOUND);\r
-  ASSERT (Status != EFI_BUFFER_TOO_SMALL);\r
-\r
-  Status = HiiUpdateForm (\r
-            HiiHandle,\r
-            &gDriverHealthFormSetGuid,\r
-            DRIVER_HEALTH_FORM_ID,\r
-            StartOpCodeHandleRepair,\r
-            EndOpCodeHandleRepair\r
-    );\r
-  ASSERT (Status != EFI_NOT_FOUND);\r
-  ASSERT (Status != EFI_BUFFER_TOO_SMALL);\r
-\r
-  ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-  Status = gFormBrowser2->SendForm (\r
-                           gFormBrowser2,\r
-                           &HiiHandle,\r
-                           1,\r
-                           &gDriverHealthFormSetGuid,\r
-                           DRIVER_HEALTH_FORM_ID,\r
-                           NULL,\r
-                           &ActionRequest\r
-                           );\r
-  if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
-    EnableResetRequired ();\r
-  }\r
-\r
-  //\r
-  // We will have returned from processing a callback - user either hit ESC to exit, or selected\r
-  // a target to display.\r
-  // Process the diver health status states here.\r
-  //\r
-  if (gCallbackKey >= DRIVER_HEALTH_KEY_OFFSET && gCallbackKey != DRIVER_HEALTH_REPAIR_ALL_KEY) {\r
-    ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-\r
-    Link = GetFirstNode (&DriverHealthList);\r
-    Index = 0;\r
-\r
-    while (!IsNull (&DriverHealthList, Link)) {\r
-      //\r
-      // Got the item relative node in the List\r
-      //\r
-      if (Index == (gCallbackKey - DRIVER_HEALTH_KEY_OFFSET)) {\r
-        DriverHealthInfo = DEVICE_MANAGER_HEALTH_INFO_FROM_LINK (Link);\r
-        //\r
-        // Process the driver's healthy status for the specify module\r
-        //\r
-        RebootRequired = FALSE;\r
-        ProcessSingleControllerHealth (\r
-          DriverHealthInfo->DriverHealth,\r
-          DriverHealthInfo->ControllerHandle,\r
-          DriverHealthInfo->ChildHandle,\r
-          DriverHealthInfo->HealthStatus,\r
-          &(DriverHealthInfo->MessageList),\r
-          DriverHealthInfo->HiiHandle,\r
-          &RebootRequired\r
-          );\r
-        if (RebootRequired) {\r
-          gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
-        }\r
-        break;\r
-      }\r
-      Index++;\r
-      Link = GetNextNode (&DriverHealthList, Link);\r
-    }\r
-\r
-    if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
-      EnableResetRequired ();\r
-    }\r
-\r
-    //\r
-    // Force return to the form of Driver Health in Device Manager\r
-    //\r
-    gCallbackKey = DRIVER_HEALTH_RETURN_KEY;\r
-  }\r
-\r
-  //\r
-  // Repair the whole platform\r
-  //\r
-  if (gCallbackKey == DRIVER_HEALTH_REPAIR_ALL_KEY) {\r
-    ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-\r
-    PlatformRepairAll (&DriverHealthList);\r
-\r
-    gCallbackKey = DRIVER_HEALTH_RETURN_KEY;\r
-  }\r
-\r
-  //\r
-  // Remove driver health packagelist from HII database.\r
-  //\r
-  HiiRemovePackages (HiiHandle);\r
-  gDeviceManagerPrivate.DriverHealthHiiHandle = NULL;\r
-\r
-  //\r
-  // Free driver health info list\r
-  //\r
-  while (!IsListEmpty (&DriverHealthList)) {\r
-\r
-    Link = GetFirstNode(&DriverHealthList);\r
-    DriverHealthInfo = DEVICE_MANAGER_HEALTH_INFO_FROM_LINK (Link);\r
-    RemoveEntryList (Link);\r
-\r
-    if (DriverHealthInfo->MessageList != NULL) {\r
-      FreePool(DriverHealthInfo->MessageList);\r
-      FreePool (DriverHealthInfo);\r
-    }\r
-  }\r
-\r
-  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
-  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-  HiiFreeOpCodeHandle (StartOpCodeHandleRepair);\r
-  HiiFreeOpCodeHandle (EndOpCodeHandleRepair);\r
-\r
-  if (gCallbackKey == DRIVER_HEALTH_RETURN_KEY) {\r
-    //\r
-    // Force return to Driver Health Form\r
-    //\r
-    gCallbackKey = DEVICE_MANAGER_KEY_DRIVER_HEALTH;\r
-    CallDriverHealth ();\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Check the Driver Health status of a single controller and try to process it if not healthy.\r
-\r
-  This function called by CheckAllControllersHealthStatus () function in order to process a specify\r
-  contoller's health state.\r
-\r
-  @param DriverHealthList   A Pointer to the list contain all of the platform driver health information.\r
-  @param DriverHandle       The handle of driver.\r
-  @param ControllerHandle   The class guid specifies which form set will be displayed.\r
-  @param ChildHandle        The handle of the child controller to retrieve the health\r
-                            status on.  This is an optional parameter that may be NULL.\r
-  @param DriverHealth       A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r
-  @param HealthStatus       The health status of the controller.\r
-\r
-  @retval EFI_INVALID_PARAMETER   HealthStatus or DriverHealth is NULL.\r
-  @retval HealthStatus            The Health status of specify controller.\r
-  @retval EFI_OUT_OF_RESOURCES    The list of Driver Health Protocol handles can not be retrieved.\r
-  @retval EFI_NOT_FOUND           No controller in the platform install Driver Health Protocol.\r
-  @retval EFI_SUCCESS             The Health related operation has been taken successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GetSingleControllerHealthStatus (\r
-  IN OUT LIST_ENTRY                   *DriverHealthList,\r
-  IN EFI_HANDLE                       DriverHandle,\r
-  IN EFI_HANDLE                       ControllerHandle,  OPTIONAL\r
-  IN EFI_HANDLE                       ChildHandle,       OPTIONAL\r
-  IN EFI_DRIVER_HEALTH_PROTOCOL       *DriverHealth,\r
-  IN EFI_DRIVER_HEALTH_STATUS         *HealthStatus\r
-  )\r
-{\r
-  EFI_STATUS                     Status;\r
-  EFI_DRIVER_HEALTH_HII_MESSAGE  *MessageList;\r
-  EFI_HII_HANDLE                 FormHiiHandle;\r
-  DRIVER_HEALTH_INFO             *DriverHealthInfo;\r
-\r
-  if (HealthStatus == NULL) {\r
-    //\r
-    // If HealthStatus is NULL, then return EFI_INVALID_PARAMETER\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Assume the HealthStatus is healthy\r
-  //\r
-  *HealthStatus = EfiDriverHealthStatusHealthy;\r
-\r
-  if (DriverHealth == NULL) {\r
-    //\r
-    // If DriverHealth is NULL, then return EFI_INVALID_PARAMETER\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (ControllerHandle == NULL) {\r
-    //\r
-    // If ControllerHandle is NULL, the return the cumulative health status of the driver\r
-    //\r
-    Status = DriverHealth->GetHealthStatus (DriverHealth, NULL, NULL, HealthStatus, NULL, NULL);\r
-    if (*HealthStatus == EfiDriverHealthStatusHealthy) {\r
-      //\r
-      // Add the driver health related information into the list\r
-      //\r
-      DriverHealthInfo = AllocateZeroPool (sizeof (DRIVER_HEALTH_INFO));\r
-      if (DriverHealthInfo == NULL) {\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      DriverHealthInfo->Signature          = DEVICE_MANAGER_DRIVER_HEALTH_INFO_SIGNATURE;\r
-      DriverHealthInfo->DriverHandle       = DriverHandle;\r
-      DriverHealthInfo->ControllerHandle   = NULL;\r
-      DriverHealthInfo->ChildHandle        = NULL;\r
-      DriverHealthInfo->HiiHandle          = NULL;\r
-      DriverHealthInfo->DriverHealth       = DriverHealth;\r
-      DriverHealthInfo->MessageList        = NULL;\r
-      DriverHealthInfo->HealthStatus       = *HealthStatus;\r
-\r
-      InsertTailList (DriverHealthList, &DriverHealthInfo->Link);\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  MessageList   = NULL;\r
-  FormHiiHandle = NULL;\r
-\r
-  //\r
-  // Collect the health status with the optional HII message list\r
-  //\r
-  Status = DriverHealth->GetHealthStatus (DriverHealth, ControllerHandle, ChildHandle, HealthStatus, &MessageList, &FormHiiHandle);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // If the health status could not be retrieved, then return immediately\r
-    //\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Add the driver health related information into the list\r
-  //\r
-  DriverHealthInfo = AllocateZeroPool (sizeof (DRIVER_HEALTH_INFO));\r
-  if (DriverHealthInfo == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  DriverHealthInfo->Signature          = DEVICE_MANAGER_DRIVER_HEALTH_INFO_SIGNATURE;\r
-  DriverHealthInfo->DriverHandle       = DriverHandle;\r
-  DriverHealthInfo->ControllerHandle   = ControllerHandle;\r
-  DriverHealthInfo->ChildHandle        = ChildHandle;\r
-  DriverHealthInfo->HiiHandle          = FormHiiHandle;\r
-  DriverHealthInfo->DriverHealth       = DriverHealth;\r
-  DriverHealthInfo->MessageList        = MessageList;\r
-  DriverHealthInfo->HealthStatus       = *HealthStatus;\r
-\r
-  InsertTailList (DriverHealthList, &DriverHealthInfo->Link);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Collects all the EFI Driver Health Protocols currently present in the EFI Handle Database,\r
-  and queries each EFI Driver Health Protocol to determine if one or more of the controllers\r
-  managed by each EFI Driver Health Protocol instance are not healthy.\r
-\r
-  @param DriverHealthList   A Pointer to the list contain all of the platform driver health\r
-                            information.\r
-\r
-  @retval    EFI_NOT_FOUND         No controller in the platform install Driver Health Protocol.\r
-  @retval    EFI_SUCCESS           All the controllers in the platform are healthy.\r
-  @retval    EFI_OUT_OF_RESOURCES  The list of Driver Health Protocol handles can not be retrieved.\r
-\r
-**/\r
-EFI_STATUS\r
-GetAllControllersHealthStatus (\r
-  IN OUT LIST_ENTRY  *DriverHealthList\r
-  )\r
-{\r
-  EFI_STATUS                 Status;\r
-  UINTN                      NumHandles;\r
-  EFI_HANDLE                 *DriverHealthHandles;\r
-  EFI_DRIVER_HEALTH_PROTOCOL *DriverHealth;\r
-  EFI_DRIVER_HEALTH_STATUS   HealthStatus;\r
-  UINTN                      DriverHealthIndex;\r
-  EFI_HANDLE                 *Handles;\r
-  UINTN                      HandleCount;\r
-  UINTN                      ControllerIndex;\r
-  UINTN                      ChildIndex;\r
-\r
-  //\r
-  // Initialize local variables\r
-  //\r
-  Handles                 = NULL;\r
-  DriverHealthHandles     = NULL;\r
-  NumHandles              = 0;\r
-  HandleCount             = 0;\r
-\r
-  HealthStatus = EfiDriverHealthStatusHealthy;\r
-\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiDriverHealthProtocolGuid,\r
-                  NULL,\r
-                  &NumHandles,\r
-                  &DriverHealthHandles\r
-                  );\r
-\r
-  if (Status == EFI_NOT_FOUND || NumHandles == 0) {\r
-    //\r
-    // If there are no Driver Health Protocols handles, then return EFI_NOT_FOUND\r
-    //\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if (EFI_ERROR (Status) || DriverHealthHandles == NULL) {\r
-    //\r
-    // If the list of Driver Health Protocol handles can not be retrieved, then\r
-    // return EFI_OUT_OF_RESOURCES\r
-    //\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Check the health status of all controllers in the platform\r
-  // Start by looping through all the Driver Health Protocol handles in the handle database\r
-  //\r
-  for (DriverHealthIndex = 0; DriverHealthIndex < NumHandles; DriverHealthIndex++) {\r
-    //\r
-    // Skip NULL Driver Health Protocol handles\r
-    //\r
-    if (DriverHealthHandles[DriverHealthIndex] == NULL) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Retrieve the Driver Health Protocol from DriverHandle\r
-    //\r
-    Status = gBS->HandleProtocol (\r
-                    DriverHealthHandles[DriverHealthIndex],\r
-                    &gEfiDriverHealthProtocolGuid,\r
-                    (VOID **)&DriverHealth\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // If the Driver Health Protocol can not be retrieved, then skip to the next\r
-      // Driver Health Protocol handle\r
-      //\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Check the health of all the controllers managed by a Driver Health Protocol handle\r
-    //\r
-    Status = GetSingleControllerHealthStatus (DriverHealthList, DriverHealthHandles[DriverHealthIndex], NULL, NULL, DriverHealth, &HealthStatus);\r
-\r
-    //\r
-    // If Status is an error code, then the health information could not be retrieved, so assume healthy\r
-    // and skip to the next Driver Health Protocol handle\r
-    //\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // If all the controllers managed by this Driver Health Protocol are healthy, then skip to the next\r
-    // Driver Health Protocol handle\r
-    //\r
-    if (HealthStatus == EfiDriverHealthStatusHealthy) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // See if the list of all handles in the handle database has been retrieved\r
-    //\r
-    //\r
-    if (Handles == NULL) {\r
-      //\r
-      // Retrieve the list of all handles from the handle database\r
-      //\r
-      Status = gBS->LocateHandleBuffer (\r
-        AllHandles,\r
-        NULL,\r
-        NULL,\r
-        &HandleCount,\r
-        &Handles\r
-        );\r
-      if (EFI_ERROR (Status) || Handles == NULL) {\r
-        //\r
-        // If all the handles in the handle database can not be retrieved, then\r
-        // return EFI_OUT_OF_RESOURCES\r
-        //\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        goto Done;\r
-      }\r
-    }\r
-    //\r
-    // Loop through all the controller handles in the handle database\r
-    //\r
-    for (ControllerIndex = 0; ControllerIndex < HandleCount; ControllerIndex++) {\r
-      //\r
-      // Skip NULL controller handles\r
-      //\r
-      if (Handles[ControllerIndex] == NULL) {\r
-        continue;\r
-      }\r
-\r
-      Status = GetSingleControllerHealthStatus (DriverHealthList, DriverHealthHandles[DriverHealthIndex], Handles[ControllerIndex], NULL, DriverHealth, &HealthStatus);\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // If Status is an error code, then the health information could not be retrieved, so assume healthy\r
-        //\r
-        HealthStatus = EfiDriverHealthStatusHealthy;\r
-      }\r
-\r
-      //\r
-      // If CheckHealthSingleController() returned an error on a terminal state, then do not check the health of child controllers\r
-      //\r
-      if (EFI_ERROR (Status)) {\r
-        continue;\r
-      }\r
-\r
-      //\r
-      // Loop through all the child handles in the handle database\r
-      //\r
-      for (ChildIndex = 0; ChildIndex < HandleCount; ChildIndex++) {\r
-        //\r
-        // Skip NULL child handles\r
-        //\r
-        if (Handles[ChildIndex] == NULL) {\r
-          continue;\r
-        }\r
-\r
-        Status = GetSingleControllerHealthStatus (DriverHealthList, DriverHealthHandles[DriverHealthIndex], Handles[ControllerIndex], Handles[ChildIndex], DriverHealth, &HealthStatus);\r
-        if (EFI_ERROR (Status)) {\r
-          //\r
-          // If Status is an error code, then the health information could not be retrieved, so assume healthy\r
-          //\r
-          HealthStatus = EfiDriverHealthStatusHealthy;\r
-        }\r
-\r
-        //\r
-        // If CheckHealthSingleController() returned an error on a terminal state, then skip to the next child\r
-        //\r
-        if (EFI_ERROR (Status)) {\r
-          continue;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-Done:\r
-  if (Handles != NULL) {\r
-    gBS->FreePool (Handles);\r
-  }\r
-  if (DriverHealthHandles != NULL) {\r
-    gBS->FreePool (DriverHealthHandles);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Check the healthy status of the platform, this function will return immediately while found one driver\r
-  in the platform are not healthy.\r
-\r
-  @retval FALSE      at least one driver in the platform are not healthy.\r
-  @retval TRUE       No controller install Driver Health Protocol,\r
-                     or all controllers in the platform are in healthy status.\r
-**/\r
-BOOLEAN\r
-PlaformHealthStatusCheck (\r
-  VOID\r
-  )\r
-{\r
-  EFI_DRIVER_HEALTH_STATUS          HealthStatus;\r
-  EFI_STATUS                        Status;\r
-  UINTN                             Index;\r
-  UINTN                             NoHandles;\r
-  EFI_HANDLE                        *DriverHealthHandles;\r
-  EFI_DRIVER_HEALTH_PROTOCOL        *DriverHealth;\r
-  BOOLEAN                           AllHealthy;\r
-\r
-  //\r
-  // Initialize local variables\r
-  //\r
-  DriverHealthHandles = NULL;\r
-  DriverHealth        = NULL;\r
-\r
-  HealthStatus = EfiDriverHealthStatusHealthy;\r
-\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiDriverHealthProtocolGuid,\r
-                  NULL,\r
-                  &NoHandles,\r
-                  &DriverHealthHandles\r
-                  );\r
-  //\r
-  // There are no handles match the search for Driver Health Protocol has been installed.\r
-  //\r
-  if (Status == EFI_NOT_FOUND) {\r
-    return TRUE;\r
-  }\r
-  //\r
-  // Assume all modules are healthy.\r
-  //\r
-  AllHealthy = TRUE;\r
-\r
-  //\r
-  // Found one or more Handles.\r
-  //\r
-  if (!EFI_ERROR (Status)) {\r
-    for (Index = 0; Index < NoHandles; Index++) {\r
-      Status = gBS->HandleProtocol (\r
-                      DriverHealthHandles[Index],\r
-                      &gEfiDriverHealthProtocolGuid,\r
-                      (VOID **) &DriverHealth\r
-                      );\r
-      if (!EFI_ERROR (Status)) {\r
-        Status = DriverHealth->GetHealthStatus (\r
-                                 DriverHealth,\r
-                                 NULL,\r
-                                 NULL,\r
-                                 &HealthStatus,\r
-                                 NULL,\r
-                                 NULL\r
-                                 );\r
-      }\r
-      //\r
-      // Get the healthy status of the module\r
-      //\r
-      if (!EFI_ERROR (Status)) {\r
-         if (HealthStatus != EfiDriverHealthStatusHealthy) {\r
-           //\r
-           // Return immediately one driver's status not in healthy.\r
-           //\r
-           return FALSE;\r
-         }\r
-      }\r
-    }\r
-  }\r
-  return AllHealthy;\r
-}\r
-\r
-/**\r
-  Processes a single controller using the EFI Driver Health Protocol associated with\r
-  that controller. This algorithm continues to query the GetHealthStatus() service until\r
-  one of the legal terminal states of the EFI Driver Health Protocol is reached. This may\r
-  require the processing of HII Messages, HII Form, and invocation of repair operations.\r
-\r
-  @param DriverHealth       A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r
-  @param ControllerHandle   The class guid specifies which form set will be displayed.\r
-  @param ChildHandle        The handle of the child controller to retrieve the health\r
-                            status on.  This is an optional parameter that may be NULL.\r
-  @param HealthStatus       The health status of the controller.\r
-  @param MessageList        An array of warning or error messages associated\r
-                            with the controller specified by ControllerHandle and\r
-                            ChildHandle.  This is an optional parameter that may be NULL.\r
-  @param FormHiiHandle      The HII handle for an HII form associated with the\r
-                            controller specified by ControllerHandle and ChildHandle.\r
-  @param RebootRequired     Indicate whether a reboot is required to repair the controller.\r
-**/\r
-VOID\r
-ProcessSingleControllerHealth (\r
-  IN  EFI_DRIVER_HEALTH_PROTOCOL         *DriverHealth,\r
-  IN  EFI_HANDLE                         ControllerHandle, OPTIONAL\r
-  IN  EFI_HANDLE                         ChildHandle,      OPTIONAL\r
-  IN  EFI_DRIVER_HEALTH_STATUS           HealthStatus,\r
-  IN  EFI_DRIVER_HEALTH_HII_MESSAGE      **MessageList,    OPTIONAL\r
-  IN  EFI_HII_HANDLE                     FormHiiHandle,\r
-  IN OUT BOOLEAN                         *RebootRequired\r
-  )\r
-{\r
-  EFI_STATUS                         Status;\r
-  EFI_DRIVER_HEALTH_STATUS           LocalHealthStatus;\r
-\r
-  LocalHealthStatus = HealthStatus;\r
-  //\r
-  // If the module need to be repaired or reconfiguration,  will process it until\r
-  // reach a terminal status. The status from EfiDriverHealthStatusRepairRequired after repair\r
-  // will be in (Health, Failed, Configuration Required).\r
-  //\r
-  while(LocalHealthStatus == EfiDriverHealthStatusConfigurationRequired ||\r
-        LocalHealthStatus == EfiDriverHealthStatusRepairRequired) {\r
-\r
-    if (LocalHealthStatus == EfiDriverHealthStatusRepairRequired) {\r
-      Status = DriverHealth->Repair (\r
-                               DriverHealth,\r
-                               ControllerHandle,\r
-                               ChildHandle,\r
-                               RepairNotify\r
-                               );\r
-    }\r
-    //\r
-    // Via a form of the driver need to do configuration provided to process of status in\r
-    // EfiDriverHealthStatusConfigurationRequired. The status after configuration should be in\r
-    // (Healthy, Reboot Required, Failed, Reconnect Required, Repair Required).\r
-    //\r
-    if (LocalHealthStatus == EfiDriverHealthStatusConfigurationRequired) {\r
-      if (FormHiiHandle != NULL) {\r
-        Status = gFormBrowser2->SendForm (\r
-                                  gFormBrowser2,\r
-                                  &FormHiiHandle,\r
-                                  1,\r
-                                  &gEfiHiiDriverHealthFormsetGuid,\r
-                                  0,\r
-                                  NULL,\r
-                                  NULL\r
-                                  );\r
-        ASSERT( !EFI_ERROR (Status));\r
-      } else {\r
-        //\r
-        // Exit the loop in case no FormHiiHandle is supplied to prevent dead-loop\r
-        //\r
-        break;\r
-      }\r
-    }\r
-\r
-    Status = DriverHealth->GetHealthStatus (\r
-                              DriverHealth,\r
-                              ControllerHandle,\r
-                              ChildHandle,\r
-                              &LocalHealthStatus,\r
-                              NULL,\r
-                              &FormHiiHandle\r
-                              );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    if (*MessageList != NULL) {\r
-      ProcessMessages (*MessageList);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Health status in {Healthy, Failed} may also have Messages need to process\r
-  //\r
-  if (LocalHealthStatus == EfiDriverHealthStatusHealthy || LocalHealthStatus == EfiDriverHealthStatusFailed) {\r
-    if (*MessageList != NULL) {\r
-      ProcessMessages (*MessageList);\r
-    }\r
-  }\r
-  //\r
-  // Check for RebootRequired or ReconnectRequired\r
-  //\r
-  if (LocalHealthStatus == EfiDriverHealthStatusRebootRequired) {\r
-    *RebootRequired = TRUE;\r
-  }\r
-\r
-  //\r
-  // Do reconnect if need.\r
-  //\r
-  if (LocalHealthStatus == EfiDriverHealthStatusReconnectRequired) {\r
-    Status = gBS->DisconnectController (ControllerHandle, NULL, NULL);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Disconnect failed.  Need to promote reconnect to a reboot.\r
-      //\r
-      *RebootRequired = TRUE;\r
-    } else {\r
-      gBS->ConnectController (ControllerHandle, NULL, NULL, TRUE);\r
-    }\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Reports the progress of a repair operation.\r
-\r
-  @param[in]  Value             A value between 0 and Limit that identifies the current\r
-                                progress of the repair operation.\r
-\r
-  @param[in]  Limit             The maximum value of Value for the current repair operation.\r
-                                For example, a driver that wants to specify progress in\r
-                                percent would use a Limit value of 100.\r
-\r
-  @retval EFI_SUCCESS           The progress of a repair operation is reported successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RepairNotify (\r
-  IN  UINTN Value,\r
-  IN  UINTN Limit\r
-  )\r
-{\r
-  UINTN Percent;\r
-\r
-  if (Limit  == 0) {\r
-    Print(L"Repair Progress Undefined\n\r");\r
-  } else {\r
-    Percent = Value * 100 / Limit;\r
-    Print(L"Repair Progress = %3d%%\n\r", Percent);\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Processes a set of messages returned by the GetHealthStatus ()\r
-  service of the EFI Driver Health Protocol\r
-\r
-  @param    MessageList  The MessageList point to messages need to processed.\r
-\r
-**/\r
-VOID\r
-ProcessMessages (\r
-  IN  EFI_DRIVER_HEALTH_HII_MESSAGE      *MessageList\r
-  )\r
-{\r
-  UINTN                           MessageIndex;\r
-  EFI_STRING                      MessageString;\r
-\r
-  for (MessageIndex = 0;\r
-       MessageList[MessageIndex].HiiHandle != NULL;\r
-       MessageIndex++) {\r
-\r
-    MessageString = HiiGetString (\r
-                        MessageList[MessageIndex].HiiHandle,\r
-                        MessageList[MessageIndex].StringId,\r
-                        NULL\r
-                        );\r
-    if (MessageString != NULL) {\r
-      //\r
-      // User can customize the output. Just simply print out the MessageString like below.\r
-      // Also can use the HiiHandle to display message on the front page.\r
-      //\r
-      // Print(L"%s\n",MessageString);\r
-      // gBS->Stall (100000);\r
-    }\r
-  }\r
-\r
-}\r
-\r
-/**\r
-  Repair the whole platform.\r
-\r
-  This function is the main entry for user choose "Repair All" in the front page.\r
-  It will try to do recovery job till all the driver health protocol installed modules\r
-  reach a terminal state.\r
-\r
-  @param DriverHealthList   A Pointer to the list contain all of the platform driver health\r
-                            information.\r
-\r
-**/\r
-VOID\r
-PlatformRepairAll (\r
-  IN LIST_ENTRY  *DriverHealthList\r
-  )\r
-{\r
-  DRIVER_HEALTH_INFO          *DriverHealthInfo;\r
-  LIST_ENTRY                  *Link;\r
-  BOOLEAN                     RebootRequired;\r
-\r
-  ASSERT (DriverHealthList != NULL);\r
-\r
-  RebootRequired = FALSE;\r
-\r
-  for ( Link = GetFirstNode (DriverHealthList)\r
-      ; !IsNull (DriverHealthList, Link)\r
-      ; Link = GetNextNode (DriverHealthList, Link)\r
-      ) {\r
-    DriverHealthInfo = DEVICE_MANAGER_HEALTH_INFO_FROM_LINK (Link);\r
-    //\r
-    // Do driver health status operation by each link node\r
-    //\r
-    ASSERT (DriverHealthInfo != NULL);\r
-\r
-    ProcessSingleControllerHealth (\r
-      DriverHealthInfo->DriverHealth,\r
-      DriverHealthInfo->ControllerHandle,\r
-      DriverHealthInfo->ChildHandle,\r
-      DriverHealthInfo->HealthStatus,\r
-      &(DriverHealthInfo->MessageList),\r
-      DriverHealthInfo->HiiHandle,\r
-      &RebootRequired\r
-      );\r
-  }\r
-\r
-  if (RebootRequired) {\r
-    gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Select the best matching language according to front page policy for best user experience.\r
-\r
-  This function supports both ISO 639-2 and RFC 4646 language codes, but language\r
-  code types may not be mixed in a single call to this function.\r
-\r
-  @param  SupportedLanguages   A pointer to a Null-terminated ASCII string that\r
-                               contains a set of language codes in the format\r
-                               specified by Iso639Language.\r
-  @param  Iso639Language       If TRUE, then all language codes are assumed to be\r
-                               in ISO 639-2 format.  If FALSE, then all language\r
-                               codes are assumed to be in RFC 4646 language format.\r
-\r
-  @retval NULL                 The best matching language could not be found in SupportedLanguages.\r
-  @retval NULL                 There are not enough resources available to return the best matching\r
-                               language.\r
-  @retval Other                A pointer to a Null-terminated ASCII string that is the best matching\r
-                               language in SupportedLanguages.\r
-**/\r
-CHAR8 *\r
-DriverHealthSelectBestLanguage (\r
-  IN CHAR8        *SupportedLanguages,\r
-  IN BOOLEAN      Iso639Language\r
-  )\r
-{\r
-  CHAR8           *LanguageVariable;\r
-  CHAR8           *BestLanguage;\r
-\r
-  GetEfiGlobalVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", (VOID**)&LanguageVariable, NULL);\r
-\r
-  BestLanguage = GetBestLanguage(\r
-                   SupportedLanguages,\r
-                   Iso639Language,\r
-                   (LanguageVariable != NULL) ? LanguageVariable : "",\r
-                   Iso639Language ? "eng" : "en-US",\r
-                   NULL\r
-                   );\r
-  if (LanguageVariable != NULL) {\r
-    FreePool (LanguageVariable);\r
-  }\r
-\r
-  return BestLanguage;\r
-}\r
-\r
-\r
-\r
-/**\r
-\r
-  This is an internal worker function to get the Component Name (2) protocol interface\r
-  and the language it supports.\r
-\r
-  @param  ProtocolGuid         A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  ComponentName        A pointer to the Component Name (2) protocol interface.\r
-  @param  SupportedLanguage    The best suitable language that matches the SupportedLangues interface for the\r
-                               located Component Name (2) instance.\r
-\r
-  @retval EFI_SUCCESS          The Component Name (2) protocol instance is successfully located and we find\r
-                               the best matching language it support.\r
-  @retval EFI_UNSUPPORTED      The input Language is not supported by the Component Name (2) protocol.\r
-  @retval Other                Some error occurs when locating Component Name (2) protocol instance or finding\r
-                               the supported language.\r
-\r
-**/\r
-EFI_STATUS\r
-GetComponentNameWorker (\r
-  IN  EFI_GUID                    *ProtocolGuid,\r
-  IN  EFI_HANDLE                  DriverBindingHandle,\r
-  OUT EFI_COMPONENT_NAME_PROTOCOL **ComponentName,\r
-  OUT CHAR8                       **SupportedLanguage\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-\r
-  //\r
-  // Locate Component Name (2) protocol on the driver binging handle.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                 DriverBindingHandle,\r
-                 ProtocolGuid,\r
-                 (VOID **) ComponentName,\r
-                 NULL,\r
-                 NULL,\r
-                 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                 );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Apply shell policy to select the best language.\r
-  //\r
-  *SupportedLanguage = DriverHealthSelectBestLanguage (\r
-                         (*ComponentName)->SupportedLanguages,\r
-                         (BOOLEAN) (ProtocolGuid == &gEfiComponentNameProtocolGuid)\r
-                         );\r
-  if (*SupportedLanguage == NULL) {\r
-    Status = EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-\r
-  This is an internal worker function to get driver name from Component Name (2) protocol interface.\r
-\r
-\r
-  @param  ProtocolGuid         A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  DriverName           A pointer to the Unicode string to return. This Unicode string is the name\r
-                               of the driver specified by This.\r
-\r
-  @retval EFI_SUCCESS          The driver name is successfully retrieved from Component Name (2) protocol\r
-                               interface.\r
-  @retval Other                The driver name cannot be retrieved from Component Name (2) protocol\r
-                               interface.\r
-\r
-**/\r
-EFI_STATUS\r
-GetDriverNameWorker (\r
-  IN  EFI_GUID    *ProtocolGuid,\r
-  IN  EFI_HANDLE  DriverBindingHandle,\r
-  OUT CHAR16      **DriverName\r
-  )\r
-{\r
-  EFI_STATUS                     Status;\r
-  CHAR8                          *BestLanguage;\r
-  EFI_COMPONENT_NAME_PROTOCOL    *ComponentName;\r
-\r
-  //\r
-  // Retrieve Component Name (2) protocol instance on the driver binding handle and\r
-  // find the best language this instance supports.\r
-  //\r
-  Status = GetComponentNameWorker (\r
-             ProtocolGuid,\r
-             DriverBindingHandle,\r
-             &ComponentName,\r
-             &BestLanguage\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get the driver name from Component Name (2) protocol instance on the driver binging handle.\r
-  //\r
-  Status = ComponentName->GetDriverName (\r
-                            ComponentName,\r
-                            BestLanguage,\r
-                            DriverName\r
-                            );\r
-  FreePool (BestLanguage);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-\r
-  This function gets driver name from Component Name 2 protocol interface and Component Name protocol interface\r
-  in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the driver name.\r
-  If the attempt fails, it then gets the driver name from EFI 1.1 Component Name protocol for backward\r
-  compatibility support.\r
-\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  DriverName           A pointer to the Unicode string to return. This Unicode string is the name\r
-                               of the driver specified by This.\r
-\r
-  @retval EFI_SUCCESS          The driver name is successfully retrieved from Component Name (2) protocol\r
-                               interface.\r
-  @retval Other                The driver name cannot be retrieved from Component Name (2) protocol\r
-                               interface.\r
-\r
-**/\r
-EFI_STATUS\r
-DriverHealthGetDriverName (\r
-  IN  EFI_HANDLE  DriverBindingHandle,\r
-  OUT CHAR16      **DriverName\r
-  )\r
-{\r
-  EFI_STATUS      Status;\r
-\r
-  //\r
-  // Get driver name from UEFI 2.0 Component Name 2 protocol interface.\r
-  //\r
-  Status = GetDriverNameWorker (&gEfiComponentName2ProtocolGuid, DriverBindingHandle, DriverName);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // If it fails to get the driver name from Component Name protocol interface, we should fall back on\r
-    // EFI 1.1 Component Name protocol interface.\r
-    //\r
-    Status = GetDriverNameWorker (&gEfiComponentNameProtocolGuid, DriverBindingHandle, DriverName);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
-  This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface\r
-  in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.\r
-  If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward\r
-  compatibility support.\r
-\r
-  @param  ProtocolGuid         A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  ControllerHandle     The handle of a controller that the driver specified by This is managing.\r
-                               This handle specifies the controller whose name is to be returned.\r
-  @param  ChildHandle          The handle of the child controller to retrieve the name of. This is an\r
-                               optional parameter that may be NULL. It will be NULL for device drivers.\r
-                               It will also be NULL for bus drivers that attempt to retrieve the name\r
-                               of the bus controller. It will not be NULL for a bus driver that attempts\r
-                               to retrieve the name of a child controller.\r
-  @param  ControllerName       A pointer to the Unicode string to return. This Unicode string\r
-                               is the name of the controller specified by ControllerHandle and ChildHandle.\r
-\r
-  @retval  EFI_SUCCESS         The controller name is successfully retrieved from Component Name (2) protocol\r
-                               interface.\r
-  @retval  Other               The controller name cannot be retrieved from Component Name (2) protocol.\r
-\r
-**/\r
-EFI_STATUS\r
-GetControllerNameWorker (\r
-  IN  EFI_GUID    *ProtocolGuid,\r
-  IN  EFI_HANDLE  DriverBindingHandle,\r
-  IN  EFI_HANDLE  ControllerHandle,\r
-  IN  EFI_HANDLE  ChildHandle,\r
-  OUT CHAR16      **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS                     Status;\r
-  CHAR8                          *BestLanguage;\r
-  EFI_COMPONENT_NAME_PROTOCOL    *ComponentName;\r
-\r
-  //\r
-  // Retrieve Component Name (2) protocol instance on the driver binding handle and\r
-  // find the best language this instance supports.\r
-  //\r
-  Status = GetComponentNameWorker (\r
-             ProtocolGuid,\r
-             DriverBindingHandle,\r
-             &ComponentName,\r
-             &BestLanguage\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get the controller name from Component Name (2) protocol instance on the driver binging handle.\r
-  //\r
-  Status = ComponentName->GetControllerName (\r
-                            ComponentName,\r
-                            ControllerHandle,\r
-                            ChildHandle,\r
-                            BestLanguage,\r
-                            ControllerName\r
-                            );\r
-  FreePool (BestLanguage);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-\r
-  This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface\r
-  in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.\r
-  If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward\r
-  compatibility support.\r
-\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  ControllerHandle     The handle of a controller that the driver specified by This is managing.\r
-                               This handle specifies the controller whose name is to be returned.\r
-  @param  ChildHandle          The handle of the child controller to retrieve the name of. This is an\r
-                               optional parameter that may be NULL. It will be NULL for device drivers.\r
-                               It will also be NULL for bus drivers that attempt to retrieve the name\r
-                               of the bus controller. It will not be NULL for a bus driver that attempts\r
-                               to retrieve the name of a child controller.\r
-  @param  ControllerName       A pointer to the Unicode string to return. This Unicode string\r
-                               is the name of the controller specified by ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_SUCCESS          The controller name is successfully retrieved from Component Name (2) protocol\r
-                               interface.\r
-  @retval Other                The controller name cannot be retrieved from Component Name (2) protocol.\r
-\r
-**/\r
-EFI_STATUS\r
-DriverHealthGetControllerName (\r
-  IN  EFI_HANDLE  DriverBindingHandle,\r
-  IN  EFI_HANDLE  ControllerHandle,\r
-  IN  EFI_HANDLE  ChildHandle,\r
-  OUT CHAR16      **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS      Status;\r
-\r
-  //\r
-  // Get controller name from UEFI 2.0 Component Name 2 protocol interface.\r
-  //\r
-  Status = GetControllerNameWorker (\r
-             &gEfiComponentName2ProtocolGuid,\r
-             DriverBindingHandle,\r
-             ControllerHandle,\r
-             ChildHandle,\r
-             ControllerName\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // If it fails to get the controller name from Component Name protocol interface, we should fall back on\r
-    // EFI 1.1 Component Name protocol interface.\r
-    //\r
-    Status = GetControllerNameWorker (\r
-               &gEfiComponentNameProtocolGuid,\r
-               DriverBindingHandle,\r
-               ControllerHandle,\r
-               ChildHandle,\r
-               ControllerName\r
-               );\r
-  }\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.h b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.h
deleted file mode 100644 (file)
index 013bc58..0000000
+++ /dev/null
@@ -1,517 +0,0 @@
-/** @file\r
-  The platform device manager reference implement\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _DEVICE_MANAGER_H_\r
-#define _DEVICE_MANAGER_H_\r
-\r
-#include "Bds.h"\r
-#include "FrontPage.h"\r
-#include "DeviceManagerVfr.h"\r
-#include <Protocol/PciIo.h>\r
-\r
-#define DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE       SIGNATURE_32 ('D', 'M', 'C', 'B')\r
-#define DEVICE_MANAGER_DRIVER_HEALTH_INFO_SIGNATURE  SIGNATURE_32 ('D', 'M', 'D', 'H')\r
-\r
-\r
-typedef struct {\r
-  UINTN                           Signature;\r
-\r
-  ///\r
-  /// Device Manager HII relative handles\r
-  ///\r
-  EFI_HII_HANDLE                  HiiHandle;\r
-\r
-  ///\r
-  /// Driver Health HII relative handles\r
-  ///\r
-  EFI_HII_HANDLE                  DriverHealthHiiHandle;\r
-\r
-  EFI_HANDLE                      DriverHandle;\r
-  EFI_HANDLE                      DriverHealthHandle;\r
-\r
-  ///\r
-  /// Device Manager Produced protocols\r
-  ///\r
-  EFI_HII_CONFIG_ACCESS_PROTOCOL  ConfigAccess;\r
-\r
-  ///\r
-  /// Driver Health Produced protocols\r
-  ///\r
-  EFI_HII_CONFIG_ACCESS_PROTOCOL  DriverHealthConfigAccess;\r
-\r
-  ///\r
-  /// Configuration data\r
-  ///\r
-  UINT8                           VideoBios;\r
-} DEVICE_MANAGER_CALLBACK_DATA;\r
-\r
-\r
-typedef struct {\r
-  UINTN                           Signature;\r
-  LIST_ENTRY                      Link;\r
-\r
-  ///\r
-  /// HII relative handles\r
-  ///\r
-  EFI_HII_HANDLE                  HiiHandle;\r
-\r
-  ///\r
-  /// Driver relative handles\r
-  ///\r
-  EFI_HANDLE                      DriverHandle;\r
-  EFI_HANDLE                      ControllerHandle;\r
-  EFI_HANDLE                      ChildHandle;\r
-\r
-  EFI_DRIVER_HEALTH_PROTOCOL      *DriverHealth;\r
-  ///\r
-  /// Driver health messages of the specify Driver\r
-  ///\r
-  EFI_DRIVER_HEALTH_HII_MESSAGE   *MessageList;\r
-\r
-  ///\r
-  /// Driver Health status\r
-  ///\r
-  EFI_DRIVER_HEALTH_STATUS        HealthStatus;\r
-} DRIVER_HEALTH_INFO;\r
-\r
-typedef struct {\r
-  EFI_STRING_ID    PromptId;\r
-  EFI_QUESTION_ID  QuestionId;\r
-}MENU_INFO_ITEM;\r
-\r
-typedef struct {\r
-  UINTN           CurListLen;\r
-  UINTN           MaxListLen;\r
-  MENU_INFO_ITEM  *NodeList;\r
-} MAC_ADDRESS_NODE_LIST;\r
-\r
-#define DEVICE_MANAGER_HEALTH_INFO_FROM_LINK(a) \\r
-  CR (a, \\r
-      DRIVER_HEALTH_INFO, \\r
-      Link, \\r
-      DEVICE_MANAGER_DRIVER_HEALTH_INFO_SIGNATURE \\r
-      )\r
-\r
-#define DEVICE_MANAGER_CALLBACK_DATA_FROM_THIS(a) \\r
-  CR (a, \\r
-      DEVICE_MANAGER_CALLBACK_DATA, \\r
-      ConfigAccess, \\r
-      DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE \\r
-      )\r
-typedef struct {\r
-  EFI_STRING_ID  StringId;\r
-  UINT16         Class;\r
-} DEVICE_MANAGER_MENU_ITEM;\r
-\r
-/**\r
-  This function is invoked if user selected a interactive opcode from Device Manager's\r
-  Formset. The decision by user is saved to gCallbackKey for later processing. If\r
-  user set VBIOS, the new value is saved to EFI variable.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceManagerCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  );\r
-\r
-/**\r
-  This function is invoked if user selected a interactive opcode from Driver Health's\r
-  Formset. The decision by user is saved to gCallbackKey for later processing.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DriverHealthCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  );\r
-\r
-\r
-/**\r
-\r
-  This function registers HII packages to HII database.\r
-\r
-  @retval  EFI_SUCCESS           HII packages for the Device Manager were registered successfully.\r
-  @retval  EFI_OUT_OF_RESOURCES  HII packages for the Device Manager failed to be registered.\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeDeviceManager (\r
-  VOID\r
-  );\r
-\r
-/**\r
-\r
-  Call the browser and display the device manager to allow user\r
-  to configure the platform.\r
-\r
-  This function create the dynamic content for device manager. It includes\r
-  section header for all class of devices, one-of opcode to set VBIOS.\r
-\r
-  @retval  EFI_SUCCESS             Operation is successful.\r
-  @retval  Other values if failed to clean up the dynamic content from HII\r
-           database.\r
-\r
-**/\r
-EFI_STATUS\r
-CallDeviceManager (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Check the Driver Health status of a single controller and try to process it if not healthy.\r
-\r
-  This function called by CheckAllControllersHealthStatus () function in order to process a specify\r
-  contoller's health state.\r
-\r
-  @param DriverHealthList   A Pointer to the list contain all of the platform driver health information.\r
-  @param DriverHandle       The handle of driver.\r
-  @param ControllerHandle   The class guid specifies which form set will be displayed.\r
-  @param ChildHandle        The handle of the child controller to retrieve the health\r
-                            status on.  This is an optional parameter that may be NULL.\r
-  @param DriverHealth       A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r
-  @param HealthStatus       The health status of the controller.\r
-\r
-  @retval EFI_INVALID_PARAMETER   HealthStatus or DriverHealth is NULL.\r
-  @retval HealthStatus            The Health status of specify controller.\r
-  @retval EFI_OUT_OF_RESOURCES    The list of Driver Health Protocol handles can not be retrieved.\r
-  @retval EFI_NOT_FOUND           No controller in the platform install Driver Health Protocol.\r
-  @retval EFI_SUCCESS             The Health related operation has been taken successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GetSingleControllerHealthStatus (\r
-  IN OUT LIST_ENTRY                   *DriverHealthList,\r
-  IN EFI_HANDLE                       DriverHandle,\r
-  IN EFI_HANDLE                       ControllerHandle,  OPTIONAL\r
-  IN EFI_HANDLE                       ChildHandle,       OPTIONAL\r
-  IN EFI_DRIVER_HEALTH_PROTOCOL       *DriverHealth,\r
-  IN EFI_DRIVER_HEALTH_STATUS         *HealthStatus\r
-  );\r
-\r
-/**\r
-  Collects all the EFI Driver Health Protocols currently present in the EFI Handle Database,\r
-  and queries each EFI Driver Health Protocol to determine if one or more of the controllers\r
-  managed by each EFI Driver Health Protocol instance are not healthy.\r
-\r
-  @param DriverHealthList   A Pointer to the list contain all of the platform driver health\r
-                            information.\r
-\r
-  @retval    EFI_NOT_FOUND         No controller in the platform install Driver Health Protocol.\r
-  @retval    EFI_SUCCESS           All the controllers in the platform are healthy.\r
-  @retval    EFI_OUT_OF_RESOURCES  The list of Driver Health Protocol handles can not be retrieved.\r
-\r
-**/\r
-EFI_STATUS\r
-GetAllControllersHealthStatus (\r
-  IN OUT LIST_ENTRY  *DriverHealthList\r
-  );\r
-\r
-/**\r
-  Check the healthy status of the platform, this function will return immediately while found one driver\r
-  in the platform are not healthy.\r
-\r
-  @retval FALSE      at least one driver in the platform are not healthy.\r
-  @retval TRUE       No controller install Driver Health Protocol,\r
-                     or all controllers in the platform are in healthy status.\r
-**/\r
-BOOLEAN\r
-PlaformHealthStatusCheck (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Repair the whole platform.\r
-\r
-  This function is the main entry for user choose "Repair All" in the front page.\r
-  It will try to do recovery job till all the driver health protocol installed modules\r
-  reach a terminal state.\r
-\r
-  @param DriverHealthList   A Pointer to the list contain all of the platform driver health\r
-                            information.\r
-\r
-**/\r
-VOID\r
-PlatformRepairAll (\r
-  IN LIST_ENTRY  *DriverHealthList\r
-  );\r
-\r
-/**\r
-  Processes a single controller using the EFI Driver Health Protocol associated with\r
-  that controller. This algorithm continues to query the GetHealthStatus() service until\r
-  one of the legal terminal states of the EFI Driver Health Protocol is reached. This may\r
-  require the processing of HII Messages, HII Form, and invocation of repair operations.\r
-\r
-  @param DriverHealth       A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r
-  @param ControllerHandle   The class guid specifies which form set will be displayed.\r
-  @param ChildHandle        The handle of the child controller to retrieve the health\r
-                            status on.  This is an optional parameter that may be NULL.\r
-  @param HealthStatus       The health status of the controller.\r
-  @param MessageList        An array of warning or error messages associated\r
-                            with the controller specified by ControllerHandle and\r
-                            ChildHandle.  This is an optional parameter that may be NULL.\r
-  @param FormHiiHandle      The HII handle for an HII form associated with the\r
-                            controller specified by ControllerHandle and ChildHandle.\r
-  @param RebootRequired     Indicate whether a reboot is required to repair the controller.\r
-**/\r
-VOID\r
-ProcessSingleControllerHealth (\r
-  IN  EFI_DRIVER_HEALTH_PROTOCOL         *DriverHealth,\r
-  IN  EFI_HANDLE                         ControllerHandle, OPTIONAL\r
-  IN  EFI_HANDLE                         ChildHandle,      OPTIONAL\r
-  IN  EFI_DRIVER_HEALTH_STATUS           HealthStatus,\r
-  IN  EFI_DRIVER_HEALTH_HII_MESSAGE      **MessageList,    OPTIONAL\r
-  IN  EFI_HII_HANDLE                     FormHiiHandle,\r
-  IN OUT BOOLEAN                         *RebootRequired\r
-  );\r
-\r
-/**\r
-  Reports the progress of a repair operation.\r
-\r
-  @param[in]  Value             A value between 0 and Limit that identifies the current\r
-                                progress of the repair operation.\r
-\r
-  @param[in]  Limit             The maximum value of Value for the current repair operation.\r
-                                For example, a driver that wants to specify progress in\r
-                                percent would use a Limit value of 100.\r
-\r
-  @retval EFI_SUCCESS           The progress of a repair operation is reported successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RepairNotify (\r
-  IN  UINTN Value,\r
-  IN  UINTN Limit\r
-  );\r
-\r
-/**\r
-  Processes a set of messages returned by the GetHealthStatus ()\r
-  service of the EFI Driver Health Protocol\r
-\r
-  @param    MessageList  The MessageList point to messages need to processed.\r
-\r
-**/\r
-VOID\r
-ProcessMessages (\r
-  IN  EFI_DRIVER_HEALTH_HII_MESSAGE      *MessageList\r
-  );\r
-\r
-\r
-/**\r
-  Collect and display the platform's driver health relative information, allow user to do interactive\r
-  operation while the platform is unhealthy.\r
-\r
-  This function display a form which divided into two parts. The one list all modules which has installed\r
-  driver health protocol. The list usually contain driver name, controller name, and it's health info.\r
-  While the driver name can't be retrieved, will use device path as backup. The other part of the form provide\r
-  a choice to the user to repair all platform.\r
-\r
-**/\r
-VOID\r
-CallDriverHealth (\r
-  VOID\r
-  );\r
-\r
-/**\r
-\r
-  Select the best matching language according to front page policy for best user experience.\r
-\r
-  This function supports both ISO 639-2 and RFC 4646 language codes, but language\r
-  code types may not be mixed in a single call to this function.\r
-\r
-  @param  SupportedLanguages   A pointer to a Null-terminated ASCII string that\r
-                               contains a set of language codes in the format\r
-                               specified by Iso639Language.\r
-  @param  Iso639Language       If TRUE, then all language codes are assumed to be\r
-                               in ISO 639-2 format.  If FALSE, then all language\r
-                               codes are assumed to be in RFC 4646 language format.\r
-\r
-  @retval NULL                 The best matching language could not be found in SupportedLanguages.\r
-  @retval NULL                 There are not enough resources available to return the best matching\r
-                               language.\r
-  @retval Other                A pointer to a Null-terminated ASCII string that is the best matching\r
-                               language in SupportedLanguages.\r
-**/\r
-CHAR8 *\r
-DriverHealthSelectBestLanguage (\r
-  IN CHAR8        *SupportedLanguages,\r
-  IN BOOLEAN      Iso639Language\r
-  );\r
-\r
-/**\r
-\r
-  This is an internal worker function to get the Component Name (2) protocol interface\r
-  and the language it supports.\r
-\r
-  @param  ProtocolGuid         A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  ComponentName        A pointer to the Component Name (2) protocol interface.\r
-  @param  SupportedLanguage    The best suitable language that matches the SupportedLangues interface for the\r
-                               located Component Name (2) instance.\r
-\r
-  @retval EFI_SUCCESS          The Component Name (2) protocol instance is successfully located and we find\r
-                               the best matching language it support.\r
-  @retval EFI_UNSUPPORTED      The input Language is not supported by the Component Name (2) protocol.\r
-  @retval Other                Some error occurs when locating Component Name (2) protocol instance or finding\r
-                               the supported language.\r
-\r
-**/\r
-EFI_STATUS\r
-GetComponentNameWorker (\r
-  IN  EFI_GUID                    *ProtocolGuid,\r
-  IN  EFI_HANDLE                  DriverBindingHandle,\r
-  OUT EFI_COMPONENT_NAME_PROTOCOL **ComponentName,\r
-  OUT CHAR8                       **SupportedLanguage\r
-  );\r
-\r
-/**\r
-\r
-  This is an internal worker function to get driver name from Component Name (2) protocol interface.\r
-\r
-\r
-  @param  ProtocolGuid         A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  DriverName           A pointer to the Unicode string to return. This Unicode string is the name\r
-                               of the driver specified by This.\r
-\r
-  @retval EFI_SUCCESS          The driver name is successfully retrieved from Component Name (2) protocol\r
-                               interface.\r
-  @retval Other                The driver name cannot be retrieved from Component Name (2) protocol\r
-                               interface.\r
-\r
-**/\r
-EFI_STATUS\r
-GetDriverNameWorker (\r
-  IN  EFI_GUID    *ProtocolGuid,\r
-  IN  EFI_HANDLE  DriverBindingHandle,\r
-  OUT CHAR16      **DriverName\r
-  );\r
-\r
-/**\r
-\r
-  This function gets driver name from Component Name 2 protocol interface and Component Name protocol interface\r
-  in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the driver name.\r
-  If the attempt fails, it then gets the driver name from EFI 1.1 Component Name protocol for backward\r
-  compatibility support.\r
-\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  DriverName           A pointer to the Unicode string to return. This Unicode string is the name\r
-                               of the driver specified by This.\r
-\r
-  @retval EFI_SUCCESS          The driver name is successfully retrieved from Component Name (2) protocol\r
-                               interface.\r
-  @retval Other                The driver name cannot be retrieved from Component Name (2) protocol\r
-                               interface.\r
-\r
-**/\r
-EFI_STATUS\r
-DriverHealthGetDriverName (\r
-  IN  EFI_HANDLE  DriverBindingHandle,\r
-  OUT CHAR16      **DriverName\r
-  );\r
-\r
-/**\r
-  This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface\r
-  in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.\r
-  If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward\r
-  compatibility support.\r
-\r
-  @param  ProtocolGuid         A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  ControllerHandle     The handle of a controller that the driver specified by This is managing.\r
-                               This handle specifies the controller whose name is to be returned.\r
-  @param  ChildHandle          The handle of the child controller to retrieve the name of. This is an\r
-                               optional parameter that may be NULL. It will be NULL for device drivers.\r
-                               It will also be NULL for bus drivers that attempt to retrieve the name\r
-                               of the bus controller. It will not be NULL for a bus driver that attempts\r
-                               to retrieve the name of a child controller.\r
-  @param  ControllerName       A pointer to the Unicode string to return. This Unicode string\r
-                               is the name of the controller specified by ControllerHandle and ChildHandle.\r
-\r
-  @retval  EFI_SUCCESS         The controller name is successfully retrieved from Component Name (2) protocol\r
-                               interface.\r
-  @retval  Other               The controller name cannot be retrieved from Component Name (2) protocol.\r
-\r
-**/\r
-EFI_STATUS\r
-GetControllerNameWorker (\r
-  IN  EFI_GUID    *ProtocolGuid,\r
-  IN  EFI_HANDLE  DriverBindingHandle,\r
-  IN  EFI_HANDLE  ControllerHandle,\r
-  IN  EFI_HANDLE  ChildHandle,\r
-  OUT CHAR16      **ControllerName\r
-  );\r
-\r
-/**\r
-  This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface\r
-  in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.\r
-  If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward\r
-  compatibility support.\r
-\r
-  @param  DriverBindingHandle  The handle on which the Component Name (2) protocol instance is retrieved.\r
-  @param  ControllerHandle     The handle of a controller that the driver specified by This is managing.\r
-                               This handle specifies the controller whose name is to be returned.\r
-  @param  ChildHandle          The handle of the child controller to retrieve the name of. This is an\r
-                               optional parameter that may be NULL. It will be NULL for device drivers.\r
-                               It will also be NULL for bus drivers that attempt to retrieve the name\r
-                               of the bus controller. It will not be NULL for a bus driver that attempts\r
-                               to retrieve the name of a child controller.\r
-  @param  ControllerName       A pointer to the Unicode string to return. This Unicode string\r
-                               is the name of the controller specified by ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_SUCCESS          The controller name is successfully retrieved from Component Name (2) protocol\r
-                               interface.\r
-  @retval Other                The controller name cannot be retrieved from Component Name (2) protocol.\r
-\r
-**/\r
-EFI_STATUS\r
-DriverHealthGetControllerName (\r
-  IN  EFI_HANDLE  DriverBindingHandle,\r
-  IN  EFI_HANDLE  ControllerHandle,\r
-  IN  EFI_HANDLE  ChildHandle,\r
-  OUT CHAR16      **ControllerName\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManagerStrings.uni b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManagerStrings.uni
deleted file mode 100644 (file)
index 6f62958..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-///** @file\r
-//\r
-//    String definitions for the Device Manager.\r
-//\r
-//  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-//**/\r
-\r
-/=#\r
-\r
-#langdef   en-US "English"\r
-#langdef   fr-FR "Français"\r
-\r
-#string STR_DEVICE_MANAGER_TITLE       #language en-US  "Device Manager"\r
-                                       #language fr-FR  "Device Manager"\r
-#string STR_DEVICES_LIST               #language en-US  "Devices List"\r
-                                       #language fr-FR  "Devices List"\r
-#string STR_DISK_DEVICE                #language en-US  "Disk Devices"\r
-                                       #language fr-FR  "Disk Devices"\r
-#string STR_VIDEO_DEVICE               #language en-US  "Video Devices"\r
-                                       #language fr-FR  "Video Devices"\r
-#string STR_NETWORK_DEVICE             #language en-US  "Network Devices"\r
-                                       #language fr-FR  "Network Devices"\r
-#string STR_INPUT_DEVICE               #language en-US  "Input Devices"\r
-                                       #language fr-FR  "Input Devices"\r
-#string STR_ON_BOARD_DEVICE            #language en-US  "Motherboard Devices"\r
-                                       #language fr-FR  "Motherboard Devices"\r
-#string STR_OTHER_DEVICE               #language en-US  "Other Devices"\r
-                                       #language fr-FR  "Other Devices"\r
-#string STR_EMPTY_STRING               #language en-US  ""\r
-                                       #language fr-FR  ""\r
-#string STR_DRIVER_HEALTH_STATUS_HELP  #language en-US  "Check whether all the controllers in the platform are healthy"\r
-                                       #language fr-FR  "Check whether all the controllers in the platform are healthy"\r
-#string STR_DRIVER_HEALTH_ALL_HEALTHY  #language en-US  "  The platform is healthy"\r
-                                       #language fr-FR  "  The platform is healthy"\r
-#string STR_DRIVER_NOT_HEALTH          #language en-US  "  Some drivers are not healthy"\r
-                                       #language fr-FR  "  Some drivers are not healthy"\r
-#string STR_DH_BANNER                  #language en-US  "Driver Health"\r
-                                       #language fr-FR  "Driver Health"\r
-#string STR_DM_DRIVER_HEALTH_TITLE     #language en-US  "Driver Health"\r
-                                       #language fr-FR  "Driver Health"\r
-#string STR_DH_STATUS_LIST             #language en-US  "All Driver Health Status List"\r
-                                       #language fr-FR  "All Driver Health Status List"\r
-#string STR_DRIVER_HEALTH_REPAIR_ALL   #language en-US  "Repair All"\r
-                                       #language fr-FR  "Repair All"\r
-#string STR_DH_REPAIR_ALL_TITLE        #language en-US  "Repair the whole platform"\r
-                                       #language fr-FR  "Repair the whole platform"\r
-#string STR_DH_REPAIR_ALL_HELP         #language en-US  "Repair the whole platform until all modules reach terminal status"\r
-                                       #language fr-FR  "Repair the whole platform until all modules reach terminal status"\r
-#string STR_DH_REPAIR_SINGLE_TITLE     #language en-US  "Item cannot get name"\r
-                                       #language fr-FR  "Item cannot get name"\r
-#string STR_DH_REPAIR_SINGLE_HELP      #language en-US  "Repair single driver with specify controller"\r
-                                       #language fr-FR  "Repair single driver with specify controller"\r
-\r
-#string STR_EXIT_STRING                #language en-US  "Press ESC to exit."\r
-                                       #language fr-FR  "Press ESC to exit."\r
-#string STR_REPAIR_REQUIRED            #language en-US  "  Repair Required."\r
-                                       #language fr-FR  "  Repair Required."\r
-#string STR_CONFIGURATION_REQUIRED     #language en-US  "  Configuration Required."\r
-                                       #language fr-FR  "  Configuration Required."\r
-#string STR_OPERATION_FAILED           #language en-US  "  Operation Failed."\r
-                                       #language fr-FR  "  Operation Failed."\r
-#string STR_RECONNECT_REQUIRED         #language en-US  "  Reconnect Required."\r
-                                       #language fr-FR  "  Reconnect Required."\r
-#string STR_REBOOT_REQUIRED            #language en-US  "  Reboot Required."\r
-                                       #language fr-FR  "  Reboot Required."\r
-#string STR_NO_OPERATION_REQUIRED      #language en-US  "  No Operation Required."\r
-                                       #language fr-FR  "  No Operation Required."\r
-#string STR_DRIVER_HEALTH_HEALTHY      #language en-US  "  Healthy."\r
-                                       #language fr-FR  "  Healthy."\r
-#string STR_FORM_NETWORK_DEVICE_TITLE  #language en-US  "Network Device"\r
-                                       #language fr-FR  "Network Device"\r
-#string STR_FORM_NETWORK_DEVICE_HELP   #language en-US  "Network Device Help..."\r
-                                       #language fr-FR  "Network Device Help..."\r
-#string STR_NETWORK_DEVICE_STRING      #language en-US  "Network Device"\r
-                                       #language fr-FR  "Network Device"\r
-#string STR_FORM_NETWORK_DEVICE_LIST_HELP   #language en-US  "Select the network device according the MAC address"\r
-                                            #language fr-FR  "Select the network device according the MAC address"\r
-#string STR_FORM_NETWORK_DEVICE_LIST_TITLE  #language en-US  "Network Device List"\r
-                                            #language fr-FR  "Network Device List"\r
-#string STR_NETWORK_DEVICE_LIST_STRING      #language en-US  "Network Device List"\r
-                                            #language fr-FR  "Network Device List"\r
-#string STR_NETWORK_DEVICE_HELP             #language en-US  "Network Device"\r
-                                            #language fr-FR  "Network Device"\r
-//\r
-// Ensure that this is the last string.  We are using it programmatically\r
-// to do string token re-usage settings for the Device Manager since we are\r
-// constantly recreating this page based on HII population.\r
-////\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManagerVfr.Vfr b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManagerVfr.Vfr
deleted file mode 100644 (file)
index 6232aa9..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-///** @file\r
-//  \r
-//    Device Manager formset.\r
-//  \r
-//  Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//  \r
-//**/\r
-\r
-#include "DeviceManagerVfr.h"\r
-\r
-#define EFI_DISK_DEVICE_CLASS              0x0001\r
-#define EFI_VIDEO_DEVICE_CLASS             0x0002\r
-#define EFI_NETWORK_DEVICE_CLASS           0x0004\r
-#define EFI_INPUT_DEVICE_CLASS             0x0008\r
-#define EFI_ON_BOARD_DEVICE_CLASS          0x0010\r
-#define EFI_OTHER_DEVICE_CLASS             0x0020\r
-\r
-#define DEVICE_MANAGER_CLASS               0x0000\r
-#define FRONT_PAGE_SUBCLASS                0x0003\r
-\r
-formset\r
-  guid      = DEVICE_MANAGER_FORMSET_GUID,\r
-  title     = STRING_TOKEN(STR_DEVICE_MANAGER_TITLE),\r
-  help      = STRING_TOKEN(STR_EMPTY_STRING),\r
-  classguid = DEVICE_MANAGER_FORMSET_GUID,\r
-\r
-  form formid = DEVICE_MANAGER_FORM_ID,\r
-       title  = STRING_TOKEN(STR_DEVICE_MANAGER_TITLE);\r
-\r
-    subtitle text = STRING_TOKEN(STR_DEVICES_LIST);\r
-    //\r
-    // This is where devices get added to the device manager hierarchy\r
-    //\r
-    label EFI_DISK_DEVICE_CLASS;\r
-//    label LABEL_END;  // Since next opcode is a label, so this one could be omitted to save code size\r
-\r
-    label EFI_VIDEO_DEVICE_CLASS;\r
-//    label LABEL_END;\r
-\r
-    label EFI_NETWORK_DEVICE_CLASS;\r
-//    label LABEL_END;\r
-\r
-    label EFI_INPUT_DEVICE_CLASS;\r
-//    label LABEL_END;\r
-\r
-    label EFI_ON_BOARD_DEVICE_CLASS;\r
-//    label LABEL_END;\r
-\r
-//    label EFI_OTHER_DEVICE_CLASS;\r
-\r
-    label LABEL_DEVICES_LIST;\r
-    label LABEL_END;\r
-      \r
-    subtitle text = STRING_TOKEN(STR_EMPTY_STRING);\r
-\r
-    label LABEL_VBIOS;\r
-    label LABEL_END;\r
-    \r
-    subtitle text = STRING_TOKEN(STR_EMPTY_STRING);\r
-    subtitle text = STRING_TOKEN(STR_EXIT_STRING);\r
-\r
-  endform;\r
-\r
-  form formid = NETWORK_DEVICE_LIST_FORM_ID,\r
-       title = STRING_TOKEN(STR_FORM_NETWORK_DEVICE_LIST_TITLE);\r
-\r
-    subtitle text = STRING_TOKEN(STR_NETWORK_DEVICE_LIST_STRING);\r
-\r
-       label LABEL_NETWORK_DEVICE_LIST_ID;\r
-       label LABEL_END;\r
-       subtitle text = STRING_TOKEN(STR_EMPTY_STRING);\r
-    subtitle text = STRING_TOKEN(STR_EXIT_STRING);\r
-  endform;\r
-\r
-  form formid = NETWORK_DEVICE_FORM_ID,\r
-       title = STRING_TOKEN(STR_FORM_NETWORK_DEVICE_TITLE);\r
-\r
-    subtitle text = STRING_TOKEN(STR_NETWORK_DEVICE_STRING);\r
-\r
-       label LABEL_NETWORK_DEVICE_ID;\r
-       label LABEL_END;\r
-       subtitle text = STRING_TOKEN(STR_EMPTY_STRING);\r
-    subtitle text = STRING_TOKEN(STR_EXIT_STRING);\r
-  endform;\r
-endformset;\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManagerVfr.h b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManagerVfr.h
deleted file mode 100644 (file)
index 0aa4785..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/** @file\r
-  The platform device manager reference implement\r
-\r
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _DEVICE_MANAGER_VFR_H_\r
-#define _DEVICE_MANAGER_VFR_H_\r
-\r
-#include <Guid/BdsHii.h>\r
-\r
-#define LABEL_DEVICES_LIST                   0x1100\r
-#define LABEL_NETWORK_DEVICE_LIST_ID         0x1101\r
-#define LABEL_NETWORK_DEVICE_ID              0x1102\r
-#define LABEL_END                            0xffff\r
-#define LABEL_FORM_ID_OFFSET                 0x0100\r
-\r
-#define LABEL_DRIVER_HEALTH                  0x2000\r
-#define LABEL_DRIVER_HEALTH_END              0x2001\r
-\r
-#define LABEL_DRIVER_HEALTH_REAPIR_ALL       0x3000\r
-#define LABEL_DRIVER_HEALTH_REAPIR_ALL_END   0x3001\r
-\r
-#define LABEL_VBIOS                          0x0040\r
-\r
-#define INVALID_FORM_ID                      0x0FFF\r
-#define DEVICE_MANAGER_FORM_ID               0x1000\r
-#define NETWORK_DEVICE_LIST_FORM_ID          0x1001\r
-#define NETWORK_DEVICE_FORM_ID               0x1002\r
-#define DRIVER_HEALTH_FORM_ID                0x1003\r
-#define DEVICE_KEY_OFFSET                    0x4000\r
-#define NETWORK_DEVICE_LIST_KEY_OFFSET       0x2000\r
-#define DEVICE_MANAGER_KEY_VBIOS             0x3000\r
-#define MAX_KEY_SECTION_LEN                  0x1000\r
-\r
-#define DEVICE_MANAGER_KEY_DRIVER_HEALTH     0x1111\r
-#define DRIVER_HEALTH_KEY_OFFSET             0x2000\r
-#define DRIVER_HEALTH_REPAIR_ALL_KEY         0x3000\r
-#define DRIVER_HEALTH_RETURN_KEY             0x4000\r
-\r
-#define QUESTION_NETWORK_DEVICE_ID           0x3FFF\r
-//\r
-// These are the VFR compiler generated data representing our VFR data.\r
-//\r
-extern UINT8  DeviceManagerVfrBin[];\r
-extern UINT8  DriverHealthVfrBin[];\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DriverHealthVfr.Vfr b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DriverHealthVfr.Vfr
deleted file mode 100644 (file)
index fda76cf..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-///** @file\r
-//  \r
-//    Driver Health formset.\r
-//  \r
-//  Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//  \r
-//**/\r
-\r
-#include "DeviceManagerVfr.h"\r
-\r
-formset\r
-  guid      = DRIVER_HEALTH_FORMSET_GUID,\r
-  title     = STRING_TOKEN(STR_DH_BANNER),\r
-  help      = STRING_TOKEN(STR_EMPTY_STRING),\r
-  classguid = DRIVER_HEALTH_FORMSET_GUID,\r
\r
-  form formid = DRIVER_HEALTH_FORM_ID,\r
-      title  = STRING_TOKEN(STR_DH_BANNER);\r
-\r
-      label LABEL_DRIVER_HEALTH;\r
-      label LABEL_DRIVER_HEALTH_END;  \r
-            \r
-      subtitle text = STRING_TOKEN(STR_LAST_STRING);\r
-      label LABEL_DRIVER_HEALTH_REAPIR_ALL;\r
-      label LABEL_DRIVER_HEALTH_REAPIR_ALL_END;\r
-            \r
-      subtitle text = STRING_TOKEN(STR_LAST_STRING);\r
-      subtitle text = STRING_TOKEN(STR_HELP_FOOTER);\r
-      subtitle text = STRING_TOKEN(STR_LAST_STRING);      \r
-  endform;   \r
-endformset;\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
deleted file mode 100644 (file)
index 67f9371..0000000
+++ /dev/null
@@ -1,1452 +0,0 @@
-/** @file\r
-  FrontPage routines to handle the callbacks and browser calls\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Bds.h"\r
-#include "FrontPage.h"\r
-#include "Language.h"\r
-#include "Hotkey.h"\r
-\r
-BOOLEAN   mModeInitialized = FALSE;\r
-\r
-BOOLEAN   gConnectAllHappened = FALSE;\r
-UINTN     gCallbackKey;\r
-CHAR8     *mLanguageString;\r
-\r
-//\r
-// Boot video resolution and text mode.\r
-//\r
-UINT32    mBootHorizontalResolution    = 0;\r
-UINT32    mBootVerticalResolution      = 0;\r
-UINT32    mBootTextModeColumn          = 0;\r
-UINT32    mBootTextModeRow             = 0;\r
-//\r
-// BIOS setup video resolution and text mode.\r
-//\r
-UINT32    mSetupTextModeColumn         = 0;\r
-UINT32    mSetupTextModeRow            = 0;\r
-UINT32    mSetupHorizontalResolution   = 0;\r
-UINT32    mSetupVerticalResolution     = 0;\r
-\r
-EFI_FORM_BROWSER2_PROTOCOL      *gFormBrowser2;\r
-\r
-FRONT_PAGE_CALLBACK_DATA  gFrontPagePrivate = {\r
-  FRONT_PAGE_CALLBACK_DATA_SIGNATURE,\r
-  NULL,\r
-  NULL,\r
-  NULL,\r
-  {\r
-    FakeExtractConfig,\r
-    FakeRouteConfig,\r
-    FrontPageCallback\r
-  }\r
-};\r
-\r
-HII_VENDOR_DEVICE_PATH  mFrontPageHiiVendorDevicePath = {\r
-  {\r
-    {\r
-      HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,\r
-      {\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    FRONT_PAGE_FORMSET_GUID\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      (UINT8) (END_DEVICE_PATH_LENGTH),\r
-      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
-    }\r
-  }\r
-};\r
-\r
-/**\r
-  This function allows a caller to extract the current configuration for one\r
-  or more named elements from the target driver.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Request         A null-terminated Unicode string in <ConfigRequest> format.\r
-  @param Progress        On return, points to a character in the Request string.\r
-                         Points to the string's null terminator if request was successful.\r
-                         Points to the most recent '&' before the first failing name/value\r
-                         pair (or the beginning of the string if the failure is in the\r
-                         first name/value pair) if the request was not successful.\r
-  @param Results         A null-terminated Unicode string in <ConfigAltResp> format which\r
-                         has all values filled in for the names in the Request string.\r
-                         String to be allocated by the called function.\r
-\r
-  @retval  EFI_SUCCESS            The Results is filled with the requested values.\r
-  @retval  EFI_OUT_OF_RESOURCES   Not enough memory to store the results.\r
-  @retval  EFI_INVALID_PARAMETER  Request is illegal syntax, or unknown name.\r
-  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeExtractConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Request,\r
-  OUT EFI_STRING                             *Progress,\r
-  OUT EFI_STRING                             *Results\r
-  )\r
-{\r
-  if (Progress == NULL || Results == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  *Progress = Request;\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Configuration   A null-terminated Unicode string in <ConfigResp> format.\r
-  @param Progress        A pointer to a string filled in with the offset of the most\r
-                         recent '&' before the first failing name/value pair (or the\r
-                         beginning of the string if the failure is in the first\r
-                         name/value pair) or the terminating NULL if all was successful.\r
-\r
-  @retval  EFI_SUCCESS            The Results is processed successfully.\r
-  @retval  EFI_INVALID_PARAMETER  Configuration is NULL.\r
-  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeRouteConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Configuration,\r
-  OUT EFI_STRING                             *Progress\r
-  )\r
-{\r
-  if (Configuration == NULL || Progress == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *Progress = Configuration;\r
-  if (!HiiIsConfigHdrMatch (Configuration, &gBootMaintFormSetGuid, mBootMaintStorageName)\r
-      && !HiiIsConfigHdrMatch (Configuration, &gFileExploreFormSetGuid, mFileExplorerStorageName)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  *Progress = Configuration + StrLen (Configuration);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-\r
-\r
-  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          Specifies the type of action taken by the browser.\r
-  @param QuestionId      A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            The type of value for the question.\r
-  @param Value           A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_OUT_OF_RESOURCES  Not enough storage is available to hold the variable and its data.\r
-  @retval  EFI_DEVICE_ERROR      The variable could not be saved.\r
-  @retval  EFI_UNSUPPORTED       The specified Action is not supported by the callback.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FrontPageCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  )\r
-{\r
-  CHAR8                         *LangCode;\r
-  CHAR8                         *Lang;\r
-  UINTN                         Index;\r
-\r
-  if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {\r
-    //\r
-    // All other action return unsupported.\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  gCallbackKey = QuestionId;\r
-\r
-  if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
-    if ((Value == NULL) || (ActionRequest == NULL)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    switch (QuestionId) {\r
-    case FRONT_PAGE_KEY_CONTINUE:\r
-      //\r
-      // This is the continue - clear the screen and return an error to get out of FrontPage loop\r
-      //\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-      break;\r
-\r
-    case FRONT_PAGE_KEY_LANGUAGE:\r
-      //\r
-      // Allocate working buffer for RFC 4646 language in supported LanguageString.\r
-      //\r
-      Lang = AllocatePool (AsciiStrSize (mLanguageString));\r
-      ASSERT (Lang != NULL);\r
-\r
-      Index = 0;\r
-      LangCode = mLanguageString;\r
-      while (*LangCode != 0) {\r
-        GetNextLanguage (&LangCode, Lang);\r
-\r
-        if (Index == Value->u8) {\r
-          break;\r
-        }\r
-\r
-        Index++;\r
-      }\r
-\r
-      if (Index == Value->u8) {\r
-        BdsDxeSetVariableAndReportStatusCodeOnError (\r
-                        L"PlatformLang",\r
-                        &gEfiGlobalVariableGuid,\r
-                        EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                        AsciiStrSize (Lang),\r
-                        Lang\r
-                        );\r
-      } else {\r
-        ASSERT (FALSE);\r
-      }\r
-\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-\r
-      FreePool (Lang);\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-  } else if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
-    if (Value == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    //\r
-    // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
-    // describe to their customers in documentation how to find their setup information (namely\r
-    // under the device manager and specific buckets)\r
-    //\r
-    switch (QuestionId) {\r
-    case FRONT_PAGE_KEY_BOOT_MANAGER:\r
-      //\r
-      // Boot Manager\r
-      //\r
-      break;\r
-\r
-    case FRONT_PAGE_KEY_DEVICE_MANAGER:\r
-      //\r
-      // Device Manager\r
-      //\r
-      break;\r
-\r
-    case FRONT_PAGE_KEY_BOOT_MAINTAIN:\r
-      //\r
-      // Boot Maintenance Manager\r
-      //\r
-      break;\r
-\r
-    default:\r
-      gCallbackKey = 0;\r
-      break;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Initialize HII information for the FrontPage\r
-\r
-\r
-  @param InitializeHiiData    TRUE if HII elements need to be initialized.\r
-\r
-  @retval  EFI_SUCCESS        The operation is successful.\r
-  @retval  EFI_DEVICE_ERROR   If the dynamic opcode creation failed.\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeFrontPage (\r
-  IN BOOLEAN                         InitializeHiiData\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  CHAR8                       *LangCode;\r
-  CHAR8                       *Lang;\r
-  UINTN                       LangSize;\r
-  CHAR8                       *CurrentLang;\r
-  UINTN                       OptionCount;\r
-  CHAR16                      *StringBuffer;\r
-  EFI_HII_HANDLE              HiiHandle;\r
-  VOID                        *OptionsOpCodeHandle;\r
-  VOID                        *StartOpCodeHandle;\r
-  VOID                        *EndOpCodeHandle;\r
-  EFI_IFR_GUID_LABEL          *StartLabel;\r
-  EFI_IFR_GUID_LABEL          *EndLabel;\r
-  EFI_HII_STRING_PROTOCOL     *HiiString;\r
-  UINTN                       StringSize;\r
-\r
-  Lang         = NULL;\r
-  StringBuffer = NULL;\r
-\r
-  if (InitializeHiiData) {\r
-    //\r
-    // Initialize the Device Manager\r
-    //\r
-    InitializeDeviceManager ();\r
-\r
-    //\r
-    // Initialize the Device Manager\r
-    //\r
-    InitializeBootManager ();\r
-\r
-    gCallbackKey  = 0;\r
-\r
-    //\r
-    // Locate Hii relative protocols\r
-    //\r
-    Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &gFormBrowser2);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    //\r
-    // Install Device Path Protocol and Config Access protocol to driver handle\r
-    //\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &gFrontPagePrivate.DriverHandle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    &mFrontPageHiiVendorDevicePath,\r
-                    &gEfiHiiConfigAccessProtocolGuid,\r
-                    &gFrontPagePrivate.ConfigAccess,\r
-                    NULL\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Publish our HII data\r
-    //\r
-    gFrontPagePrivate.HiiHandle = HiiAddPackages (\r
-                                    &gFrontPageFormSetGuid,\r
-                                    gFrontPagePrivate.DriverHandle,\r
-                                    FrontPageVfrBin,\r
-                                    BdsDxeStrings,\r
-                                    NULL\r
-                                    );\r
-    if (gFrontPagePrivate.HiiHandle == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-  }\r
-\r
-\r
-  //\r
-  // Init OpCode Handle and Allocate space for creation of UpdateData Buffer\r
-  //\r
-  StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (StartOpCodeHandle != NULL);\r
-\r
-  EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (EndOpCodeHandle != NULL);\r
-\r
-  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
-  ASSERT (OptionsOpCodeHandle != NULL);\r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  StartLabel->Number       = LABEL_SELECT_LANGUAGE;\r
-\r
-  //\r
-  // Create Hii Extend Label OpCode as the end opcode\r
-  //\r
-  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
-  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
-  EndLabel->Number       = LABEL_END;\r
-\r
-  //\r
-  // Collect the languages from what our current Language support is based on our VFR\r
-  //\r
-  HiiHandle = gFrontPagePrivate.HiiHandle;\r
-\r
-  GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLang, NULL);\r
-\r
-  //\r
-  // Get Support language list from variable.\r
-  //\r
-  if (mLanguageString == NULL){\r
-    GetEfiGlobalVariable2 (L"PlatformLangCodes", (VOID**)&mLanguageString, NULL);\r
-    if (mLanguageString == NULL) {\r
-      mLanguageString = AllocateCopyPool (\r
-                                 AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),\r
-                                 (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)\r
-                                 );\r
-      ASSERT (mLanguageString != NULL);\r
-    }\r
-  }\r
-\r
-  if (gFrontPagePrivate.LanguageToken == NULL) {\r
-    //\r
-    // Count the language list number.\r
-    //\r
-    LangCode      = mLanguageString;\r
-    Lang          = AllocatePool (AsciiStrSize (mLanguageString));\r
-    ASSERT (Lang != NULL);\r
-    OptionCount = 0;\r
-    while (*LangCode != 0) {\r
-      GetNextLanguage (&LangCode, Lang);\r
-      OptionCount ++;\r
-    }\r
-\r
-    //\r
-    // Allocate extra 1 as the end tag.\r
-    //\r
-    gFrontPagePrivate.LanguageToken = AllocateZeroPool ((OptionCount + 1) * sizeof (EFI_STRING_ID));\r
-    ASSERT (gFrontPagePrivate.LanguageToken != NULL);\r
-\r
-    Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    LangCode     = mLanguageString;\r
-    OptionCount  = 0;\r
-    while (*LangCode != 0) {\r
-      GetNextLanguage (&LangCode, Lang);\r
-\r
-      StringSize = 0;\r
-      Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);\r
-      if (Status == EFI_BUFFER_TOO_SMALL) {\r
-        StringBuffer = AllocateZeroPool (StringSize);\r
-        ASSERT (StringBuffer != NULL);\r
-        Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);\r
-        ASSERT_EFI_ERROR (Status);\r
-      }\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        LangSize = AsciiStrSize (Lang);\r
-        StringBuffer = AllocatePool (LangSize * sizeof (CHAR16));\r
-        ASSERT (StringBuffer != NULL);\r
-        AsciiStrToUnicodeStrS (Lang, StringBuffer, LangSize);\r
-      }\r
-\r
-      ASSERT (StringBuffer != NULL);\r
-      gFrontPagePrivate.LanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL);\r
-      FreePool (StringBuffer);\r
-\r
-      OptionCount++;\r
-    }\r
-  }\r
-\r
-  ASSERT (gFrontPagePrivate.LanguageToken != NULL);\r
-  LangCode     = mLanguageString;\r
-  OptionCount  = 0;\r
-  if (Lang == NULL) {\r
-    Lang = AllocatePool (AsciiStrSize (mLanguageString));\r
-    ASSERT (Lang != NULL);\r
-  }\r
-  while (*LangCode != 0) {\r
-    GetNextLanguage (&LangCode, Lang);\r
-\r
-    if (CurrentLang != NULL && AsciiStrCmp (Lang, CurrentLang) == 0) {\r
-      HiiCreateOneOfOptionOpCode (\r
-        OptionsOpCodeHandle,\r
-        gFrontPagePrivate.LanguageToken[OptionCount],\r
-        EFI_IFR_OPTION_DEFAULT,\r
-        EFI_IFR_NUMERIC_SIZE_1,\r
-        (UINT8) OptionCount\r
-        );\r
-    } else {\r
-      HiiCreateOneOfOptionOpCode (\r
-        OptionsOpCodeHandle,\r
-        gFrontPagePrivate.LanguageToken[OptionCount],\r
-        0,\r
-        EFI_IFR_NUMERIC_SIZE_1,\r
-        (UINT8) OptionCount\r
-        );\r
-    }\r
-\r
-    OptionCount++;\r
-  }\r
-\r
-  if (CurrentLang != NULL) {\r
-    FreePool (CurrentLang);\r
-  }\r
-  FreePool (Lang);\r
-\r
-  HiiCreateOneOfOpCode (\r
-    StartOpCodeHandle,\r
-    FRONT_PAGE_KEY_LANGUAGE,\r
-    0,\r
-    0,\r
-    STRING_TOKEN (STR_LANGUAGE_SELECT),\r
-    STRING_TOKEN (STR_LANGUAGE_SELECT_HELP),\r
-    EFI_IFR_FLAG_CALLBACK,\r
-    EFI_IFR_NUMERIC_SIZE_1,\r
-    OptionsOpCodeHandle,\r
-    NULL\r
-    );\r
-\r
-  Status = HiiUpdateForm (\r
-             HiiHandle,\r
-             &gFrontPageFormSetGuid,\r
-             FRONT_PAGE_FORM_ID,\r
-             StartOpCodeHandle, // LABEL_SELECT_LANGUAGE\r
-             EndOpCodeHandle    // LABEL_END\r
-             );\r
-\r
-  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
-  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Call the browser and display the front page\r
-\r
-  @return   Status code that will be returned by\r
-            EFI_FORM_BROWSER2_PROTOCOL.SendForm ().\r
-\r
-**/\r
-EFI_STATUS\r
-CallFrontPage (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_BROWSER_ACTION_REQUEST  ActionRequest;\r
-\r
-  //\r
-  // Begin waiting for USER INPUT\r
-  //\r
-  REPORT_STATUS_CODE (\r
-    EFI_PROGRESS_CODE,\r
-    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)\r
-    );\r
-\r
-  ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-  Status = gFormBrowser2->SendForm (\r
-                            gFormBrowser2,\r
-                            &gFrontPagePrivate.HiiHandle,\r
-                            1,\r
-                            &gFrontPageFormSetGuid,\r
-                            0,\r
-                            NULL,\r
-                            &ActionRequest\r
-                            );\r
-  //\r
-  // Check whether user change any option setting which needs a reset to be effective\r
-  //\r
-  if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
-    EnableResetRequired ();\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Convert Processor Frequency Data to a string.\r
-\r
-  @param ProcessorFrequency The frequency data to process\r
-  @param Base10Exponent     The exponent based on 10\r
-  @param String             The string that is created\r
-\r
-**/\r
-VOID\r
-ConvertProcessorToString (\r
-  IN  UINT16                               ProcessorFrequency,\r
-  IN  UINT16                               Base10Exponent,\r
-  OUT CHAR16                               **String\r
-  )\r
-{\r
-  CHAR16  *StringBuffer;\r
-  UINTN   Index;\r
-  UINT32  FreqMhz;\r
-\r
-  if (Base10Exponent >= 6) {\r
-    FreqMhz = ProcessorFrequency;\r
-    for (Index = 0; Index < ((UINT32)Base10Exponent - 6); Index++) {\r
-      FreqMhz *= 10;\r
-    }\r
-  } else {\r
-    FreqMhz = 0;\r
-  }\r
-\r
-  StringBuffer = AllocateZeroPool (0x20);\r
-  ASSERT (StringBuffer != NULL);\r
-  UnicodeValueToStringS (StringBuffer, 0x20, LEFT_JUSTIFY, FreqMhz / 1000, 3);\r
-  Index = StrnLenS (StringBuffer, 0x20 / sizeof (CHAR16));\r
-  StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L".");\r
-  UnicodeValueToStringS (\r
-    StringBuffer + Index + 1,\r
-    0x20 - sizeof (CHAR16) * (Index + 1),\r
-    PREFIX_ZERO,\r
-    (FreqMhz % 1000) / 10,\r
-    2\r
-    );\r
-  StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L" GHz");\r
-  *String = (CHAR16 *) StringBuffer;\r
-  return ;\r
-}\r
-\r
-\r
-/**\r
-  Convert Memory Size to a string.\r
-\r
-  @param MemorySize      The size of the memory to process\r
-  @param String          The string that is created\r
-\r
-**/\r
-VOID\r
-ConvertMemorySizeToString (\r
-  IN  UINT32          MemorySize,\r
-  OUT CHAR16          **String\r
-  )\r
-{\r
-  CHAR16  *StringBuffer;\r
-\r
-  StringBuffer = AllocateZeroPool (0x20);\r
-  ASSERT (StringBuffer != NULL);\r
-  UnicodeValueToStringS (StringBuffer, 0x20, LEFT_JUSTIFY, MemorySize, 6);\r
-  StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L" MB RAM");\r
-\r
-  *String = (CHAR16 *) StringBuffer;\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-\r
-  Acquire the string associated with the Index from smbios structure and return it.\r
-  The caller is responsible for free the string buffer.\r
-\r
-  @param    OptionalStrStart  The start position to search the string\r
-  @param    Index             The index of the string to extract\r
-  @param    String            The string that is extracted\r
-\r
-  @retval   EFI_SUCCESS       The function returns EFI_SUCCESS always.\r
-\r
-**/\r
-EFI_STATUS\r
-GetOptionalStringByIndex (\r
-  IN      CHAR8                   *OptionalStrStart,\r
-  IN      UINT8                   Index,\r
-  OUT     CHAR16                  **String\r
-  )\r
-{\r
-  UINTN          StrSize;\r
-\r
-  if (Index == 0) {\r
-    *String = AllocateZeroPool (sizeof (CHAR16));\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  StrSize = 0;\r
-  do {\r
-    Index--;\r
-    OptionalStrStart += StrSize;\r
-    StrSize           = AsciiStrSize (OptionalStrStart);\r
-  } while (OptionalStrStart[StrSize] != 0 && Index != 0);\r
-\r
-  if ((Index != 0) || (StrSize == 1)) {\r
-    //\r
-    // Meet the end of strings set but Index is non-zero, or\r
-    // Find an empty string\r
-    //\r
-    *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
-  } else {\r
-    *String = AllocatePool (StrSize * sizeof (CHAR16));\r
-    AsciiStrToUnicodeStrS (OptionalStrStart, *String, StrSize);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Update the banner information for the Front Page based on DataHub information.\r
-\r
-**/\r
-VOID\r
-UpdateFrontPageStrings (\r
-  VOID\r
-  )\r
-{\r
-  UINT8                             StrIndex;\r
-  CHAR16                            *NewString;\r
-  EFI_STATUS                        Status;\r
-  EFI_STRING_ID                     TokenToUpdate;\r
-  EFI_SMBIOS_HANDLE                 SmbiosHandle;\r
-  EFI_SMBIOS_PROTOCOL               *Smbios;\r
-  SMBIOS_TABLE_TYPE0                *Type0Record;\r
-  SMBIOS_TABLE_TYPE1                *Type1Record;\r
-  SMBIOS_TABLE_TYPE4                *Type4Record;\r
-  SMBIOS_TABLE_TYPE19               *Type19Record;\r
-  EFI_SMBIOS_TABLE_HEADER           *Record;\r
-  UINT64                            InstalledMemory;\r
-\r
-  InstalledMemory = 0;\r
-\r
-  //\r
-  // Update Front Page strings\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiSmbiosProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &Smbios\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
-    Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);\r
-    while (!EFI_ERROR(Status)) {\r
-      if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {\r
-        Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;\r
-        StrIndex = Type0Record->BiosVersion;\r
-        GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);\r
-        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);\r
-        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
-        FreePool (NewString);\r
-      }\r
-\r
-      if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) {\r
-        Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;\r
-        StrIndex = Type1Record->ProductName;\r
-        GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);\r
-        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);\r
-        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
-        FreePool (NewString);\r
-      }\r
-\r
-      if (Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) {\r
-        Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;\r
-        StrIndex = Type4Record->ProcessorVersion;\r
-        GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);\r
-        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);\r
-        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
-        FreePool (NewString);\r
-      }\r
-\r
-      if (Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) {\r
-        Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;\r
-        ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);\r
-        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);\r
-        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
-        FreePool (NewString);\r
-      }\r
-\r
-      if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {\r
-        Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;\r
-        if (Type19Record->StartingAddress != 0xFFFFFFFF ) {\r
-          InstalledMemory += RShiftU64(Type19Record->EndingAddress -\r
-                                       Type19Record->StartingAddress + 1, 10);\r
-        } else {\r
-          InstalledMemory += RShiftU64(Type19Record->ExtendedEndingAddress -\r
-                                       Type19Record->ExtendedStartingAddress + 1, 20);\r
-        }\r
-      }\r
-\r
-      Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);\r
-    }\r
-\r
-    // now update the total installed RAM size\r
-    ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString );\r
-    TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);\r
-    HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
-    FreePool (NewString);\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-\r
-/**\r
-  Function waits for a given event to fire, or for an optional timeout to expire.\r
-\r
-  @param   Event              The event to wait for\r
-  @param   Timeout            An optional timeout value in 100 ns units.\r
-\r
-  @retval  EFI_SUCCESS      Event fired before Timeout expired.\r
-  @retval  EFI_TIME_OUT     Timout expired before Event fired..\r
-\r
-**/\r
-EFI_STATUS\r
-WaitForSingleEvent (\r
-  IN EFI_EVENT                  Event,\r
-  IN UINT64                     Timeout OPTIONAL\r
-  )\r
-{\r
-  UINTN       Index;\r
-  EFI_STATUS  Status;\r
-  EFI_EVENT   TimerEvent;\r
-  EFI_EVENT   WaitList[2];\r
-\r
-  if (Timeout != 0) {\r
-    //\r
-    // Create a timer event\r
-    //\r
-    Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Set the timer event\r
-      //\r
-      gBS->SetTimer (\r
-             TimerEvent,\r
-             TimerRelative,\r
-             Timeout\r
-             );\r
-\r
-      //\r
-      // Wait for the original event or the timer\r
-      //\r
-      WaitList[0] = Event;\r
-      WaitList[1] = TimerEvent;\r
-      Status      = gBS->WaitForEvent (2, WaitList, &Index);\r
-      gBS->CloseEvent (TimerEvent);\r
-\r
-      //\r
-      // If the timer expired, change the return to timed out\r
-      //\r
-      if (!EFI_ERROR (Status) && Index == 1) {\r
-        Status = EFI_TIMEOUT;\r
-      }\r
-    }\r
-  } else {\r
-    //\r
-    // No timeout... just wait on the event\r
-    //\r
-    Status = gBS->WaitForEvent (1, &Event, &Index);\r
-    ASSERT (!EFI_ERROR (Status));\r
-    ASSERT (Index == 0);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Function show progress bar to wait for user input.\r
-\r
-\r
-  @param   TimeoutDefault  The fault time out value before the system continue to boot.\r
-\r
-  @retval  EFI_SUCCESS       User pressed some key except "Enter"\r
-  @retval  EFI_TIME_OUT      Timeout expired or user press "Enter"\r
-\r
-**/\r
-EFI_STATUS\r
-ShowProgress (\r
-  IN UINT16                       TimeoutDefault\r
-  )\r
-{\r
-  CHAR16                        *TmpStr;\r
-  UINT16                        TimeoutRemain;\r
-  EFI_STATUS                    Status;\r
-  EFI_INPUT_KEY                 Key;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;\r
-\r
-  if (TimeoutDefault != 0) {\r
-    DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));\r
-\r
-    SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
-    SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
-    SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
-\r
-    TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));\r
-\r
-    if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
-      //\r
-      // Clear the progress status bar first\r
-      //\r
-      if (TmpStr != NULL) {\r
-        PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0);\r
-      }\r
-    }\r
-\r
-\r
-    TimeoutRemain = TimeoutDefault;\r
-    while (TimeoutRemain != 0) {\r
-      DEBUG ((EFI_D_INFO, "Showing progress bar...Remaining %d second!\n", TimeoutRemain));\r
-\r
-      Status = WaitForSingleEvent (gST->ConIn->WaitForKey, ONE_SECOND);\r
-      if (Status != EFI_TIMEOUT) {\r
-        break;\r
-      }\r
-      TimeoutRemain--;\r
-\r
-      if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
-        //\r
-        // Show progress\r
-        //\r
-        if (TmpStr != NULL) {\r
-          PlatformBdsShowProgress (\r
-            Foreground,\r
-            Background,\r
-            TmpStr,\r
-            Color,\r
-            ((TimeoutDefault - TimeoutRemain) * 100 / TimeoutDefault),\r
-            0\r
-            );\r
-        }\r
-      }\r
-    }\r
-\r
-    if (TmpStr != NULL) {\r
-      gBS->FreePool (TmpStr);\r
-    }\r
-\r
-    //\r
-    // Timeout expired\r
-    //\r
-    if (TimeoutRemain == 0) {\r
-      return EFI_TIMEOUT;\r
-    }\r
-  }\r
-\r
-  //\r
-  // User pressed some key\r
-  //\r
-  if (!PcdGetBool (PcdConInConnectOnDemand)) {\r
-    Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
-      //\r
-      // User pressed enter, equivalent to select "continue"\r
-      //\r
-      return EFI_TIMEOUT;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is the main entry of the platform setup entry.\r
-  The function will present the main menu of the system setup,\r
-  this is the platform reference part and can be customize.\r
-\r
-\r
-  @param TimeoutDefault     The fault time out value before the system\r
-                            continue to boot.\r
-  @param ConnectAllHappened The indicater to check if the connect all have\r
-                            already happened.\r
-\r
-**/\r
-VOID\r
-PlatformBdsEnterFrontPage (\r
-  IN UINT16                       TimeoutDefault,\r
-  IN BOOLEAN                      ConnectAllHappened\r
-  )\r
-{\r
-  EFI_STATUS                         Status;\r
-  EFI_STATUS                         StatusHotkey;\r
-  EFI_BOOT_LOGO_PROTOCOL             *BootLogo;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL       *GraphicsOutput;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL    *SimpleTextOut;\r
-  UINTN                              BootTextColumn;\r
-  UINTN                              BootTextRow;\r
-  UINT64                             OsIndication;\r
-  UINTN                              DataSize;\r
-  EFI_INPUT_KEY                      Key;\r
-\r
-  GraphicsOutput = NULL;\r
-  SimpleTextOut = NULL;\r
-\r
-  PERF_START (NULL, "BdsTimeOut", "BDS", 0);\r
-  //\r
-  // Indicate if we need connect all in the platform setup\r
-  //\r
-  if (ConnectAllHappened) {\r
-    gConnectAllHappened = TRUE;\r
-  }\r
-\r
-  if (!mModeInitialized) {\r
-    //\r
-    // After the console is ready, get current video resolution\r
-    // and text mode before launching setup at first time.\r
-    //\r
-    Status = gBS->HandleProtocol (\r
-                    gST->ConsoleOutHandle,\r
-                    &gEfiGraphicsOutputProtocolGuid,\r
-                    (VOID**)&GraphicsOutput\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      GraphicsOutput = NULL;\r
-    }\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    gST->ConsoleOutHandle,\r
-                    &gEfiSimpleTextOutProtocolGuid,\r
-                    (VOID**)&SimpleTextOut\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      SimpleTextOut = NULL;\r
-    }\r
-\r
-    if (GraphicsOutput != NULL) {\r
-      //\r
-      // Get current video resolution and text mode.\r
-      //\r
-      mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
-      mBootVerticalResolution   = GraphicsOutput->Mode->Info->VerticalResolution;\r
-    }\r
-\r
-    if (SimpleTextOut != NULL) {\r
-      Status = SimpleTextOut->QueryMode (\r
-                                SimpleTextOut,\r
-                                SimpleTextOut->Mode->Mode,\r
-                                &BootTextColumn,\r
-                                &BootTextRow\r
-                                );\r
-      mBootTextModeColumn = (UINT32)BootTextColumn;\r
-      mBootTextModeRow    = (UINT32)BootTextRow;\r
-    }\r
-\r
-    //\r
-    // Get user defined text mode for setup.\r
-    //\r
-    mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
-    mSetupVerticalResolution   = PcdGet32 (PcdSetupVideoVerticalResolution);\r
-    mSetupTextModeColumn       = PcdGet32 (PcdSetupConOutColumn);\r
-    mSetupTextModeRow          = PcdGet32 (PcdSetupConOutRow);\r
-\r
-    mModeInitialized           = TRUE;\r
-  }\r
-\r
-\r
-  //\r
-  // goto FrontPage directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set\r
-  //\r
-  OsIndication = 0;\r
-  DataSize = sizeof(UINT64);\r
-  Status = gRT->GetVariable (\r
-                  L"OsIndications",\r
-                  &gEfiGlobalVariableGuid,\r
-                  NULL,\r
-                  &DataSize,\r
-                  &OsIndication\r
-                  );\r
-\r
-  //\r
-  // goto FrontPage directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. Skip HotkeyBoot\r
-  //\r
-  if (!EFI_ERROR(Status) && ((OsIndication & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0)) {\r
-    //\r
-    // Clear EFI_OS_INDICATIONS_BOOT_TO_FW_UI to acknowledge OS\r
-    //\r
-    OsIndication &= ~((UINT64)EFI_OS_INDICATIONS_BOOT_TO_FW_UI);\r
-    Status = gRT->SetVariable (\r
-                    L"OsIndications",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    sizeof(UINT64),\r
-                    &OsIndication\r
-                    );\r
-    //\r
-    // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Follow generic rule, Call ReadKeyStroke to connect ConIn before enter UI\r
-    //\r
-    if (PcdGetBool (PcdConInConnectOnDemand)) {\r
-      gST->ConIn->ReadKeyStroke(gST->ConIn, &Key);\r
-    }\r
-\r
-    //\r
-    // Ensure screen is clear when switch Console from Graphics mode to Text mode\r
-    //\r
-    gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
-    gST->ConOut->ClearScreen (gST->ConOut);\r
-\r
-  } else {\r
-\r
-    HotkeyBoot ();\r
-    if (TimeoutDefault != 0xffff) {\r
-      Status = ShowProgress (TimeoutDefault);\r
-      StatusHotkey = HotkeyBoot ();\r
-\r
-      if (!FeaturePcdGet(PcdBootlogoOnlyEnable) || !EFI_ERROR(Status) || !EFI_ERROR(StatusHotkey)){\r
-        //\r
-        // Ensure screen is clear when switch Console from Graphics mode to Text mode\r
-        // Skip it in normal boot\r
-        //\r
-        gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
-        gST->ConOut->ClearScreen (gST->ConOut);\r
-      }\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // Timeout or user press enter to continue\r
-        //\r
-        goto Exit;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Boot Logo is corrupted, report it using Boot Logo protocol.\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);\r
-  if (!EFI_ERROR (Status) && (BootLogo != NULL)) {\r
-    BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);\r
-  }\r
-\r
-  //\r
-  // Install BM HiiPackages.\r
-  // Keep BootMaint HiiPackage, so that it can be covered by global setting.\r
-  //\r
-  InitBMPackage ();\r
-\r
-  Status = EFI_SUCCESS;\r
-  do {\r
-    //\r
-    // Set proper video resolution and text mode for setup\r
-    //\r
-    BdsSetConsoleMode (TRUE);\r
-\r
-    InitializeFrontPage (FALSE);\r
-\r
-    //\r
-    // Update Front Page strings\r
-    //\r
-    UpdateFrontPageStrings ();\r
-\r
-    gCallbackKey = 0;\r
-    CallFrontPage ();\r
-\r
-    //\r
-    // If gCallbackKey is greater than 1 and less or equal to 5,\r
-    // it will launch configuration utilities.\r
-    // 2 = set language\r
-    // 3 = boot manager\r
-    // 4 = device manager\r
-    // 5 = boot maintenance manager\r
-    //\r
-    if (gCallbackKey != 0) {\r
-      REPORT_STATUS_CODE (\r
-        EFI_PROGRESS_CODE,\r
-        (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)\r
-        );\r
-    }\r
-    //\r
-    // Based on the key that was set, we can determine what to do\r
-    //\r
-    switch (gCallbackKey) {\r
-    //\r
-    // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
-    // describe to their customers in documentation how to find their setup information (namely\r
-    // under the device manager and specific buckets)\r
-    //\r
-    // These entries consist of the Continue, Select language, Boot Manager, and Device Manager\r
-    //\r
-    case FRONT_PAGE_KEY_CONTINUE:\r
-      //\r
-      // User hit continue\r
-      //\r
-      break;\r
-\r
-    case FRONT_PAGE_KEY_LANGUAGE:\r
-      //\r
-      // User made a language setting change - display front page again\r
-      //\r
-      break;\r
-\r
-    case FRONT_PAGE_KEY_BOOT_MANAGER:\r
-      //\r
-      // Remove the installed BootMaint HiiPackages when exit.\r
-      //\r
-      FreeBMPackage ();\r
-\r
-      //\r
-      // User chose to run the Boot Manager\r
-      //\r
-      CallBootManager ();\r
-\r
-      //\r
-      // Reinstall BootMaint HiiPackages after exiting from Boot Manager.\r
-      //\r
-      InitBMPackage ();\r
-      break;\r
-\r
-    case FRONT_PAGE_KEY_DEVICE_MANAGER:\r
-      //\r
-      // Display the Device Manager\r
-      //\r
-      do {\r
-        CallDeviceManager ();\r
-      } while (gCallbackKey == FRONT_PAGE_KEY_DEVICE_MANAGER);\r
-      break;\r
-\r
-    case FRONT_PAGE_KEY_BOOT_MAINTAIN:\r
-      //\r
-      // Display the Boot Maintenance Manager\r
-      //\r
-      BdsStartBootMaint ();\r
-      break;\r
-    }\r
-\r
-  } while ((Status == EFI_SUCCESS) && (gCallbackKey != FRONT_PAGE_KEY_CONTINUE));\r
-\r
-  if (mLanguageString != NULL) {\r
-    FreePool (mLanguageString);\r
-    mLanguageString = NULL;\r
-  }\r
-  //\r
-  //Will leave browser, check any reset required change is applied? if yes, reset system\r
-  //\r
-  SetupResetReminder ();\r
-\r
-  //\r
-  // Remove the installed BootMaint HiiPackages when exit.\r
-  //\r
-  FreeBMPackage ();\r
-\r
-Exit:\r
-  //\r
-  // Automatically load current entry\r
-  // Note: The following lines of code only execute when Auto boot\r
-  // takes affect\r
-  //\r
-  PERF_END (NULL, "BdsTimeOut", "BDS", 0);\r
-}\r
-\r
-/**\r
-  This function will change video resolution and text mode\r
-  according to defined setup mode or defined boot mode\r
-\r
-  @param  IsSetupMode   Indicate mode is changed to setup mode or boot mode.\r
-\r
-  @retval  EFI_SUCCESS  Mode is changed successfully.\r
-  @retval  Others             Mode failed to be changed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsSetConsoleMode (\r
-  BOOLEAN  IsSetupMode\r
-  )\r
-{\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL          *GraphicsOutput;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL       *SimpleTextOut;\r
-  UINTN                                 SizeOfInfo;\r
-  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info;\r
-  UINT32                                MaxGopMode;\r
-  UINT32                                MaxTextMode;\r
-  UINT32                                ModeNumber;\r
-  UINT32                                NewHorizontalResolution;\r
-  UINT32                                NewVerticalResolution;\r
-  UINT32                                NewColumns;\r
-  UINT32                                NewRows;\r
-  UINTN                                 HandleCount;\r
-  EFI_HANDLE                            *HandleBuffer;\r
-  EFI_STATUS                            Status;\r
-  UINTN                                 Index;\r
-  UINTN                                 CurrentColumn;\r
-  UINTN                                 CurrentRow;\r
-\r
-  MaxGopMode  = 0;\r
-  MaxTextMode = 0;\r
-\r
-  //\r
-  // Get current video resolution and text mode\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  gST->ConsoleOutHandle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID**)&GraphicsOutput\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    GraphicsOutput = NULL;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  gST->ConsoleOutHandle,\r
-                  &gEfiSimpleTextOutProtocolGuid,\r
-                  (VOID**)&SimpleTextOut\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    SimpleTextOut = NULL;\r
-  }\r
-\r
-  if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (IsSetupMode) {\r
-    //\r
-    // The required resolution and text mode is setup mode.\r
-    //\r
-    NewHorizontalResolution = mSetupHorizontalResolution;\r
-    NewVerticalResolution   = mSetupVerticalResolution;\r
-    NewColumns              = mSetupTextModeColumn;\r
-    NewRows                 = mSetupTextModeRow;\r
-  } else {\r
-    //\r
-    // The required resolution and text mode is boot mode.\r
-    //\r
-    NewHorizontalResolution = mBootHorizontalResolution;\r
-    NewVerticalResolution   = mBootVerticalResolution;\r
-    NewColumns              = mBootTextModeColumn;\r
-    NewRows                 = mBootTextModeRow;\r
-  }\r
-\r
-  if (GraphicsOutput != NULL) {\r
-    MaxGopMode  = GraphicsOutput->Mode->MaxMode;\r
-  }\r
-\r
-  if (SimpleTextOut != NULL) {\r
-    MaxTextMode = SimpleTextOut->Mode->MaxMode;\r
-  }\r
-\r
-  //\r
-  // 1. If current video resolution is same with required video resolution,\r
-  //    video resolution need not be changed.\r
-  //    1.1. If current text mode is same with required text mode, text mode need not be changed.\r
-  //    1.2. If current text mode is different from required text mode, text mode need be changed.\r
-  // 2. If current video resolution is different from required video resolution, we need restart whole console drivers.\r
-  //\r
-  for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {\r
-    Status = GraphicsOutput->QueryMode (\r
-                       GraphicsOutput,\r
-                       ModeNumber,\r
-                       &SizeOfInfo,\r
-                       &Info\r
-                       );\r
-    if (!EFI_ERROR (Status)) {\r
-      if ((Info->HorizontalResolution == NewHorizontalResolution) &&\r
-          (Info->VerticalResolution == NewVerticalResolution)) {\r
-        if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&\r
-            (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {\r
-          //\r
-          // Current resolution is same with required resolution, check if text mode need be set\r
-          //\r
-          Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);\r
-          ASSERT_EFI_ERROR (Status);\r
-          if (CurrentColumn == NewColumns && CurrentRow == NewRows) {\r
-            //\r
-            // If current text mode is same with required text mode. Do nothing\r
-            //\r
-            FreePool (Info);\r
-            return EFI_SUCCESS;\r
-          } else {\r
-            //\r
-            // If current text mode is different from required text mode.  Set new video mode\r
-            //\r
-            for (Index = 0; Index < MaxTextMode; Index++) {\r
-              Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);\r
-              if (!EFI_ERROR(Status)) {\r
-                if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {\r
-                  //\r
-                  // Required text mode is supported, set it.\r
-                  //\r
-                  Status = SimpleTextOut->SetMode (SimpleTextOut, Index);\r
-                  ASSERT_EFI_ERROR (Status);\r
-                  //\r
-                  // Update text mode PCD.\r
-                  //\r
-                  Status = PcdSet32S (PcdConOutColumn, mSetupTextModeColumn);\r
-                  ASSERT_EFI_ERROR (Status);\r
-                  Status = PcdSet32S (PcdConOutRow, mSetupTextModeRow);\r
-                  ASSERT_EFI_ERROR (Status);\r
-                  FreePool (Info);\r
-                  return EFI_SUCCESS;\r
-                }\r
-              }\r
-            }\r
-            if (Index == MaxTextMode) {\r
-              //\r
-              // If required text mode is not supported, return error.\r
-              //\r
-              FreePool (Info);\r
-              return EFI_UNSUPPORTED;\r
-            }\r
-          }\r
-        } else {\r
-          //\r
-          // If current video resolution is not same with the new one, set new video resolution.\r
-          // In this case, the driver which produces simple text out need be restarted.\r
-          //\r
-          Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);\r
-          if (!EFI_ERROR (Status)) {\r
-            FreePool (Info);\r
-            break;\r
-          }\r
-        }\r
-      }\r
-      FreePool (Info);\r
-    }\r
-  }\r
-\r
-  if (ModeNumber == MaxGopMode) {\r
-    //\r
-    // If the resolution is not supported, return error.\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Set PCD to Inform GraphicsConsole to change video resolution.\r
-  // Set PCD to Inform Consplitter to change text mode.\r
-  //\r
-  Status = PcdSet32S (PcdVideoHorizontalResolution, NewHorizontalResolution);\r
-  ASSERT_EFI_ERROR (Status);\r
-  Status = PcdSet32S (PcdVideoVerticalResolution, NewVerticalResolution);\r
-  ASSERT_EFI_ERROR (Status);\r
-  Status = PcdSet32S (PcdConOutColumn, NewColumns);\r
-  ASSERT_EFI_ERROR (Status);\r
-  Status = PcdSet32S (PcdConOutRow, NewRows);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
-  //\r
-  // Video mode is changed, so restart graphics console driver and higher level driver.\r
-  // Reconnect graphics console driver and higher level driver.\r
-  // Locate all the handles with GOP protocol and reconnect it.\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                   ByProtocol,\r
-                   &gEfiSimpleTextOutProtocolGuid,\r
-                   NULL,\r
-                   &HandleCount,\r
-                   &HandleBuffer\r
-                   );\r
-  if (!EFI_ERROR (Status)) {\r
-    for (Index = 0; Index < HandleCount; Index++) {\r
-      gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
-    }\r
-    for (Index = 0; Index < HandleCount; Index++) {\r
-      gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
-    }\r
-    if (HandleBuffer != NULL) {\r
-      FreePool (HandleBuffer);\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.h b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.h
deleted file mode 100644 (file)
index e8519db..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/** @file\r
-  FrontPage routines to handle the callbacks and browser calls\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _FRONT_PAGE_H_\r
-#define _FRONT_PAGE_H_\r
-\r
-#include "DeviceMngr/DeviceManager.h"\r
-#include "BootMaint/BootMaint.h"\r
-#include "BootMngr/BootManager.h"\r
-#include "String.h"\r
-\r
-\r
-//\r
-// These are the VFR compiler generated data representing our VFR data.\r
-//\r
-extern UINT8  FrontPageVfrBin[];\r
-\r
-extern EFI_FORM_BROWSER2_PROTOCOL      *gFormBrowser2;\r
-\r
-extern UINTN    gCallbackKey;\r
-extern BOOLEAN  gConnectAllHappened;\r
-\r
-//\r
-// Boot video resolution and text mode.\r
-//\r
-extern UINT32    mBootHorizontalResolution;\r
-extern UINT32    mBootVerticalResolution;\r
-extern UINT32    mBootTextModeColumn;\r
-extern UINT32    mBootTextModeRow;\r
-//\r
-// BIOS setup video resolution and text mode.\r
-//\r
-extern UINT32    mSetupTextModeColumn;\r
-extern UINT32    mSetupTextModeRow;\r
-extern UINT32    mSetupHorizontalResolution;\r
-extern UINT32    mSetupVerticalResolution;\r
-\r
-\r
-#define ONE_SECOND  10000000\r
-\r
-///\r
-/// The size of a 3 character ISO639 language code.\r
-///\r
-#define ISO_639_2_ENTRY_SIZE   3\r
-\r
-//\r
-// This is the VFR compiler generated header file which defines the\r
-// string identifiers.\r
-//\r
-#define PRINTABLE_LANGUAGE_NAME_STRING_ID     0x0001\r
-\r
-//\r
-// These are defined as the same with vfr file\r
-//\r
-#define FRONT_PAGE_FORM_ID             0x1000\r
-\r
-#define FRONT_PAGE_KEY_CONTINUE        0x1000\r
-#define FRONT_PAGE_KEY_LANGUAGE        0x1234\r
-#define FRONT_PAGE_KEY_BOOT_MANAGER    0x1064\r
-#define FRONT_PAGE_KEY_DEVICE_MANAGER  0x8567\r
-#define FRONT_PAGE_KEY_BOOT_MAINTAIN   0x9876\r
-\r
-#define LABEL_SELECT_LANGUAGE          0x1000\r
-#define LABEL_END                      0xffff\r
-\r
-#define FRONT_PAGE_CALLBACK_DATA_SIGNATURE  SIGNATURE_32 ('F', 'P', 'C', 'B')\r
-\r
-typedef struct {\r
-  UINTN                           Signature;\r
-\r
-  //\r
-  // HII relative handles\r
-  //\r
-  EFI_HII_HANDLE                  HiiHandle;\r
-  EFI_HANDLE                      DriverHandle;\r
-  EFI_STRING_ID                   *LanguageToken;\r
-\r
-  //\r
-  // Produced protocols\r
-  //\r
-  EFI_HII_CONFIG_ACCESS_PROTOCOL  ConfigAccess;\r
-} FRONT_PAGE_CALLBACK_DATA;\r
-\r
-#define EFI_FP_CALLBACK_DATA_FROM_THIS(a) \\r
-  CR (a, \\r
-      FRONT_PAGE_CALLBACK_DATA, \\r
-      ConfigAccess, \\r
-      FRONT_PAGE_CALLBACK_DATA_SIGNATURE \\r
-      )\r
-\r
-/**\r
-  This function allows a caller to extract the current configuration for one\r
-  or more named elements from the target driver.\r
-\r
-\r
-  @param This            - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Request         - A null-terminated Unicode string in <ConfigRequest> format.\r
-  @param Progress        - On return, points to a character in the Request string.\r
-                         Points to the string's null terminator if request was successful.\r
-                         Points to the most recent '&' before the first failing name/value\r
-                         pair (or the beginning of the string if the failure is in the\r
-                         first name/value pair) if the request was not successful.\r
-  @param Results         - A null-terminated Unicode string in <ConfigAltResp> format which\r
-                         has all values filled in for the names in the Request string.\r
-                         String to be allocated by the called function.\r
-\r
-  @retval  EFI_SUCCESS            The Results is filled with the requested values.\r
-  @retval  EFI_OUT_OF_RESOURCES   Not enough memory to store the results.\r
-  @retval  EFI_INVALID_PARAMETER  Request is NULL, illegal syntax, or unknown name.\r
-  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeExtractConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Request,\r
-  OUT EFI_STRING                             *Progress,\r
-  OUT EFI_STRING                             *Results\r
-  );\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-\r
-\r
-  @param This            - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Configuration   - A null-terminated Unicode string in <ConfigResp> format.\r
-  @param Progress        - A pointer to a string filled in with the offset of the most\r
-                         recent '&' before the first failing name/value pair (or the\r
-                         beginning of the string if the failure is in the first\r
-                         name/value pair) or the terminating NULL if all was successful.\r
-\r
-  @retval  EFI_SUCCESS            The Results is processed successfully.\r
-  @retval  EFI_INVALID_PARAMETER  Configuration is NULL.\r
-  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeRouteConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Configuration,\r
-  OUT EFI_STRING                             *Progress\r
-  );\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-\r
-\r
-  @param This            - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param Action          - Specifies the type of action taken by the browser.\r
-  @param QuestionId      - A unique value which is sent to the original exporting driver\r
-                         so that it can identify the type of data to expect.\r
-  @param Type            - The type of value for the question.\r
-  @param Value           - A pointer to the data being sent to the original exporting driver.\r
-  @param ActionRequest   - On return, points to the action requested by the callback function.\r
-\r
-  @retval  EFI_SUCCESS           The callback successfully handled the action.\r
-  @retval  EFI_OUT_OF_RESOURCES  Not enough storage is available to hold the variable and its data.\r
-  @retval  EFI_DEVICE_ERROR      The variable could not be saved.\r
-  @retval  EFI_UNSUPPORTED       The specified Action is not supported by the callback.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FrontPageCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        QuestionId,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  );\r
-\r
-/**\r
-  Initialize HII information for the FrontPage\r
-\r
-\r
-  @param InitializeHiiData    TRUE if HII elements need to be initialized.\r
-\r
-  @retval  EFI_SUCCESS        The operation is successful.\r
-  @retval  EFI_DEVICE_ERROR   If the dynamic opcode creation failed.\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeFrontPage (\r
-  IN BOOLEAN    InitializeHiiData\r
-  );\r
-\r
-\r
-/**\r
-  This function is the main entry of the platform setup entry.\r
-  The function will present the main menu of the system setup,\r
-  this is the platform reference part and can be customize.\r
-\r
-\r
-  @param TimeoutDefault  - The fault time out value before the system\r
-                         continue to boot.\r
-  @param ConnectAllHappened - The indicater to check if the connect all have\r
-                         already happened.\r
-\r
-**/\r
-VOID\r
-PlatformBdsEnterFrontPage (\r
-  IN UINT16                 TimeoutDefault,\r
-  IN BOOLEAN                ConnectAllHappened\r
-  );\r
-\r
-/**\r
-  This function will change video resolution and text mode\r
-  according to defined setup mode or defined boot mode\r
-\r
-  @param  IsSetupMode   Indicate mode is changed to setup mode or boot mode.\r
-\r
-  @retval  EFI_SUCCESS  Mode is changed successfully.\r
-  @retval  Others             Mode failed to be changed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsSetConsoleMode (\r
-  BOOLEAN  IsSetupMode\r
-  );\r
-\r
-#endif // _FRONT_PAGE_H_\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPageStrings.uni b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPageStrings.uni
deleted file mode 100644 (file)
index 7252f36..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-///** @file\r
-//\r
-//    String definitions for BdsPlatform formset.\r
-//\r
-//  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-//**/\r
-\r
-/=#\r
-\r
-#langdef   en-US "English"\r
-#langdef   fr-FR "Français"\r
-#langdef   en    "Standard English"\r
-#langdef   fr    "Standard Français"\r
-\r
-#string STR_FRONT_PAGE_TITLE           #language en-US  "Front Page"\r
-                                       #language fr-FR  "Front Page"\r
-#string STR_FRONT_PAGE_COMPUTER_MODEL  #language en-US  ""\r
-                                       #language fr-FR  ""\r
-#string STR_FRONT_PAGE_CPU_MODEL       #language en-US  ""\r
-                                       #language fr-FR  ""\r
-#string STR_FRONT_PAGE_CPU_SPEED       #language en-US  ""\r
-                                       #language fr-FR  ""\r
-#string STR_FRONT_PAGE_MEMORY_SIZE     #language en-US  ""\r
-                                       #language fr-FR  ""\r
-#string STR_FRONT_PAGE_BIOS_VERSION    #language en-US  ""\r
-                                       #language fr-FR  ""\r
-#string STR_FRONT_PAGE_BANNER_0_LEFT   #language en-US  "Wonder Computer Model 1000Z  Manufactured by Intel®"\r
-                                       #language fr-FR  "Demander le Modèle d'Ordinateur 1000Z A Fabriqué par Intel®"\r
-#string STR_FRONT_PAGE_BANNER_0_RIGHT  #language en-US  "OK"\r
-                                       #language fr-FR  "Bon"\r
-#string STR_FRONT_PAGE_BANNER_1_LEFT   #language en-US  "2 Pentium® X Xeon processors running at 800Thz"\r
-                                       #language fr-FR  "2 Pentium® X les processeurs de Xeon courants Ã  800Thz"\r
-#string STR_FRONT_PAGE_BANNER_1_RIGHT  #language en-US  "24 TB System RAM"\r
-                                       #language fr-FR  "24 TB RAM de Système"\r
-#string STR_FRONT_PAGE_BANNER_2_LEFT   #language en-US  "ACME® EFI BIOS Version 13.5 Release 1039.92"\r
-                                       #language fr-FR  "ACME® EFI BIOS Version 13.5 Release 1039.92"\r
-#string STR_FRONT_PAGE_BANNER_3_LEFT   #language en-US  "Serial Number: 1Z123456789MARMAR (Need SMBIOS entries)"\r
-                                       #language fr-FR  "Numéro de série: 1Z123456789MARMAR (Les entrées de SMBIOS de besoin)"\r
-#string STR_CONTINUE_PROMPT            #language en-US  "Continue"\r
-                                       #language fr-FR  "Continuer"\r
-#string STR_CONTINUE_HELP              #language en-US  "This selection will direct the system to continue to booting process"\r
-                                       #language fr-FR  "Cette sélection dirigera le système pour continuer au charger de procédé"\r
-#string STR_LANGUAGE_SELECT            #language en-US  "Select Language"\r
-                                       #language fr-FR  "Choisir la Langue"\r
-#string STR_LANGUAGE_SELECT_HELP       #language en-US  "This is the option one adjusts to change the language for the current system"\r
-                                       #language fr-FR  "Ceci est l'option que celui ajuste changer la langue pour le système actuel"\r
-#string STR_BOOT_MANAGER               #language en-US  "Boot Manager"\r
-                                       #language fr-FR  "Charger le Directeur"\r
-#string STR_BOOT_MANAGER_HELP          #language en-US  "This selection will take you to the Boot Manager"\r
-                                       #language fr-FR  "Cette sélection vous prendra au Directeur de Botte"\r
-#string STR_BOOT_MAINT_MANAGER         #language en-US  "Boot Maintenance Manager"\r
-                                       #language fr-FR  "Directeur d'Entretien"\r
-#string STR_BOOT_MAINT_MANAGER_HELP    #language en-US  "This selection will take you to the Boot Maintenance Manager"\r
-                                       #language fr-FR  "Cette sélection vous prendra au Directeur d'Entretien"\r
-#string STR_DEVICE_MANAGER             #language en-US  "Device Manager"\r
-                                       #language fr-FR  "Directeur d'appareil"\r
-#string STR_DEVICE_MANAGER_HELP        #language en-US  "This selection will take you to the Device Manager"\r
-                                       #language fr-FR  "Cette sélection vous prendra au Directeur d'Appareil"\r
-#string STR_TIME_OUT_PROMPT            #language en-US  "Boot process will continue in %d seconds"\r
-                                       #language fr-FR  "Le procédé de botte continuera dans %d secondes"\r
-#string STR_MISSING_STRING             #language en-US  "Missing String"\r
-                                       #language fr-FR  "Missing String"\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPageVfr.Vfr b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPageVfr.Vfr
deleted file mode 100644 (file)
index b2675c4..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-///** @file\r
-//  \r
-//    Browser formset.\r
-//  \r
-//  Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//  \r
-//**/\r
-\r
-#include <Guid/BdsHii.h>\r
-\r
-#define FRONT_PAGE_CLASS               0x0000\r
-#define FRONT_PAGE_SUBCLASS            0x0002\r
-\r
-#define FRONT_PAGE_FORM_ID             0x1000\r
-\r
-#define FRONT_PAGE_ITEM_ONE            0x0001\r
-#define FRONT_PAGE_ITEM_TWO            0x0002\r
-#define FRONT_PAGE_ITEM_THREE          0x0003\r
-#define FRONT_PAGE_ITEM_FOUR           0x0004\r
-#define FRONT_PAGE_ITEM_FIVE           0x0005\r
-\r
-#define FRONT_PAGE_KEY_CONTINUE        0x1000\r
-#define FRONT_PAGE_KEY_LANGUAGE        0x1234\r
-#define FRONT_PAGE_KEY_BOOT_MANAGER    0x1064\r
-#define FRONT_PAGE_KEY_DEVICE_MANAGER  0x8567\r
-#define FRONT_PAGE_KEY_BOOT_MAINTAIN   0x9876\r
-\r
-#define LABEL_SELECT_LANGUAGE          0x1000\r
-#define LABEL_TIMEOUT                  0x2000\r
-#define LABEL_END                      0xffff\r
-\r
-formset\r
-  guid     = FRONT_PAGE_FORMSET_GUID,\r
-  title    = STRING_TOKEN(STR_FRONT_PAGE_TITLE),\r
-  help     = STRING_TOKEN(STR_NULL_STRING),\r
-  classguid = FRONT_PAGE_FORMSET_GUID,\r
-\r
-  form formid = FRONT_PAGE_FORM_ID,\r
-       title  = STRING_TOKEN(STR_FRONT_PAGE_TITLE);\r
-\r
-    banner\r
-      title = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL),\r
-      line  1,\r
-      align left;\r
-\r
-    banner\r
-      title = STRING_TOKEN(STR_FRONT_PAGE_CPU_MODEL),\r
-      line  2,\r
-      align left;\r
-\r
-    banner\r
-      title = STRING_TOKEN(STR_FRONT_PAGE_CPU_SPEED),\r
-      line  2,\r
-      align right;\r
-\r
-    banner\r
-      title = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION),\r
-      line  3,\r
-      align left;\r
-\r
-    banner\r
-      title = STRING_TOKEN(STR_FRONT_PAGE_MEMORY_SIZE),\r
-      line  3,\r
-      align right;\r
-\r
-//    banner\r
-//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_0_LEFT),\r
-//      line  0,\r
-//      align left;\r
-\r
-//    banner\r
-//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_0_RIGHT),\r
-//      line  0,\r
-//      align right;\r
-\r
-//    banner\r
-//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_1_LEFT),\r
-//      line  1,\r
-//      align left;\r
-\r
-//    banner\r
-//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_1_RIGHT),\r
-//      line  1,\r
-//      align right;\r
-\r
-//    banner\r
-//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_2_LEFT),\r
-//      line  2,\r
-//      align left;\r
-\r
-//    banner\r
-//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_3_LEFT),\r
-//      line  3,\r
-//      align left;\r
-\r
-\r
-    text\r
-      help    = STRING_TOKEN(STR_CONTINUE_HELP),\r
-      text    = STRING_TOKEN(STR_CONTINUE_PROMPT),\r
-      flags   = INTERACTIVE,\r
-      key     = FRONT_PAGE_KEY_CONTINUE;\r
-\r
-    label LABEL_SELECT_LANGUAGE;\r
-    //\r
-    // This is where we will dynamically add a OneOf type op-code to select\r
-    // Languages from the currently available choices\r
-    //\r
-    label LABEL_END;\r
-\r
-    goto FRONT_PAGE_ITEM_THREE,\r
-      prompt  = STRING_TOKEN(STR_BOOT_MANAGER),\r
-      help    = STRING_TOKEN(STR_BOOT_MANAGER_HELP),\r
-      flags   = INTERACTIVE,\r
-      key     = FRONT_PAGE_KEY_BOOT_MANAGER;\r
-\r
-    goto FRONT_PAGE_ITEM_FOUR,\r
-      prompt  = STRING_TOKEN(STR_DEVICE_MANAGER),\r
-      help    = STRING_TOKEN(STR_DEVICE_MANAGER_HELP),\r
-      flags   = INTERACTIVE,\r
-      key     = FRONT_PAGE_KEY_DEVICE_MANAGER;\r
-\r
-    goto FRONT_PAGE_ITEM_FIVE,\r
-      prompt  = STRING_TOKEN(STR_BOOT_MAINT_MANAGER),\r
-      help    = STRING_TOKEN(STR_BOOT_MAINT_MANAGER_HELP),\r
-      flags   = INTERACTIVE,\r
-      key     = FRONT_PAGE_KEY_BOOT_MAINTAIN;\r
-\r
-  endform;\r
-\r
-endformset;\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c b/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c
deleted file mode 100644 (file)
index 396f1fe..0000000
+++ /dev/null
@@ -1,591 +0,0 @@
-/** @file\r
-  Provides a way for 3rd party applications to register themselves for launch by the\r
-  Boot Manager based on hot key\r
-\r
-Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Hotkey.h"\r
-\r
-\r
-LIST_ENTRY        mHotkeyList = INITIALIZE_LIST_HEAD_VARIABLE (mHotkeyList);\r
-BDS_COMMON_OPTION *mHotkeyBootOption = NULL;\r
-EFI_EVENT         mHotkeyEvent;\r
-VOID              *mHotkeyRegistration;\r
-\r
-\r
-/**\r
-  Check if the Key Option is valid or not.\r
-\r
-  @param KeyOption       The Hot Key Option to be checked.\r
-\r
-  @retval  TRUE          The Hot Key Option is valid.\r
-  @retval  FALSE         The Hot Key Option is invalid.\r
-\r
-**/\r
-BOOLEAN\r
-IsKeyOptionValid (\r
-  IN EFI_KEY_OPTION     *KeyOption\r
-)\r
-{\r
-  UINT16   BootOptionName[10];\r
-  UINT8    *BootOptionVar;\r
-  UINTN    BootOptionSize;\r
-  UINT32   Crc;\r
-\r
-  //\r
-  // Check whether corresponding Boot Option exist\r
-  //\r
-  UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", KeyOption->BootOption);\r
-  BootOptionVar = BdsLibGetVariableAndSize (\r
-                    BootOptionName,\r
-                    &gEfiGlobalVariableGuid,\r
-                    &BootOptionSize\r
-                    );\r
-\r
-  if (BootOptionVar == NULL || BootOptionSize == 0) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Check CRC for Boot Option\r
-  //\r
-  gBS->CalculateCrc32 (BootOptionVar, BootOptionSize, &Crc);\r
-  FreePool (BootOptionVar);\r
-\r
-  return (BOOLEAN) ((KeyOption->BootOptionCrc == Crc) ? TRUE : FALSE);\r
-}\r
-\r
-/**\r
-  Try to boot the boot option triggered by hotkey.\r
-  @retval  EFI_SUCCESS             There is HotkeyBootOption & it is processed\r
-  @retval  EFI_NOT_FOUND           There is no HotkeyBootOption\r
-**/\r
-EFI_STATUS\r
-HotkeyBoot (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS           Status;\r
-  UINTN                ExitDataSize;\r
-  CHAR16               *ExitData;\r
-\r
-  if (mHotkeyBootOption == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  BdsLibConnectDevicePath (mHotkeyBootOption->DevicePath);\r
-\r
-  //\r
-  // Clear the screen before launch this BootOption\r
-  //\r
-  gST->ConOut->Reset (gST->ConOut, FALSE);\r
-\r
-  Status = BdsLibBootViaBootOption (mHotkeyBootOption, mHotkeyBootOption->DevicePath, &ExitDataSize, &ExitData);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Call platform action to indicate the boot fail\r
-    //\r
-    mHotkeyBootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));\r
-    PlatformBdsBootFail (mHotkeyBootOption, Status, ExitData, ExitDataSize);\r
-  } else {\r
-    //\r
-    // Call platform action to indicate the boot success\r
-    //\r
-    mHotkeyBootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));\r
-    PlatformBdsBootSuccess (mHotkeyBootOption);\r
-  }\r
-  FreePool (mHotkeyBootOption->Description);\r
-  FreePool (mHotkeyBootOption->DevicePath);\r
-  FreePool (mHotkeyBootOption->LoadOptions);\r
-  FreePool (mHotkeyBootOption);\r
-\r
-  mHotkeyBootOption = NULL;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  This is the common notification function for HotKeys, it will be registered\r
-  with SimpleTextInEx protocol interface - RegisterKeyNotify() of ConIn handle.\r
-\r
-  @param KeyData         A pointer to a buffer that is filled in with the keystroke\r
-                         information for the key that was pressed.\r
-\r
-  @retval  EFI_SUCCESS   KeyData is successfully processed.\r
-  @return  EFI_NOT_FOUND Fail to find boot option variable.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HotkeyCallback (\r
-  IN EFI_KEY_DATA     *KeyData\r
-)\r
-{\r
-  BOOLEAN            HotkeyCatched;\r
-  LIST_ENTRY         BootLists;\r
-  LIST_ENTRY         *Link;\r
-  BDS_HOTKEY_OPTION  *Hotkey;\r
-  UINT16             Buffer[10];\r
-  EFI_STATUS         Status;\r
-  EFI_KEY_DATA       *HotkeyData;\r
-\r
-  if (mHotkeyBootOption != NULL) {\r
-    //\r
-    // Do not process sequential hotkey stroke until the current boot option returns\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Status                 = EFI_SUCCESS;\r
-\r
-  for ( Link = GetFirstNode (&mHotkeyList)\r
-      ; !IsNull (&mHotkeyList, Link)\r
-      ; Link = GetNextNode (&mHotkeyList, Link)\r
-      ) {\r
-    HotkeyCatched = FALSE;\r
-    Hotkey = BDS_HOTKEY_OPTION_FROM_LINK (Link);\r
-\r
-    //\r
-    // Is this Key Stroke we are waiting for?\r
-    //\r
-    ASSERT (Hotkey->WaitingKey < (sizeof (Hotkey->KeyData) / sizeof (Hotkey->KeyData[0])));\r
-    HotkeyData = &Hotkey->KeyData[Hotkey->WaitingKey];\r
-    if ((KeyData->Key.ScanCode == HotkeyData->Key.ScanCode) &&\r
-        (KeyData->Key.UnicodeChar == HotkeyData->Key.UnicodeChar) &&\r
-        (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) ?\r
-          (KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : TRUE\r
-        )\r
-       ) {\r
-      //\r
-      // For hotkey of key combination, transit to next waiting state\r
-      //\r
-      Hotkey->WaitingKey++;\r
-\r
-      if (Hotkey->WaitingKey == Hotkey->CodeCount) {\r
-        //\r
-        // Received the whole key stroke sequence\r
-        //\r
-        HotkeyCatched = TRUE;\r
-      }\r
-    } else {\r
-      //\r
-      // Receive an unexpected key stroke, reset to initial waiting state\r
-      //\r
-      Hotkey->WaitingKey = 0;\r
-    }\r
-\r
-    if (HotkeyCatched) {\r
-      //\r
-      // Reset to initial waiting state\r
-      //\r
-      Hotkey->WaitingKey = 0;\r
-\r
-      //\r
-      // Launch its BootOption\r
-      //\r
-      InitializeListHead (&BootLists);\r
-\r
-      UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", Hotkey->BootOptionNumber);\r
-      mHotkeyBootOption = BdsLibVariableToOption (&BootLists, Buffer);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Register the common HotKey notify function to given SimpleTextInEx protocol instance.\r
-\r
-  @param SimpleTextInEx  Simple Text Input Ex protocol instance\r
-\r
-  @retval  EFI_SUCCESS            Register hotkey notification function successfully.\r
-  @retval  EFI_OUT_OF_RESOURCES   Unable to allocate necessary data structures.\r
-\r
-**/\r
-EFI_STATUS\r
-HotkeyRegisterNotify (\r
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *SimpleTextInEx\r
-)\r
-{\r
-  UINTN              Index;\r
-  EFI_STATUS         Status;\r
-  LIST_ENTRY         *Link;\r
-  BDS_HOTKEY_OPTION  *Hotkey;\r
-\r
-  //\r
-  // Register notification function for each hotkey\r
-  //\r
-  Link = GetFirstNode (&mHotkeyList);\r
-\r
-  while (!IsNull (&mHotkeyList, Link)) {\r
-    Hotkey = BDS_HOTKEY_OPTION_FROM_LINK (Link);\r
-\r
-    Index = 0;\r
-    do {\r
-      Status = SimpleTextInEx->RegisterKeyNotify (\r
-                                 SimpleTextInEx,\r
-                                 &Hotkey->KeyData[Index],\r
-                                 HotkeyCallback,\r
-                                 &Hotkey->NotifyHandle\r
-                                 );\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // some of the hotkey registry failed\r
-        //\r
-        return Status;\r
-      }\r
-      Index ++;\r
-    } while ((Index < Hotkey->CodeCount) && (Index < (sizeof (Hotkey->KeyData) / sizeof (EFI_KEY_DATA))));\r
-\r
-    Link = GetNextNode (&mHotkeyList, Link);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Callback function for SimpleTextInEx protocol install events\r
-\r
-  @param Event           the event that is signaled.\r
-  @param Context         not used here.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-HotkeyEvent (\r
-  IN EFI_EVENT    Event,\r
-  IN VOID         *Context\r
-  )\r
-{\r
-  EFI_STATUS                         Status;\r
-  UINTN                              BufferSize;\r
-  EFI_HANDLE                         Handle;\r
-  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *SimpleTextInEx;\r
-\r
-  while (TRUE) {\r
-    BufferSize = sizeof (EFI_HANDLE);\r
-    Status = gBS->LocateHandle (\r
-                    ByRegisterNotify,\r
-                    NULL,\r
-                    mHotkeyRegistration,\r
-                    &BufferSize,\r
-                    &Handle\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // If no more notification events exist\r
-      //\r
-      return ;\r
-    }\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    Handle,\r
-                    &gEfiSimpleTextInputExProtocolGuid,\r
-                    (VOID **) &SimpleTextInEx\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    HotkeyRegisterNotify (SimpleTextInEx);\r
-  }\r
-}\r
-\r
-/**\r
-  Insert Key Option to hotkey list.\r
-\r
-  @param KeyOption       The Hot Key Option to be added to hotkey list.\r
-\r
-  @retval EFI_SUCCESS           Add to hotkey list success.\r
-  @retval EFI_OUT_OF_RESOURCES  Fail to allocate memory resource.\r
-**/\r
-EFI_STATUS\r
-HotkeyInsertList (\r
-  IN EFI_KEY_OPTION     *KeyOption\r
-)\r
-{\r
-  BDS_HOTKEY_OPTION  *HotkeyLeft;\r
-  BDS_HOTKEY_OPTION  *HotkeyRight;\r
-  UINTN              Index;\r
-  EFI_BOOT_KEY_DATA  KeyOptions;\r
-  UINT32             KeyShiftStateLeft;\r
-  UINT32             KeyShiftStateRight;\r
-  EFI_INPUT_KEY      *InputKey;\r
-  EFI_KEY_DATA       *KeyData;\r
-\r
-  HotkeyLeft = AllocateZeroPool (sizeof (BDS_HOTKEY_OPTION));\r
-  if (HotkeyLeft == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  HotkeyLeft->Signature = BDS_HOTKEY_OPTION_SIGNATURE;\r
-  HotkeyLeft->BootOptionNumber = KeyOption->BootOption;\r
-\r
-  KeyOptions = KeyOption->KeyData;\r
-\r
-  HotkeyLeft->CodeCount = (UINT8) KeyOptions.Options.InputKeyCount;\r
-\r
-  //\r
-  // Map key shift state from KeyOptions to EFI_KEY_DATA.KeyState\r
-  //\r
-  KeyShiftStateRight = EFI_SHIFT_STATE_VALID;\r
-  if (KeyOptions.Options.ShiftPressed) {\r
-    KeyShiftStateRight |= EFI_RIGHT_SHIFT_PRESSED;\r
-  }\r
-  if (KeyOptions.Options.ControlPressed) {\r
-    KeyShiftStateRight |= EFI_RIGHT_CONTROL_PRESSED;\r
-  }\r
-  if (KeyOptions.Options.AltPressed) {\r
-    KeyShiftStateRight |= EFI_RIGHT_ALT_PRESSED;\r
-  }\r
-  if (KeyOptions.Options.LogoPressed) {\r
-    KeyShiftStateRight |= EFI_RIGHT_LOGO_PRESSED;\r
-  }\r
-  if (KeyOptions.Options.MenuPressed) {\r
-    KeyShiftStateRight |= EFI_MENU_KEY_PRESSED;\r
-  }\r
-  if (KeyOptions.Options.SysReqPressed) {\r
-    KeyShiftStateRight |= EFI_SYS_REQ_PRESSED;\r
-  }\r
-\r
-  KeyShiftStateLeft = (KeyShiftStateRight & 0xffffff00) | ((KeyShiftStateRight & 0xff) << 1);\r
-\r
-  InputKey = (EFI_INPUT_KEY *) (((UINT8 *) KeyOption) + sizeof (EFI_KEY_OPTION));\r
-\r
-  Index = 0;\r
-  KeyData = &HotkeyLeft->KeyData[0];\r
-  do {\r
-    //\r
-    // If Key CodeCount is 0, then only KeyData[0] is used;\r
-    // if Key CodeCount is n, then KeyData[0]~KeyData[n-1] are used\r
-    //\r
-    KeyData->Key.ScanCode = InputKey[Index].ScanCode;\r
-    KeyData->Key.UnicodeChar = InputKey[Index].UnicodeChar;\r
-    KeyData->KeyState.KeyShiftState = KeyShiftStateLeft;\r
-\r
-    Index++;\r
-    KeyData++;\r
-  } while (Index < HotkeyLeft->CodeCount);\r
-  InsertTailList (&mHotkeyList, &HotkeyLeft->Link);\r
-\r
-  if (KeyShiftStateLeft != KeyShiftStateRight) {\r
-    //\r
-    // Need an extra hotkey for shift key on right\r
-    //\r
-    HotkeyRight = AllocateCopyPool (sizeof (BDS_HOTKEY_OPTION), HotkeyLeft);\r
-    if (HotkeyRight == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    Index = 0;\r
-    KeyData = &HotkeyRight->KeyData[0];\r
-    do {\r
-      //\r
-      // Key.ScanCode and Key.UnicodeChar have already been initialized,\r
-      // only need to update KeyState.KeyShiftState\r
-      //\r
-      KeyData->KeyState.KeyShiftState = KeyShiftStateRight;\r
-\r
-      Index++;\r
-      KeyData++;\r
-    } while (Index < HotkeyRight->CodeCount);\r
-    InsertTailList (&mHotkeyList, &HotkeyRight->Link);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Return TRUE when the variable pointed by Name and Guid is a Key#### variable.\r
-\r
-  @param Name         The name of the variable.\r
-  @param Guid         The GUID of the variable.\r
-  @param OptionNumber Return the option number parsed from the Name.\r
-\r
-  @retval TRUE  The variable pointed by Name and Guid is a Key#### variable.\r
-  @retval FALSE The variable pointed by Name and Guid isn't a Key#### variable.\r
-**/\r
-BOOLEAN\r
-IsKeyOptionVariable (\r
-  CHAR16        *Name,\r
-  EFI_GUID      *Guid,\r
-  UINT16        *OptionNumber\r
-  )\r
-{\r
-  UINTN         Index;\r
-\r
-  if (!CompareGuid (Guid, &gEfiGlobalVariableGuid) ||\r
-      (StrSize (Name) != sizeof (L"Key####")) ||\r
-      (StrnCmp (Name, L"Key", 3) != 0)\r
-     ) {\r
-    return FALSE;\r
-  }\r
-\r
-  *OptionNumber = 0;\r
-  for (Index = 3; Index < 7; Index++) {\r
-    if ((Name[Index] >= L'0') && (Name[Index] <= L'9')) {\r
-      *OptionNumber = *OptionNumber * 16 + Name[Index] - L'0';\r
-    } else if ((Name[Index] >= L'A') && (Name[Index] <= L'F')) {\r
-      *OptionNumber = *OptionNumber * 16 + Name[Index] - L'A' + 10;\r
-    } else {\r
-      return FALSE;\r
-    }\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Return an array of key option numbers.\r
-\r
-  @param Count       Return the count of key option numbers.\r
-\r
-  @return UINT16*    Pointer to an array of key option numbers;\r
-**/\r
-UINT16 *\r
-EFIAPI\r
-HotkeyGetOptionNumbers (\r
-  OUT UINTN     *Count\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  UINTN                       Index;\r
-  CHAR16                      *Name;\r
-  EFI_GUID                    Guid;\r
-  UINTN                       NameSize;\r
-  UINTN                       NewNameSize;\r
-  UINT16                      *OptionNumbers;\r
-  UINT16                      OptionNumber;\r
-\r
-  if (Count == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  *Count        = 0;\r
-  OptionNumbers = NULL;\r
-\r
-  NameSize = sizeof (CHAR16);\r
-  Name     = AllocateZeroPool (NameSize);\r
-  ASSERT (Name != NULL);\r
-  while (TRUE) {\r
-    NewNameSize = NameSize;\r
-    Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);\r
-    if (Status == EFI_BUFFER_TOO_SMALL) {\r
-      Name = ReallocatePool (NameSize, NewNameSize, Name);\r
-      ASSERT (Name != NULL);\r
-      Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);\r
-      NameSize = NewNameSize;\r
-    }\r
-\r
-    if (Status == EFI_NOT_FOUND) {\r
-      break;\r
-    }\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    if (IsKeyOptionVariable (Name ,&Guid, &OptionNumber)) {\r
-      OptionNumbers = ReallocatePool (\r
-                        *Count * sizeof (UINT16),\r
-                        (*Count + 1) * sizeof (UINT16),\r
-                        OptionNumbers\r
-                        );\r
-      ASSERT (OptionNumbers != NULL);\r
-      for (Index = 0; Index < *Count; Index++) {\r
-        if (OptionNumber < OptionNumbers[Index]) {\r
-          break;\r
-        }\r
-      }\r
-      CopyMem (&OptionNumbers[Index + 1], &OptionNumbers[Index], (*Count - Index) * sizeof (UINT16));\r
-      OptionNumbers[Index] = OptionNumber;\r
-      (*Count)++;\r
-    }\r
-  }\r
-\r
-  FreePool (Name);\r
-\r
-  return OptionNumbers;\r
-}\r
-\r
-/**\r
-\r
-  Process all the "Key####" variables, associate Hotkeys with corresponding Boot Options.\r
-\r
-  @retval  EFI_SUCCESS    Hotkey services successfully initialized.\r
-**/\r
-EFI_STATUS\r
-InitializeHotkeyService (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS      Status;\r
-  UINT32          BootOptionSupport;\r
-  UINT16          *KeyOptionNumbers;\r
-  UINTN           KeyOptionCount;\r
-  UINTN           Index;\r
-  CHAR16          KeyOptionName[8];\r
-  EFI_KEY_OPTION  *KeyOption;\r
-\r
-  //\r
-  // Export our capability - EFI_BOOT_OPTION_SUPPORT_KEY and EFI_BOOT_OPTION_SUPPORT_APP.\r
-  // with maximum number of key presses of 3\r
-  // Do not report the hotkey capability if PcdConInConnectOnDemand is enabled.\r
-  //\r
-  BootOptionSupport = EFI_BOOT_OPTION_SUPPORT_APP;\r
-  if (!PcdGetBool (PcdConInConnectOnDemand)) {\r
-    BootOptionSupport |= EFI_BOOT_OPTION_SUPPORT_KEY;\r
-    SET_BOOT_OPTION_SUPPORT_KEY_COUNT (BootOptionSupport, 3);\r
-  }\r
-\r
-  Status = gRT->SetVariable (\r
-                  L"BootOptionSupport",\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                  sizeof (UINT32),\r
-                  &BootOptionSupport\r
-                  );\r
-  //\r
-  // Platform needs to make sure setting volatile variable before calling 3rd party code shouldn't fail.\r
-  //\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  KeyOptionNumbers = HotkeyGetOptionNumbers (&KeyOptionCount);\r
-  for (Index = 0; Index < KeyOptionCount; Index ++) {\r
-    UnicodeSPrint (KeyOptionName, sizeof (KeyOptionName), L"Key%04x", KeyOptionNumbers[Index]);\r
-    GetEfiGlobalVariable2 (KeyOptionName, (VOID **) &KeyOption, NULL);\r
-    ASSERT (KeyOption != NULL);\r
-    if (IsKeyOptionValid (KeyOption)) {\r
-      HotkeyInsertList (KeyOption);\r
-    }\r
-    FreePool (KeyOption);\r
-  }\r
-\r
-  if (KeyOptionNumbers != NULL) {\r
-    FreePool (KeyOptionNumbers);\r
-  }\r
-\r
-  //\r
-  // Register Protocol notify for Hotkey service\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  HotkeyEvent,\r
-                  NULL,\r
-                  &mHotkeyEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Register for protocol notifications on this event\r
-  //\r
-  Status = gBS->RegisterProtocolNotify (\r
-                  &gEfiSimpleTextInputExProtocolGuid,\r
-                  mHotkeyEvent,\r
-                  &mHotkeyRegistration\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.h b/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.h
deleted file mode 100644 (file)
index d73a1cb..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/** @file\r
-  Provides a way for 3rd party applications to register themselves for launch by the\r
-  Boot Manager based on hot key\r
-\r
-Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _HOTKEY_H_\r
-#define _HOTKEY_H_\r
-\r
-#include "Bds.h"\r
-#include "String.h"\r
-\r
-#define SET_BOOT_OPTION_SUPPORT_KEY_COUNT(a, c) {  \\r
-      (a) = ((a) & ~EFI_BOOT_OPTION_SUPPORT_COUNT) | (((c) << LowBitSet32 (EFI_BOOT_OPTION_SUPPORT_COUNT)) & EFI_BOOT_OPTION_SUPPORT_COUNT); \\r
-      }\r
-\r
-#define BDS_HOTKEY_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'K', 'O')\r
-\r
-\r
-typedef struct {\r
-  UINTN                     Signature;\r
-  LIST_ENTRY                Link;\r
-\r
-  VOID                      *NotifyHandle;\r
-  UINT16                    BootOptionNumber;\r
-  UINT8                     CodeCount;\r
-  UINT8                     WaitingKey;\r
-  EFI_KEY_DATA              KeyData[3];\r
-} BDS_HOTKEY_OPTION;\r
-\r
-#define BDS_HOTKEY_OPTION_FROM_LINK(a) CR (a, BDS_HOTKEY_OPTION, Link, BDS_HOTKEY_OPTION_SIGNATURE)\r
-\r
-/**\r
-\r
-  Process all the "Key####" variables, associate Hotkeys with corresponding Boot Options.\r
-\r
-\r
-  @param VOID\r
-\r
-  @retval  EFI_SUCCESS    Hotkey services successfully initialized.\r
-\r
-**/\r
-EFI_STATUS\r
-InitializeHotkeyService (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Try to boot the boot option triggered by hotkey.\r
-  @retval  EFI_SUCCESS             There is HotkeyBootOption & it is processed\r
-  @retval  EFI_NOT_FOUND           There is no HotkeyBootOption\r
-**/\r
-EFI_STATUS\r
-HotkeyBoot (\r
-  VOID\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/HwErrRecSupport.c b/IntelFrameworkModulePkg/Universal/BdsDxe/HwErrRecSupport.c
deleted file mode 100644 (file)
index 6e74119..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/** @file\r
-  Set the level of support for Hardware Error Record Persistence that is\r
-  implemented by the platform.\r
-\r
-Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "HwErrRecSupport.h"\r
-\r
-/**\r
-  Set the HwErrRecSupport variable contains a binary UINT16 that supplies the\r
-  level of support for Hardware Error Record Persistence that is implemented\r
-  by the platform.\r
-\r
-**/\r
-VOID\r
-InitializeHwErrRecSupport (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  UINT16        HardwareErrorRecordLevel;\r
-\r
-  HardwareErrorRecordLevel = PcdGet16 (PcdHardwareErrorRecordLevel);\r
-\r
-  if (HardwareErrorRecordLevel != 0) {\r
-    //\r
-    // If level value equal 0, no need set to 0 to variable area because UEFI specification\r
-    // define same behavior between no value or 0 value for L"HwErrRecSupport".\r
-    //\r
-    Status = gRT->SetVariable (\r
-                    L"HwErrRecSupport",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    sizeof (UINT16),\r
-                    &HardwareErrorRecordLevel\r
-                    );\r
-    ASSERT_EFI_ERROR(Status);\r
-  }\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/HwErrRecSupport.h b/IntelFrameworkModulePkg/Universal/BdsDxe/HwErrRecSupport.h
deleted file mode 100644 (file)
index 540f950..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/** @file\r
-  Set the level of support for Hardware Error Record Persistence that is\r
-  implemented by the platform.\r
-\r
-Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _HW_ERR_REC_SUPPORT_H_\r
-#define _HW_ERR_REC_SUPPORT_H_\r
-\r
-#include "Bds.h"\r
-\r
-/**\r
-  Set the HwErrRecSupport variable contains a binary UINT16 that supplies the\r
-  level of support for Hardware Error Record Persistence that is implemented\r
-  by the platform.\r
-\r
-**/\r
-VOID\r
-InitializeHwErrRecSupport (\r
-  VOID\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Language.c b/IntelFrameworkModulePkg/Universal/BdsDxe/Language.c
deleted file mode 100644 (file)
index 32134e3..0000000
+++ /dev/null
@@ -1,493 +0,0 @@
-/** @file\r
-  Language settings\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Language.h"\r
-#include "FrontPage.h"\r
-\r
-EFI_GUID  mFontPackageGuid = {\r
-  0x78941450, 0x90ab, 0x4fb1, {0xb7, 0x5f, 0x58, 0x92, 0x14, 0xe2, 0x4a, 0xc}\r
-};\r
-\r
-#define NARROW_GLYPH_NUMBER 8\r
-#define WIDE_GLYPH_NUMBER   75\r
-\r
-typedef struct {\r
-  ///\r
-  /// This 4-bytes total array length is required by HiiAddPackages()\r
-  ///\r
-  UINT32                 Length;\r
-\r
-  //\r
-  // This is the Font package definition\r
-  //\r
-  EFI_HII_PACKAGE_HEADER Header;\r
-  UINT16                 NumberOfNarrowGlyphs;\r
-  UINT16                 NumberOfWideGlyphs;\r
-  EFI_NARROW_GLYPH       NarrowArray[NARROW_GLYPH_NUMBER];\r
-  EFI_WIDE_GLYPH         WideArray[WIDE_GLYPH_NUMBER];\r
-} FONT_PACK_BIN;\r
-\r
-FONT_PACK_BIN mFontBin = {\r
-  sizeof (FONT_PACK_BIN),\r
-  {\r
-    sizeof (FONT_PACK_BIN) - sizeof (UINT32),\r
-    EFI_HII_PACKAGE_SIMPLE_FONTS,\r
-  },\r
-  NARROW_GLYPH_NUMBER,\r
-  0,\r
-  {     // Narrow Glyphs\r
-    {\r
-      0x05d0,\r
-      0x00,\r
-      {\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x4E,\r
-        0x6E,\r
-        0x62,\r
-        0x32,\r
-        0x32,\r
-        0x3C,\r
-        0x68,\r
-        0x4C,\r
-        0x4C,\r
-        0x46,\r
-        0x76,\r
-        0x72,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00\r
-      }\r
-    },\r
-    {\r
-      0x05d1,\r
-      0x00,\r
-      {\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x78,\r
-        0x7C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x7E,\r
-        0x7E,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00\r
-      }\r
-    },\r
-    {\r
-      0x05d2,\r
-      0x00,\r
-      {\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x78,\r
-        0x7C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x1C,\r
-        0x3E,\r
-        0x66,\r
-        0x66,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00\r
-      }\r
-    },\r
-    {\r
-      0x05d3,\r
-      0x00,\r
-      {\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x7E,\r
-        0x7E,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00\r
-      }\r
-    },\r
-    {\r
-      0x05d4,\r
-      0x00,\r
-      {\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x7C,\r
-        0x7E,\r
-        0x06,\r
-        0x06,\r
-        0x06,\r
-        0x06,\r
-        0x66,\r
-        0x66,\r
-        0x66,\r
-        0x66,\r
-        0x66,\r
-        0x66,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00\r
-      }\r
-    },\r
-    {\r
-      0x05d5,\r
-      0x00,\r
-      {\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x3C,\r
-        0x3C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x0C,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00\r
-      }\r
-    },\r
-    {\r
-      0x05d6,\r
-      0x00,\r
-      {\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x38,\r
-        0x38,\r
-        0x1E,\r
-        0x1E,\r
-        0x18,\r
-        0x18,\r
-        0x18,\r
-        0x18,\r
-        0x18,\r
-        0x18,\r
-        0x18,\r
-        0x18,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00\r
-      }\r
-    },\r
-    {\r
-      0x0000,\r
-      0x00,\r
-      {\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00,\r
-        0x00\r
-      }\r
-    }\r
-  }\r
-};\r
-\r
-/**\r
-  Routine to export glyphs to the HII database.  This is in addition to whatever is defined in the Graphics Console driver.\r
-\r
-**/\r
-VOID\r
-ExportFonts (\r
-  VOID\r
-  )\r
-{\r
-  EFI_HII_HANDLE               HiiHandle;\r
-\r
-  HiiHandle = HiiAddPackages (\r
-                &mFontPackageGuid,\r
-                gImageHandle,\r
-                &mFontBin,\r
-                NULL\r
-                );\r
-  ASSERT (HiiHandle != NULL);\r
-}\r
-\r
-/**\r
-  Get next language from language code list (with separator ';').\r
-\r
-  If LangCode is NULL, then ASSERT.\r
-  If Lang is NULL, then ASSERT.\r
-\r
-  @param  LangCode    On input: point to first language in the list. On\r
-                                 output: point to next language in the list, or\r
-                                 NULL if no more language in the list.\r
-  @param  Lang           The first language in the list.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-GetNextLanguage (\r
-  IN OUT CHAR8      **LangCode,\r
-  OUT CHAR8         *Lang\r
-  )\r
-{\r
-  UINTN  Index;\r
-  CHAR8  *StringPtr;\r
-\r
-  ASSERT (LangCode != NULL);\r
-  ASSERT (*LangCode != NULL);\r
-  ASSERT (Lang != NULL);\r
-\r
-  Index = 0;\r
-  StringPtr = *LangCode;\r
-  while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {\r
-    Index++;\r
-  }\r
-\r
-  CopyMem (Lang, StringPtr, Index);\r
-  Lang[Index] = 0;\r
-\r
-  if (StringPtr[Index] == ';') {\r
-    Index++;\r
-  }\r
-  *LangCode = StringPtr + Index;\r
-}\r
-\r
-/**\r
-  Check if lang is in supported language codes according to language string.\r
-\r
-  This code is used to check if lang is in in supported language codes. It can handle\r
-  RFC4646 and ISO639 language tags.\r
-  In ISO639 language tags, take 3-characters as a delimitation to find matched string.\r
-  In RFC4646 language tags, take semicolon as a delimitation to find matched string.\r
-\r
-  For example:\r
-    SupportedLang  = "engfraengfra"\r
-    Iso639Language = TRUE\r
-    Lang           = "eng", the return value is "TRUE", or\r
-    Lang           = "chs", the return value is "FALSE".\r
-  Another example:\r
-    SupportedLang  = "en;fr;en-US;fr-FR"\r
-    Iso639Language = FALSE\r
-    Lang           = "en", the return value is "TRUE", or\r
-    Lang           = "zh", the return value is "FALSE".\r
-\r
-  @param  SupportedLang               Platform supported language codes.\r
-  @param  Lang                        Configured language.\r
-  @param  Iso639Language              A bool value to signify if the handler is operated on ISO639 or RFC4646.\r
-\r
-  @retval TRUE  lang is in supported language codes.\r
-  @retval FALSE lang is not in supported language codes.\r
-\r
-**/\r
-BOOLEAN\r
-IsLangInSupportedLangCodes(\r
-  IN  CHAR8            *SupportedLang,\r
-  IN  CHAR8            *Lang,\r
-  IN  BOOLEAN          Iso639Language\r
-  )\r
-{\r
-  UINTN    Index;\r
-  UINTN    CompareLength;\r
-  UINTN    LanguageLength;\r
-\r
-  if (Iso639Language) {\r
-    CompareLength = ISO_639_2_ENTRY_SIZE;\r
-    for (Index = 0; Index < AsciiStrLen (SupportedLang); Index += CompareLength) {\r
-      if (AsciiStrnCmp (Lang, SupportedLang + Index, CompareLength) == 0) {\r
-        //\r
-        // Successfully find the Lang string in SupportedLang string.\r
-        //\r
-        return TRUE;\r
-      }\r
-    }\r
-    return FALSE;\r
-  } else {\r
-    //\r
-    // Compare RFC4646 language code\r
-    //\r
-    for (LanguageLength = 0; Lang[LanguageLength] != '\0'; LanguageLength++);\r
-\r
-    for (; *SupportedLang != '\0'; SupportedLang += CompareLength) {\r
-      //\r
-      // Skip ';' characters in SupportedLang\r
-      //\r
-      for (; *SupportedLang != '\0' && *SupportedLang == ';'; SupportedLang++);\r
-      //\r
-      // Determine the length of the next language code in SupportedLang\r
-      //\r
-      for (CompareLength = 0; SupportedLang[CompareLength] != '\0' && SupportedLang[CompareLength] != ';'; CompareLength++);\r
-\r
-      if ((CompareLength == LanguageLength) &&\r
-          (AsciiStrnCmp (Lang, SupportedLang, CompareLength) == 0)) {\r
-        //\r
-        // Successfully find the Lang string in SupportedLang string.\r
-        //\r
-        return TRUE;\r
-      }\r
-    }\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-/**\r
-  Initialize Lang or PlatformLang variable, if Lang or PlatformLang variable is not found,\r
-  or it has been set to an unsupported value(not one of platform supported language codes),\r
-  set the default language code to it.\r
-\r
-  @param  LangName                    Language name, L"Lang" or L"PlatformLang".\r
-  @param  SupportedLang               Platform supported language codes.\r
-  @param  DefaultLang                 Default language code.\r
-  @param  Iso639Language              A bool value to signify if the handler is operated on ISO639 or RFC4646,\r
-                                      TRUE for L"Lang" LangName or FALSE for L"PlatformLang" LangName.\r
-\r
-**/\r
-VOID\r
-InitializeLangVariable (\r
-  IN CHAR16     *LangName,\r
-  IN CHAR8      *SupportedLang,\r
-  IN CHAR8      *DefaultLang,\r
-  IN BOOLEAN    Iso639Language\r
-  )\r
-{\r
-  CHAR8       *Lang;\r
-\r
-  //\r
-  // Find current Lang or PlatformLang from EFI Variable.\r
-  //\r
-  GetEfiGlobalVariable2 (LangName, (VOID **) &Lang, NULL);\r
-  //\r
-  // If Lang or PlatformLang variable is not found,\r
-  // or it has been set to an unsupported value(not one of the supported language codes),\r
-  // set the default language code to it.\r
-  //\r
-  if ((Lang == NULL) || !IsLangInSupportedLangCodes (SupportedLang, Lang, Iso639Language)) {\r
-    //\r
-    // The default language code should be one of the supported language codes.\r
-    //\r
-    ASSERT (IsLangInSupportedLangCodes (SupportedLang, DefaultLang, Iso639Language));\r
-    BdsDxeSetVariableAndReportStatusCodeOnError (\r
-                    LangName,\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                    AsciiStrSize (DefaultLang),\r
-                    DefaultLang\r
-                    );\r
-  }\r
-\r
-  if (Lang != NULL) {\r
-    FreePool (Lang);\r
-  }\r
-}\r
-\r
-/**\r
-  Determine the current language that will be used\r
-  based on language related EFI Variables.\r
-\r
-  @param LangCodesSettingRequired - If required to set LangCodes variable\r
-\r
-**/\r
-VOID\r
-InitializeLanguage (\r
-  BOOLEAN LangCodesSettingRequired\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  CHAR8       *LangCodes;\r
-  CHAR8       *PlatformLangCodes;\r
-\r
-  ExportFonts ();\r
-\r
-  LangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLangCodes);\r
-  PlatformLangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes);\r
-  if (LangCodesSettingRequired) {\r
-    if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) {\r
-      //\r
-      // UEFI 2.0 depricated this variable so we support turning it off\r
-      //\r
-      Status = gRT->SetVariable (\r
-                      L"LangCodes",\r
-                      &gEfiGlobalVariableGuid,\r
-                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                      AsciiStrSize (LangCodes),\r
-                      LangCodes\r
-                      );\r
-      //\r
-      // Platform needs to make sure setting volatile variable before calling 3rd party code shouldn't fail.\r
-      //\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-\r
-    Status = gRT->SetVariable (\r
-                    L"PlatformLangCodes",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                    AsciiStrSize (PlatformLangCodes),\r
-                    PlatformLangCodes\r
-                    );\r
-    //\r
-    // Platform needs to make sure setting volatile variable before calling 3rd party code shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) {\r
-    //\r
-    // UEFI 2.0 depricated this variable so we support turning it off\r
-    //\r
-    InitializeLangVariable (L"Lang", LangCodes, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultLang), TRUE);\r
-  }\r
-  InitializeLangVariable (L"PlatformLang", PlatformLangCodes, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang), FALSE);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Language.h b/IntelFrameworkModulePkg/Universal/BdsDxe/Language.h
deleted file mode 100644 (file)
index 956bc8a..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/** @file\r
-  Language setting\r
-\r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _LANGUAGE_H_\r
-#define _LANGUAGE_H_\r
-\r
-#include "String.h"\r
-\r
-/**\r
-  Get next language from language code list (with separator ';').\r
-\r
-  If LangCode is NULL, then ASSERT.\r
-  If Lang is NULL, then ASSERT.\r
-\r
-  @param  LangCode    On input: point to first language in the list. On\r
-                                 output: point to next language in the list, or\r
-                                 NULL if no more language in the list.\r
-  @param  Lang           The first language in the list.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-GetNextLanguage (\r
-  IN OUT CHAR8      **LangCode,\r
-  OUT CHAR8         *Lang\r
-  );\r
-\r
-/**\r
-  Determine the current language that will be used\r
-  based on language related EFI Variables.\r
-\r
-  @param LangCodesSettingRequired If required to set LangCode variable\r
-\r
-**/\r
-VOID\r
-InitializeLanguage (\r
-  BOOLEAN LangCodesSettingRequired\r
-  );\r
-\r
-#endif // _LANGUAGE_H_\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c b/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
deleted file mode 100644 (file)
index 0759c15..0000000
+++ /dev/null
@@ -1,430 +0,0 @@
-/** @file\r
-  Perform the platform memory test\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Bds.h"\r
-#include "String.h"\r
-\r
-//\r
-// BDS Platform Functions\r
-//\r
-/**\r
-\r
-  Show progress bar with title above it. It only works in Graphics mode.\r
-\r
-\r
-  @param TitleForeground Foreground color for Title.\r
-  @param TitleBackground Background color for Title.\r
-  @param Title           Title above progress bar.\r
-  @param ProgressColor   Progress bar color.\r
-  @param Progress        Progress (0-100)\r
-  @param PreviousValue   The previous value of the progress.\r
-\r
-  @retval  EFI_STATUS       Success update the progress bar\r
-\r
-**/\r
-EFI_STATUS\r
-PlatformBdsShowProgress (\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,\r
-  IN CHAR16                        *Title,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,\r
-  IN UINTN                         Progress,\r
-  IN UINTN                         PreviousValue\r
-  )\r
-{\r
-  EFI_STATUS                     Status;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL   *GraphicsOutput;\r
-  EFI_UGA_DRAW_PROTOCOL          *UgaDraw;\r
-  UINT32                         SizeOfX;\r
-  UINT32                         SizeOfY;\r
-  UINT32                         ColorDepth;\r
-  UINT32                         RefreshRate;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Color;\r
-  UINTN                          BlockHeight;\r
-  UINTN                          BlockWidth;\r
-  UINTN                          BlockNum;\r
-  UINTN                          PosX;\r
-  UINTN                          PosY;\r
-  UINTN                          Index;\r
-\r
-  if (Progress > 100) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  UgaDraw = NULL;\r
-  Status = gBS->HandleProtocol (\r
-                  gST->ConsoleOutHandle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID **) &GraphicsOutput\r
-                  );\r
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-    GraphicsOutput = NULL;\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    gST->ConsoleOutHandle,\r
-                    &gEfiUgaDrawProtocolGuid,\r
-                    (VOID **) &UgaDraw\r
-                    );\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  SizeOfX = 0;\r
-  SizeOfY = 0;\r
-  if (GraphicsOutput != NULL) {\r
-    SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
-    SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
-  } else if (UgaDraw != NULL) {\r
-    Status = UgaDraw->GetMode (\r
-                        UgaDraw,\r
-                        &SizeOfX,\r
-                        &SizeOfY,\r
-                        &ColorDepth,\r
-                        &RefreshRate\r
-                        );\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  BlockWidth  = SizeOfX / 100;\r
-  BlockHeight = SizeOfY / 50;\r
-\r
-  BlockNum    = Progress;\r
-\r
-  PosX        = 0;\r
-  PosY        = SizeOfY * 48 / 50;\r
-\r
-  if (BlockNum == 0) {\r
-    //\r
-    // Clear progress area\r
-    //\r
-    SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
-\r
-    if (GraphicsOutput != NULL) {\r
-      Status = GraphicsOutput->Blt (\r
-                          GraphicsOutput,\r
-                          &Color,\r
-                          EfiBltVideoFill,\r
-                          0,\r
-                          0,\r
-                          0,\r
-                          PosY - EFI_GLYPH_HEIGHT - 1,\r
-                          SizeOfX,\r
-                          SizeOfY - (PosY - EFI_GLYPH_HEIGHT - 1),\r
-                          SizeOfX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-                          );\r
-    } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-      Status = UgaDraw->Blt (\r
-                          UgaDraw,\r
-                          (EFI_UGA_PIXEL *) &Color,\r
-                          EfiUgaVideoFill,\r
-                          0,\r
-                          0,\r
-                          0,\r
-                          PosY - EFI_GLYPH_HEIGHT - 1,\r
-                          SizeOfX,\r
-                          SizeOfY - (PosY - EFI_GLYPH_HEIGHT - 1),\r
-                          SizeOfX * sizeof (EFI_UGA_PIXEL)\r
-                          );\r
-    } else {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-  //\r
-  // Show progress by drawing blocks\r
-  //\r
-  for (Index = PreviousValue; Index < BlockNum; Index++) {\r
-    PosX = Index * BlockWidth;\r
-    if (GraphicsOutput != NULL) {\r
-      Status = GraphicsOutput->Blt (\r
-                          GraphicsOutput,\r
-                          &ProgressColor,\r
-                          EfiBltVideoFill,\r
-                          0,\r
-                          0,\r
-                          PosX,\r
-                          PosY,\r
-                          BlockWidth - 1,\r
-                          BlockHeight,\r
-                          (BlockWidth) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-                          );\r
-    } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-      Status = UgaDraw->Blt (\r
-                          UgaDraw,\r
-                          (EFI_UGA_PIXEL *) &ProgressColor,\r
-                          EfiUgaVideoFill,\r
-                          0,\r
-                          0,\r
-                          PosX,\r
-                          PosY,\r
-                          BlockWidth - 1,\r
-                          BlockHeight,\r
-                          (BlockWidth) * sizeof (EFI_UGA_PIXEL)\r
-                          );\r
-    } else {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-\r
-  PrintXY (\r
-    (SizeOfX - StrLen (Title) * EFI_GLYPH_WIDTH) / 2,\r
-    PosY - EFI_GLYPH_HEIGHT - 1,\r
-    &TitleForeground,\r
-    &TitleBackground,\r
-    Title\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Perform the memory test base on the memory test intensive level,\r
-  and update the memory resource.\r
-\r
-  @param  Level         The memory test intensive level.\r
-\r
-  @retval EFI_STATUS    Success test all the system memory and update\r
-                        the memory resource\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsMemoryTest (\r
-  IN EXTENDMEM_COVERAGE_LEVEL Level\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_STATUS                        KeyStatus;\r
-  EFI_STATUS                        InitStatus;\r
-  EFI_STATUS                        ReturnStatus;\r
-  BOOLEAN                           RequireSoftECCInit;\r
-  EFI_GENERIC_MEMORY_TEST_PROTOCOL  *GenMemoryTest;\r
-  UINT64                            TestedMemorySize;\r
-  UINT64                            TotalMemorySize;\r
-  UINTN                             TestPercent;\r
-  UINT64                            PreviousValue;\r
-  BOOLEAN                           ErrorOut;\r
-  BOOLEAN                           TestAbort;\r
-  EFI_INPUT_KEY                     Key;\r
-  CHAR16                            StrPercent[80];\r
-  CHAR16                            *StrTotalMemory;\r
-  CHAR16                            *Pos;\r
-  CHAR16                            *TmpStr;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     Foreground;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     Background;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     Color;\r
-  BOOLEAN                           IsFirstBoot;\r
-  UINT32                            TempData;\r
-  UINTN                             StrTotalMemorySize;\r
-\r
-  ReturnStatus = EFI_SUCCESS;\r
-  ZeroMem (&Key, sizeof (EFI_INPUT_KEY));\r
-\r
-  StrTotalMemorySize = 128;\r
-  Pos = AllocateZeroPool (StrTotalMemorySize);\r
-\r
-  if (Pos == NULL) {\r
-    return ReturnStatus;\r
-  }\r
-\r
-  StrTotalMemory    = Pos;\r
-\r
-  TestedMemorySize  = 0;\r
-  TotalMemorySize   = 0;\r
-  PreviousValue     = 0;\r
-  ErrorOut          = FALSE;\r
-  TestAbort         = FALSE;\r
-\r
-  SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
-  SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
-  SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
-\r
-  RequireSoftECCInit = FALSE;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiGenericMemTestProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &GenMemoryTest\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    FreePool (Pos);\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  InitStatus = GenMemoryTest->MemoryTestInit (\r
-                                GenMemoryTest,\r
-                                Level,\r
-                                &RequireSoftECCInit\r
-                                );\r
-  if (InitStatus == EFI_NO_MEDIA) {\r
-    //\r
-    // The PEI codes also have the relevant memory test code to check the memory,\r
-    // it can select to test some range of the memory or all of them. If PEI code\r
-    // checks all the memory, this BDS memory test will has no not-test memory to\r
-    // do the test, and then the status of EFI_NO_MEDIA will be returned by\r
-    // "MemoryTestInit". So it does not need to test memory again, just return.\r
-    //\r
-    FreePool (Pos);\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
-    TmpStr = GetStringById (STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST));\r
-\r
-    if (TmpStr != NULL) {\r
-      PrintXY (10, 10, NULL, NULL, TmpStr);\r
-      FreePool (TmpStr);\r
-    }\r
-  } else {\r
-    DEBUG ((EFI_D_INFO, "Enter memory test.\n"));\r
-  }\r
-  do {\r
-    Status = GenMemoryTest->PerformMemoryTest (\r
-                              GenMemoryTest,\r
-                              &TestedMemorySize,\r
-                              &TotalMemorySize,\r
-                              &ErrorOut,\r
-                              TestAbort\r
-                              );\r
-    if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {\r
-      TmpStr = GetStringById (STRING_TOKEN (STR_SYSTEM_MEM_ERROR));\r
-      if (TmpStr != NULL) {\r
-        PrintXY (10, 10, NULL, NULL, TmpStr);\r
-        FreePool (TmpStr);\r
-      }\r
-\r
-      ASSERT (0);\r
-    }\r
-\r
-    if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
-      TempData = (UINT32) DivU64x32 (TotalMemorySize, 16);\r
-      TestPercent = (UINTN) DivU64x32 (\r
-                              DivU64x32 (MultU64x32 (TestedMemorySize, 100), 16),\r
-                              TempData\r
-                              );\r
-      if (TestPercent != PreviousValue) {\r
-        UnicodeValueToStringS (StrPercent, sizeof (StrPercent), 0, TestPercent, 0);\r
-        TmpStr = GetStringById (STRING_TOKEN (STR_MEMORY_TEST_PERCENT));\r
-        if (TmpStr != NULL) {\r
-          //\r
-          // TmpStr size is 64, StrPercent is reserved to 16.\r
-          //\r
-          StrnCatS (\r
-            StrPercent,\r
-            sizeof (StrPercent) / sizeof (CHAR16),\r
-            TmpStr,\r
-            sizeof (StrPercent) / sizeof (CHAR16) - StrLen (StrPercent) - 1\r
-            );\r
-          PrintXY (10, 10, NULL, NULL, StrPercent);\r
-          FreePool (TmpStr);\r
-        }\r
-\r
-        TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));\r
-        if (TmpStr != NULL) {\r
-          PlatformBdsShowProgress (\r
-            Foreground,\r
-            Background,\r
-            TmpStr,\r
-            Color,\r
-            TestPercent,\r
-            (UINTN) PreviousValue\r
-            );\r
-          FreePool (TmpStr);\r
-        }\r
-      }\r
-\r
-      PreviousValue = TestPercent;\r
-    } else {\r
-      DEBUG ((EFI_D_INFO, "Perform memory test (ESC to skip).\n"));\r
-    }\r
-\r
-    if (!PcdGetBool (PcdConInConnectOnDemand)) {\r
-      KeyStatus     = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-      if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {\r
-        if (!RequireSoftECCInit) {\r
-          if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
-            TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));\r
-            if (TmpStr != NULL) {\r
-              PlatformBdsShowProgress (\r
-                Foreground,\r
-                Background,\r
-                TmpStr,\r
-                Color,\r
-                100,\r
-                (UINTN) PreviousValue\r
-                );\r
-              FreePool (TmpStr);\r
-            }\r
-\r
-            PrintXY (10, 10, NULL, NULL, L"100");\r
-          }\r
-          Status = GenMemoryTest->Finished (GenMemoryTest);\r
-          goto Done;\r
-        }\r
-\r
-        TestAbort = TRUE;\r
-      }\r
-    }\r
-  } while (Status != EFI_NOT_FOUND);\r
-\r
-  Status = GenMemoryTest->Finished (GenMemoryTest);\r
-\r
-Done:\r
-  if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
-    UnicodeValueToStringS (StrTotalMemory, StrTotalMemorySize, COMMA_TYPE, TotalMemorySize, 0);\r
-    if (StrTotalMemory[0] == L',') {\r
-      StrTotalMemory++;\r
-      StrTotalMemorySize -= sizeof (CHAR16);\r
-    }\r
-\r
-    TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED));\r
-    if (TmpStr != NULL) {\r
-      StrnCatS (\r
-        StrTotalMemory,\r
-        StrTotalMemorySize / sizeof (CHAR16),\r
-        TmpStr,\r
-        StrTotalMemorySize / sizeof (CHAR16) - StrLen (StrTotalMemory) - 1\r
-        );\r
-      FreePool (TmpStr);\r
-    }\r
-\r
-    PrintXY (10, 10, NULL, NULL, StrTotalMemory);\r
-    PlatformBdsShowProgress (\r
-      Foreground,\r
-      Background,\r
-      StrTotalMemory,\r
-      Color,\r
-      100,\r
-      (UINTN) PreviousValue\r
-      );\r
-\r
-  } else {\r
-    DEBUG ((EFI_D_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize));\r
-  }\r
-\r
-  FreePool (Pos);\r
-\r
-\r
-  //\r
-  // Use a DynamicHii type pcd to save the boot status, which is used to\r
-  // control configuration mode, such as FULL/MINIMAL/NO_CHANGES configuration.\r
-  //\r
-  IsFirstBoot = PcdGetBool(PcdBootState);\r
-  if (IsFirstBoot) {\r
-    Status = PcdSetBoolS(PcdBootState, FALSE);\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "Set PcdBootState to FALSE failed.\n"));\r
-    }\r
-  }\r
-\r
-  return ReturnStatus;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/String.c b/IntelFrameworkModulePkg/Universal/BdsDxe/String.c
deleted file mode 100644 (file)
index 998ed49..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/** @file\r
-  String support\r
-\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Bds.h"\r
-#include "Language.h"\r
-#include "FrontPage.h"\r
-\r
-EFI_HII_HANDLE gStringPackHandle;\r
-\r
-EFI_GUID mBdsStringPackGuid = {\r
-  0x7bac95d3, 0xddf, 0x42f3, {0x9e, 0x24, 0x7c, 0x64, 0x49, 0x40, 0x37, 0x9a}\r
-};\r
-\r
-/**\r
-  Initialize HII global accessor for string support.\r
-\r
-**/\r
-VOID\r
-InitializeStringSupport (\r
-  VOID\r
-  )\r
-{\r
-  gStringPackHandle = HiiAddPackages (\r
-                         &mBdsStringPackGuid,\r
-                         gImageHandle,\r
-                         BdsDxeStrings,\r
-                         NULL\r
-                         );\r
-  ASSERT (gStringPackHandle != NULL);\r
-}\r
-\r
-/**\r
-  Get string by string id from HII Interface\r
-\r
-\r
-  @param Id              String ID.\r
-\r
-  @retval  CHAR16 *  String from ID.\r
-  @retval  NULL      If error occurs.\r
-\r
-**/\r
-CHAR16 *\r
-GetStringById (\r
-  IN  EFI_STRING_ID   Id\r
-  )\r
-{\r
-  return HiiGetString (gStringPackHandle, Id, NULL);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/String.h b/IntelFrameworkModulePkg/Universal/BdsDxe/String.h
deleted file mode 100644 (file)
index d8196a6..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/** @file\r
-  String support\r
-\r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _STRING_H_\r
-#define _STRING_H_\r
-\r
-#include "Bds.h"\r
-\r
-extern EFI_HII_HANDLE gStringPackHandle;\r
-\r
-//\r
-// This is the VFR compiler generated header file which defines the\r
-// string identifiers.\r
-//\r
-\r
-extern UINT8  BdsDxeStrings[];\r
-\r
-/**\r
-  Get string by string id from HII Interface\r
-\r
-\r
-  @param Id              String ID.\r
-\r
-  @retval  CHAR16 *  String from ID.\r
-  @retval  NULL      If error occurs.\r
-\r
-**/\r
-CHAR16 *\r
-GetStringById (\r
-  IN  EFI_STRING_ID   Id\r
-  );\r
-\r
-/**\r
-  Initialize HII global accessor for string support.\r
-\r
-**/\r
-VOID\r
-InitializeStringSupport (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Call the browser and display the front page\r
-\r
-  @return   Status code that will be returned by\r
-            EFI_FORM_BROWSER2_PROTOCOL.SendForm ().\r
-\r
-**/\r
-EFI_STATUS\r
-CallFrontPage (\r
-  VOID\r
-  );\r
-\r
-#endif // _STRING_H_\r
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Strings.uni b/IntelFrameworkModulePkg/Universal/BdsDxe/Strings.uni
deleted file mode 100644 (file)
index 093b908..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-///** @file\r
-//\r
-//    String definitions for BdsPlatform formset.\r
-//\r
-//  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-//**/\r
-\r
-/=#\r
-\r
-#langdef   en-US "English"\r
-#langdef   fr-FR "Français"\r
-\r
-#string STR_INTERNAL_EFI_SHELL         #language en-US  "[Internal EFI Shell]"\r
-                                       #language fr-FR  "[la Coquille interne de EFI]"\r
-#string STR_LEGACY_BOOT_A              #language en-US  "[Internal Legacy Boot A:]"\r
-                                       #language fr-FR  "[Le Legs interne Charge A:]"\r
-#string STR_PROCESSED_ALL_BOOT_OPTIONS #language en-US  "[ProcessedAllBootOptions(): Load shell from the FV]"\r
-                                       #language fr-FR  "[ProcessedAllBootOptions() : la coquille de Chargement du FV]"\r
-#string STR_BOOT_FAILED                #language en-US  "Boot Failed. "\r
-                                       #language fr-FR  "la Botte A. "\r
-#string STR_BOOT_SUCCEEDED             #language en-US  "Boot Succeeded - "\r
-                                       #language fr-FR  "Charge Réussi - "\r
-#string STR_DEFAULT_TIMEOUT_BANNER     #language en-US  "Default boot selection will be booted in "\r
-                                       #language fr-FR  "la sélection de botte de Défaut sera dans "\r
-#string STR_SECONDS                    #language en-US  " seconds"\r
-                                       #language fr-FR  " les secondes"\r
-#string STR_EXIT_DATA                  #language en-US  "ExitData: "\r
-                                       #language fr-FR  "ExitData: "\r
-#string STR_LOADING                    #language en-US  "Loading: "\r
-                                       #language fr-FR  "Chargement: "\r
-#string STR_ENTER_NORMAL_BOOT          #language en-US  "Entering Normal Boot Process..."\r
-                                       #language fr-FR  "l'Entrer le Procédé de Botte Normal..."\r
-#string STR_PERFORM_MEM_TEST           #language en-US  "Perform memory test (ESC to skip)"\r
-                                       #language fr-FR  "Exécute l'examen de mémoire (ESC pour sauter)"\r
-#string STR_MEMORY_TEST_PERCENT        #language en-US  "% of the system memory tested OK"\r
-                                       #language fr-FR  "% de la mémoire de système essayée D'ACCORD"\r
-#string STR_ESC_TO_SKIP_MEM_TEST       #language en-US  "Press ESC key to skip memory test"\r
-                                       #language fr-FR  "Appuie sur ESC sauter examen de mémoire"\r
-#string STR_MEM_TEST_COMPLETED         #language en-US  " bytes of system memory tested OK\r\n"\r
-                                       #language fr-FR  "octets dela mémoire de système essayée D'ACCORD\r\n"\r
-#string STR_NO_EXT_MEM_FOUND           #language en-US  "Memory resource updated!"\r
-                                       #language fr-FR  "la mémoire Non Ã©tendue trouvée!"\r
-#string STR_SYSTEM_MEM_ERROR           #language en-US  "System encounters memory errors"\r
-                                       #language fr-FR  "le Système rencontre les erreurs de mémoire"\r
-#string STR_START_BOOT_OPTION          #language en-US  "Start boot option"\r
-                                       #language fr-FR  "l'option de botte de Début"\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.c b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/ComponentName.c
deleted file mode 100644 (file)
index 6b13d90..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/** @file\r
-  UEFI Component Name(2) protocol implementation for VGA Class Driver.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "VgaClass.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gVgaClassComponentName = {\r
-  VgaClassComponentNameGetDriverName,\r
-  VgaClassComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gVgaClassComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) VgaClassComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) VgaClassComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVgaClassDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"VGA Class Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param  Language              A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-  @param  DriverName            A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mVgaClassDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gVgaClassComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param  ControllerHandle      The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-  @param  ChildHandle           The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-  @param  Language              A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-  @param  ControllerName        A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.c b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.c
deleted file mode 100644 (file)
index 76b4aa9..0000000
+++ /dev/null
@@ -1,1282 +0,0 @@
-/** @file\r
-  VGA Class Driver that managers VGA devices and produces Simple Text Output Protocol.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "VgaClass.h"\r
-\r
-//\r
-// EFI Driver Binding Protocol for the VGA Class Driver\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gVgaClassDriverBinding = {\r
-  VgaClassDriverBindingSupported,\r
-  VgaClassDriverBindingStart,\r
-  VgaClassDriverBindingStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-//\r
-// Local variables\r
-//\r
-CHAR16               CrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r
-\r
-//\r
-// This list is used to define the valid extend chars.\r
-// It also provides a mapping from Unicode to PCANSI or\r
-// ASCII. The ASCII mapping we just made up.\r
-//\r
-//\r
-UNICODE_TO_CHAR  UnicodeToPcAnsiOrAscii[] = {\r
-  {\r
-    BOXDRAW_HORIZONTAL,\r
-    0xc4,\r
-    L'-'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL,\r
-    0xb3,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_DOWN_RIGHT,\r
-    0xda,\r
-    L'/'\r
-  },\r
-  {\r
-    BOXDRAW_DOWN_LEFT,\r
-    0xbf,\r
-    L'\\'\r
-  },\r
-  {\r
-    BOXDRAW_UP_RIGHT,\r
-    0xc0,\r
-    L'\\'\r
-  },\r
-  {\r
-    BOXDRAW_UP_LEFT,\r
-    0xd9,\r
-    L'/'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL_RIGHT,\r
-    0xc3,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL_LEFT,\r
-    0xb4,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_DOWN_HORIZONTAL,\r
-    0xc2,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_UP_HORIZONTAL,\r
-    0xc1,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL_HORIZONTAL,\r
-    0xc5,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_HORIZONTAL,\r
-    0xcd,\r
-    L'-'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_VERTICAL,\r
-    0xba,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_DOWN_RIGHT_DOUBLE,\r
-    0xd5,\r
-    L'/'\r
-  },\r
-  {\r
-    BOXDRAW_DOWN_DOUBLE_RIGHT,\r
-    0xd6,\r
-    L'/'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_DOWN_RIGHT,\r
-    0xc9,\r
-    L'/'\r
-  },\r
-  {\r
-    BOXDRAW_DOWN_LEFT_DOUBLE,\r
-    0xb8,\r
-    L'\\'\r
-  },\r
-  {\r
-    BOXDRAW_DOWN_DOUBLE_LEFT,\r
-    0xb7,\r
-    L'\\'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_DOWN_LEFT,\r
-    0xbb,\r
-    L'\\'\r
-  },\r
-  {\r
-    BOXDRAW_UP_RIGHT_DOUBLE,\r
-    0xd4,\r
-    L'\\'\r
-  },\r
-  {\r
-    BOXDRAW_UP_DOUBLE_RIGHT,\r
-    0xd3,\r
-    L'\\'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_UP_RIGHT,\r
-    0xc8,\r
-    L'\\'\r
-  },\r
-  {\r
-    BOXDRAW_UP_LEFT_DOUBLE,\r
-    0xbe,\r
-    L'/'\r
-  },\r
-  {\r
-    BOXDRAW_UP_DOUBLE_LEFT,\r
-    0xbd,\r
-    L'/'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_UP_LEFT,\r
-    0xbc,\r
-    L'/'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL_RIGHT_DOUBLE,\r
-    0xc6,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL_DOUBLE_RIGHT,\r
-    0xc7,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_VERTICAL_RIGHT,\r
-    0xcc,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL_LEFT_DOUBLE,\r
-    0xb5,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL_DOUBLE_LEFT,\r
-    0xb6,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_VERTICAL_LEFT,\r
-    0xb9,\r
-    L'|'\r
-  },\r
-  {\r
-    BOXDRAW_DOWN_HORIZONTAL_DOUBLE,\r
-    0xd1,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_DOWN_DOUBLE_HORIZONTAL,\r
-    0xd2,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_DOWN_HORIZONTAL,\r
-    0xcb,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_UP_HORIZONTAL_DOUBLE,\r
-    0xcf,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_UP_DOUBLE_HORIZONTAL,\r
-    0xd0,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_UP_HORIZONTAL,\r
-    0xca,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE,\r
-    0xd8,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL,\r
-    0xd7,\r
-    L'+'\r
-  },\r
-  {\r
-    BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL,\r
-    0xce,\r
-    L'+'\r
-  },\r
-\r
-  {\r
-    BLOCKELEMENT_FULL_BLOCK,\r
-    0xdb,\r
-    L'*'\r
-  },\r
-  {\r
-    BLOCKELEMENT_LIGHT_SHADE,\r
-    0xb0,\r
-    L'+'\r
-  },\r
-\r
-  {\r
-    GEOMETRICSHAPE_UP_TRIANGLE,\r
-    0x1e,\r
-    L'^'\r
-  },\r
-  {\r
-    GEOMETRICSHAPE_RIGHT_TRIANGLE,\r
-    0x10,\r
-    L'>'\r
-  },\r
-  {\r
-    GEOMETRICSHAPE_DOWN_TRIANGLE,\r
-    0x1f,\r
-    L'v'\r
-  },\r
-  {\r
-    GEOMETRICSHAPE_LEFT_TRIANGLE,\r
-    0x11,\r
-    L'<'\r
-  },\r
-\r
-  {\r
-    ARROW_LEFT,\r
-    0x3c,\r
-    L'<'\r
-  },\r
-\r
-  {\r
-    ARROW_UP,\r
-    0x18,\r
-    L'^'\r
-  },\r
-\r
-  {\r
-    ARROW_RIGHT,\r
-    0x3e,\r
-    L'>'\r
-  },\r
-\r
-  {\r
-    ARROW_DOWN,\r
-    0x19,\r
-    L'v'\r
-  },\r
-\r
-  {\r
-    0x0000,\r
-    0x00,\r
-    0x00\r
-  }\r
-};\r
-\r
-/**\r
-  Entrypoint of this VGA Class Driver.\r
-\r
-  This function is the entrypoint of this VGA Class Driver. It installs Driver Binding\r
-  Protocols together with Component Name Protocols.\r
-\r
-  @param  ImageHandle       The firmware allocated handle for the EFI image.\r
-  @param  SystemTable       A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeVgaClass(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gVgaClassDriverBinding,\r
-             ImageHandle,\r
-             &gVgaClassComponentName,\r
-             &gVgaClassComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Internal worker function to program CRTC register via PCI I/O Protocol.\r
-\r
-  @param VgaClassDev  device instance object\r
-  @param Address      Address of register to write\r
-  @param Data         Data to write to register.\r
-\r
-**/\r
-VOID\r
-WriteCrtc (\r
-  IN  VGA_CLASS_DEV  *VgaClassDev,\r
-  IN  UINT16         Address,\r
-  IN  UINT8          Data\r
-  )\r
-{\r
-  VgaClassDev->PciIo->Io.Write (\r
-                           VgaClassDev->PciIo,\r
-                           EfiPciIoWidthUint8,\r
-                           VgaClassDev->VgaMiniPort->CrtcAddressRegisterBar,\r
-                           VgaClassDev->VgaMiniPort->CrtcAddressRegisterOffset,\r
-                           1,\r
-                           &Address\r
-                           );\r
-\r
-  VgaClassDev->PciIo->Io.Write (\r
-                           VgaClassDev->PciIo,\r
-                           EfiPciIoWidthUint8,\r
-                           VgaClassDev->VgaMiniPort->CrtcDataRegisterBar,\r
-                           VgaClassDev->VgaMiniPort->CrtcDataRegisterOffset,\r
-                           1,\r
-                           &Data\r
-                           );\r
-}\r
-\r
-/**\r
-  Internal worker function to set cursor's position to VgaClass device\r
-\r
-  @param  VgaClassDev   Private data structure for device instance.\r
-  @param  Column        Colomn of position to set cursor to.\r
-  @param  Row           Row of position to set cursor to.\r
-  @param  MaxColumn     Max value of column.\r
-\r
-**/\r
-VOID\r
-SetVideoCursorPosition (\r
-  IN  VGA_CLASS_DEV  *VgaClassDev,\r
-  IN  UINTN          Column,\r
-  IN  UINTN          Row,\r
-  IN  UINTN          MaxColumn\r
-  )\r
-{\r
-  Column    = Column & 0xff;\r
-  Row       = Row & 0xff;\r
-  MaxColumn = MaxColumn & 0xff;\r
-\r
-  WriteCrtc (\r
-    VgaClassDev,\r
-    CRTC_CURSOR_LOCATION_HIGH,\r
-    (UINT8) ((Row * MaxColumn + Column) >> 8)\r
-    );\r
-  WriteCrtc (\r
-    VgaClassDev,\r
-    CRTC_CURSOR_LOCATION_LOW,\r
-    (UINT8) ((Row * MaxColumn + Column) & 0xff)\r
-    );\r
-}\r
-\r
-/**\r
-  Internal worker function to detect if a Unicode char is for Box Drawing text graphics.\r
-\r
-  @param  Graphic  Unicode char to test.\r
-  @param  PcAnsi   Pointer to PCANSI equivalent of Graphic for output.\r
-                   If NULL, then PCANSI value is not returned.\r
-  @param  Ascii    Pointer to ASCII equivalent of Graphic for output.\r
-                   If NULL, then ASCII value is not returned.\r
-\r
-  @retval TRUE     Gpaphic is a supported Unicode Box Drawing character.\r
-  @retval FALSE    Gpaphic is not a supported Unicode Box Drawing character.\r
-\r
-**/\r
-BOOLEAN\r
-LibIsValidTextGraphics (\r
-  IN  CHAR16  Graphic,\r
-  OUT CHAR8   *PcAnsi, OPTIONAL\r
-  OUT CHAR8   *Ascii OPTIONAL\r
-  )\r
-{\r
-  UNICODE_TO_CHAR *Table;\r
-\r
-  //\r
-  // Unicode drawing code charts are all in the 0x25xx range, arrows are 0x21xx.\r
-  // So first filter out values not in these 2 ranges.\r
-  //\r
-  if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Search UnicodeToPcAnsiOrAscii table for matching entry.\r
-  //\r
-  for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {\r
-    if (Graphic == Table->Unicode) {\r
-      if (PcAnsi != NULL) {\r
-        *PcAnsi = Table->PcAnsi;\r
-      }\r
-\r
-      if (Ascii != NULL) {\r
-        *Ascii = Table->Ascii;\r
-      }\r
-\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // If value is not found in UnicodeToPcAnsiOrAscii table, then return FALSE.\r
-  //\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Internal worker function to check whether input value is an ASCII char.\r
-\r
-  @param  Char     Character to check.\r
-\r
-  @retval TRUE     Input value is an ASCII char.\r
-  @retval FALSE    Input value is not an ASCII char.\r
-\r
-**/\r
-BOOLEAN\r
-IsValidAscii (\r
-  IN  CHAR16  Char\r
-  )\r
-{\r
-  if ((Char >= 0x20) && (Char <= 0x7f)) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Internal worker function to check whether input value is a unicode control char.\r
-\r
-  @param  Char    Character to check.\r
-\r
-  @retval TRUE     Input value is a unicode control char.\r
-  @retval FALSE    Input value is not a unicode control char.\r
-\r
-**/\r
-BOOLEAN\r
-IsValidEfiCntlChar (\r
-  IN  CHAR16  Char\r
-  )\r
-{\r
-  if (Char == CHAR_NULL || Char == CHAR_BACKSPACE || Char == CHAR_LINEFEED || Char == CHAR_CARRIAGE_RETURN) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Tests to see if this driver supports a given controller.\r
-\r
-  This function implments EFI_DRIVER_BINDING_PROTOCOL.Supported().\r
-  It Checks if this driver supports the controller specified. Any Controller\r
-  with VgaMiniPort Protocol and Pci I/O protocol can be supported.\r
-\r
-  @param  This                A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  ControllerHandle    Handle of device to test\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device.\r
-  @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
-  @retval EFI_UNSUPPORTED     This driver does not support this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-\r
-  //\r
-  // Checks if Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiVgaMiniPortProtocolGuid,\r
-                  NULL,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  NULL,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Starts the device controller.\r
-\r
-  This function implments EFI_DRIVER_BINDING_PROTOCOL.Start().\r
-  It starts the device specified by Controller with the driver based on PCI I/O Protocol\r
-  and VgaMiniPort Protocol. It creates context for device instance and install EFI_SIMPLE_TEXT_OUT_PROTOCOL.\r
-\r
-  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
-                               device to start.\r
-\r
-  @retval EFI_SUCCESS          The device was started.\r
-  @retval other                Fail to start the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_VGA_MINI_PORT_PROTOCOL  *VgaMiniPort;\r
-  EFI_PCI_IO_PROTOCOL         *PciIo;\r
-  VGA_CLASS_DEV               *VgaClassPrivate;\r
-  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Report that VGA Class driver is being enabled\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_ENABLE,\r
-    DevicePath\r
-    );\r
-\r
-  //\r
-  // Open the PCI I/O Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Open the VGA Mini Port Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiVgaMiniPortProtocolGuid,\r
-                  (VOID **) &VgaMiniPort,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Allocate the private device structure\r
-  //\r
-  VgaClassPrivate = AllocateZeroPool (sizeof (VGA_CLASS_DEV));\r
-  ASSERT (VgaClassPrivate != NULL);\r
-\r
-  //\r
-  // Initialize the private device structure\r
-  //\r
-  VgaClassPrivate->Signature   = VGA_CLASS_DEV_SIGNATURE;\r
-  VgaClassPrivate->Handle      = Controller;\r
-  VgaClassPrivate->VgaMiniPort = VgaMiniPort;\r
-  VgaClassPrivate->PciIo       = PciIo;\r
-\r
-  VgaClassPrivate->SimpleTextOut.Reset             = VgaClassReset;\r
-  VgaClassPrivate->SimpleTextOut.OutputString      = VgaClassOutputString;\r
-  VgaClassPrivate->SimpleTextOut.TestString        = VgaClassTestString;\r
-  VgaClassPrivate->SimpleTextOut.ClearScreen       = VgaClassClearScreen;\r
-  VgaClassPrivate->SimpleTextOut.SetAttribute      = VgaClassSetAttribute;\r
-  VgaClassPrivate->SimpleTextOut.SetCursorPosition = VgaClassSetCursorPosition;\r
-  VgaClassPrivate->SimpleTextOut.EnableCursor      = VgaClassEnableCursor;\r
-  VgaClassPrivate->SimpleTextOut.QueryMode         = VgaClassQueryMode;\r
-  VgaClassPrivate->SimpleTextOut.SetMode           = VgaClassSetMode;\r
-\r
-  VgaClassPrivate->SimpleTextOut.Mode              = &VgaClassPrivate->SimpleTextOutputMode;\r
-  VgaClassPrivate->SimpleTextOutputMode.MaxMode    = VgaMiniPort->MaxMode;\r
-  VgaClassPrivate->DevicePath                      = DevicePath;\r
-\r
-  //\r
-  // Initialize the VGA device.\r
-  //\r
-  Status = VgaClassPrivate->SimpleTextOut.SetAttribute (\r
-                                            &VgaClassPrivate->SimpleTextOut,\r
-                                            EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK)\r
-                                            );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrorExit;\r
-  }\r
-\r
-  Status = VgaClassPrivate->SimpleTextOut.Reset (\r
-                                            &VgaClassPrivate->SimpleTextOut,\r
-                                            FALSE\r
-                                            );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrorExit;\r
-  }\r
-\r
-  Status = VgaClassPrivate->SimpleTextOut.EnableCursor (\r
-                                            &VgaClassPrivate->SimpleTextOut,\r
-                                            TRUE\r
-                                            );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrorExit;\r
-  }\r
-\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiSimpleTextOutProtocolGuid,\r
-                  &VgaClassPrivate->SimpleTextOut,\r
-                  NULL\r
-                  );\r
-\r
-  return Status;\r
-\r
-ErrorExit:\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-    EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR,\r
-    DevicePath\r
-    );\r
-\r
-  return Status;\r
-\r
-}\r
-\r
-/**\r
-  Starts the device controller.\r
-\r
-  This function implments EFI_DRIVER_BINDING_PROTOCOL.Stop().\r
-  It stops this driver on Controller. Support stopping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  ControllerHandle  A handle to the device being stopped.\r
-  @param  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param  ChildHandleBuffer An array of child handles to be freed.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Controller,\r
-  IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *SimpleTextOut;\r
-  VGA_CLASS_DEV                 *VgaClassPrivate;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiSimpleTextOutProtocolGuid,\r
-                  (VOID **) &SimpleTextOut,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  VgaClassPrivate = VGA_CLASS_DEV_FROM_THIS (SimpleTextOut);\r
-\r
-  //\r
-  // Report that VGA Class driver is being disabled\r
-  //\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_DISABLE,\r
-    VgaClassPrivate->DevicePath\r
-    );\r
-\r
-  Status = gBS->UninstallProtocolInterface (\r
-                  Controller,\r
-                  &gEfiSimpleTextOutProtocolGuid,\r
-                  &VgaClassPrivate->SimpleTextOut\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Release PCI I/O and VGA Mini Port Protocols on the controller handle.\r
-  //\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiPciIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiVgaMiniPortProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  FreePool (VgaClassPrivate);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Resets the text output device hardware.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r
-  It resets the text output device hardware. The cursor position is set to (0, 0),\r
-  and the screen is cleared to the default background color for the output device.\r
-\r
-  @param  This                 Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  ExtendedVerification Indicates that the driver may perform a more exhaustive\r
-                               verification operation of the device during reset.\r
-\r
-  @retval EFI_SUCCESS          The text output device was reset.\r
-  @retval EFI_DEVICE_ERROR     The text output device is not functioning correctly and could not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassReset (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL     *This,\r
-  IN  BOOLEAN                             ExtendedVerification\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  VGA_CLASS_DEV *VgaClassPrivate;\r
-\r
-  VgaClassPrivate = VGA_CLASS_DEV_FROM_THIS (This);\r
-\r
-  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-    EFI_PROGRESS_CODE,\r
-    EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_RESET,\r
-    VgaClassPrivate->DevicePath\r
-    );\r
-\r
-  This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));\r
-\r
-  Status = This->SetMode (This, 0);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return This->ClearScreen (This);\r
-}\r
-\r
-/**\r
-  Writes a Unicode string to the output device.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r
-  It writes a Unicode string to the output device. This is the most basic output mechanism\r
-  on an output device.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  String                 The Null-terminated Unicode string to be displayed on the output device(s).\r
-\r
-  @retval EFI_SUCCESS            The string was output to the device.\r
-  @retval EFI_DEVICE_ERROR       The device reported an error while attempting to output the text.\r
-  @retval EFI_UNSUPPORTED        The output device's mode is not currently in a defined text mode.\r
-  @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the characters in\r
-                                 the Unicode string could not be rendered and were skipped.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassOutputString (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  CHAR16                          *String\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  VGA_CLASS_DEV               *VgaClassDev;\r
-  EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;\r
-  UINTN                       MaxColumn;\r
-  UINTN                       MaxRow;\r
-  UINT32                      VideoChar;\r
-  CHAR8                       GraphicChar;\r
-\r
-  VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
-  Mode        = This->Mode;\r
-\r
-  Status = This->QueryMode (\r
-                   This,\r
-                   Mode->Mode,\r
-                   &MaxColumn,\r
-                   &MaxRow\r
-                   );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Parse each character of the string to output\r
-  //\r
-  for (; *String != CHAR_NULL; String++) {\r
-\r
-    switch (*String) {\r
-    case CHAR_BACKSPACE:\r
-      if (Mode->CursorColumn > 0) {\r
-        Mode->CursorColumn--;\r
-      }\r
-      break;\r
-\r
-    case CHAR_LINEFEED:\r
-      if (Mode->CursorRow == (INT32) (MaxRow - 1)) {\r
-        //\r
-        // Scroll the screen by copying the contents\r
-        // of the VGA display up one line\r
-        //\r
-        VgaClassDev->PciIo->CopyMem (\r
-                              VgaClassDev->PciIo,\r
-                              EfiPciIoWidthUint32,\r
-                              VgaClassDev->VgaMiniPort->VgaMemoryBar,\r
-                              VgaClassDev->VgaMiniPort->VgaMemoryOffset,\r
-                              VgaClassDev->VgaMiniPort->VgaMemoryBar,\r
-                              VgaClassDev->VgaMiniPort->VgaMemoryOffset + MaxColumn * 2,\r
-                              ((MaxRow - 1) * MaxColumn) >> 1\r
-                              );\r
-\r
-        //\r
-        // Print Blank Line of spaces with the current color attributes\r
-        //\r
-        VideoChar = (Mode->Attribute << 8) | ' ';\r
-        VideoChar = (VideoChar << 16) | VideoChar;\r
-        VgaClassDev->PciIo->Mem.Write (\r
-                                  VgaClassDev->PciIo,\r
-                                  EfiPciIoWidthFillUint32,\r
-                                  VgaClassDev->VgaMiniPort->VgaMemoryBar,\r
-                                  VgaClassDev->VgaMiniPort->VgaMemoryOffset + (MaxRow - 1) * MaxColumn * 2,\r
-                                  MaxColumn >> 1,\r
-                                  &VideoChar\r
-                                  );\r
-      }\r
-\r
-      if (Mode->CursorRow < (INT32) (MaxRow - 1)) {\r
-        Mode->CursorRow++;\r
-      }\r
-      break;\r
-\r
-    case CHAR_CARRIAGE_RETURN:\r
-      Mode->CursorColumn = 0;\r
-      break;\r
-\r
-    default:\r
-      if (!LibIsValidTextGraphics (*String, &GraphicChar, NULL)) {\r
-        //\r
-        // If this character is not ,Box Drawing text graphics, then convert it to ASCII.\r
-        //\r
-        GraphicChar = (CHAR8) *String;\r
-        if (!IsValidAscii (GraphicChar)) {\r
-          //\r
-          // If not valid ASCII char, convert it to "?"\r
-          //\r
-          GraphicChar = '?';\r
-        }\r
-      }\r
-\r
-      VideoChar = (Mode->Attribute << 8) | GraphicChar;\r
-      VgaClassDev->PciIo->Mem.Write (\r
-                                VgaClassDev->PciIo,\r
-                                EfiPciIoWidthUint16,\r
-                                VgaClassDev->VgaMiniPort->VgaMemoryBar,\r
-                                VgaClassDev->VgaMiniPort->VgaMemoryOffset + ((Mode->CursorRow * MaxColumn + Mode->CursorColumn) * 2),\r
-                                1,\r
-                                &VideoChar\r
-                                );\r
-\r
-      if (Mode->CursorColumn >= (INT32) (MaxColumn - 1)) {\r
-        This->OutputString (This, CrLfString);\r
-      } else {\r
-        Mode->CursorColumn++;\r
-      }\r
-      break;\r
-    }\r
-  }\r
-\r
-  SetVideoCursorPosition (\r
-    VgaClassDev,\r
-    (UINTN) Mode->CursorColumn,\r
-    (UINTN) Mode->CursorRow,\r
-    MaxColumn\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Verifies that all characters in a Unicode string can be output to the target device.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().\r
-  It verifies that all characters in a Unicode string can be output to the target device.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  String                 The Null-terminated Unicode string to be examined for the output device(s).\r
-\r
-  @retval EFI_SUCCESS            The device(s) are capable of rendering the output string.\r
-  @retval EFI_UNSUPPORTED        Some of the characters in the Unicode string cannot be rendered by\r
-                                 one or more of the output devices mapped by the EFI handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassTestString (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  CHAR16                          *String\r
-  )\r
-{\r
-  while (*String != CHAR_NULL) {\r
-    if (!(IsValidAscii (*String) || IsValidEfiCntlChar (*String) || LibIsValidTextGraphics (*String, NULL, NULL))) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    String++;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Clears the output device(s) display to the currently selected background color.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().\r
-  The ClearScreen() function clears the output device(s) display to the currently\r
-  selected background color. The cursor position is set to (0, 0).\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-\r
-  @retval EFI_SUCESS             The operation completed successfully.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-  @retval EFI_UNSUPPORTED        The output device is not in a valid text mode.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassClearScreen (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL    *This\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  VGA_CLASS_DEV *VgaClassDev;\r
-  UINTN         MaxRow;\r
-  UINTN         MaxColumn;\r
-  UINT32        VideoChar;\r
-\r
-  VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
-\r
-  Status = This->QueryMode (\r
-                   This,\r
-                   This->Mode->Mode,\r
-                   &MaxColumn,\r
-                   &MaxRow\r
-                   );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  VideoChar = (This->Mode->Attribute << 8) | ' ';\r
-  VideoChar = (VideoChar << 16) | VideoChar;\r
-  VgaClassDev->PciIo->Mem.Write (\r
-                            VgaClassDev->PciIo,\r
-                            EfiPciIoWidthFillUint32,\r
-                            VgaClassDev->VgaMiniPort->VgaMemoryBar,\r
-                            VgaClassDev->VgaMiniPort->VgaMemoryOffset,\r
-                            (MaxRow * MaxColumn) >> 1,\r
-                            &VideoChar\r
-                            );\r
-\r
-  This->SetCursorPosition (This, 0, 0);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Sets the background and foreground colors for theOutputString() and ClearScreen() functions.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().\r
-  It sets the background and foreground colors for the OutputString() and ClearScreen() functions.\r
-  The color mask can be set even when the device is in an invalid text mode.\r
-  Devices supporting a different number of text colors are required to emulate the above colors\r
-  to the best of the device's capabilities.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  Attribute              The attribute to set.\r
-                                 Bits 0..3 are the foreground color,\r
-                                 and bits 4..6 are the background color.\r
-\r
-  @retval EFI_SUCCESS            The requested attributes were set.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassSetAttribute (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  UINTN                           Attribute\r
-  )\r
-{\r
-  if (Attribute <= EFI_MAX_ATTRIBUTE) {\r
-    This->Mode->Attribute = (INT32) Attribute;\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Sets the current coordinates of the cursor position.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().\r
-  It sets the current coordinates of the cursor position.\r
-  The upper left corner of the screen is defined as coordinate (0, 0).\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  Column                 Column of position to set the cursor to.\r
-  @param  Row                    Row of position to set the cursor to.\r
-\r
-  @retval EFI_SUCCESS            The operation completed successfully.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-  @retval EFI_UNSUPPORTED        The output device is not in a valid text mode, or the cursor\r
-                                 position is invalid for the current mode.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassSetCursorPosition (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  UINTN                           Column,\r
-  IN  UINTN                           Row\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  VGA_CLASS_DEV *VgaClassDev;\r
-  UINTN         MaxColumn;\r
-  UINTN         MaxRow;\r
-\r
-  VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
-\r
-  Status = This->QueryMode (\r
-                   This,\r
-                   This->Mode->Mode,\r
-                   &MaxColumn,\r
-                   &MaxRow\r
-                   );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (Column >= MaxColumn || Row >= MaxRow) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  SetVideoCursorPosition (VgaClassDev, Column, Row, MaxColumn);\r
-\r
-  This->Mode->CursorColumn  = (INT32) Column;\r
-  This->Mode->CursorRow     = (INT32) Row;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Makes the cursor visible or invisible.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.EnableCursor().\r
-  It makes the cursor visible or invisible.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  Visible                If TRUE, the cursor is set to be visible.\r
-                                 If FALSE, the cursor is set to be invisible.\r
-\r
-  @retval EFI_SUCESS             The operation completed successfully.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request or the\r
-                                 device does not support changing the cursor mode.\r
-  @retval EFI_UNSUPPORTED        The output device does not support visibility control of the cursor.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassEnableCursor (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  BOOLEAN                         Visible\r
-  )\r
-{\r
-  VGA_CLASS_DEV *VgaClassDev;\r
-\r
-  VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
-  if (Visible) {\r
-    if (This->Mode->Mode == 1) {\r
-      //\r
-      // 80 * 50\r
-      //\r
-      WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x06);\r
-      WriteCrtc (VgaClassDev, CRTC_CURSOR_END, 0x07);\r
-    } else {\r
-      //\r
-      // 80 * 25\r
-      //\r
-      WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x0e);\r
-      WriteCrtc (VgaClassDev, CRTC_CURSOR_END, 0x0f);\r
-    }\r
-  } else {\r
-    WriteCrtc (VgaClassDev, CRTC_CURSOR_START, 0x20);\r
-  }\r
-\r
-  This->Mode->CursorVisible = Visible;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Returns information for an available text mode that the output device(s) supports.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
-  It returns information for an available text mode that the output device(s) supports.\r
-  It is required that all output devices support at least 80x25 text mode. This mode is defined to be mode 0.\r
-  If the output devices support 80x50, that is defined to be mode 1.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  ModeNumber             The mode number to return information on.\r
-  @param  Columns                Columen in current mode number\r
-  @param  Rows                   Row in current mode number.\r
-\r
-  @retval EFI_SUCCESS            The requested mode information was returned.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-  @retval EFI_UNSUPPORTED        The mode number was not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassQueryMode (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  UINTN                           ModeNumber,\r
-  OUT UINTN                           *Columns,\r
-  OUT UINTN                           *Rows\r
-  )\r
-{\r
-  if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r
-    *Columns  = 0;\r
-    *Rows     = 0;\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  switch (ModeNumber) {\r
-  case 0:\r
-    *Columns  = 80;\r
-    *Rows     = 25;\r
-    break;\r
-\r
-  case 1:\r
-    *Columns  = 80;\r
-    *Rows     = 50;\r
-    break;\r
-\r
-  default:\r
-    *Columns  = 0;\r
-    *Rows     = 0;\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Sets the output device(s) to a specified mode.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
-  It sets the output device(s) to the requested mode.\r
-  On success the device is in the geometry for the requested mode,\r
-  and the device has been cleared to the current background color with the cursor at (0,0).\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  ModeNumber             The text mode to set.\r
-\r
-  @retval EFI_SUCCESS            The requested text mode was set.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-  @retval EFI_UNSUPPORTED        The mode number was not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassSetMode (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  UINTN                           ModeNumber\r
-  )\r
-{\r
-  VGA_CLASS_DEV *VgaClassDev;\r
-\r
-  VgaClassDev = VGA_CLASS_DEV_FROM_THIS (This);\r
-\r
-  if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  This->ClearScreen (This);\r
-\r
-  This->Mode->Mode  = (INT32) ModeNumber;\r
-\r
-  return VgaClassDev->VgaMiniPort->SetMode (VgaClassDev->VgaMiniPort, ModeNumber);\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.h b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClass.h
deleted file mode 100644 (file)
index 118a764..0000000
+++ /dev/null
@@ -1,478 +0,0 @@
-/** @file\r
-  Internal include file of the VGA Class Driver.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#ifndef _VGA_CLASS_H__\r
-#define _VGA_CLASS_H__\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Protocol/SimpleTextOut.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/VgaMiniPort.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gVgaClassDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gVgaClassComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gVgaClassComponentName2;\r
-\r
-\r
-//\r
-// Structure for tuple containing mapping among uniocde, PC Ansi and ASCII code.\r
-//\r
-typedef struct {\r
-  CHAR16  Unicode;\r
-  CHAR8   PcAnsi;\r
-  CHAR8   Ascii;\r
-} UNICODE_TO_CHAR;\r
-\r
-//\r
-// VGA specific registers\r
-//\r
-#define CRTC_CURSOR_START         0xA\r
-#define CRTC_CURSOR_END           0xB\r
-\r
-#define CRTC_CURSOR_LOCATION_HIGH 0xE\r
-#define CRTC_CURSOR_LOCATION_LOW  0xF\r
-\r
-#define EFI_MAX_ATTRIBUTE         0x7f\r
-\r
-//\r
-// VGA Class Device Structure\r
-//\r
-#define VGA_CLASS_DEV_SIGNATURE SIGNATURE_32 ('V', 'G', 'A', 'C')\r
-\r
-typedef struct {\r
-  UINTN                            Signature;\r
-  EFI_HANDLE                       Handle;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  SimpleTextOut;\r
-  EFI_SIMPLE_TEXT_OUTPUT_MODE      SimpleTextOutputMode;\r
-  EFI_VGA_MINI_PORT_PROTOCOL       *VgaMiniPort;\r
-  EFI_PCI_IO_PROTOCOL              *PciIo;\r
-  EFI_DEVICE_PATH_PROTOCOL         *DevicePath;\r
-} VGA_CLASS_DEV;\r
-\r
-#define VGA_CLASS_DEV_FROM_THIS(a)  CR (a, VGA_CLASS_DEV, SimpleTextOut, VGA_CLASS_DEV_SIGNATURE)\r
-\r
-//\r
-// Driver Binding Protocol functions\r
-//\r
-\r
-/**\r
-  Tests to see if this driver supports a given controller.\r
-\r
-  This function implments EFI_DRIVER_BINDING_PROTOCOL.Supported().\r
-  It Checks if this driver supports the controller specified. Any Controller\r
-  with VgaMiniPort Protocol and Pci I/O protocol can be supported.\r
-\r
-  @param  This                A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  ControllerHandle    Handle of device to test\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device.\r
-  @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
-  @retval EFI_UNSUPPORTED     This driver does not support this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  );\r
-\r
-/**\r
-  Starts the device controller.\r
-\r
-  This function implments EFI_DRIVER_BINDING_PROTOCOL.Start().\r
-  It starts the device specified by Controller with the driver based on PCI I/O Protocol\r
-  and VgaMiniPort Protocol. It creates context for device instance and install EFI_SIMPLE_TEXT_OUT_PROTOCOL.\r
-\r
-  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
-                               device to start.\r
-\r
-  @retval EFI_SUCCESS          The device was started.\r
-  @retval other                Fail to start the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  );\r
-\r
-/**\r
-  Starts the device controller.\r
-\r
-  This function implments EFI_DRIVER_BINDING_PROTOCOL.Stop().\r
-  It stops this driver on Controller. Support stopping any child handles\r
-  created by this driver.\r
-\r
-  @param  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  ControllerHandle  A handle to the device being stopped.\r
-  @param  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param  ChildHandleBuffer An array of child handles to be freed.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
-  @retval other             This driver was not removed from this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Controller,\r
-  IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer OPTIONAL\r
-  );\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param  Language              A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-  @param  DriverName            A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param  ControllerHandle      The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-  @param  ChildHandle           The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-  @param  Language              A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-  @param  ControllerName        A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-//\r
-// Simple Text Output Protocol functions\r
-//\r
-/**\r
-  Resets the text output device hardware.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r
-  It resets the text output device hardware. The cursor position is set to (0, 0),\r
-  and the screen is cleared to the default background color for the output device.\r
-\r
-  @param  This                 Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  ExtendedVerification Indicates that the driver may perform a more exhaustive\r
-                               verification operation of the device during reset.\r
-\r
-  @retval EFI_SUCCESS          The text output device was reset.\r
-  @retval EFI_DEVICE_ERROR     The text output device is not functioning correctly and could not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassReset (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL     *This,\r
-  IN  BOOLEAN                             ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Writes a Unicode string to the output device.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r
-  It writes a Unicode string to the output device. This is the most basic output mechanism\r
-  on an output device.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  String                 The Null-terminated Unicode string to be displayed on the output device(s).\r
-\r
-  @retval EFI_SUCCESS            The string was output to the device.\r
-  @retval EFI_DEVICE_ERROR       The device reported an error while attempting to output the text.\r
-  @retval EFI_UNSUPPORTED        The output device's mode is not currently in a defined text mode.\r
-  @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the characters in\r
-                                 the Unicode string could not be rendered and were skipped.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassOutputString (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  CHAR16                          *String\r
-  );\r
-\r
-/**\r
-  Verifies that all characters in a Unicode string can be output to the target device.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().\r
-  It verifies that all characters in a Unicode string can be output to the target device.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  String                 The Null-terminated Unicode string to be examined for the output device(s).\r
-\r
-  @retval EFI_SUCCESS            The device(s) are capable of rendering the output string.\r
-  @retval EFI_UNSUPPORTED        Some of the characters in the Unicode string cannot be rendered by\r
-                                 one or more of the output devices mapped by the EFI handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassTestString (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  CHAR16                          *String\r
-  );\r
-\r
-/**\r
-  Clears the output device(s) display to the currently selected background color.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().\r
-  The ClearScreen() function clears the output device(s) display to the currently\r
-  selected background color. The cursor position is set to (0, 0).\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-\r
-  @retval EFI_SUCESS             The operation completed successfully.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-  @retval EFI_UNSUPPORTED        The output device is not in a valid text mode.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassClearScreen (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL    *This\r
-  );\r
-\r
-/**\r
-  Sets the background and foreground colors for theOutputString() and ClearScreen() functions.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().\r
-  It sets the background and foreground colors for the OutputString() and ClearScreen() functions.\r
-  The color mask can be set even when the device is in an invalid text mode.\r
-  Devices supporting a different number of text colors are required to emulate the above colors\r
-  to the best of the device's capabilities.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  Attribute              The attribute to set.\r
-                                 Bits 0..3 are the foreground color,\r
-                                 and bits 4..6 are the background color.\r
-\r
-  @retval EFI_SUCCESS            The requested attributes were set.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassSetAttribute (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  UINTN                           Attribute\r
-  );\r
-\r
-/**\r
-  Sets the current coordinates of the cursor position.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().\r
-  It sets the current coordinates of the cursor position.\r
-  The upper left corner of the screen is defined as coordinate (0, 0).\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  Column                 Column of position to set the cursor to.\r
-  @param  Row                    Row of position to set the cursor to.\r
-\r
-  @retval EFI_SUCCESS            The operation completed successfully.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-  @retval EFI_UNSUPPORTED        The output device is not in a valid text mode, or the cursor\r
-                                 position is invalid for the current mode.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassSetCursorPosition (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  UINTN                           Column,\r
-  IN  UINTN                           Row\r
-  );\r
-\r
-/**\r
-  Makes the cursor visible or invisible.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.EnableCursor().\r
-  It makes the cursor visible or invisible.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  Visible                If TRUE, the cursor is set to be visible.\r
-                                 If FALSE, the cursor is set to be invisible.\r
-\r
-  @retval EFI_SUCESS             The operation completed successfully.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request or the\r
-                                 device does not support changing the cursor mode.\r
-  @retval EFI_UNSUPPORTED        The output device does not support visibility control of the cursor.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassEnableCursor (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  BOOLEAN                         Visible\r
-  );\r
-\r
-/**\r
-  Returns information for an available text mode that the output device(s) supports.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
-  It returns information for an available text mode that the output device(s) supports.\r
-  It is required that all output devices support at least 80x25 text mode. This mode is defined to be mode 0.\r
-  If the output devices support 80x50, that is defined to be mode 1.\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  ModeNumber             The mode number to return information on.\r
-  @param  Columns                Columen in current mode number\r
-  @param  Rows                   Row in current mode number.\r
-\r
-  @retval EFI_SUCCESS            The requested mode information was returned.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-  @retval EFI_UNSUPPORTED        The mode number was not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassQueryMode (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  UINTN                           ModeNumber,\r
-  OUT UINTN                           *Columns,\r
-  OUT UINTN                           *Rows\r
-  );\r
-\r
-/**\r
-  Sets the output device(s) to a specified mode.\r
-\r
-  This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
-  It sets the output device(s) to the requested mode.\r
-  On success the device is in the geometry for the requested mode,\r
-  and the device has been cleared to the current background color with the cursor at (0,0).\r
-\r
-  @param  This                   Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.\r
-  @param  ModeNumber             The text mode to set.\r
-\r
-  @retval EFI_SUCCESS            The requested text mode was set.\r
-  @retval EFI_DEVICE_ERROR       The device had an error and could not complete the request.\r
-  @retval EFI_UNSUPPORTED        The mode number was not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VgaClassSetMode (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
-  IN  UINTN                           ModeNumber\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf
deleted file mode 100644 (file)
index 9deca6e..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-## @file\r
-#  VGA Class Driver that managers VGA devices and produces Simple Text Output Protocol.\r
-#\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = VgaClassDxe\r
-  MODULE_UNI_FILE                = VgaClassDxe.uni\r
-  FILE_GUID                      = BF89F10D-B205-474f-96E3-7A7BB1B4A407\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializeVgaClass\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-#  DRIVER_BINDING                =  gVgaClassDriverBinding\r
-#  COMPONENT_NAME                =  gVgaClassComponentName\r
-#  COMPONENT_NAME2               =  gVgaClassComponentName2\r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  VgaClass.h\r
-  VgaClass.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  ReportStatusCodeLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-\r
-\r
-[Protocols]\r
-  gEfiSimpleTextOutProtocolGuid                 ## BY_START\r
-  gEfiVgaMiniPortProtocolGuid                   ## TO_START\r
-  gEfiPciIoProtocolGuid                         ## TO_START\r
-  gEfiDevicePathProtocolGuid                    ## TO_START\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  VgaClassDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.uni b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.uni
deleted file mode 100644 (file)
index 105720b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// VGA Class Driver that managers VGA devices and produces Simple Text Output Protocol.\r
-//\r
-// The VGA Class Driver that manages VGA devices and produces Simple Text Output Protocol.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Manages VGA devices and produces Simple Text Output Protocol"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "The VGA Class Driver that manages VGA devices and produces Simple Text Output Protocol."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxeExtra.uni b/IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxeExtra.uni
deleted file mode 100644 (file)
index ed3e14a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// VgaClassDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"VGA Class DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIo.c b/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIo.c
deleted file mode 100644 (file)
index ce7ae9d..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-/** @file\r
-  Uses the services of the I/O Library to produce the CPU I/O Protocol\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "CpuIo.h"\r
-\r
-//\r
-// Handle for the CPU I/O Protocol\r
-//\r
-EFI_HANDLE  mHandle = NULL;\r
-\r
-//\r
-// CPU I/O Protocol inatance\r
-//\r
-EFI_CPU_IO_PROTOCOL mCpuIo = {\r
-  {\r
-    CpuMemoryServiceRead,\r
-    CpuMemoryServiceWrite\r
-  },\r
-  {\r
-    CpuIoServiceRead,\r
-    CpuIoServiceWrite\r
-  }\r
-};\r
-\r
-//\r
-// Lookup table for increment values based on transfer widths\r
-//\r
-UINT8 mInStride[] = {\r
-  1, // EfiCpuIoWidthUint8\r
-  2, // EfiCpuIoWidthUint16\r
-  4, // EfiCpuIoWidthUint32\r
-  8, // EfiCpuIoWidthUint64\r
-  0, // EfiCpuIoWidthFifoUint8\r
-  0, // EfiCpuIoWidthFifoUint16\r
-  0, // EfiCpuIoWidthFifoUint32\r
-  0, // EfiCpuIoWidthFifoUint64\r
-  1, // EfiCpuIoWidthFillUint8\r
-  2, // EfiCpuIoWidthFillUint16\r
-  4, // EfiCpuIoWidthFillUint32\r
-  8  // EfiCpuIoWidthFillUint64\r
-};\r
-\r
-//\r
-// Lookup table for increment values based on transfer widths\r
-//\r
-UINT8 mOutStride[] = {\r
-  1, // EfiCpuIoWidthUint8\r
-  2, // EfiCpuIoWidthUint16\r
-  4, // EfiCpuIoWidthUint32\r
-  8, // EfiCpuIoWidthUint64\r
-  1, // EfiCpuIoWidthFifoUint8\r
-  2, // EfiCpuIoWidthFifoUint16\r
-  4, // EfiCpuIoWidthFifoUint32\r
-  8, // EfiCpuIoWidthFifoUint64\r
-  0, // EfiCpuIoWidthFillUint8\r
-  0, // EfiCpuIoWidthFillUint16\r
-  0, // EfiCpuIoWidthFillUint32\r
-  0  // EfiCpuIoWidthFillUint64\r
-};\r
-\r
-/**\r
-  Check parameters to a CPU I/O Protocol service request.\r
-\r
-  The I/O operations are carried out exactly as requested. The caller is responsible\r
-  for satisfying any alignment and I/O width restrictions that a PI System on a\r
-  platform might require. For example on some platforms, width requests of\r
-  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will\r
-  be handled by the driver.\r
-\r
-  @param[in] MmioOperation  TRUE for an MMIO operation, FALSE for I/O Port operation.\r
-  @param[in] Width          Signifies the width of the I/O or Memory operation.\r
-  @param[in] Address        The base address of the I/O operation.\r
-  @param[in] Count          The number of I/O operations to perform. The number of\r
-                            bytes moved is Width size * Count, starting at Address.\r
-  @param[in] Buffer         For read operations, the destination buffer to store the results.\r
-                            For write operations, the source buffer from which to write data.\r
-\r
-  @retval EFI_SUCCESS            The parameters for this request pass the checks.\r
-  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
-  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Address, Width,\r
-                                 and Count is not valid for this PI system.\r
-\r
-**/\r
-EFI_STATUS\r
-CpuIoCheckParameter (\r
-  IN BOOLEAN                    MmioOperation,\r
-  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                     Address,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  )\r
-{\r
-  UINT64  MaxCount;\r
-  UINT64  Limit;\r
-\r
-  //\r
-  // Check to see if Buffer is NULL\r
-  //\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Check to see if Width is in the valid range\r
-  //\r
-  if ((UINT32)Width >= EfiCpuIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // For FIFO type, the target address won't increase during the access,\r
-  // so treat Count as 1\r
-  //\r
-  if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) {\r
-    Count = 1;\r
-  }\r
-\r
-  //\r
-  // Check to see if Width is in the valid range for I/O Port operations\r
-  //\r
-  Width = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-  if (!MmioOperation && (Width == EfiCpuIoWidthUint64)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Check to see if Address is aligned\r
-  //\r
-  if ((Address & ((UINT64)mInStride[Width] - 1)) != 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Check to see if any address associated with this transfer exceeds the maximum\r
-  // allowed address.  The maximum address implied by the parameters passed in is\r
-  // Address + Size * Count.  If the following condition is met, then the transfer\r
-  // is not supported.\r
-  //\r
-  //    Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1\r
-  //\r
-  // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count\r
-  // can also be the maximum integer value supported by the CPU, this range\r
-  // check must be adjusted to avoid all overflow conditions.\r
-  //\r
-  // The following form of the range check is equivalent but assumes that\r
-  // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1).\r
-  //\r
-  Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS);\r
-  if (Count == 0) {\r
-    if (Address > Limit) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  } else {\r
-    MaxCount = RShiftU64 (Limit, Width);\r
-    if (MaxCount < (Count - 1)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    if (Address > LShiftU64 (MaxCount - Count + 1, Width)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Check to see if Buffer is aligned\r
-  // (IA-32 allows UINT64 and INT64 data types to be 32-bit aligned.)\r
-  //\r
-  if (((UINTN)Buffer & ((MIN (sizeof (UINTN), mInStride[Width])  - 1))) != 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Reads memory-mapped registers.\r
-\r
-  The I/O operations are carried out exactly as requested. The caller is responsible\r
-  for satisfying any alignment and I/O width restrictions that a PI System on a\r
-  platform might require. For example on some platforms, width requests of\r
-  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will\r
-  be handled by the driver.\r
-\r
-  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32,\r
-  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for\r
-  each of the Count operations that is performed.\r
-\r
-  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16,\r
-  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times on the same Address.\r
-\r
-  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16,\r
-  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times from the first element of Buffer.\r
-\r
-  @param[in]  This     A pointer to the EFI_CPU_IO_PROTOCOL instance.\r
-  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
-  @param[in]  Address  The base address of the I/O operation.\r
-  @param[in]  Count    The number of I/O operations to perform. The number of\r
-                       bytes moved is Width size * Count, starting at Address.\r
-  @param[out] Buffer   For read operations, the destination buffer to store the results.\r
-                       For write operations, the source buffer from which to write data.\r
-\r
-  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
-  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
-  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Address, Width,\r
-                                 and Count is not valid for this PI system.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceRead (\r
-  IN  EFI_CPU_IO_PROTOCOL        *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                     Address,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8                      InStride;\r
-  UINT8                      OutStride;\r
-  EFI_CPU_IO_PROTOCOL_WIDTH  OperationWidth;\r
-  UINT8       *Uint8Buffer;\r
-\r
-  Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Select loop based on the width of the transfer\r
-  //\r
-  InStride = mInStride[Width];\r
-  OutStride = mOutStride[Width];\r
-  OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-  for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {\r
-    if (OperationWidth == EfiCpuIoWidthUint8) {\r
-      *Uint8Buffer = MmioRead8 ((UINTN)Address);\r
-    } else if (OperationWidth == EfiCpuIoWidthUint16) {\r
-      *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address);\r
-    } else if (OperationWidth == EfiCpuIoWidthUint32) {\r
-      *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address);\r
-    } else if (OperationWidth == EfiCpuIoWidthUint64) {\r
-      *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address);\r
-    }\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Writes memory-mapped registers.\r
-\r
-  The I/O operations are carried out exactly as requested. The caller is responsible\r
-  for satisfying any alignment and I/O width restrictions that a PI System on a\r
-  platform might require. For example on some platforms, width requests of\r
-  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will\r
-  be handled by the driver.\r
-\r
-  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32,\r
-  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for\r
-  each of the Count operations that is performed.\r
-\r
-  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16,\r
-  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times on the same Address.\r
-\r
-  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16,\r
-  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times from the first element of Buffer.\r
-\r
-  @param[in]  This     A pointer to the EFI_CPU_IO_PROTOCOL instance.\r
-  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
-  @param[in]  Address  The base address of the I/O operation.\r
-  @param[in]  Count    The number of I/O operations to perform. The number of\r
-                       bytes moved is Width size * Count, starting at Address.\r
-  @param[in]  Buffer   For read operations, the destination buffer to store the results.\r
-                       For write operations, the source buffer from which to write data.\r
-\r
-  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
-  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
-  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Address, Width,\r
-                                 and Count is not valid for this PI system.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceWrite (\r
-  IN EFI_CPU_IO_PROTOCOL        *This,\r
-  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                     Address,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8                      InStride;\r
-  UINT8                      OutStride;\r
-  EFI_CPU_IO_PROTOCOL_WIDTH  OperationWidth;\r
-  UINT8       *Uint8Buffer;\r
-\r
-  Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Select loop based on the width of the transfer\r
-  //\r
-  InStride = mInStride[Width];\r
-  OutStride = mOutStride[Width];\r
-  OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-  for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {\r
-    if (OperationWidth == EfiCpuIoWidthUint8) {\r
-      MmioWrite8 ((UINTN)Address, *Uint8Buffer);\r
-    } else if (OperationWidth == EfiCpuIoWidthUint16) {\r
-      MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer));\r
-    } else if (OperationWidth == EfiCpuIoWidthUint32) {\r
-      MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer));\r
-    } else if (OperationWidth == EfiCpuIoWidthUint64) {\r
-      MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer));\r
-    }\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Reads I/O registers.\r
-\r
-  The I/O operations are carried out exactly as requested. The caller is responsible\r
-  for satisfying any alignment and I/O width restrictions that a PI System on a\r
-  platform might require. For example on some platforms, width requests of\r
-  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will\r
-  be handled by the driver.\r
-\r
-  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32,\r
-  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for\r
-  each of the Count operations that is performed.\r
-\r
-  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16,\r
-  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times on the same Address.\r
-\r
-  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16,\r
-  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times from the first element of Buffer.\r
-\r
-  @param[in]  This     A pointer to the EFI_CPU_IO_PROTOCOL instance.\r
-  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
-  @param[in]  Address  The base address of the I/O operation.\r
-  @param[in]  Count    The number of I/O operations to perform. The number of\r
-                       bytes moved is Width size * Count, starting at Address.\r
-  @param[out] Buffer   For read operations, the destination buffer to store the results.\r
-                       For write operations, the source buffer from which to write data.\r
-\r
-  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
-  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
-  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Address, Width,\r
-                                 and Count is not valid for this PI system.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceRead (\r
-  IN  EFI_CPU_IO_PROTOCOL        *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                     Address,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8                      InStride;\r
-  UINT8                      OutStride;\r
-  EFI_CPU_IO_PROTOCOL_WIDTH  OperationWidth;\r
-  UINT8       *Uint8Buffer;\r
-\r
-  Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Select loop based on the width of the transfer\r
-  //\r
-  InStride = mInStride[Width];\r
-  OutStride = mOutStride[Width];\r
-  OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-\r
-  //\r
-  // Fifo operations supported for (mInStride[Width] == 0)\r
-  //\r
-  if (InStride == 0) {\r
-    switch (OperationWidth) {\r
-    case EfiCpuIoWidthUint8:\r
-      IoReadFifo8 ((UINTN)Address, Count, Buffer);\r
-      return EFI_SUCCESS;\r
-    case EfiCpuIoWidthUint16:\r
-      IoReadFifo16 ((UINTN)Address, Count, Buffer);\r
-      return EFI_SUCCESS;\r
-    case EfiCpuIoWidthUint32:\r
-      IoReadFifo32 ((UINTN)Address, Count, Buffer);\r
-      return EFI_SUCCESS;\r
-    default:\r
-      //\r
-      // The CpuIoCheckParameter call above will ensure that this\r
-      // path is not taken.\r
-      //\r
-      ASSERT (FALSE);\r
-      break;\r
-    }\r
-  }\r
-\r
-  for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {\r
-    if (OperationWidth == EfiCpuIoWidthUint8) {\r
-      *Uint8Buffer = IoRead8 ((UINTN)Address);\r
-    } else if (OperationWidth == EfiCpuIoWidthUint16) {\r
-      *((UINT16 *)Uint8Buffer) = IoRead16 ((UINTN)Address);\r
-    } else if (OperationWidth == EfiCpuIoWidthUint32) {\r
-      *((UINT32 *)Uint8Buffer) = IoRead32 ((UINTN)Address);\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write I/O registers.\r
-\r
-  The I/O operations are carried out exactly as requested. The caller is responsible\r
-  for satisfying any alignment and I/O width restrictions that a PI System on a\r
-  platform might require. For example on some platforms, width requests of\r
-  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will\r
-  be handled by the driver.\r
-\r
-  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32,\r
-  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for\r
-  each of the Count operations that is performed.\r
-\r
-  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16,\r
-  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times on the same Address.\r
-\r
-  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16,\r
-  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times from the first element of Buffer.\r
-\r
-  @param[in]  This     A pointer to the EFI_CPU_IO_PROTOCOL instance.\r
-  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
-  @param[in]  Address  The base address of the I/O operation.\r
-  @param[in]  Count    The number of I/O operations to perform. The number of\r
-                       bytes moved is Width size * Count, starting at Address.\r
-  @param[in]  Buffer   For read operations, the destination buffer to store the results.\r
-                       For write operations, the source buffer from which to write data.\r
-\r
-  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
-  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
-  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Address, Width,\r
-                                 and Count is not valid for this PI system.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceWrite (\r
-  IN EFI_CPU_IO_PROTOCOL        *This,\r
-  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                     Address,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8                      InStride;\r
-  UINT8                      OutStride;\r
-  EFI_CPU_IO_PROTOCOL_WIDTH  OperationWidth;\r
-  UINT8       *Uint8Buffer;\r
-\r
-  //\r
-  // Make sure the parameters are valid\r
-  //\r
-  Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Select loop based on the width of the transfer\r
-  //\r
-  InStride = mInStride[Width];\r
-  OutStride = mOutStride[Width];\r
-  OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-\r
-  //\r
-  // Fifo operations supported for (mInStride[Width] == 0)\r
-  //\r
-  if (InStride == 0) {\r
-    switch (OperationWidth) {\r
-    case EfiCpuIoWidthUint8:\r
-      IoWriteFifo8 ((UINTN)Address, Count, Buffer);\r
-      return EFI_SUCCESS;\r
-    case EfiCpuIoWidthUint16:\r
-      IoWriteFifo16 ((UINTN)Address, Count, Buffer);\r
-      return EFI_SUCCESS;\r
-    case EfiCpuIoWidthUint32:\r
-      IoWriteFifo32 ((UINTN)Address, Count, Buffer);\r
-      return EFI_SUCCESS;\r
-    default:\r
-      //\r
-      // The CpuIoCheckParameter call above will ensure that this\r
-      // path is not taken.\r
-      //\r
-      ASSERT (FALSE);\r
-      break;\r
-    }\r
-  }\r
-\r
-  for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {\r
-    if (OperationWidth == EfiCpuIoWidthUint8) {\r
-      IoWrite8 ((UINTN)Address, *Uint8Buffer);\r
-    } else if (OperationWidth == EfiCpuIoWidthUint16) {\r
-      IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer));\r
-    } else if (OperationWidth == EfiCpuIoWidthUint32) {\r
-      IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer));\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  The user Entry Point for module CpuIo. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoInitialize (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-\r
-  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiCpuIoProtocolGuid);\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &mHandle,\r
-                  &gEfiCpuIoProtocolGuid, &mCpuIo,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIo.h b/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIo.h
deleted file mode 100644 (file)
index d7c9448..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/** @file\r
-  Internal include file of CPU I/O DXE Driver.\r
-\r
-  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __CPU_IO_DXE_H__\r
-#define __CPU_IO_DXE_H__\r
-\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/CpuIo.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-#define MAX_IO_PORT_ADDRESS   0xFFFF\r
-\r
-/**\r
-  Reads memory-mapped registers.\r
-\r
-  The I/O operations are carried out exactly as requested. The caller is responsible\r
-  for satisfying any alignment and I/O width restrictions that a PI System on a\r
-  platform might require. For example on some platforms, width requests of\r
-  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will\r
-  be handled by the driver.\r
-\r
-  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32,\r
-  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for\r
-  each of the Count operations that is performed.\r
-\r
-  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16,\r
-  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times on the same Address.\r
-\r
-  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16,\r
-  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times from the first element of Buffer.\r
-\r
-  @param[in]  This     A pointer to the EFI_CPU_IO_PROTOCOL instance.\r
-  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
-  @param[in]  Address  The base address of the I/O operation.\r
-  @param[in]  Count    The number of I/O operations to perform. The number of\r
-                       bytes moved is Width size * Count, starting at Address.\r
-  @param[out] Buffer   For read operations, the destination buffer to store the results.\r
-                       For write operations, the source buffer from which to write data.\r
-\r
-  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
-  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
-  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Address, Width,\r
-                                 and Count is not valid for this PI system.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceRead (\r
-  IN  EFI_CPU_IO_PROTOCOL        *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                     Address,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Writes memory-mapped registers.\r
-\r
-  The I/O operations are carried out exactly as requested. The caller is responsible\r
-  for satisfying any alignment and I/O width restrictions that a PI System on a\r
-  platform might require. For example on some platforms, width requests of\r
-  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will\r
-  be handled by the driver.\r
-\r
-  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32,\r
-  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for\r
-  each of the Count operations that is performed.\r
-\r
-  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16,\r
-  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times on the same Address.\r
-\r
-  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16,\r
-  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times from the first element of Buffer.\r
-\r
-  @param[in]  This     A pointer to the EFI_CPU_IO_PROTOCOL instance.\r
-  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
-  @param[in]  Address  The base address of the I/O operation.\r
-  @param[in]  Count    The number of I/O operations to perform. The number of\r
-                       bytes moved is Width size * Count, starting at Address.\r
-  @param[in]  Buffer   For read operations, the destination buffer to store the results.\r
-                       For write operations, the source buffer from which to write data.\r
-\r
-  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
-  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
-  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Address, Width,\r
-                                 and Count is not valid for this PI system.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceWrite (\r
-  IN EFI_CPU_IO_PROTOCOL        *This,\r
-  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                     Address,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Reads I/O registers.\r
-\r
-  The I/O operations are carried out exactly as requested. The caller is responsible\r
-  for satisfying any alignment and I/O width restrictions that a PI System on a\r
-  platform might require. For example on some platforms, width requests of\r
-  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will\r
-  be handled by the driver.\r
-\r
-  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32,\r
-  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for\r
-  each of the Count operations that is performed.\r
-\r
-  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16,\r
-  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times on the same Address.\r
-\r
-  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16,\r
-  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times from the first element of Buffer.\r
-\r
-  @param[in]  This     A pointer to the EFI_CPU_IO_PROTOCOL instance.\r
-  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
-  @param[in]  Address  The base address of the I/O operation.\r
-  @param[in]  Count    The number of I/O operations to perform. The number of\r
-                       bytes moved is Width size * Count, starting at Address.\r
-  @param[out] Buffer   For read operations, the destination buffer to store the results.\r
-                       For write operations, the source buffer from which to write data.\r
-\r
-  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
-  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
-  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Address, Width,\r
-                                 and Count is not valid for this PI system.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceRead (\r
-  IN  EFI_CPU_IO_PROTOCOL        *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                     Address,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Write I/O registers.\r
-\r
-  The I/O operations are carried out exactly as requested. The caller is responsible\r
-  for satisfying any alignment and I/O width restrictions that a PI System on a\r
-  platform might require. For example on some platforms, width requests of\r
-  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will\r
-  be handled by the driver.\r
-\r
-  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32,\r
-  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for\r
-  each of the Count operations that is performed.\r
-\r
-  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16,\r
-  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times on the same Address.\r
-\r
-  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16,\r
-  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is\r
-  incremented for each of the Count operations that is performed. The read or\r
-  write operation is performed Count times from the first element of Buffer.\r
-\r
-  @param[in]  This     A pointer to the EFI_CPU_IO_PROTOCOL instance.\r
-  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
-  @param[in]  Address  The base address of the I/O operation.\r
-  @param[in]  Count    The number of I/O operations to perform. The number of\r
-                       bytes moved is Width size * Count, starting at Address.\r
-  @param[in]  Buffer   For read operations, the destination buffer to store the results.\r
-                       For write operations, the source buffer from which to write data.\r
-\r
-  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
-  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
-  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED        The address range specified by Address, Width,\r
-                                 and Count is not valid for this PI system.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceWrite (\r
-  IN EFI_CPU_IO_PROTOCOL        *This,\r
-  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                     Address,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxe.inf b/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxe.inf
deleted file mode 100644 (file)
index c677bb9..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-## @file\r
-#  Module that produces the Framework CPU I/O Protocol using the services of the I/O Library\r
-#\r
-#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = CpuIoDxe\r
-  MODULE_UNI_FILE                = CpuIoDxe.uni\r
-  FILE_GUID                      = BAE7599F-3C6B-43b7-BDF0-9CE07AA91AA6\r
-  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = CpuIoInitialize\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64\r
-#\r
-\r
-[Sources]\r
-  CpuIo.c\r
-  CpuIo.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiDriverEntryPoint\r
-  BaseLib\r
-  DebugLib\r
-  IoLib\r
-  UefiBootServicesTableLib\r
-\r
-[Protocols]\r
-  gEfiCpuIoProtocolGuid                         ## PRODUCES\r
-\r
-[Depex]\r
-  TRUE\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  CpuIoDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxe.uni b/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxe.uni
deleted file mode 100644 (file)
index 3f6c0ef..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// Module that produces the Framework CPU I/O Protocol using the services of the I/O Library\r
-//\r
-// The module that produces the Framework CPU I/O Protocol using the services of the I/O Library.\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Produces the Framework CPU I/O Protocol using the services of the I/O Library"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "The module that produces the Framework CPU I/O Protocol using the services of the I/O Library."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxeExtra.uni b/IntelFrameworkModulePkg/Universal/CpuIoDxe/CpuIoDxeExtra.uni
deleted file mode 100644 (file)
index 5467d23..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// CpuIoDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Processor I/O DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHub.c b/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHub.c
deleted file mode 100644 (file)
index fe71fd2..0000000
+++ /dev/null
@@ -1,581 +0,0 @@
-/** @file\r
-  This code produces the Data Hub protocol. It preloads the data hub\r
-  with status information copied in from PEI HOBs.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "DataHub.h"\r
-\r
-//\r
-//  Since this driver will only ever produce one instance of the Logging Hub\r
-//  protocol you are not required to dynamically allocate the PrivateData.\r
-//\r
-DATA_HUB_INSTANCE mPrivateData;\r
-\r
-/**\r
-  Log data record into the data logging hub\r
-\r
-  @param This                   Protocol instance structure\r
-  @param DataRecordGuid         GUID that defines record contents\r
-  @param ProducerName           GUID that defines the name of the producer of the data\r
-  @param DataRecordClass        Class that defines generic record type\r
-  @param RawData                Data Log record as defined by DataRecordGuid\r
-  @param RawDataSize            Size of Data Log data in bytes\r
-\r
-  @retval EFI_SUCCESS           If data was logged\r
-  @retval EFI_OUT_OF_RESOURCES  If data was not logged due to lack of system\r
-                                resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DataHubLogData (\r
-  IN  EFI_DATA_HUB_PROTOCOL   *This,\r
-  IN  EFI_GUID                *DataRecordGuid,\r
-  IN  EFI_GUID                *ProducerName,\r
-  IN  UINT64                  DataRecordClass,\r
-  IN  VOID                    *RawData,\r
-  IN  UINT32                  RawDataSize\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  DATA_HUB_INSTANCE       *Private;\r
-  EFI_DATA_ENTRY          *LogEntry;\r
-  UINT32                  TotalSize;\r
-  UINT32                  RecordSize;\r
-  EFI_DATA_RECORD_HEADER  *Record;\r
-  VOID                    *Raw;\r
-  DATA_HUB_FILTER_DRIVER  *FilterEntry;\r
-  LIST_ENTRY              *Link;\r
-  LIST_ENTRY              *Head;\r
-  EFI_TIME                LogTime;\r
-\r
-  Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
-\r
-  //\r
-  // Combine the storage for the internal structs and a copy of the log record.\r
-  //  Record follows PrivateLogEntry. The consumer will be returned a pointer\r
-  //  to Record so we don't what it to be the thing that was allocated from\r
-  //  pool, so the consumer can't free an data record by mistake.\r
-  //\r
-  RecordSize  = sizeof (EFI_DATA_RECORD_HEADER) + RawDataSize;\r
-  TotalSize   = sizeof (EFI_DATA_ENTRY) + RecordSize;\r
-\r
-  //\r
-  // First try to get log time at TPL level <= TPL_CALLBACK.\r
-  //\r
-  ZeroMem (&LogTime, sizeof (LogTime));\r
-  if (EfiGetCurrentTpl() <= TPL_CALLBACK) {\r
-    gRT->GetTime (&LogTime, NULL);\r
-  }\r
-\r
-  //\r
-  // The Logging action is the critical section, so it is locked.\r
-  //  The MTC asignment & update and logging must be an\r
-  //  atomic operation, so use the lock.\r
-  //\r
-  Status = EfiAcquireLockOrFail (&Private->DataLock);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Reentrancy detected so exit!\r
-    //\r
-    return Status;\r
-  }\r
-\r
-  LogEntry = AllocatePool (TotalSize);\r
-\r
-  if (LogEntry == NULL) {\r
-    EfiReleaseLock (&Private->DataLock);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  ZeroMem (LogEntry, TotalSize);\r
-\r
-  Record  = (EFI_DATA_RECORD_HEADER *) (LogEntry + 1);\r
-  Raw     = (VOID *) (Record + 1);\r
-\r
-  //\r
-  // Build Standard Log Header\r
-  //\r
-  Record->Version     = EFI_DATA_RECORD_HEADER_VERSION;\r
-  Record->HeaderSize  = (UINT16) sizeof (EFI_DATA_RECORD_HEADER);\r
-  Record->RecordSize  = RecordSize;\r
-  CopyMem (&Record->DataRecordGuid, DataRecordGuid, sizeof (EFI_GUID));\r
-  CopyMem (&Record->ProducerName, ProducerName, sizeof (EFI_GUID));\r
-  Record->DataRecordClass   = DataRecordClass;\r
-\r
-  //\r
-  // Ensure LogMonotonicCount is not zero\r
-  //\r
-  Record->LogMonotonicCount = ++Private->GlobalMonotonicCount;\r
-\r
-  CopyMem (&Record->LogTime, &LogTime, sizeof (LogTime));\r
-\r
-  //\r
-  // Insert log into the internal linked list.\r
-  //\r
-  LogEntry->Signature   = EFI_DATA_ENTRY_SIGNATURE;\r
-  LogEntry->Record      = Record;\r
-  LogEntry->RecordSize  = sizeof (EFI_DATA_ENTRY) + RawDataSize;\r
-  InsertTailList (&Private->DataListHead, &LogEntry->Link);\r
-\r
-  CopyMem (Raw, RawData, RawDataSize);\r
-\r
-  EfiReleaseLock (&Private->DataLock);\r
-\r
-  //\r
-  // Send Signal to all the filter drivers which are interested\r
-  //  in the record's class and guid.\r
-  //\r
-  Head = &Private->FilterDriverListHead;\r
-  for (Link = GetFirstNode(Head); Link != Head; Link = GetNextNode(Head, Link)) {\r
-    FilterEntry = FILTER_ENTRY_FROM_LINK (Link);\r
-    if (((FilterEntry->ClassFilter & DataRecordClass) != 0) &&\r
-        (IsZeroGuid (&FilterEntry->FilterDataRecordGuid) ||\r
-         CompareGuid (&FilterEntry->FilterDataRecordGuid, DataRecordGuid))) {\r
-      gBS->SignalEvent (FilterEntry->Event);\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Search the Head doubly linked list for the passed in MTC. Return the\r
-  matching element in Head and the MTC on the next entry.\r
-\r
-  @param Head             Head of Data Log linked list.\r
-  @param ClassFilter      Only match the MTC if it is in the same Class as the\r
-                          ClassFilter.\r
-  @param PtrCurrentMTC    On IN contians MTC to search for. On OUT contians next\r
-                          MTC in the data log list or zero if at end of the list.\r
-\r
-  @retval EFI_DATA_LOG_ENTRY  Return pointer to data log data from Head list.\r
-  @retval NULL                If no data record exists.\r
-\r
-**/\r
-EFI_DATA_RECORD_HEADER *\r
-GetNextDataRecord (\r
-  IN  LIST_ENTRY          *Head,\r
-  IN  UINT64              ClassFilter,\r
-  IN OUT  UINT64          *PtrCurrentMTC\r
-  )\r
-\r
-{\r
-  EFI_DATA_ENTRY          *LogEntry;\r
-  LIST_ENTRY              *Link;\r
-  BOOLEAN                 ReturnFirstEntry;\r
-  EFI_DATA_RECORD_HEADER  *Record;\r
-  EFI_DATA_ENTRY          *NextLogEntry;\r
-\r
-  //\r
-  // If MonotonicCount == 0 just return the first one\r
-  //\r
-  ReturnFirstEntry  = (BOOLEAN) (*PtrCurrentMTC == 0);\r
-\r
-  Record            = NULL;\r
-  for (Link = GetFirstNode(Head); Link != Head; Link = GetNextNode(Head, Link)) {\r
-    LogEntry = DATA_ENTRY_FROM_LINK (Link);\r
-    if ((LogEntry->Record->DataRecordClass & ClassFilter) == 0) {\r
-      //\r
-      // Skip any entry that does not have the correct ClassFilter\r
-      //\r
-      continue;\r
-    }\r
-\r
-    if ((LogEntry->Record->LogMonotonicCount == *PtrCurrentMTC) || ReturnFirstEntry) {\r
-      //\r
-      // Return record to the user\r
-      //\r
-      Record = LogEntry->Record;\r
-\r
-      //\r
-      // Calculate the next MTC value. If there is no next entry set\r
-      // MTC to zero.\r
-      //\r
-      *PtrCurrentMTC = 0;\r
-      for (Link = GetNextNode(Head, Link); Link != Head; Link = GetNextNode(Head, Link)) {\r
-        NextLogEntry = DATA_ENTRY_FROM_LINK (Link);\r
-        if ((NextLogEntry->Record->DataRecordClass & ClassFilter) != 0) {\r
-          //\r
-          // Return the MTC of the next thing to search for if found\r
-          //\r
-          *PtrCurrentMTC = NextLogEntry->Record->LogMonotonicCount;\r
-          break;\r
-        }\r
-      }\r
-      //\r
-      // Record found exit loop and return\r
-      //\r
-      break;\r
-    }\r
-  }\r
-\r
-  return Record;\r
-}\r
-\r
-/**\r
-  Search the Head list for a EFI_DATA_HUB_FILTER_DRIVER member that\r
-  represents Event and return it.\r
-\r
-  @param Head   Pointer to head of dual linked list of EFI_DATA_HUB_FILTER_DRIVER structures.\r
-  @param Event  Event to be search for in the Head list.\r
-\r
-  @retval EFI_DATA_HUB_FILTER_DRIVER  Returned if Event stored in the Head doubly linked list.\r
-  @retval NULL                        If Event is not in the list\r
-\r
-**/\r
-DATA_HUB_FILTER_DRIVER *\r
-FindFilterDriverByEvent (\r
-  IN  LIST_ENTRY      *Head,\r
-  IN  EFI_EVENT       Event\r
-  )\r
-{\r
-  DATA_HUB_FILTER_DRIVER  *FilterEntry;\r
-  LIST_ENTRY              *Link;\r
-\r
-  for (Link = GetFirstNode(Head); Link != Head; Link = GetNextNode(Head, Link)) {\r
-    FilterEntry = FILTER_ENTRY_FROM_LINK (Link);\r
-    if (FilterEntry->Event == Event) {\r
-      return FilterEntry;\r
-    }\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-/**\r
-\r
-  Get a previously logged data record and the MonotonicCount for the next\r
-  available Record. This allows all records or all records later\r
-  than a give MonotonicCount to be returned. If an optional FilterDriverEvent\r
-  is passed in with a MonotonicCout of zero return the first record\r
-  not yet read by the filter driver. If FilterDriverEvent is NULL and\r
-  MonotonicCount is zero return the first data record.\r
-\r
-  @param This                     Pointer to the EFI_DATA_HUB_PROTOCOL instance.\r
-  @param MonotonicCount           Specifies the Record to return. On input, zero means\r
-                                  return the first record. On output, contains the next\r
-                                  record to available. Zero indicates no more records.\r
-  @param FilterDriverEvent        If FilterDriverEvent is not passed in a MonotonicCount\r
-                                  of zero, it means to return the first data record.\r
-                                  If FilterDriverEvent is passed in, then a MonotonicCount\r
-                                  of zero means to return the first data not yet read by\r
-                                  FilterDriverEvent.\r
-  @param Record                   Returns a dynamically allocated memory buffer with a data\r
-                                  record that matches MonotonicCount.\r
-\r
-  @retval EFI_SUCCESS             Data was returned in Record.\r
-  @retval EFI_INVALID_PARAMETER   FilterDriverEvent was passed in but does not exist.\r
-  @retval EFI_NOT_FOUND           MonotonicCount does not match any data record in the\r
-                                  system. If a MonotonicCount of zero was passed in, then\r
-                                  no data records exist in the system.\r
-  @retval EFI_OUT_OF_RESOURCES    Record was not returned due to lack of system resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DataHubGetNextRecord (\r
-  IN EFI_DATA_HUB_PROTOCOL            *This,\r
-  IN OUT UINT64                       *MonotonicCount,\r
-  IN EFI_EVENT                        *FilterDriverEvent, OPTIONAL\r
-  OUT EFI_DATA_RECORD_HEADER          **Record\r
-  )\r
-{\r
-  DATA_HUB_INSTANCE       *Private;\r
-  DATA_HUB_FILTER_DRIVER  *FilterDriver;\r
-  UINT64                  ClassFilter;\r
-\r
-  Private               = DATA_HUB_INSTANCE_FROM_THIS (This);\r
-\r
-  FilterDriver          = NULL;\r
-  ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
-    EFI_DATA_RECORD_CLASS_ERROR |\r
-    EFI_DATA_RECORD_CLASS_DATA |\r
-    EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
-\r
-  //\r
-  // If FilterDriverEvent is NULL, then return the next record\r
-  //\r
-  if (FilterDriverEvent == NULL) {\r
-    *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
-    if (*Record == NULL) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // For events the beginning is the last unread record. This info is\r
-  // stored in the instance structure, so we must look up the event\r
-  // to get the data.\r
-  //\r
-  FilterDriver = FindFilterDriverByEvent (\r
-                  &Private->FilterDriverListHead,\r
-                  *FilterDriverEvent\r
-                  );\r
-  if (FilterDriver == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Use the Class filter the event was created with.\r
-  //\r
-  ClassFilter = FilterDriver->ClassFilter;\r
-\r
-  //\r
-  // Retrieve the next record or the first record.\r
-  //\r
-  if (*MonotonicCount != 0 || FilterDriver->GetNextMonotonicCount == 0) {\r
-    *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
-    if (*Record == NULL) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    if (*MonotonicCount != 0) {\r
-      //\r
-      // If this was not the last record then update the count associated with the filter\r
-      //\r
-      FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
-    } else {\r
-      //\r
-      // Save the MonotonicCount of the last record which has been read\r
-      //\r
-      FilterDriver->GetNextMonotonicCount = (*Record)->LogMonotonicCount;\r
-    }\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // This is a request to read the first record that has not been read yet.\r
-  // Set MonotoicCount to the last record successfuly read\r
-  //\r
-  *MonotonicCount = FilterDriver->GetNextMonotonicCount;\r
-\r
-  //\r
-  // Retrieve the last record successfuly read again, but do not return it since\r
-  // it has already been returned before.\r
-  //\r
-  *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
-  if (*Record == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if (*MonotonicCount != 0) {\r
-    //\r
-    // Update the count associated with the filter\r
-    //\r
-    FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
-\r
-    //\r
-    // Retrieve the record after the last record successfuly read\r
-    //\r
-    *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
-    if (*Record == NULL) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function registers the data hub filter driver that is represented\r
-  by FilterEvent. Only one instance of each FilterEvent can be registered.\r
-  After the FilterEvent is registered, it will be signaled so it can sync\r
-  with data records that have been recorded prior to the FilterEvent being\r
-  registered.\r
-\r
-  @param This                   Pointer to  The EFI_DATA_HUB_PROTOCOL instance.\r
-  @param FilterEvent            The EFI_EVENT to signal whenever data that matches\r
-                                FilterClass is logged in the system.\r
-  @param FilterTpl              The maximum EFI_TPL at which FilterEvent can be\r
-                                signaled. It is strongly recommended that you use the\r
-                                lowest EFI_TPL possible.\r
-  @param FilterClass            FilterEvent will be signaled whenever a bit in\r
-                                EFI_DATA_RECORD_HEADER.DataRecordClass is also set in\r
-                                FilterClass. If FilterClass is zero, no class-based\r
-                                filtering will be performed.\r
-  @param FilterDataRecordGuid   FilterEvent will be signaled whenever FilterDataRecordGuid\r
-                                matches EFI_DATA_RECORD_HEADER.DataRecordGuid. If\r
-                                FilterDataRecordGuid is NULL, then no GUID-based filtering\r
-                                will be performed.\r
-\r
-  @retval EFI_SUCCESS           The filter driver event was registered.\r
-  @retval EFI_ALREADY_STARTED   FilterEvent was previously registered and cannot be\r
-                                registered again.\r
-  @retval EFI_OUT_OF_RESOURCES  The filter driver event was not registered due to lack of\r
-                                system resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DataHubRegisterFilterDriver (\r
-  IN EFI_DATA_HUB_PROTOCOL    * This,\r
-  IN EFI_EVENT                FilterEvent,\r
-  IN EFI_TPL                  FilterTpl,\r
-  IN UINT64                   FilterClass,\r
-  IN EFI_GUID                 * FilterDataRecordGuid OPTIONAL\r
-  )\r
-\r
-{\r
-  DATA_HUB_INSTANCE       *Private;\r
-  DATA_HUB_FILTER_DRIVER  *FilterDriver;\r
-\r
-  Private       = DATA_HUB_INSTANCE_FROM_THIS (This);\r
-\r
-  FilterDriver  = (DATA_HUB_FILTER_DRIVER *) AllocateZeroPool (sizeof (DATA_HUB_FILTER_DRIVER));\r
-  if (FilterDriver == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Initialize filter driver info\r
-  //\r
-  FilterDriver->Signature             = EFI_DATA_HUB_FILTER_DRIVER_SIGNATURE;\r
-  FilterDriver->Event                 = FilterEvent;\r
-  FilterDriver->Tpl                   = FilterTpl;\r
-  FilterDriver->GetNextMonotonicCount = 0;\r
-  if (FilterClass == 0) {\r
-    FilterDriver->ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
-      EFI_DATA_RECORD_CLASS_ERROR |\r
-      EFI_DATA_RECORD_CLASS_DATA |\r
-      EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
-  } else {\r
-    FilterDriver->ClassFilter = FilterClass;\r
-  }\r
-\r
-  if (FilterDataRecordGuid != NULL) {\r
-    CopyMem (&FilterDriver->FilterDataRecordGuid, FilterDataRecordGuid, sizeof (EFI_GUID));\r
-  }\r
-  //\r
-  // Search for duplicate entries\r
-  //\r
-  if (FindFilterDriverByEvent (&Private->FilterDriverListHead, FilterEvent) != NULL) {\r
-    FreePool (FilterDriver);\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-  //\r
-  // Make insertion an atomic operation with the lock.\r
-  //\r
-  EfiAcquireLock (&Private->DataLock);\r
-  InsertTailList (&Private->FilterDriverListHead, &FilterDriver->Link);\r
-  EfiReleaseLock (&Private->DataLock);\r
-\r
-  //\r
-  // Signal the Filter driver we just loaded so they will recieve all the\r
-  // previous history. If we did not signal here we would have to wait until\r
-  // the next data was logged to get the history. In a case where no next\r
-  // data was logged we would never get synced up.\r
-  //\r
-  gBS->SignalEvent (FilterEvent);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Remove a Filter Driver, so it no longer gets called when data\r
-   information is logged.\r
-\r
-  @param This           Protocol instance structure\r
-\r
-  @param FilterEvent    Event that represents a filter driver that is to be\r
-                        Unregistered.\r
-\r
-  @retval EFI_SUCCESS   If FilterEvent was unregistered\r
-  @retval EFI_NOT_FOUND If FilterEvent does not exist\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DataHubUnregisterFilterDriver (\r
-  IN EFI_DATA_HUB_PROTOCOL    *This,\r
-  IN EFI_EVENT                FilterEvent\r
-  )\r
-{\r
-  DATA_HUB_INSTANCE       *Private;\r
-  DATA_HUB_FILTER_DRIVER  *FilterDriver;\r
-\r
-  Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
-\r
-  //\r
-  // Search for duplicate entries\r
-  //\r
-  FilterDriver = FindFilterDriverByEvent (\r
-                  &Private->FilterDriverListHead,\r
-                  FilterEvent\r
-                  );\r
-  if (FilterDriver == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Make removal an atomic operation with the lock\r
-  //\r
-  EfiAcquireLock (&Private->DataLock);\r
-  RemoveEntryList (&FilterDriver->Link);\r
-  EfiReleaseLock (&Private->DataLock);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Driver's Entry point routine that install Driver to produce Data Hub protocol.\r
-\r
-  @param ImageHandle    Module's image handle\r
-  @param SystemTable    Pointer of EFI_SYSTEM_TABLE\r
-\r
-  @retval EFI_SUCCESS   Logging Hub protocol installed\r
-  @retval Other         No protocol installed, unload driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DataHubInstall (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT32      HighMontonicCount;\r
-\r
-  mPrivateData.Signature                      = DATA_HUB_INSTANCE_SIGNATURE;\r
-  mPrivateData.DataHub.LogData                = DataHubLogData;\r
-  mPrivateData.DataHub.GetNextRecord          = DataHubGetNextRecord;\r
-  mPrivateData.DataHub.RegisterFilterDriver   = DataHubRegisterFilterDriver;\r
-  mPrivateData.DataHub.UnregisterFilterDriver = DataHubUnregisterFilterDriver;\r
-\r
-  //\r
-  // Initialize Private Data in CORE_LOGGING_HUB_INSTANCE that is\r
-  // required by this protocol\r
-  //\r
-  InitializeListHead (&mPrivateData.DataListHead);\r
-  InitializeListHead (&mPrivateData.FilterDriverListHead);\r
-\r
-  EfiInitializeLock (&mPrivateData.DataLock, TPL_NOTIFY);\r
-\r
-  //\r
-  // Make sure we get a bigger MTC number on every boot!\r
-  //\r
-  Status = gRT->GetNextHighMonotonicCount (&HighMontonicCount);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // if system service fails pick a sane value.\r
-    //\r
-    mPrivateData.GlobalMonotonicCount = 0;\r
-  } else {\r
-    mPrivateData.GlobalMonotonicCount = LShiftU64 ((UINT64) HighMontonicCount, 32);\r
-  }\r
-  //\r
-  // Make a new handle and install the protocol\r
-  //\r
-  mPrivateData.Handle = NULL;\r
-  Status = gBS->InstallProtocolInterface (\r
-                  &mPrivateData.Handle,\r
-                  &gEfiDataHubProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &mPrivateData.DataHub\r
-                  );\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHub.h b/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHub.h
deleted file mode 100644 (file)
index 20a4204..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/** @file\r
-  This code supports a the private implementation\r
-  of the Data Hub protocol\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _DATA_HUB_H_\r
-#define _DATA_HUB_H_\r
-\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Protocol/DataHub.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-\r
-#define DATA_HUB_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'H', 'u', 'b')\r
-typedef struct {\r
-  UINT32                Signature;\r
-\r
-  EFI_HANDLE            Handle;\r
-\r
-  //\r
-  // Produced protocol(s)\r
-  //\r
-  EFI_DATA_HUB_PROTOCOL DataHub;\r
-\r
-  //\r
-  // Private Data\r
-  //\r
-  //\r
-  // Updates to GlobalMonotonicCount, LogListHead, and FilterDriverListHead\r
-  //  must be locked.\r
-  //\r
-  EFI_LOCK              DataLock;\r
-\r
-  //\r
-  // Runing Monotonic Count to use for each error record.\r
-  //  Increment AFTER use in an error record.\r
-  //\r
-  UINT64                GlobalMonotonicCount;\r
-\r
-  //\r
-  // List of EFI_DATA_ENTRY structures. This is the data log! The list\r
-  //  must be in assending order of LogMonotonicCount.\r
-  //\r
-  LIST_ENTRY            DataListHead;\r
-\r
-  //\r
-  // List of EFI_DATA_HUB_FILTER_DRIVER structures. Represents all\r
-  //  the registered filter drivers.\r
-  //\r
-  LIST_ENTRY            FilterDriverListHead;\r
-\r
-} DATA_HUB_INSTANCE;\r
-\r
-#define DATA_HUB_INSTANCE_FROM_THIS(this) CR (this, DATA_HUB_INSTANCE, DataHub, DATA_HUB_INSTANCE_SIGNATURE)\r
-\r
-//\r
-// Private data structure to contain the data log. One record per\r
-//  structure. Head pointer to the list is the Log member of\r
-//  EFI_DATA_ENTRY. Record is a copy of the data passed in.\r
-//\r
-#define EFI_DATA_ENTRY_SIGNATURE  SIGNATURE_32 ('D', 'r', 'e', 'c')\r
-typedef struct {\r
-  UINT32                  Signature;\r
-  LIST_ENTRY              Link;\r
-\r
-  EFI_DATA_RECORD_HEADER  *Record;\r
-\r
-  UINTN                   RecordSize;\r
-\r
-} EFI_DATA_ENTRY;\r
-\r
-#define DATA_ENTRY_FROM_LINK(link)  CR (link, EFI_DATA_ENTRY, Link, EFI_DATA_ENTRY_SIGNATURE)\r
-\r
-//\r
-// Private data to contain the filter driver Event and it's\r
-//  associated EFI_TPL.\r
-//\r
-#define EFI_DATA_HUB_FILTER_DRIVER_SIGNATURE  SIGNATURE_32 ('D', 'h', 'F', 'd')\r
-\r
-typedef struct {\r
-  UINT32          Signature;\r
-  LIST_ENTRY      Link;\r
-\r
-  //\r
-  // Store Filter Driver Event and Tpl level it can be Signaled at.\r
-  //\r
-  EFI_EVENT       Event;\r
-  EFI_TPL         Tpl;\r
-\r
-  //\r
-  // Monotonic count on the get next operation for Event.\r
-  //  Zero indicates get next has not been called for this event yet.\r
-  //\r
-  UINT64          GetNextMonotonicCount;\r
-\r
-  //\r
-  // Filter driver will register what class filter should be used.\r
-  //\r
-  UINT64          ClassFilter;\r
-\r
-  //\r
-  // Filter driver will register what record guid filter should be used.\r
-  //\r
-  EFI_GUID        FilterDataRecordGuid;\r
-\r
-} DATA_HUB_FILTER_DRIVER;\r
-\r
-#define FILTER_ENTRY_FROM_LINK(link)  CR (link, DATA_HUB_FILTER_DRIVER, Link, EFI_DATA_HUB_FILTER_DRIVER_SIGNATURE)\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.inf b/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.inf
deleted file mode 100644 (file)
index e03148b..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-## @file\r
-#  This driver initializes and installs the Data Hub protocol.\r
-#\r
-#  The data hub is a volatile database that is intended as the major focus for the accumulation of\r
-#  manageability data.T he hub is fed by "producers" with chunks of data in a defined format.\r
-#  Consumers may then extract the data in temporal "log" order.As an example, progress codes might\r
-#  be recorded in the data hub for future processing.Ot her data contributed to the data hub might\r
-#  include, for example, statistics on enumerated items such as memory, add-in buses, and add-in\r
-#  cards and data on errors encountered during boot (for example, the system did not boot off the\r
-#  network because the cable was not plugged in).\r
-#  Some classes of data have defined formats.For example, the amount of memory in the system is\r
-#  reported in a standard format so that consumers can be written to extract the data.O ther data is\r
-#  system specific.For example, additional detail on errors might be specific to the driver that\r
-#  discovered the error.The consumer might be a driver that tabularizes data from the data hub,\r
-#  providing a mechanism for the raw data to be made available to the OS for post-processing by\r
-#  OS-based applications.\r
-#  The intent of the data hub is for drivers that enumerate and configure parts of the system to report\r
-#  their discoveries to the data hub.This data can then be extracted by other drivers that report those\r
-#  discoveries using standard manageability interfaces such as SMBIOS and Intelligent Platform\r
-#  Management Interface (IPMI).The alternative to a data-hub-like architecture is to require all\r
-#  drivers to be aware of all reporting formats.\r
-#  For more information, please ref http://www.intel.com/technology/framework/\r
-#\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DataHubDxe\r
-  MODULE_UNI_FILE                = DataHubDxe.uni\r
-  FILE_GUID                      = 53BCC14F-C24F-434C-B294-8ED2D4CC1860\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = DataHubInstall\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  DataHub.h\r
-  DataHub.c\r
-\r
-\r
-[Packages]\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  UefiRuntimeServicesTableLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-\r
-\r
-[Protocols]\r
-  gEfiDataHubProtocolGuid                       ## PRODUCES\r
-\r
-\r
-[Depex]\r
-  TRUE\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  DataHubDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.uni b/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.uni
deleted file mode 100644 (file)
index 281c5bc..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// /** @file\r
-// This driver initializes and installs the Data Hub protocol.\r
-//\r
-// The data hub is a volatile database that is intended as the major focus for the accumulation of\r
-// manageability data.T he hub is fed by "producers" with chunks of data in a defined format.\r
-// Consumers may then extract the data in temporal "log" order.As an example, progress codes might\r
-// be recorded in the data hub for future processing.Ot her data contributed to the data hub might\r
-// include, for example, statistics on enumerated items such as memory, add-in buses, and add-in\r
-// cards and data on errors encountered during boot (for example, the system did not boot off the\r
-// network because the cable was not plugged in).\r
-// Some classes of data have defined formats.For example, the amount of memory in the system is\r
-// reported in a standard format so that consumers can be written to extract the data.O ther data is\r
-// system specific.For example, additional detail on errors might be specific to the driver that\r
-// discovered the error.The consumer might be a driver that tabularizes data from the data hub,\r
-// providing a mechanism for the raw data to be made available to the OS for post-processing by\r
-// OS-based applications.\r
-// The intent of the data hub is for drivers that enumerate and configure parts of the system to report\r
-// their discoveries to the data hub.This data can then be extracted by other drivers that report those\r
-// discoveries using standard manageability interfaces such as SMBIOS and Intelligent Platform\r
-// Management Interface (IPMI).The alternative to a data-hub-like architecture is to require all\r
-// drivers to be aware of all reporting formats.\r
-// For more information, please ref http://www.intel.com/technology/framework/\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Initializes and installs the Data Hub protocol"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "The data hub is a volatile database that is intended as the major focus for the accumulation of manageability data. The hub is fed by \"producers\" with chunks of data in a defined format. Consumers may then extract the data in a temporal \"log\" order. As an example, progress codes might be recorded in the data hub for future processing. For example, other data contributed to the data hub might include,  statistics on enumerated items such as memory, add-in buses, and add-in cards, and data on errors encountered during boot (such as, the system did not boot off the network because the cable was not plugged in). Some classes of data have defined formats. For example, the amount of memory in the system is reported in a standard format so that consumers can be written to extract the data. Other data is system specific. For example, additional detail on errors might be specific to the driver that discovered the error. The consumer might be a driver that tabularizes data from the data hub, providing a mechanism for the raw data to be made available to the OS for post-processing by OS-based applications. The intent of the data hub is for drivers that enumerate and configure parts of the system to report their discoveries to the data hub. This data can then be extracted by other drivers that report those discoveries using standard manageability interfaces such as SMBIOS and Intelligent Platform Management Interface (IPMI). The alternative to a data-hub-like architecture is to require all drivers to be aware of all reporting formats. For more information, refer to http://www.intel.com/technology/framework/ ."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxeExtra.uni b/IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxeExtra.uni
deleted file mode 100644 (file)
index 5113309..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// DataHubDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Data Hub DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErr.c b/IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErr.c
deleted file mode 100644 (file)
index 7c6c8f5..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/** @file\r
-  Data Hub filter driver that takes DEBUG () info from Data Hub and writes it\r
-  to StdErr if it exists.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <FrameworkDxe.h>\r
-#include <Guid/DataHubStatusCodeRecord.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Protocol/DataHub.h>\r
-#include <Protocol/SimpleTextOut.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-EFI_DATA_HUB_PROTOCOL *mDataHub = NULL;\r
-\r
-EFI_EVENT             mDataHubStdErrEvent;\r
-\r
-/**\r
-  Event handler registered with the Data Hub to parse EFI_DEBUG_CODE. This\r
-  handler reads the Data Hub and sends any DEBUG info to StdErr.\r
-\r
-  @param Event      The event that occured, not used\r
-  @param Context    DataHub Protocol Pointer\r
-**/\r
-VOID\r
-EFIAPI\r
-DataHubStdErrEventHandler (\r
-  IN EFI_EVENT Event,\r
-  IN VOID      *Context\r
-  )\r
-{\r
-  EFI_STATUS                           Status;\r
-  EFI_DATA_HUB_PROTOCOL                *DataHub;\r
-  EFI_DATA_RECORD_HEADER               *Record;\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD     *DataRecord;\r
-  UINT64                               Mtc;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL      *Sto;\r
-  INT32                                OldAttribute;\r
-\r
-  DataHub = (EFI_DATA_HUB_PROTOCOL *) Context;\r
-\r
-  //\r
-  // If StdErr is not yet initialized just return a DEBUG print in the BDS\r
-  // after consoles are connect will make sure data gets flushed properly\r
-  // when StdErr is available.\r
-  //\r
-  if (gST == NULL) {\r
-    return ;\r
-  }\r
-\r
-  if (gST->StdErr == NULL) {\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Mtc of zero means return the next record that has not been read by the\r
-  // event handler.\r
-  //\r
-  Mtc = 0;\r
-  do {\r
-    Status = DataHub->GetNextRecord (DataHub, &Mtc, &mDataHubStdErrEvent, &Record);\r
-    if (!EFI_ERROR (Status)) {\r
-      if (CompareGuid (&Record->DataRecordGuid, &gEfiDataHubStatusCodeRecordGuid)) {\r
-        DataRecord = (DATA_HUB_STATUS_CODE_DATA_RECORD *) (((CHAR8 *) Record) + Record->HeaderSize);\r
-\r
-        if (DataRecord->Data.HeaderSize > 0) {\r
-          if (CompareGuid (&DataRecord->Data.Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r
-            //\r
-            // If the Data record is from a DEBUG () then send it to Standard Error\r
-            //\r
-            Sto           = gST->StdErr;\r
-            OldAttribute  = Sto->Mode->Attribute;\r
-            Sto->SetAttribute (Sto, EFI_TEXT_ATTR (EFI_MAGENTA, EFI_BLACK));\r
-            Sto->OutputString (Sto, (CHAR16 *) (DataRecord + 1));\r
-            Sto->SetAttribute (Sto, OldAttribute);\r
-          }\r
-        }\r
-      }\r
-    }\r
-  } while ((Mtc != 0) && !EFI_ERROR (Status));\r
-}\r
-\r
-/**\r
-  Register an event handler with the Data Hub to parse EFI_DEBUG_CODE. This\r
-  handler reads the Data Hub and sends any DEBUG info to StdErr.\r
-\r
-  @param ImageHandle                Image handle of this driver.\r
-  @param SystemTable                Pointer to EFI system table.\r
-\r
-  @retval EFI_SUCCESS               The event handler was registered.\r
-  @retval EFI_OUT_OF_RESOURCES      The event hadler was not registered due to lack of system resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DataHubStdErrInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT64      DataClass;\r
-\r
-  gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID **) &mDataHub);\r
-  //\r
-  // Should never fail due to Depex grammer.\r
-  //\r
-  ASSERT (mDataHub != NULL);\r
-\r
-  //\r
-  // Create an event and register it with the filter driver\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  DataHubStdErrEventHandler,\r
-                  mDataHub,\r
-                  &mDataHubStdErrEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  DataClass = EFI_DATA_RECORD_CLASS_DEBUG | EFI_DATA_RECORD_CLASS_ERROR;\r
-  Status = mDataHub->RegisterFilterDriver (\r
-                      mDataHub,\r
-                      mDataHubStdErrEvent,\r
-                      TPL_CALLBACK,\r
-                      DataClass,\r
-                      NULL\r
-                      );\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->CloseEvent (mDataHubStdErrEvent);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxe.inf b/IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxe.inf
deleted file mode 100644 (file)
index 4c9dc8a..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-## @file\r
-#  This driver takes DEBUG info from Data Hub and writes it to StdErr if it exists.\r
-#\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DataHubStdErrDxe\r
-  MODULE_UNI_FILE                = DataHubStdErrDxe.uni\r
-  FILE_GUID                      = CA515306-00CE-4032-874E-11B755FF6866\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = DataHubStdErrInitialize\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  DataHubStdErr.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-\r
-[Guids]\r
-  gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_CONSUMES ## UNDEFINED  # DataRecord Date Type\r
-  gEfiDataHubStatusCodeRecordGuid               ## SOMETIMES_CONSUMES ## UNDEFINED  # DataRecordGuid\r
-\r
-\r
-[Protocols]\r
-  gEfiDataHubProtocolGuid                       ## CONSUMES\r
-\r
-[Depex]\r
-  gEfiDataHubProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  DataHubStdErrDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxe.uni b/IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxe.uni
deleted file mode 100644 (file)
index d4b76a5..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// This driver takes DEBUG info from Data Hub and writes it to StdErr if it exists.\r
-//\r
-// This driver takes DEBUG info from a Data Hub and writes it to StdErr if it exists.\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Takes DEBUG information from a Data Hub; writes it to StdErr if it exists"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This driver takes DEBUG info from a Data Hub and writes it to StdErr if it exists."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxeExtra.uni b/IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxeExtra.uni
deleted file mode 100644 (file)
index 897064e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// DataHubStdErrDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Data Hub stderr DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/Ffs.c b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/Ffs.c
deleted file mode 100644 (file)
index 950982b..0000000
+++ /dev/null
@@ -1,601 +0,0 @@
-/** @file\r
-  FFS file access utilities.\r
-\r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "FwVolDriver.h"\r
-\r
-#define PHYSICAL_ADDRESS_TO_POINTER(Address)  ((VOID *) ((UINTN) Address))\r
-\r
-/**\r
-  Set File State in the FfsHeader.\r
-\r
-  @param  State          File state to be set into FFS header.\r
-  @param  FfsHeader      Points to the FFS file header\r
-\r
-**/\r
-VOID\r
-SetFileState (\r
-  IN UINT8                State,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-{\r
-  //\r
-  // Set File State in the FfsHeader\r
-  //\r
-  FfsHeader->State = (EFI_FFS_FILE_STATE) (FfsHeader->State ^ State);\r
-  return ;\r
-}\r
-\r
-/**\r
-  Get the FFS file state by checking the highest bit set in the header's state field.\r
-\r
-  @param  ErasePolarity  Erase polarity attribute of the firmware volume\r
-  @param  FfsHeader      Points to the FFS file header\r
-\r
-  @return FFS File state\r
-\r
-**/\r
-EFI_FFS_FILE_STATE\r
-GetFileState (\r
-  IN UINT8                ErasePolarity,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-{\r
-  EFI_FFS_FILE_STATE  FileState;\r
-  UINT8               HighestBit;\r
-\r
-  FileState = FfsHeader->State;\r
-\r
-  if (ErasePolarity != 0) {\r
-    FileState = (EFI_FFS_FILE_STATE)~FileState;\r
-  }\r
-\r
-  HighestBit = 0x80;\r
-  while (HighestBit != 0 && ((HighestBit & FileState) == 0)) {\r
-    HighestBit >>= 1;\r
-  }\r
-\r
-  return (EFI_FFS_FILE_STATE) HighestBit;\r
-}\r
-\r
-/**\r
-  Convert the Buffer Address to LBA Entry Address.\r
-\r
-  @param FvDevice        Cached FvDevice\r
-  @param BufferAddress   Address of Buffer\r
-  @param LbaListEntry    Pointer to the got LBA entry that contains the address.\r
-\r
-  @retval EFI_NOT_FOUND  Buffer address is out of FvDevice.\r
-  @retval EFI_SUCCESS    LBA entry is found for Buffer address.\r
-\r
-**/\r
-EFI_STATUS\r
-Buffer2LbaEntry (\r
-  IN     FV_DEVICE              *FvDevice,\r
-  IN     EFI_PHYSICAL_ADDRESS   BufferAddress,\r
-  OUT LBA_ENTRY                 **LbaListEntry\r
-  )\r
-{\r
-  LBA_ENTRY   *LbaEntry;\r
-  LIST_ENTRY  *Link;\r
-\r
-  Link      = FvDevice->LbaHeader.ForwardLink;\r
-  LbaEntry  = (LBA_ENTRY *) Link;\r
-\r
-  //\r
-  // Locate LBA which contains the address\r
-  //\r
-  while (&LbaEntry->Link != &FvDevice->LbaHeader) {\r
-    if ((EFI_PHYSICAL_ADDRESS) (UINTN) (LbaEntry->StartingAddress) > BufferAddress) {\r
-      break;\r
-    }\r
-\r
-    Link      = LbaEntry->Link.ForwardLink;\r
-    LbaEntry  = (LBA_ENTRY *) Link;\r
-  }\r
-\r
-  if (&LbaEntry->Link == &FvDevice->LbaHeader) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  Link      = LbaEntry->Link.BackLink;\r
-  LbaEntry  = (LBA_ENTRY *) Link;\r
-\r
-  if (&LbaEntry->Link == &FvDevice->LbaHeader) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  *LbaListEntry = LbaEntry;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Convert the Buffer Address to LBA Address & Offset.\r
-\r
-  @param FvDevice        Cached FvDevice\r
-  @param BufferAddress   Address of Buffer\r
-  @param Lba             Pointer to the gob Lba value\r
-  @param Offset          Pointer to the got Offset\r
-\r
-  @retval EFI_NOT_FOUND  Buffer address is out of FvDevice.\r
-  @retval EFI_SUCCESS    LBA and Offset is found for Buffer address.\r
-\r
-**/\r
-EFI_STATUS\r
-Buffer2Lba (\r
-  IN     FV_DEVICE              *FvDevice,\r
-  IN     EFI_PHYSICAL_ADDRESS   BufferAddress,\r
-  OUT EFI_LBA                   *Lba,\r
-  OUT UINTN                     *Offset\r
-  )\r
-{\r
-  LBA_ENTRY   *LbaEntry;\r
-  EFI_STATUS  Status;\r
-\r
-  LbaEntry = NULL;\r
-\r
-  Status = Buffer2LbaEntry (\r
-            FvDevice,\r
-            BufferAddress,\r
-            &LbaEntry\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  *Lba    = LbaEntry->LbaIndex;\r
-  *Offset = (UINTN) BufferAddress - (UINTN) LbaEntry->StartingAddress;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Check if a block of buffer is erased.\r
-\r
-  @param  ErasePolarity  Erase polarity attribute of the firmware volume\r
-  @param  Buffer         The buffer to be checked\r
-  @param  BufferSize     Size of the buffer in bytes\r
-\r
-  @retval TRUE           The block of buffer is erased\r
-  @retval FALSE          The block of buffer is not erased\r
-\r
-**/\r
-BOOLEAN\r
-IsBufferErased (\r
-  IN UINT8    ErasePolarity,\r
-  IN UINT8    *Buffer,\r
-  IN UINTN    BufferSize\r
-  )\r
-{\r
-  UINTN Count;\r
-  UINT8 EraseByte;\r
-\r
-  if (ErasePolarity == 1) {\r
-    EraseByte = 0xFF;\r
-  } else {\r
-    EraseByte = 0;\r
-  }\r
-\r
-  for (Count = 0; Count < BufferSize; Count++) {\r
-    if (Buffer[Count] != EraseByte) {\r
-      return FALSE;\r
-    }\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Verify checksum of the firmware volume header.\r
-\r
-  @param  FvHeader       Points to the firmware volume header to be checked\r
-\r
-  @retval TRUE           Checksum verification passed\r
-  @retval FALSE          Checksum verification failed\r
-\r
-**/\r
-BOOLEAN\r
-VerifyFvHeaderChecksum (\r
-  IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader\r
-  )\r
-{\r
-  UINT16  Checksum;\r
-\r
-  Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength);\r
-\r
-  if (Checksum == 0) {\r
-    return TRUE;\r
-  } else {\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-/**\r
-  Verify checksum of the FFS file header.\r
-\r
-  @param  FfsHeader      Points to the FFS file header to be checked\r
-\r
-  @retval TRUE           Checksum verification passed\r
-  @retval FALSE          Checksum verification failed\r
-\r
-**/\r
-BOOLEAN\r
-VerifyHeaderChecksum (\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-{\r
-  UINT8 HeaderChecksum;\r
-\r
-  if (IS_FFS_FILE2 (FfsHeader)) {\r
-    HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER2));\r
-  } else {\r
-    HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));\r
-  }\r
-  HeaderChecksum = (UINT8) (HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File);\r
-\r
-  if (HeaderChecksum == 0) {\r
-    return TRUE;\r
-  } else {\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-/**\r
-  Verify checksum of the FFS file data.\r
-\r
-  @param  FfsHeader      Points to the FFS file header to be checked\r
-\r
-  @retval TRUE           Checksum verification passed\r
-  @retval FALSE          Checksum verification failed\r
-\r
-**/\r
-BOOLEAN\r
-VerifyFileChecksum (\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-{\r
-  UINT8                   FileChecksum;\r
-  EFI_FV_FILE_ATTRIBUTES  Attributes;\r
-\r
-  Attributes = FfsHeader->Attributes;\r
-\r
-  if ((Attributes & FFS_ATTRIB_CHECKSUM) != 0) {\r
-\r
-    //\r
-    // Check checksum of FFS data\r
-    //\r
-    if (IS_FFS_FILE2 (FfsHeader)) {\r
-      FileChecksum = CalculateSum8 ((UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER2), FFS_FILE2_SIZE (FfsHeader) - sizeof (EFI_FFS_FILE_HEADER2));\r
-    } else {\r
-      FileChecksum = CalculateSum8 ((UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER), FFS_FILE_SIZE (FfsHeader) - sizeof (EFI_FFS_FILE_HEADER));\r
-    }\r
-    FileChecksum = (UINT8) (FileChecksum + FfsHeader->IntegrityCheck.Checksum.File);\r
-\r
-    if (FileChecksum == 0) {\r
-      return TRUE;\r
-    } else {\r
-      return FALSE;\r
-    }\r
-\r
-  } else {\r
-\r
-    if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {\r
-      return FALSE;\r
-    } else {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-}\r
-\r
-/**\r
-  Check if it's a valid FFS file header.\r
-\r
-  @param  ErasePolarity  Erase polarity attribute of the firmware volume\r
-  @param  FfsHeader      Points to the FFS file header to be checked\r
-\r
-  @retval TRUE           Valid FFS file header\r
-  @retval FALSE          Invalid FFS file header\r
-\r
-**/\r
-BOOLEAN\r
-IsValidFFSHeader (\r
-  IN UINT8                ErasePolarity,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-{\r
-  EFI_FFS_FILE_STATE  FileState;\r
-\r
-  //\r
-  // Check if it is a free space\r
-  //\r
-  if (IsBufferErased (\r
-        ErasePolarity,\r
-        (UINT8 *) FfsHeader,\r
-        sizeof (EFI_FFS_FILE_HEADER)\r
-        )) {\r
-    return FALSE;\r
-  }\r
-\r
-  FileState = GetFileState (ErasePolarity, FfsHeader);\r
-\r
-  switch (FileState) {\r
-  case EFI_FILE_HEADER_CONSTRUCTION:\r
-    //\r
-    // fall through\r
-    //\r
-  case EFI_FILE_HEADER_INVALID:\r
-    return FALSE;\r
-\r
-  case EFI_FILE_HEADER_VALID:\r
-    //\r
-    // fall through\r
-    //\r
-  case EFI_FILE_DATA_VALID:\r
-    //\r
-    // fall through\r
-    //\r
-  case EFI_FILE_MARKED_FOR_UPDATE:\r
-    //\r
-    // fall through\r
-    //\r
-  case EFI_FILE_DELETED:\r
-    //\r
-    // Here we need to verify header checksum\r
-    //\r
-    if (!VerifyHeaderChecksum (FfsHeader)) {\r
-      return FALSE;\r
-    }\r
-    break;\r
-\r
-  default:\r
-    //\r
-    // return\r
-    //\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Get next possible of Firmware File System Header.\r
-\r
-  @param  ErasePolarity  Erase polarity attribute of the firmware volume\r
-  @param  FfsHeader      Points to the FFS file header to be skipped.\r
-\r
-  @return  Pointer to next FFS header.\r
-\r
-**/\r
-EFI_PHYSICAL_ADDRESS\r
-GetNextPossibleFileHeader (\r
-  IN UINT8                ErasePolarity,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-{\r
-  UINT32  FileLength;\r
-  UINT32  SkipLength;\r
-\r
-  if (!IsValidFFSHeader (ErasePolarity, FfsHeader)) {\r
-    //\r
-    // Skip this header\r
-    //\r
-    if (IS_FFS_FILE2 (FfsHeader)) {\r
-      return (EFI_PHYSICAL_ADDRESS) (UINTN) FfsHeader + sizeof (EFI_FFS_FILE_HEADER2);\r
-    } else {\r
-      return (EFI_PHYSICAL_ADDRESS) (UINTN) FfsHeader + sizeof (EFI_FFS_FILE_HEADER);\r
-    }\r
-  }\r
-\r
-  if (IS_FFS_FILE2 (FfsHeader)) {\r
-    FileLength = FFS_FILE2_SIZE (FfsHeader);\r
-  } else {\r
-    FileLength = FFS_FILE_SIZE (FfsHeader);\r
-  }\r
-\r
-  //\r
-  // Since FileLength is not multiple of 8, we need skip some bytes\r
-  // to get next possible header\r
-  //\r
-  SkipLength = FileLength;\r
-  while ((SkipLength & 0x07) != 0) {\r
-    SkipLength++;\r
-  }\r
-\r
-  return (EFI_PHYSICAL_ADDRESS) (UINTN) FfsHeader + SkipLength;\r
-}\r
-\r
-/**\r
-  Search FFS file with the same FFS name in FV Cache.\r
-\r
-  @param  FvDevice     Cached FV image.\r
-  @param  FfsHeader    Points to the FFS file header to be skipped.\r
-  @param  StateBit     FFS file state bit to be checked.\r
-\r
-  @return  Pointer to next found FFS header. NULL will return if no found.\r
-\r
-**/\r
-EFI_FFS_FILE_HEADER *\r
-DuplicateFileExist (\r
-  IN FV_DEVICE            *FvDevice,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
-  IN EFI_FFS_FILE_STATE   StateBit\r
-  )\r
-{\r
-  UINT8               *Ptr;\r
-  EFI_FFS_FILE_HEADER *NextFfsFile;\r
-\r
-  //\r
-  // Search duplicate file, not from the beginning of FV,\r
-  // just search the next ocurrence of this file\r
-  //\r
-  NextFfsFile = FfsHeader;\r
-\r
-  do {\r
-    Ptr = (UINT8 *) PHYSICAL_ADDRESS_TO_POINTER (\r
-                      GetNextPossibleFileHeader (FvDevice->ErasePolarity,\r
-                      NextFfsFile)\r
-                      );\r
-    NextFfsFile = (EFI_FFS_FILE_HEADER *) Ptr;\r
-\r
-    if ((UINT8 *) PHYSICAL_ADDRESS_TO_POINTER (FvDevice->CachedFv) + FvDevice->FwVolHeader->FvLength - Ptr <\r
-        sizeof (EFI_FFS_FILE_HEADER)\r
-          ) {\r
-      break;\r
-    }\r
-\r
-    if (!IsValidFFSHeader (FvDevice->ErasePolarity, NextFfsFile)) {\r
-      continue;\r
-    }\r
-\r
-    if (!VerifyFileChecksum (NextFfsFile)) {\r
-      continue;\r
-    }\r
-\r
-    if (CompareGuid (&NextFfsFile->Name, &FfsHeader->Name)) {\r
-      if (GetFileState (FvDevice->ErasePolarity, NextFfsFile) == StateBit) {\r
-        return NextFfsFile;\r
-      }\r
-    }\r
-  } while (Ptr < (UINT8 *) PHYSICAL_ADDRESS_TO_POINTER (FvDevice->CachedFv) + FvDevice->FwVolHeader->FvLength);\r
-\r
-  return NULL;\r
-}\r
-\r
-/**\r
-  Change FFS file header state and write to FV.\r
-\r
-  @param  FvDevice     Cached FV image.\r
-  @param  FfsHeader    Points to the FFS file header to be updated.\r
-  @param  State        FFS file state to be set.\r
-\r
-  @retval EFI_SUCCESS  File state is writen into FV.\r
-  @retval others       File state can't be writen into FV.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateHeaderBit (\r
-  IN FV_DEVICE            *FvDevice,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
-  IN EFI_FFS_FILE_STATE   State\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  EFI_LBA     Lba;\r
-  UINTN       Offset;\r
-  UINTN       NumBytesWritten;\r
-\r
-  Lba    = 0;\r
-  Offset = 0;\r
-\r
-  SetFileState (State, FfsHeader);\r
-\r
-  Buffer2Lba (\r
-    FvDevice,\r
-    (EFI_PHYSICAL_ADDRESS) (UINTN) (&FfsHeader->State),\r
-    &Lba,\r
-    &Offset\r
-    );\r
-  //\r
-  // Write the state byte into FV\r
-  //\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvDevice->Fvb->Write (\r
-                            FvDevice->Fvb,\r
-                            Lba,\r
-                            Offset,\r
-                            &NumBytesWritten,\r
-                            &FfsHeader->State\r
-                            );\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Check if it's a valid FFS file.\r
-  Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.\r
-\r
-  @param  FvDevice       Cached FV image.\r
-  @param  FfsHeader      Points to the FFS file to be checked\r
-\r
-  @retval TRUE           Valid FFS file\r
-  @retval FALSE          Invalid FFS file\r
-\r
-**/\r
-BOOLEAN\r
-IsValidFFSFile (\r
-  IN FV_DEVICE            *FvDevice,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-{\r
-  EFI_FFS_FILE_STATE  FileState;\r
-  UINT8               ErasePolarity;\r
-\r
-  ErasePolarity = FvDevice->ErasePolarity;\r
-\r
-  FileState     = GetFileState (ErasePolarity, FfsHeader);\r
-\r
-  switch (FileState) {\r
-  case EFI_FILE_DATA_VALID:\r
-    if (!VerifyFileChecksum (FfsHeader)) {\r
-      return FALSE;\r
-    }\r
-\r
-    if (FfsHeader->Type == EFI_FV_FILETYPE_FFS_PAD) {\r
-      break;\r
-    }\r
-    //\r
-    // Check if there is another duplicated file with the EFI_FILE_DATA_VALID\r
-    //\r
-    if (DuplicateFileExist (FvDevice, FfsHeader, EFI_FILE_DATA_VALID) != NULL) {\r
-      return FALSE;\r
-    }\r
-\r
-    break;\r
-\r
-  case EFI_FILE_MARKED_FOR_UPDATE:\r
-    if (!VerifyFileChecksum (FfsHeader)) {\r
-      return FALSE;\r
-    }\r
-\r
-    if (FfsHeader->Type == EFI_FV_FILETYPE_FFS_PAD) {\r
-      //\r
-      // since its data area is not unperturbed, it cannot be reclaimed,\r
-      // marked it as deleted\r
-      //\r
-      UpdateHeaderBit (FvDevice, FfsHeader, EFI_FILE_DELETED);\r
-      return TRUE;\r
-\r
-    } else if (DuplicateFileExist (FvDevice, FfsHeader, EFI_FILE_DATA_VALID) != NULL) {\r
-      //\r
-      // Here the found file is more recent than this file,\r
-      // mark it as deleted\r
-      //\r
-      UpdateHeaderBit (FvDevice, FfsHeader, EFI_FILE_DELETED);\r
-      return TRUE;\r
-\r
-    } else {\r
-      return TRUE;\r
-    }\r
-\r
-    break;\r
-\r
-  case EFI_FILE_DELETED:\r
-    if (!VerifyFileChecksum (FfsHeader)) {\r
-      return FALSE;\r
-    }\r
-\r
-    break;\r
-\r
-  default:\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwPadFile.c b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwPadFile.c
deleted file mode 100644 (file)
index a50bd13..0000000
+++ /dev/null
@@ -1,1221 +0,0 @@
-/** @file\r
-  Implements functions to pad firmware file.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "FwVolDriver.h"\r
-\r
-/**\r
-  Calculate the checksum for a PAD file.\r
-\r
-  @param PadFileHeader   The Pad File to be caculeted the checksum.\r
-\r
-**/\r
-VOID\r
-SetPadFileChecksum (\r
-  IN EFI_FFS_FILE_HEADER *PadFileHeader\r
-  )\r
-{\r
-  if ((PadFileHeader->Attributes & FFS_ATTRIB_CHECKSUM) != 0) {\r
-\r
-    if (IS_FFS_FILE2 (PadFileHeader)) {\r
-      //\r
-      // Calculate checksum of Pad File Data\r
-      //\r
-      PadFileHeader->IntegrityCheck.Checksum.File =\r
-        CalculateCheckSum8 ((UINT8 *) PadFileHeader + sizeof (EFI_FFS_FILE_HEADER2), FFS_FILE2_SIZE (PadFileHeader) - sizeof (EFI_FFS_FILE_HEADER2));\r
-\r
-      } else {\r
-      //\r
-      // Calculate checksum of Pad File Data\r
-      //\r
-      PadFileHeader->IntegrityCheck.Checksum.File =\r
-        CalculateCheckSum8 ((UINT8 *) PadFileHeader + sizeof (EFI_FFS_FILE_HEADER), FFS_FILE_SIZE (PadFileHeader) - sizeof (EFI_FFS_FILE_HEADER));\r
-    }\r
-\r
-  } else {\r
-\r
-    PadFileHeader->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Create a PAD File in the Free Space.\r
-\r
-  @param FvDevice        Firmware Volume Device.\r
-  @param FreeSpaceEntry  Indicating in which Free Space(Cache) the Pad file will be inserted.\r
-  @param Size            Pad file Size, not include the header.\r
-  @param PadFileEntry    The Ffs File Entry that points to this Pad File.\r
-\r
-  @retval EFI_SUCCESS            Successfully create a PAD file.\r
-  @retval EFI_OUT_OF_RESOURCES   No enough free space to create a PAD file.\r
-  @retval EFI_INVALID_PARAMETER  Size is not 8 byte alignment.\r
-  @retval EFI_DEVICE_ERROR       Free space is not erased.\r
-**/\r
-EFI_STATUS\r
-FvCreatePadFileInFreeSpace (\r
-  IN  FV_DEVICE           *FvDevice,\r
-  IN  FREE_SPACE_ENTRY    *FreeSpaceEntry,\r
-  IN  UINTN               Size,\r
-  OUT FFS_FILE_LIST_ENTRY **PadFileEntry\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_FFS_FILE_HEADER                 *PadFileHeader;\r
-  UINTN                               Offset;\r
-  UINTN                               NumBytesWritten;\r
-  UINTN                               StateOffset;\r
-  UINT8                               *StartPos;\r
-  FFS_FILE_LIST_ENTRY                 *FfsFileEntry;\r
-  UINTN                               HeaderSize;\r
-  UINTN                               FileSize;\r
-\r
-  HeaderSize = sizeof (EFI_FFS_FILE_HEADER);\r
-  FileSize = Size + HeaderSize;\r
-  if (FileSize > 0x00FFFFFF) {\r
-    HeaderSize = sizeof (EFI_FFS_FILE_HEADER2);\r
-    FileSize = Size + HeaderSize;\r
-  }\r
-\r
-  if (FreeSpaceEntry->Length < FileSize) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  if ((Size & 0x07) != 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  StartPos = FreeSpaceEntry->StartingAddress;\r
-\r
-  //\r
-  // First double check the space\r
-  //\r
-  if (!IsBufferErased (\r
-        FvDevice->ErasePolarity,\r
-        StartPos,\r
-        FileSize\r
-        )) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  PadFileHeader = (EFI_FFS_FILE_HEADER *) StartPos;\r
-\r
-  //\r
-  // Create File Step 1\r
-  //\r
-  SetFileState (EFI_FILE_HEADER_CONSTRUCTION, PadFileHeader);\r
-\r
-  Offset          = (UINTN) (StartPos - FvDevice->CachedFv);\r
-  StateOffset     = Offset + (UINT8 *) &PadFileHeader->State - (UINT8 *) PadFileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            StateOffset,\r
-            &NumBytesWritten,\r
-            &PadFileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    SetFileState (EFI_FILE_HEADER_CONSTRUCTION, PadFileHeader);\r
-    return Status;\r
-  }\r
-  //\r
-  // Update Free Space Entry, since header is allocated\r
-  //\r
-  FreeSpaceEntry->Length -= HeaderSize;\r
-  FreeSpaceEntry->StartingAddress += HeaderSize;\r
-\r
-  //\r
-  // Fill File Name Guid, here we assign a NULL-GUID to Pad files\r
-  //\r
-  ZeroMem (&PadFileHeader->Name, sizeof (EFI_GUID));\r
-\r
-  //\r
-  // Fill File Type, checksum(0), Attributes(0), Size\r
-  //\r
-  PadFileHeader->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
-  PadFileHeader->Attributes = 0;\r
-  if ((FileSize) > 0x00FFFFFF) {\r
-    ((EFI_FFS_FILE_HEADER2 *) PadFileHeader)->ExtendedSize = (UINT32) FileSize;\r
-    *(UINT32 *) PadFileHeader->Size &= 0xFF000000;\r
-    PadFileHeader->Attributes |= FFS_ATTRIB_LARGE_FILE;\r
-  } else {\r
-    *(UINT32 *) PadFileHeader->Size &= 0xFF000000;\r
-    *(UINT32 *) PadFileHeader->Size |= FileSize;\r
-  }\r
-\r
-  SetHeaderChecksum (PadFileHeader);\r
-  SetPadFileChecksum (PadFileHeader);\r
-\r
-  Offset          = (UINTN) (StartPos - FvDevice->CachedFv);\r
-\r
-  NumBytesWritten = HeaderSize;\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            Offset,\r
-            &NumBytesWritten,\r
-            (UINT8 *) PadFileHeader\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Step 2, then Mark header valid, since no data write,\r
-  // mark the data valid at the same time.\r
-  //\r
-  SetFileState (EFI_FILE_HEADER_VALID, PadFileHeader);\r
-  SetFileState (EFI_FILE_DATA_VALID, PadFileHeader);\r
-\r
-  Offset          = (UINTN) (StartPos - FvDevice->CachedFv);\r
-  StateOffset     = Offset + (UINT8 *) &PadFileHeader->State - (UINT8 *) PadFileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            StateOffset,\r
-            &NumBytesWritten,\r
-            &PadFileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    SetFileState (EFI_FILE_HEADER_VALID, PadFileHeader);\r
-    SetFileState (EFI_FILE_DATA_VALID, PadFileHeader);\r
-    return Status;\r
-  }\r
-  //\r
-  // Update Free Space Entry, since header is allocated\r
-  //\r
-  FreeSpaceEntry->Length -= Size;\r
-  FreeSpaceEntry->StartingAddress += Size;\r
-\r
-  //\r
-  // If successfully, insert an FfsFileEntry at the end of ffs file list\r
-  //\r
-  FfsFileEntry = AllocateZeroPool (sizeof (FFS_FILE_LIST_ENTRY));\r
-  ASSERT (FfsFileEntry != NULL);\r
-\r
-  FfsFileEntry->FfsHeader = (UINT8 *) (UINTN) StartPos;\r
-  InsertTailList (&FvDevice->FfsFileListHeader, &FfsFileEntry->Link);\r
-\r
-  *PadFileEntry             = FfsFileEntry;\r
-  FvDevice->CurrentFfsFile  = FfsFileEntry;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Fill pad file header within firmware cache.\r
-\r
-  @param PadFileHeader    The start of the Pad File Buffer.\r
-  @param PadFileLength    The length of the pad file including the header.\r
-\r
-**/\r
-VOID\r
-FvFillPadFile (\r
-  IN EFI_FFS_FILE_HEADER  *PadFileHeader,\r
-  IN UINTN                PadFileLength\r
-  )\r
-{\r
-  //\r
-  // Fill File Name Guid, here we assign a NULL-GUID to Pad files\r
-  //\r
-  ZeroMem (&PadFileHeader->Name, sizeof (EFI_GUID));\r
-\r
-  //\r
-  // Fill File Type, checksum(0), Attributes(0), Size\r
-  //\r
-  PadFileHeader->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
-  PadFileHeader->Attributes = 0;\r
-  if (PadFileLength > 0x00FFFFFF) {\r
-    ((EFI_FFS_FILE_HEADER2 *) PadFileHeader)->ExtendedSize = (UINT32) PadFileLength;\r
-    *(UINT32 *) PadFileHeader->Size &= 0xFF000000;\r
-    PadFileHeader->Attributes |= FFS_ATTRIB_LARGE_FILE;\r
-  } else {\r
-    *(UINT32 *) PadFileHeader->Size &= 0xFF000000;\r
-    *(UINT32 *) PadFileHeader->Size |= PadFileLength;\r
-  }\r
-\r
-  SetHeaderChecksum (PadFileHeader);\r
-  SetPadFileChecksum (PadFileHeader);\r
-\r
-  //\r
-  // Set File State to 0x00000111\r
-  //\r
-  SetFileState (EFI_FILE_HEADER_CONSTRUCTION, PadFileHeader);\r
-  SetFileState (EFI_FILE_HEADER_VALID, PadFileHeader);\r
-  SetFileState (EFI_FILE_DATA_VALID, PadFileHeader);\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Create entire FFS file.\r
-\r
-  @param FileHeader      Starting Address of a Buffer that hold the FFS File image.\r
-  @param FfsFileBuffer   The source buffer that contains the File Data.\r
-  @param BufferSize      The length of FfsFileBuffer.\r
-  @param ActualFileSize  Size of FFS file.\r
-  @param FileName        The Guid of Ffs File.\r
-  @param FileType        The type of the written Ffs File.\r
-  @param FileAttributes  The attributes of the written Ffs File.\r
-\r
-  @retval EFI_INVALID_PARAMETER  File type is not valid.\r
-  @retval EFI_SUCCESS            FFS file is successfully created.\r
-\r
-**/\r
-EFI_STATUS\r
-FvFillFfsFile (\r
-  OUT EFI_FFS_FILE_HEADER   *FileHeader,\r
-  IN UINT8                  *FfsFileBuffer,\r
-  IN UINTN                  BufferSize,\r
-  IN UINTN                  ActualFileSize,\r
-  IN EFI_GUID               *FileName,\r
-  IN EFI_FV_FILETYPE        FileType,\r
-  IN EFI_FV_FILE_ATTRIBUTES FileAttributes\r
-  )\r
-{\r
-  EFI_FFS_FILE_ATTRIBUTES TmpFileAttribute;\r
-  EFI_FFS_FILE_HEADER     *TmpFileHeader;\r
-\r
-  //\r
-  // File Type value 0x0E~0xE0 are reserved\r
-  //\r
-  if ((FileType > EFI_FV_FILETYPE_SMM_CORE) && (FileType < 0xE0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  TmpFileHeader = (EFI_FFS_FILE_HEADER *) FfsFileBuffer;\r
-  //\r
-  // First fill all fields ready in FfsFileBuffer\r
-  //\r
-  CopyGuid (&TmpFileHeader->Name, FileName);\r
-  TmpFileHeader->Type = FileType;\r
-\r
-  //\r
-  // Convert the FileAttributes to FFSFileAttributes\r
-  //\r
-  FvFileAttrib2FfsFileAttrib (FileAttributes, &TmpFileAttribute);\r
-\r
-  TmpFileHeader->Attributes = TmpFileAttribute;\r
-\r
-  if (ActualFileSize > 0x00FFFFFF) {\r
-    ((EFI_FFS_FILE_HEADER2 *) FileHeader)->ExtendedSize = (UINT32) ActualFileSize;\r
-    *(UINT32 *) FileHeader->Size &= 0xFF000000;\r
-    FileHeader->Attributes |= FFS_ATTRIB_LARGE_FILE;\r
-  } else {\r
-    *(UINT32 *) FileHeader->Size &= 0xFF000000;\r
-    *(UINT32 *) FileHeader->Size |= ActualFileSize;\r
-  }\r
-\r
-  SetHeaderChecksum (TmpFileHeader);\r
-  SetFileChecksum (TmpFileHeader, ActualFileSize);\r
-\r
-  SetFileState (EFI_FILE_HEADER_CONSTRUCTION, TmpFileHeader);\r
-  SetFileState (EFI_FILE_HEADER_VALID, TmpFileHeader);\r
-  SetFileState (EFI_FILE_DATA_VALID, TmpFileHeader);\r
-\r
-  //\r
-  // Copy data from FfsFileBuffer to FileHeader(cache)\r
-  //\r
-  CopyMem (FileHeader, FfsFileBuffer, BufferSize);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Fill some other extra space using 0xFF(Erase Value).\r
-\r
-  @param  ErasePolarity  Fv erase value.\r
-  @param  FileHeader     Point to the start of FFS File.\r
-  @param  ExtraLength    The pading length.\r
-\r
-**/\r
-VOID\r
-FvAdjustFfsFile (\r
-  IN  UINT8                 ErasePolarity,\r
-  IN  EFI_FFS_FILE_HEADER   *FileHeader,\r
-  IN  UINTN                 ExtraLength\r
-  )\r
-{\r
-  UINT8 *Ptr;\r
-  UINT8 PadingByte;\r
-\r
-  if (IS_FFS_FILE2 (FileHeader)) {\r
-    Ptr         = (UINT8 *) FileHeader + FFS_FILE2_SIZE (FileHeader);\r
-  } else {\r
-    Ptr         = (UINT8 *) FileHeader + FFS_FILE_SIZE (FileHeader);\r
-  }\r
-\r
-  if (ErasePolarity == 0) {\r
-    PadingByte = 0;\r
-  } else {\r
-    PadingByte = 0xFF;\r
-  }\r
-  //\r
-  // Fill the non-used space with Padding Byte\r
-  //\r
-  SetMem (Ptr, ExtraLength, PadingByte);\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Free File List entry pointed by FileListHead.\r
-\r
-  @param FileListHeader   FileListEntry Header.\r
-\r
-**/\r
-VOID\r
-FreeFileList (\r
-  IN  LIST_ENTRY  *FileListHead\r
-  )\r
-{\r
-  FFS_FILE_LIST_ENTRY *FfsFileEntry;\r
-  LIST_ENTRY      *NextEntry;\r
-\r
-  FfsFileEntry = (FFS_FILE_LIST_ENTRY *) (FileListHead->ForwardLink);\r
-\r
-  //\r
-  // Loop the whole list entry to free resources\r
-  //\r
-  while (&FfsFileEntry->Link != FileListHead) {\r
-    NextEntry = (&FfsFileEntry->Link)->ForwardLink;\r
-    FreePool (FfsFileEntry);\r
-    FfsFileEntry = (FFS_FILE_LIST_ENTRY *) NextEntry;\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Create a new file within a PAD file area.\r
-\r
-  @param FvDevice        Firmware Volume Device.\r
-  @param FfsFileBuffer   A buffer that holds an FFS file,(it contains a File Header which is in init state).\r
-  @param BufferSize      The size of FfsFileBuffer.\r
-  @param ActualFileSize  The actual file length, it may not be multiples of 8.\r
-  @param FileName        The FFS File Name.\r
-  @param FileType        The FFS File Type.\r
-  @param FileAttributes  The Attributes of the FFS File to be created.\r
-\r
-  @retval EFI_SUCCESS           Successfully create a new file within the found PAD file area.\r
-  @retval EFI_OUT_OF_RESOURCES  No suitable PAD file is found.\r
-  @retval other errors          New file is created failed.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCreateNewFileInsidePadFile (\r
-  IN  FV_DEVICE               *FvDevice,\r
-  IN  UINT8                   *FfsFileBuffer,\r
-  IN  UINTN                   BufferSize,\r
-  IN  UINTN                   ActualFileSize,\r
-  IN  EFI_GUID                *FileName,\r
-  IN  EFI_FV_FILETYPE         FileType,\r
-  IN  EFI_FV_FILE_ATTRIBUTES  FileAttributes\r
-  )\r
-{\r
-  UINTN                               RequiredAlignment;\r
-  FFS_FILE_LIST_ENTRY                 *PadFileEntry;\r
-  EFI_STATUS                          Status;\r
-  UINTN                               PadAreaLength;\r
-  UINTN                               PadSize;\r
-  EFI_FFS_FILE_HEADER                 *FileHeader;\r
-  EFI_FFS_FILE_HEADER                 *OldPadFileHeader;\r
-  EFI_FFS_FILE_HEADER                 *PadFileHeader;\r
-  EFI_FFS_FILE_HEADER                 *TailPadFileHeader;\r
-  UINTN                               StateOffset;\r
-  UINTN                               Offset;\r
-  UINTN                               NumBytesWritten;\r
-  UINT8                               *StartPos;\r
-  LIST_ENTRY                          NewFileList;\r
-  FFS_FILE_LIST_ENTRY                 *NewFileListEntry;\r
-  FFS_FILE_LIST_ENTRY                 *FfsEntry;\r
-  FFS_FILE_LIST_ENTRY                 *NextFfsEntry;\r
-\r
-  //\r
-  // First get the required alignment from the File Attributes\r
-  //\r
-  RequiredAlignment = GetRequiredAlignment (FileAttributes);\r
-\r
-  //\r
-  // Find a suitable PAD File\r
-  //\r
-  Status = FvLocatePadFile (\r
-            FvDevice,\r
-            BufferSize,\r
-            RequiredAlignment,\r
-            &PadSize,\r
-            &PadFileEntry\r
-            );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  OldPadFileHeader = (EFI_FFS_FILE_HEADER *) PadFileEntry->FfsHeader;\r
-\r
-  //\r
-  // Step 1: Update Pad File Header\r
-  //\r
-  SetFileState (EFI_FILE_MARKED_FOR_UPDATE, OldPadFileHeader);\r
-\r
-  StartPos = PadFileEntry->FfsHeader;\r
-\r
-  Offset          = (UINTN) (StartPos - FvDevice->CachedFv);\r
-  StateOffset     = Offset + (UINT8 *) &OldPadFileHeader->State - (UINT8 *) OldPadFileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            StateOffset,\r
-            &NumBytesWritten,\r
-            &OldPadFileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    SetFileState (EFI_FILE_HEADER_CONSTRUCTION, OldPadFileHeader);\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Step 2: Update Pad area\r
-  //\r
-  InitializeListHead (&NewFileList);\r
-\r
-  if (IS_FFS_FILE2 (OldPadFileHeader)) {\r
-    PadAreaLength = FFS_FILE2_SIZE (OldPadFileHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
-    PadFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) OldPadFileHeader + sizeof (EFI_FFS_FILE_HEADER2));\r
-  } else {\r
-    PadAreaLength = FFS_FILE_SIZE (OldPadFileHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
-    PadFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) OldPadFileHeader + sizeof (EFI_FFS_FILE_HEADER));\r
-  }\r
-\r
-  if (PadSize != 0) {\r
-    //\r
-    // Insert a PAD file before to achieve required alignment\r
-    //\r
-    FvFillPadFile (PadFileHeader, PadSize);\r
-    NewFileListEntry            = AllocatePool (sizeof (FFS_FILE_LIST_ENTRY));\r
-    ASSERT (NewFileListEntry   != NULL);\r
-    NewFileListEntry->FfsHeader = (UINT8 *) PadFileHeader;\r
-    InsertTailList (&NewFileList, &NewFileListEntry->Link);\r
-  }\r
-\r
-  FileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) PadFileHeader + PadSize);\r
-\r
-  Status = FvFillFfsFile (\r
-            FileHeader,\r
-            FfsFileBuffer,\r
-            BufferSize,\r
-            ActualFileSize,\r
-            FileName,\r
-            FileType,\r
-            FileAttributes\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    FreeFileList (&NewFileList);\r
-    return Status;\r
-  }\r
-\r
-  NewFileListEntry            = AllocatePool (sizeof (FFS_FILE_LIST_ENTRY));\r
-  ASSERT (NewFileListEntry   != NULL);\r
-\r
-  NewFileListEntry->FfsHeader = (UINT8 *) FileHeader;\r
-  InsertTailList (&NewFileList, &NewFileListEntry->Link);\r
-\r
-  FvDevice->CurrentFfsFile = NewFileListEntry;\r
-\r
-  if (PadAreaLength > (BufferSize + PadSize)) {\r
-    if ((PadAreaLength - BufferSize - PadSize) >= sizeof (EFI_FFS_FILE_HEADER)) {\r
-      //\r
-      // we can insert another PAD file\r
-      //\r
-      TailPadFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FileHeader + BufferSize);\r
-      FvFillPadFile (TailPadFileHeader, PadAreaLength - BufferSize - PadSize);\r
-\r
-      NewFileListEntry            = AllocatePool (sizeof (FFS_FILE_LIST_ENTRY));\r
-      ASSERT (NewFileListEntry   != NULL);\r
-\r
-      NewFileListEntry->FfsHeader = (UINT8 *) TailPadFileHeader;\r
-      InsertTailList (&NewFileList, &NewFileListEntry->Link);\r
-    } else {\r
-      //\r
-      // because left size cannot hold another PAD file header,\r
-      // adjust the writing file size (just in cache)\r
-      //\r
-      FvAdjustFfsFile (\r
-        FvDevice->ErasePolarity,\r
-        FileHeader,\r
-        PadAreaLength - BufferSize - PadSize\r
-        );\r
-    }\r
-  }\r
-  //\r
-  // Start writing to FV\r
-  //\r
-  if (IS_FFS_FILE2 (OldPadFileHeader)) {\r
-    StartPos = (UINT8 *) OldPadFileHeader + sizeof (EFI_FFS_FILE_HEADER2);\r
-  } else {\r
-    StartPos = (UINT8 *) OldPadFileHeader + sizeof (EFI_FFS_FILE_HEADER);\r
-  }\r
-\r
-  Offset          = (UINTN) (StartPos - FvDevice->CachedFv);\r
-\r
-  NumBytesWritten = PadAreaLength;\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            Offset,\r
-            &NumBytesWritten,\r
-            StartPos\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    FreeFileList (&NewFileList);\r
-    FvDevice->CurrentFfsFile = NULL;\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Step 3: Mark Pad file header as EFI_FILE_HEADER_INVALID\r
-  //\r
-  SetFileState (EFI_FILE_HEADER_INVALID, OldPadFileHeader);\r
-\r
-  StartPos = PadFileEntry->FfsHeader;\r
-\r
-  Offset          = (UINTN) (StartPos - FvDevice->CachedFv);\r
-  StateOffset     = Offset + (UINT8 *) &OldPadFileHeader->State - (UINT8 *) OldPadFileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            StateOffset,\r
-            &NumBytesWritten,\r
-            &OldPadFileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    SetFileState (EFI_FILE_HEADER_INVALID, OldPadFileHeader);\r
-    FreeFileList (&NewFileList);\r
-    FvDevice->CurrentFfsFile = NULL;\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // If all successfully, update FFS_FILE_LIST\r
-  //\r
-\r
-  //\r
-  // Delete old pad file entry\r
-  //\r
-  FfsEntry      = (FFS_FILE_LIST_ENTRY *) PadFileEntry->Link.BackLink;\r
-  NextFfsEntry  = (FFS_FILE_LIST_ENTRY *) PadFileEntry->Link.ForwardLink;\r
-\r
-  FreePool (PadFileEntry);\r
-\r
-  FfsEntry->Link.ForwardLink          = NewFileList.ForwardLink;\r
-  (NewFileList.ForwardLink)->BackLink = &FfsEntry->Link;\r
-  NextFfsEntry->Link.BackLink         = NewFileList.BackLink;\r
-  (NewFileList.BackLink)->ForwardLink = &NextFfsEntry->Link;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Free all FfsBuffer.\r
-\r
-  @param NumOfFiles      Number of FfsBuffer.\r
-  @param FfsBuffer       An array of pointer to an FFS File Buffer\r
-\r
-**/\r
-VOID\r
-FreeFfsBuffer (\r
-  IN UINTN    NumOfFiles,\r
-  IN UINT8    **FfsBuffer\r
-  )\r
-{\r
-  UINTN Index;\r
-  for (Index = 0; Index < NumOfFiles; Index++) {\r
-    if (FfsBuffer[Index] != NULL) {\r
-      FreePool (FfsBuffer[Index]);\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Create multiple files within a PAD File area.\r
-\r
-  @param FvDevice        Firmware Volume Device.\r
-  @param PadFileEntry    The pad file entry to be written in.\r
-  @param NumOfFiles      Total File number to be written.\r
-  @param BufferSize      The array of buffer size of each FfsBuffer.\r
-  @param ActualFileSize  The array of actual file size.\r
-  @param PadSize         The array of leading pad file size for each FFS File\r
-  @param FfsBuffer       The array of Ffs Buffer pointer.\r
-  @param FileData        The array of EFI_FV_WRITE_FILE_DATA structure,\r
-                         used to get name, attributes, type, etc.\r
-\r
-  @retval EFI_SUCCESS           Add the input multiple files into PAD file area.\r
-  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.\r
-  @retval other error           Files can't be added into PAD file area.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCreateMultipleFilesInsidePadFile (\r
-  IN FV_DEVICE              *FvDevice,\r
-  IN FFS_FILE_LIST_ENTRY    *PadFileEntry,\r
-  IN UINTN                  NumOfFiles,\r
-  IN UINTN                  *BufferSize,\r
-  IN UINTN                  *ActualFileSize,\r
-  IN UINTN                  *PadSize,\r
-  IN UINT8                  **FfsBuffer,\r
-  IN EFI_FV_WRITE_FILE_DATA *FileData\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_FFS_FILE_HEADER                 *OldPadFileHeader;\r
-  UINTN                               Index;\r
-  EFI_FFS_FILE_HEADER                 *PadFileHeader;\r
-  EFI_FFS_FILE_HEADER                 *FileHeader;\r
-  EFI_FFS_FILE_HEADER                 *TailPadFileHeader;\r
-  UINTN                               TotalSize;\r
-  UINTN                               PadAreaLength;\r
-  LIST_ENTRY                          NewFileList;\r
-  FFS_FILE_LIST_ENTRY                 *NewFileListEntry;\r
-  UINTN                               Offset;\r
-  UINTN                               NumBytesWritten;\r
-  UINT8                               *StartPos;\r
-  FFS_FILE_LIST_ENTRY                 *FfsEntry;\r
-  FFS_FILE_LIST_ENTRY                 *NextFfsEntry;\r
-\r
-  InitializeListHead (&NewFileList);\r
-\r
-  NewFileListEntry  = NULL;\r
-\r
-  OldPadFileHeader  = (EFI_FFS_FILE_HEADER *) PadFileEntry->FfsHeader;\r
-  if (IS_FFS_FILE2 (OldPadFileHeader)) {\r
-    PadAreaLength = FFS_FILE2_SIZE (OldPadFileHeader) - sizeof (EFI_FFS_FILE_HEADER2);\r
-  } else {\r
-    PadAreaLength = FFS_FILE_SIZE (OldPadFileHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
-  }\r
-\r
-  Status = UpdateHeaderBit (\r
-            FvDevice,\r
-            OldPadFileHeader,\r
-            EFI_FILE_MARKED_FOR_UPDATE\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Update PAD area\r
-  //\r
-  TotalSize     = 0;\r
-  if (IS_FFS_FILE2 (OldPadFileHeader)) {\r
-    PadFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) OldPadFileHeader + sizeof (EFI_FFS_FILE_HEADER2));\r
-  } else {\r
-    PadFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) OldPadFileHeader + sizeof (EFI_FFS_FILE_HEADER));\r
-  }\r
-  FileHeader    = PadFileHeader;\r
-\r
-  for (Index = 0; Index < NumOfFiles; Index++) {\r
-    if (PadSize[Index] != 0) {\r
-      FvFillPadFile (PadFileHeader, PadSize[Index]);\r
-      NewFileListEntry = AllocatePool (sizeof (FFS_FILE_LIST_ENTRY));\r
-      if (NewFileListEntry == NULL) {\r
-        FreeFileList (&NewFileList);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      NewFileListEntry->FfsHeader = (UINT8 *) PadFileHeader;\r
-      InsertTailList (&NewFileList, &NewFileListEntry->Link);\r
-    }\r
-\r
-    FileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) PadFileHeader + PadSize[Index]);\r
-    Status = FvFillFfsFile (\r
-              FileHeader,\r
-              FfsBuffer[Index],\r
-              BufferSize[Index],\r
-              ActualFileSize[Index],\r
-              FileData[Index].NameGuid,\r
-              FileData[Index].Type,\r
-              FileData[Index].FileAttributes\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      FreeFileList (&NewFileList);\r
-      return Status;\r
-    }\r
-\r
-    NewFileListEntry = AllocatePool (sizeof (FFS_FILE_LIST_ENTRY));\r
-    if (NewFileListEntry == NULL) {\r
-      FreeFileList (&NewFileList);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    NewFileListEntry->FfsHeader = (UINT8 *) FileHeader;\r
-    InsertTailList (&NewFileList, &NewFileListEntry->Link);\r
-\r
-    PadFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FileHeader + BufferSize[Index]);\r
-    TotalSize += PadSize[Index];\r
-    TotalSize += BufferSize[Index];\r
-  }\r
-\r
-  FvDevice->CurrentFfsFile = NewFileListEntry;\r
-  //\r
-  // Maybe we need a tail pad file\r
-  //\r
-  if (PadAreaLength > TotalSize) {\r
-    if ((PadAreaLength - TotalSize) >= sizeof (EFI_FFS_FILE_HEADER)) {\r
-      //\r
-      // we can insert another PAD file\r
-      //\r
-      TailPadFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FileHeader + BufferSize[NumOfFiles - 1]);\r
-      FvFillPadFile (TailPadFileHeader, PadAreaLength - TotalSize);\r
-\r
-      NewFileListEntry = AllocatePool (sizeof (FFS_FILE_LIST_ENTRY));\r
-      if (NewFileListEntry == NULL) {\r
-        FreeFileList (&NewFileList);\r
-        FvDevice->CurrentFfsFile = NULL;\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      NewFileListEntry->FfsHeader = (UINT8 *) TailPadFileHeader;\r
-      InsertTailList (&NewFileList, &NewFileListEntry->Link);\r
-    } else {\r
-      //\r
-      // because left size cannot hold another PAD file header,\r
-      // adjust the writing file size (just in cache)\r
-      //\r
-      FvAdjustFfsFile (\r
-        FvDevice->ErasePolarity,\r
-        FileHeader,\r
-        PadAreaLength - TotalSize\r
-        );\r
-    }\r
-  }\r
-  //\r
-  // Start writing to FV\r
-  //\r
-  if (IS_FFS_FILE2 (OldPadFileHeader)) {\r
-    StartPos = (UINT8 *) OldPadFileHeader + sizeof (EFI_FFS_FILE_HEADER2);\r
-  } else {\r
-    StartPos = (UINT8 *) OldPadFileHeader + sizeof (EFI_FFS_FILE_HEADER);\r
-  }\r
-\r
-  Offset          = (UINTN) (StartPos - FvDevice->CachedFv);\r
-\r
-  NumBytesWritten = PadAreaLength;\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            Offset,\r
-            &NumBytesWritten,\r
-            StartPos\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    FreeFileList (&NewFileList);\r
-    FvDevice->CurrentFfsFile = NULL;\r
-    return Status;\r
-  }\r
-\r
-  Status = UpdateHeaderBit (\r
-            FvDevice,\r
-            OldPadFileHeader,\r
-            EFI_FILE_HEADER_INVALID\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    FreeFileList (&NewFileList);\r
-    FvDevice->CurrentFfsFile = NULL;\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Update File List Link\r
-  //\r
-\r
-  //\r
-  // First delete old pad file entry\r
-  //\r
-  FfsEntry      = (FFS_FILE_LIST_ENTRY *) PadFileEntry->Link.BackLink;\r
-  NextFfsEntry  = (FFS_FILE_LIST_ENTRY *) PadFileEntry->Link.ForwardLink;\r
-\r
-  FreePool (PadFileEntry);\r
-\r
-  FfsEntry->Link.ForwardLink          = NewFileList.ForwardLink;\r
-  (NewFileList.ForwardLink)->BackLink = &FfsEntry->Link;\r
-  NextFfsEntry->Link.BackLink         = NewFileList.BackLink;\r
-  (NewFileList.BackLink)->ForwardLink = &NextFfsEntry->Link;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Create multiple files within the Free Space.\r
-\r
-  @param FvDevice        Firmware Volume Device.\r
-  @param FreeSpaceEntry  Indicating in which Free Space(Cache) the multiple files will be inserted.\r
-  @param NumOfFiles      Total File number to be written.\r
-  @param BufferSize      The array of buffer size of each FfsBuffer.\r
-  @param ActualFileSize  The array of actual file size.\r
-  @param PadSize         The array of leading pad file size for each FFS File\r
-  @param FfsBuffer       The array of Ffs Buffer pointer.\r
-  @param FileData        The array of EFI_FV_WRITE_FILE_DATA structure,\r
-                         used to get name, attributes, type, etc.\r
-\r
-  @retval EFI_SUCCESS           Add the input multiple files into PAD file area.\r
-  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.\r
-  @retval other error           Files can't be added into PAD file area.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCreateMultipleFilesInsideFreeSpace (\r
-  IN FV_DEVICE              *FvDevice,\r
-  IN FREE_SPACE_ENTRY       *FreeSpaceEntry,\r
-  IN UINTN                  NumOfFiles,\r
-  IN UINTN                  *BufferSize,\r
-  IN UINTN                  *ActualFileSize,\r
-  IN UINTN                  *PadSize,\r
-  IN UINT8                  **FfsBuffer,\r
-  IN EFI_FV_WRITE_FILE_DATA *FileData\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  UINTN                               Index;\r
-  EFI_FFS_FILE_HEADER                 *PadFileHeader;\r
-  EFI_FFS_FILE_HEADER                 *FileHeader;\r
-  UINTN                               TotalSize;\r
-  LIST_ENTRY                          NewFileList;\r
-  FFS_FILE_LIST_ENTRY                 *NewFileListEntry;\r
-  UINTN                               Offset;\r
-  UINTN                               NumBytesWritten;\r
-  UINT8                               *StartPos;\r
-\r
-  InitializeListHead (&NewFileList);\r
-\r
-  NewFileListEntry  = NULL;\r
-\r
-  TotalSize     = 0;\r
-  StartPos      = FreeSpaceEntry->StartingAddress;\r
-  PadFileHeader = (EFI_FFS_FILE_HEADER *) StartPos;\r
-  FileHeader    = PadFileHeader;\r
-\r
-  for (Index = 0; Index < NumOfFiles; Index++) {\r
-    if (PadSize[Index] != 0) {\r
-      FvFillPadFile (PadFileHeader, PadSize[Index]);\r
-      NewFileListEntry = AllocatePool (sizeof (FFS_FILE_LIST_ENTRY));\r
-      if (NewFileListEntry == NULL) {\r
-        FreeFileList (&NewFileList);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      NewFileListEntry->FfsHeader = (UINT8 *) PadFileHeader;\r
-      InsertTailList (&NewFileList, &NewFileListEntry->Link);\r
-    }\r
-\r
-    FileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) PadFileHeader + PadSize[Index]);\r
-    Status = FvFillFfsFile (\r
-              FileHeader,\r
-              FfsBuffer[Index],\r
-              BufferSize[Index],\r
-              ActualFileSize[Index],\r
-              FileData[Index].NameGuid,\r
-              FileData[Index].Type,\r
-              FileData[Index].FileAttributes\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      FreeFileList (&NewFileList);\r
-      return Status;\r
-    }\r
-\r
-    NewFileListEntry = AllocatePool (sizeof (FFS_FILE_LIST_ENTRY));\r
-    if (NewFileListEntry == NULL) {\r
-      FreeFileList (&NewFileList);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    NewFileListEntry->FfsHeader = (UINT8 *) FileHeader;\r
-    InsertTailList (&NewFileList, &NewFileListEntry->Link);\r
-\r
-    PadFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FileHeader + BufferSize[Index]);\r
-    TotalSize += PadSize[Index];\r
-    TotalSize += BufferSize[Index];\r
-  }\r
-\r
-  if (FreeSpaceEntry->Length < TotalSize) {\r
-    FreeFileList (&NewFileList);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  FvDevice->CurrentFfsFile = NewFileListEntry;\r
-\r
-  //\r
-  // Start writing to FV\r
-  //\r
-  Offset          = (UINTN) (StartPos - FvDevice->CachedFv);\r
-\r
-  NumBytesWritten = TotalSize;\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            Offset,\r
-            &NumBytesWritten,\r
-            StartPos\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    FreeFileList (&NewFileList);\r
-    FvDevice->CurrentFfsFile = NULL;\r
-    return Status;\r
-  }\r
-\r
-  FreeSpaceEntry->Length -= TotalSize;\r
-  FreeSpaceEntry->StartingAddress += TotalSize;\r
-\r
-  NewFileListEntry = (FFS_FILE_LIST_ENTRY *) (NewFileList.ForwardLink);\r
-\r
-  while (NewFileListEntry != (FFS_FILE_LIST_ENTRY *) &NewFileList) {\r
-    InsertTailList (&FvDevice->FfsFileListHeader, &NewFileListEntry->Link);\r
-    NewFileListEntry = (FFS_FILE_LIST_ENTRY *) (NewFileListEntry->Link.ForwardLink);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write multiple files into FV in reliable method.\r
-\r
-  @param FvDevice        Firmware Volume Device.\r
-  @param NumOfFiles      Total File number to be written.\r
-  @param FileData        The array of EFI_FV_WRITE_FILE_DATA structure,\r
-                         used to get name, attributes, type, etc\r
-  @param FileOperation   The array of operation for each file.\r
-\r
-  @retval EFI_SUCCESS            Files are added into FV.\r
-  @retval EFI_OUT_OF_RESOURCES   No enough free PAD files to add the input files.\r
-  @retval EFI_INVALID_PARAMETER  File number is less than or equal to 1.\r
-  @retval EFI_UNSUPPORTED        File number exceeds the supported max numbers of files.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCreateMultipleFiles (\r
-  IN  FV_DEVICE               *FvDevice,\r
-  IN  UINTN                   NumOfFiles,\r
-  IN  EFI_FV_WRITE_FILE_DATA  *FileData,\r
-  IN  BOOLEAN                 *FileOperation\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  UINT8                         *FfsBuffer[MAX_FILES];\r
-  UINTN                         Index1;\r
-  UINTN                         Index2;\r
-  UINTN                         BufferSize[MAX_FILES];\r
-  UINTN                         ActualFileSize[MAX_FILES];\r
-  UINTN                         RequiredAlignment[MAX_FILES];\r
-  UINTN                         PadSize[MAX_FILES];\r
-  FFS_FILE_LIST_ENTRY           *PadFileEntry;\r
-  UINTN                         TotalSizeNeeded;\r
-  FREE_SPACE_ENTRY              *FreeSpaceEntry;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
-  UINTN                         Key;\r
-  EFI_GUID                      FileNameGuid;\r
-  EFI_FV_FILETYPE               OldFileType;\r
-  EFI_FV_FILE_ATTRIBUTES        OldFileAttributes;\r
-  UINTN                         OldFileSize;\r
-  FFS_FILE_LIST_ENTRY           *OldFfsFileEntry[MAX_FILES];\r
-  EFI_FFS_FILE_HEADER           *OldFileHeader[MAX_FILES];\r
-  BOOLEAN                       IsCreateFile;\r
-  UINTN                         HeaderSize;\r
-\r
-  //\r
-  // To use this function, we must ensure that the NumOfFiles is great\r
-  // than 1\r
-  //\r
-  if (NumOfFiles <= 1) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (NumOfFiles > MAX_FILES) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Fv = &FvDevice->Fv;\r
-\r
-  SetMem (FfsBuffer, NumOfFiles, 0);\r
-  SetMem (RequiredAlignment, NumOfFiles, 8);\r
-  SetMem (PadSize, NumOfFiles, 0);\r
-  ZeroMem (OldFfsFileEntry, sizeof (OldFfsFileEntry));\r
-  ZeroMem (OldFileHeader, sizeof (OldFileHeader));\r
-\r
-  //\r
-  // Adjust file size\r
-  //\r
-  for (Index1 = 0; Index1 < NumOfFiles; Index1++) {\r
-    HeaderSize = sizeof (EFI_FFS_FILE_HEADER);\r
-    ActualFileSize[Index1] = FileData[Index1].BufferSize + HeaderSize;\r
-    if (ActualFileSize[Index1] > 0x00FFFFFF) {\r
-      HeaderSize = sizeof (EFI_FFS_FILE_HEADER2);\r
-      ActualFileSize[Index1] = FileData[Index1].BufferSize + HeaderSize;\r
-    }\r
-    BufferSize[Index1]     = ActualFileSize[Index1];\r
-\r
-    if (BufferSize[Index1] == HeaderSize) {\r
-      //\r
-      // clear file attributes, zero-length file does not have any attributes\r
-      //\r
-      FileData[Index1].FileAttributes = 0;\r
-    }\r
-\r
-    while ((BufferSize[Index1] & 0x07) != 0) {\r
-      BufferSize[Index1]++;\r
-    }\r
-\r
-    FfsBuffer[Index1] = AllocateZeroPool (BufferSize[Index1]);\r
-\r
-    //\r
-    // Copy File Data into FileBuffer\r
-    //\r
-    CopyMem (\r
-      FfsBuffer[Index1] + HeaderSize,\r
-      FileData[Index1].Buffer,\r
-      FileData[Index1].BufferSize\r
-      );\r
-\r
-    if (FvDevice->ErasePolarity == 1) {\r
-      for (Index2 = 0; Index2 < HeaderSize; Index2++) {\r
-        FfsBuffer[Index1][Index2] = (UINT8)~FfsBuffer[Index1][Index2];\r
-      }\r
-    }\r
-\r
-    if ((FileData[Index1].FileAttributes & EFI_FV_FILE_ATTRIB_ALIGNMENT) != 0) {\r
-      RequiredAlignment[Index1] = GetRequiredAlignment (FileData[Index1].FileAttributes);\r
-    }\r
-    //\r
-    // If update file, mark the original file header to\r
-    // EFI_FILE_MARKED_FOR_UPDATE\r
-    //\r
-    IsCreateFile = FileOperation[Index1];\r
-    if (!IsCreateFile) {\r
-\r
-      Key = 0;\r
-      do {\r
-        OldFileType = 0;\r
-        Status = Fv->GetNextFile (\r
-                      Fv,\r
-                      &Key,\r
-                      &OldFileType,\r
-                      &FileNameGuid,\r
-                      &OldFileAttributes,\r
-                      &OldFileSize\r
-                      );\r
-        if (EFI_ERROR (Status)) {\r
-          FreeFfsBuffer (NumOfFiles, FfsBuffer);\r
-          return Status;\r
-        }\r
-      } while (!CompareGuid (&FileNameGuid, FileData[Index1].NameGuid));\r
-\r
-      //\r
-      // Get FfsFileEntry from the search key\r
-      //\r
-      OldFfsFileEntry[Index1]  = (FFS_FILE_LIST_ENTRY *) Key;\r
-      OldFileHeader[Index1]    = (EFI_FFS_FILE_HEADER *) OldFfsFileEntry[Index1]->FfsHeader;\r
-      Status = UpdateHeaderBit (\r
-                FvDevice,\r
-                OldFileHeader[Index1],\r
-                EFI_FILE_MARKED_FOR_UPDATE\r
-                );\r
-      if (EFI_ERROR (Status)) {\r
-        FreeFfsBuffer (NumOfFiles, FfsBuffer);\r
-        return Status;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // First to search a suitable pad file that can hold so\r
-  // many files\r
-  //\r
-  Status = FvSearchSuitablePadFile (\r
-            FvDevice,\r
-            NumOfFiles,\r
-            BufferSize,\r
-            RequiredAlignment,\r
-            PadSize,\r
-            &TotalSizeNeeded,\r
-            &PadFileEntry\r
-            );\r
-\r
-  if (Status == EFI_NOT_FOUND) {\r
-    //\r
-    // Try to find a free space that can hold these files\r
-    //\r
-    Status = FvSearchSuitableFreeSpace (\r
-              FvDevice,\r
-              NumOfFiles,\r
-              BufferSize,\r
-              RequiredAlignment,\r
-              PadSize,\r
-              &TotalSizeNeeded,\r
-              &FreeSpaceEntry\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      FreeFfsBuffer (NumOfFiles, FfsBuffer);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    Status = FvCreateMultipleFilesInsideFreeSpace (\r
-              FvDevice,\r
-              FreeSpaceEntry,\r
-              NumOfFiles,\r
-              BufferSize,\r
-              ActualFileSize,\r
-              PadSize,\r
-              FfsBuffer,\r
-              FileData\r
-              );\r
-\r
-  } else {\r
-    //\r
-    // Create multiple files inside such a pad file\r
-    // to achieve lock-step update\r
-    //\r
-    Status = FvCreateMultipleFilesInsidePadFile (\r
-              FvDevice,\r
-              PadFileEntry,\r
-              NumOfFiles,\r
-              BufferSize,\r
-              ActualFileSize,\r
-              PadSize,\r
-              FfsBuffer,\r
-              FileData\r
-              );\r
-  }\r
-\r
-  FreeFfsBuffer (NumOfFiles, FfsBuffer);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Delete those updated files\r
-  //\r
-  for (Index1 = 0; Index1 < NumOfFiles; Index1++) {\r
-    IsCreateFile = FileOperation[Index1];\r
-    if (!IsCreateFile && OldFfsFileEntry[Index1] != NULL) {\r
-      (OldFfsFileEntry[Index1]->Link.BackLink)->ForwardLink  = OldFfsFileEntry[Index1]->Link.ForwardLink;\r
-      (OldFfsFileEntry[Index1]->Link.ForwardLink)->BackLink  = OldFfsFileEntry[Index1]->Link.BackLink;\r
-      FreePool (OldFfsFileEntry[Index1]);\r
-    }\r
-  }\r
-  //\r
-  // Set those files' state to EFI_FILE_DELETED\r
-  //\r
-  for (Index1 = 0; Index1 < NumOfFiles; Index1++) {\r
-    IsCreateFile = FileOperation[Index1];\r
-    if (!IsCreateFile && OldFileHeader[Index1] != NULL) {\r
-      Status = UpdateHeaderBit (FvDevice, OldFileHeader[Index1], EFI_FILE_DELETED);\r
-      if (EFI_ERROR (Status)) {\r
-        return Status;\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVol.c b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVol.c
deleted file mode 100644 (file)
index 553fa39..0000000
+++ /dev/null
@@ -1,824 +0,0 @@
-/** @file\r
-\r
-  Firmware File System driver that produce full Firmware Volume2 protocol.\r
-  Layers on top of Firmware Block protocol to produce a file abstraction\r
-  of FV based files.\r
-\r
-  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "FwVolDriver.h"\r
-\r
-#define KEYSIZE sizeof (UINTN)\r
-\r
-/**\r
-  Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and\r
-  copy the real length volume header into it.\r
-\r
-  @param  Fvb                   The FW_VOL_BLOCK_PROTOCOL instance from which to\r
-                                read the volume header\r
-  @param  FwVolHeader           Pointer to pointer to allocated buffer in which\r
-                                the volume header is returned.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  No enough buffer could be allocated.\r
-  @retval EFI_SUCCESS           Successfully read volume header to the allocated\r
-                                buffer.\r
-  @retval EFI_ACCESS_DENIED     Read status of FV is not enabled.\r
-  @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
-                                the file system could not be understood.\r
-**/\r
-EFI_STATUS\r
-GetFwVolHeader (\r
-  IN     EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *Fvb,\r
-  OUT EFI_FIRMWARE_VOLUME_HEADER                **FwVolHeader\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_FIRMWARE_VOLUME_HEADER  TempFvh;\r
-  EFI_FVB_ATTRIBUTES_2        FvbAttributes;\r
-  UINTN                       FvhLength;\r
-  EFI_PHYSICAL_ADDRESS        BaseAddress;\r
-\r
-  //\r
-  // Determine the real length of FV header\r
-  //\r
-  Status = Fvb->GetAttributes (\r
-                  Fvb,\r
-                  &FvbAttributes\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if ((FvbAttributes & EFI_FVB2_READ_STATUS) == 0) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-\r
-  //\r
-  // Just avoid compiling warning\r
-  //\r
-  BaseAddress = 0;\r
-  FvhLength   = sizeof (EFI_FIRMWARE_VOLUME_HEADER);\r
-\r
-  //\r
-  // memory-mapped FV and non memory-mapped has different ways to read\r
-  //\r
-  if ((FvbAttributes & EFI_FVB2_MEMORY_MAPPED) != 0) {\r
-    Status = Fvb->GetPhysicalAddress (\r
-                    Fvb,\r
-                    &BaseAddress\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    CopyMem (&TempFvh, (VOID *) (UINTN) BaseAddress, FvhLength);\r
-  } else {\r
-    Status = Fvb->Read (\r
-                    Fvb,\r
-                    0,\r
-                    0,\r
-                    &FvhLength,\r
-                    (UINT8 *) &TempFvh\r
-                    );\r
-  }\r
-\r
-  //\r
-  // Validate FV Header signature, if not as expected, continue.\r
-  //\r
-  if (TempFvh.Signature != EFI_FVH_SIGNATURE) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Check to see that the file system is indeed formatted in a way we can\r
-  // understand it...\r
-  //\r
-  if ((!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&\r
-      (!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *FwVolHeader = AllocatePool (TempFvh.HeaderLength);\r
-  if (*FwVolHeader == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Read the whole header\r
-  //\r
-  if ((FvbAttributes & EFI_FVB2_MEMORY_MAPPED) != 0) {\r
-    CopyMem (*FwVolHeader, (VOID *) (UINTN) BaseAddress, TempFvh.HeaderLength);\r
-  } else {\r
-    //\r
-    // Assumed the first block is bigger than the length of Fv headder\r
-    //\r
-    FvhLength = TempFvh.HeaderLength;\r
-    Status = Fvb->Read (\r
-                    Fvb,\r
-                    0,\r
-                    0,\r
-                    &FvhLength,\r
-                    (UINT8 *) *FwVolHeader\r
-                    );\r
-    //\r
-    // Check whether Read successes.\r
-    //\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (*FwVolHeader);\r
-      *FwVolHeader = NULL;\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Free FvDevice resource when error happens.\r
-\r
-  @param FvDevice   Pointer to the FvDevice to be freed.\r
-**/\r
-VOID\r
-FreeFvDeviceResource (\r
-  IN FV_DEVICE  *FvDevice\r
-  )\r
-{\r
-  LBA_ENTRY           *LbaEntry;\r
-  FREE_SPACE_ENTRY    *FreeSpaceEntry;\r
-  FFS_FILE_LIST_ENTRY *FfsFileEntry;\r
-  LIST_ENTRY      *NextEntry;\r
-\r
-  //\r
-  // Free LAB Entry\r
-  //\r
-  LbaEntry = (LBA_ENTRY *) FvDevice->LbaHeader.ForwardLink;\r
-  while (&LbaEntry->Link != &FvDevice->LbaHeader) {\r
-    NextEntry = (&LbaEntry->Link)->ForwardLink;\r
-    FreePool (LbaEntry);\r
-    LbaEntry = (LBA_ENTRY *) NextEntry;\r
-  }\r
-  //\r
-  // Free File List Entry\r
-  //\r
-  FfsFileEntry = (FFS_FILE_LIST_ENTRY *) FvDevice->FfsFileListHeader.ForwardLink;\r
-  while (&FfsFileEntry->Link != &FvDevice->FfsFileListHeader) {\r
-    NextEntry = (&FfsFileEntry->Link)->ForwardLink;\r
-    FreePool (FfsFileEntry);\r
-    FfsFileEntry = (FFS_FILE_LIST_ENTRY *) NextEntry;\r
-  }\r
-  //\r
-  // Free Space Entry\r
-  //\r
-  FreeSpaceEntry = (FREE_SPACE_ENTRY *) FvDevice->FreeSpaceHeader.ForwardLink;\r
-  while (&FreeSpaceEntry->Link != &FvDevice->FreeSpaceHeader) {\r
-    NextEntry = (&FreeSpaceEntry->Link)->ForwardLink;\r
-    FreePool (FreeSpaceEntry);\r
-    FreeSpaceEntry = (FREE_SPACE_ENTRY *) NextEntry;\r
-  }\r
-  //\r
-  // Free the cache\r
-  //\r
-  FreePool ((UINT8 *) (UINTN) FvDevice->CachedFv);\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-\r
-  Firmware volume inherits authentication status from the FV image file and section(in another firmware volume)\r
-  where it came from or propagated from PEI-phase.\r
-\r
-  @param  FvDevice              A pointer to the FvDevice.\r
-\r
-**/\r
-VOID\r
-FwVolInheritAuthenticationStatus (\r
-  IN FV_DEVICE  *FvDevice\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_FIRMWARE_VOLUME_HEADER            *CachedFvHeader;\r
-  EFI_FIRMWARE_VOLUME_EXT_HEADER        *CachedFvExtHeader;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL         *ParentFvProtocol;\r
-  UINTN                                 Key;\r
-  EFI_GUID                              FileNameGuid;\r
-  EFI_FV_FILETYPE                       FileType;\r
-  EFI_FV_FILE_ATTRIBUTES                FileAttributes;\r
-  UINTN                                 FileSize;\r
-  EFI_SECTION_TYPE                      SectionType;\r
-  UINT32                                AuthenticationStatus;\r
-  EFI_FIRMWARE_VOLUME_HEADER            *FvHeader;\r
-  EFI_FIRMWARE_VOLUME_EXT_HEADER        *FvExtHeader;\r
-  UINTN                                 BufferSize;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *Fvb;\r
-  EFI_FVB_ATTRIBUTES_2                  FvbAttributes;\r
-  EFI_PHYSICAL_ADDRESS                  BaseAddress;\r
-  EFI_PEI_HOB_POINTERS                  Fv3Hob;\r
-\r
-  if (FvDevice->Fv.ParentHandle != NULL) {\r
-    CachedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvDevice->CachedFv;\r
-\r
-    //\r
-    // By Parent Handle, find out the FV image file and section(in another firmware volume) where the firmware volume came from\r
-    //\r
-    Status = gBS->HandleProtocol (FvDevice->Fv.ParentHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **) &ParentFvProtocol);\r
-    if (!EFI_ERROR (Status) && (ParentFvProtocol != NULL)) {\r
-      Key = 0;\r
-      do {\r
-        FileType = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE;\r
-        Status = ParentFvProtocol->GetNextFile (\r
-                                     ParentFvProtocol,\r
-                                     &Key,\r
-                                     &FileType,\r
-                                     &FileNameGuid,\r
-                                     &FileAttributes,\r
-                                     &FileSize\r
-                                     );\r
-        if (EFI_ERROR (Status)) {\r
-          return;\r
-        }\r
-\r
-        SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r
-        FvHeader = NULL;\r
-        BufferSize = 0;\r
-        Status = ParentFvProtocol->ReadSection (\r
-                                     ParentFvProtocol,\r
-                                     &FileNameGuid,\r
-                                     SectionType,\r
-                                     0,\r
-                                     (VOID **) &FvHeader,\r
-                                     &BufferSize,\r
-                                     &AuthenticationStatus\r
-                                     );\r
-        if (!EFI_ERROR (Status)) {\r
-          if ((FvHeader->FvLength == CachedFvHeader->FvLength) &&\r
-              (FvHeader->ExtHeaderOffset == CachedFvHeader->ExtHeaderOffset)) {\r
-            if (FvHeader->ExtHeaderOffset != 0) {\r
-              //\r
-              // Both FVs contain extension header, then compare their FV Name GUID\r
-              //\r
-              FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINTN) FvHeader + FvHeader->ExtHeaderOffset);\r
-              CachedFvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINTN) CachedFvHeader + CachedFvHeader->ExtHeaderOffset);\r
-              if (CompareGuid (&FvExtHeader->FvName, &CachedFvExtHeader->FvName)) {\r
-                //\r
-                // Found the FV image section where the firmware volume came from,\r
-                // and then inherit authentication status from it.\r
-                //\r
-                FvDevice->AuthenticationStatus = AuthenticationStatus;\r
-                FreePool ((VOID *) FvHeader);\r
-                return;\r
-              }\r
-            } else {\r
-              //\r
-              // Both FVs don't contain extension header, then compare their whole FV Image.\r
-              //\r
-              if (CompareMem ((VOID *) FvHeader, (VOID *) CachedFvHeader, (UINTN) FvHeader->FvLength) == 0) {\r
-                //\r
-                // Found the FV image section where the firmware volume came from\r
-                // and then inherit authentication status from it.\r
-                //\r
-                FvDevice->AuthenticationStatus = AuthenticationStatus;\r
-                FreePool ((VOID *) FvHeader);\r
-                return;\r
-              }\r
-            }\r
-          }\r
-          FreePool ((VOID *) FvHeader);\r
-        }\r
-      } while (TRUE);\r
-    }\r
-  } else {\r
-    Fvb = FvDevice->Fvb;\r
-\r
-    Status  = Fvb->GetAttributes (Fvb, &FvbAttributes);\r
-    if (EFI_ERROR (Status)) {\r
-      return;\r
-    }\r
-\r
-    if ((FvbAttributes & EFI_FVB2_MEMORY_MAPPED) != 0) {\r
-      //\r
-      // Get volume base address\r
-      //\r
-      Status = Fvb->GetPhysicalAddress (Fvb, &BaseAddress);\r
-      if (EFI_ERROR (Status)) {\r
-        return;\r
-      }\r
-\r
-      //\r
-      // Get the authentication status propagated from PEI-phase to DXE.\r
-      //\r
-      Fv3Hob.Raw = GetHobList ();\r
-      while ((Fv3Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV3, Fv3Hob.Raw)) != NULL) {\r
-        if (Fv3Hob.FirmwareVolume3->BaseAddress == BaseAddress) {\r
-          FvDevice->AuthenticationStatus = Fv3Hob.FirmwareVolume3->AuthenticationStatus;\r
-          return;\r
-        }\r
-        Fv3Hob.Raw = GET_NEXT_HOB (Fv3Hob);\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Check if an FV is consistent and allocate cache for it.\r
-\r
-  @param  FvDevice              A pointer to the FvDevice to be checked.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  No enough buffer could be allocated.\r
-  @retval EFI_VOLUME_CORRUPTED  File system is corrupted.\r
-  @retval EFI_SUCCESS           FV is consistent and cache is allocated.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCheck (\r
-  IN FV_DEVICE  *FvDevice\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *Fvb;\r
-  EFI_FVB_ATTRIBUTES_2                FvbAttributes;\r
-  EFI_FV_BLOCK_MAP_ENTRY              *BlockMap;\r
-  EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
-  EFI_FIRMWARE_VOLUME_EXT_HEADER      *FwVolExtHeader;\r
-  UINT8                               *FwCache;\r
-  LBA_ENTRY                           *LbaEntry;\r
-  FREE_SPACE_ENTRY                    *FreeSpaceEntry;\r
-  FFS_FILE_LIST_ENTRY                 *FfsFileEntry;\r
-  UINT8                               *LbaStart;\r
-  UINTN                               Index;\r
-  EFI_LBA                             LbaIndex;\r
-  UINT8                               *Ptr;\r
-  UINTN                               Size;\r
-  UINT8                               *FreeStart;\r
-  UINTN                               FreeSize;\r
-  UINT8                               ErasePolarity;\r
-  EFI_FFS_FILE_STATE                  FileState;\r
-  UINT8                               *TopFvAddress;\r
-  UINTN                               TestLength;\r
-  EFI_PHYSICAL_ADDRESS                BaseAddress;\r
-\r
-  Fvb     = FvDevice->Fvb;\r
-\r
-  Status  = Fvb->GetAttributes (Fvb, &FvbAttributes);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  InitializeListHead (&FvDevice->LbaHeader);\r
-  InitializeListHead (&FvDevice->FreeSpaceHeader);\r
-  InitializeListHead (&FvDevice->FfsFileListHeader);\r
-\r
-  FwVolHeader = NULL;\r
-  Status = GetFwVolHeader (Fvb, &FwVolHeader);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  ASSERT (FwVolHeader != NULL);\r
-\r
-  FvDevice->IsFfs3Fv = CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem3Guid);\r
-\r
-  //\r
-  // Double Check firmware volume header here\r
-  //\r
-  if (!VerifyFvHeaderChecksum (FwVolHeader)) {\r
-    FreePool (FwVolHeader);\r
-    return EFI_VOLUME_CORRUPTED;\r
-  }\r
-\r
-  BlockMap = FwVolHeader->BlockMap;\r
-\r
-  //\r
-  // FwVolHeader->FvLength is the whole FV length including FV header\r
-  //\r
-  FwCache = AllocateZeroPool ((UINTN) FwVolHeader->FvLength);\r
-  if (FwCache == NULL) {\r
-    FreePool (FwVolHeader);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  FvDevice->CachedFv = (EFI_PHYSICAL_ADDRESS) (UINTN) FwCache;\r
-\r
-  //\r
-  // Copy to memory\r
-  //\r
-  LbaStart  = FwCache;\r
-  LbaIndex  = 0;\r
-  Ptr       = NULL;\r
-\r
-  if ((FvbAttributes & EFI_FVB2_MEMORY_MAPPED) != 0) {\r
-    //\r
-    // Get volume base address\r
-    //\r
-    Status = Fvb->GetPhysicalAddress (Fvb, &BaseAddress);\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (FwVolHeader);\r
-      return Status;\r
-    }\r
-\r
-    Ptr = (UINT8 *) ((UINTN) BaseAddress);\r
-\r
-    DEBUG((EFI_D_INFO, "Fv Base Address is 0x%LX\n", BaseAddress));\r
-  }\r
-  //\r
-  // Copy whole FV into the memory\r
-  //\r
-  while ((BlockMap->NumBlocks != 0) || (BlockMap->Length != 0)) {\r
-\r
-    for (Index = 0; Index < BlockMap->NumBlocks; Index++) {\r
-      LbaEntry = AllocatePool (sizeof (LBA_ENTRY));\r
-      if (LbaEntry == NULL) {\r
-        FreePool (FwVolHeader);\r
-        FreeFvDeviceResource (FvDevice);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      LbaEntry->LbaIndex        = LbaIndex;\r
-      LbaEntry->StartingAddress = LbaStart;\r
-      LbaEntry->BlockLength     = BlockMap->Length;\r
-\r
-      //\r
-      // Copy each LBA into memory\r
-      //\r
-      if ((FvbAttributes & EFI_FVB2_MEMORY_MAPPED) != 0) {\r
-\r
-        CopyMem (LbaStart, Ptr, BlockMap->Length);\r
-        Ptr += BlockMap->Length;\r
-\r
-      } else {\r
-\r
-        Size = BlockMap->Length;\r
-        Status = Fvb->Read (\r
-                        Fvb,\r
-                        LbaIndex,\r
-                        0,\r
-                        &Size,\r
-                        LbaStart\r
-                        );\r
-        //\r
-        // Not check EFI_BAD_BUFFER_SIZE, for Size = BlockMap->Length\r
-        //\r
-        if (EFI_ERROR (Status)) {\r
-          FreePool (FwVolHeader);\r
-          FreeFvDeviceResource (FvDevice);\r
-          return Status;\r
-        }\r
-\r
-      }\r
-\r
-      LbaIndex++;\r
-      LbaStart += BlockMap->Length;\r
-\r
-      InsertTailList (&FvDevice->LbaHeader, &LbaEntry->Link);\r
-    }\r
-\r
-    BlockMap++;\r
-  }\r
-\r
-  FvDevice->FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FwCache;\r
-\r
-  //\r
-  // it is not used any more, so free FwVolHeader\r
-  //\r
-  FreePool (FwVolHeader);\r
-\r
-  //\r
-  // Scan to check the free space & File list\r
-  //\r
-  if ((FvbAttributes & EFI_FVB2_ERASE_POLARITY) != 0) {\r
-    ErasePolarity = 1;\r
-  } else {\r
-    ErasePolarity = 0;\r
-  }\r
-\r
-  FvDevice->ErasePolarity = ErasePolarity;\r
-\r
-  //\r
-  // go through the whole FV cache, check the consistence of the FV\r
-  //\r
-  if (FvDevice->FwVolHeader->ExtHeaderOffset != 0) {\r
-    //\r
-    // Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.\r
-    //\r
-    FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->ExtHeaderOffset);\r
-    Ptr = (UINT8 *) FwVolExtHeader + FwVolExtHeader->ExtHeaderSize;\r
-  } else {\r
-    Ptr = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->HeaderLength);\r
-  }\r
-  Ptr = (UINT8 *) ALIGN_POINTER (Ptr, 8);\r
-  TopFvAddress = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->FvLength);\r
-\r
-  //\r
-  // Build FFS list & Free Space List here\r
-  //\r
-  while (Ptr < TopFvAddress) {\r
-    TestLength = TopFvAddress - Ptr;\r
-\r
-    if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {\r
-      TestLength = sizeof (EFI_FFS_FILE_HEADER);\r
-    }\r
-\r
-    if (IsBufferErased (ErasePolarity, Ptr, TestLength)) {\r
-      //\r
-      // We found free space\r
-      //\r
-      FreeStart = Ptr;\r
-      FreeSize  = 0;\r
-\r
-      do {\r
-        TestLength = TopFvAddress - Ptr;\r
-\r
-        if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {\r
-          TestLength = sizeof (EFI_FFS_FILE_HEADER);\r
-        }\r
-\r
-        if (!IsBufferErased (ErasePolarity, Ptr, TestLength)) {\r
-          break;\r
-        }\r
-\r
-        FreeSize += TestLength;\r
-        Ptr += TestLength;\r
-      } while (Ptr < TopFvAddress);\r
-\r
-      FreeSpaceEntry = AllocateZeroPool (sizeof (FREE_SPACE_ENTRY));\r
-      if (FreeSpaceEntry == NULL) {\r
-        FreeFvDeviceResource (FvDevice);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-      //\r
-      // Create a Free space entry\r
-      //\r
-      FreeSpaceEntry->StartingAddress = FreeStart;\r
-      FreeSpaceEntry->Length          = FreeSize;\r
-      InsertTailList (&FvDevice->FreeSpaceHeader, &FreeSpaceEntry->Link);\r
-      continue;\r
-    }\r
-    //\r
-    // double check boundary\r
-    //\r
-    if (TestLength < sizeof (EFI_FFS_FILE_HEADER)) {\r
-      break;\r
-    }\r
-\r
-    if (!IsValidFFSHeader (\r
-          FvDevice->ErasePolarity,\r
-          (EFI_FFS_FILE_HEADER *) Ptr\r
-          )) {\r
-      FileState = GetFileState (\r
-                    FvDevice->ErasePolarity,\r
-                    (EFI_FFS_FILE_HEADER *) Ptr\r
-                    );\r
-      if ((FileState == EFI_FILE_HEADER_INVALID) || (FileState == EFI_FILE_HEADER_CONSTRUCTION)) {\r
-        if (IS_FFS_FILE2 (Ptr)) {\r
-          if (!FvDevice->IsFfs3Fv) {\r
-            DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &((EFI_FFS_FILE_HEADER *) Ptr)->Name));\r
-          }\r
-          Ptr = Ptr + sizeof (EFI_FFS_FILE_HEADER2);\r
-        } else {\r
-          Ptr = Ptr + sizeof (EFI_FFS_FILE_HEADER);\r
-        }\r
-\r
-        continue;\r
-\r
-      } else {\r
-        //\r
-        // File system is corrputed, return\r
-        //\r
-        FreeFvDeviceResource (FvDevice);\r
-        return EFI_VOLUME_CORRUPTED;\r
-      }\r
-    }\r
-\r
-    if (IS_FFS_FILE2 (Ptr)) {\r
-      ASSERT (FFS_FILE2_SIZE (Ptr) > 0x00FFFFFF);\r
-      if (!FvDevice->IsFfs3Fv) {\r
-        DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &((EFI_FFS_FILE_HEADER *) Ptr)->Name));\r
-        Ptr = Ptr + FFS_FILE2_SIZE (Ptr);\r
-        //\r
-        // Adjust Ptr to the next 8-byte aligned boundary.\r
-        //\r
-        while (((UINTN) Ptr & 0x07) != 0) {\r
-          Ptr++;\r
-        }\r
-        continue;\r
-      }\r
-    }\r
-\r
-    if (IsValidFFSFile (FvDevice, (EFI_FFS_FILE_HEADER *) Ptr)) {\r
-      FileState = GetFileState (\r
-                    FvDevice->ErasePolarity,\r
-                    (EFI_FFS_FILE_HEADER *) Ptr\r
-                    );\r
-\r
-      //\r
-      // check for non-deleted file\r
-      //\r
-      if (FileState != EFI_FILE_DELETED) {\r
-        //\r
-        // Create a FFS list entry for each non-deleted file\r
-        //\r
-        FfsFileEntry = AllocateZeroPool (sizeof (FFS_FILE_LIST_ENTRY));\r
-        if (FfsFileEntry == NULL) {\r
-          FreeFvDeviceResource (FvDevice);\r
-          return EFI_OUT_OF_RESOURCES;\r
-        }\r
-\r
-        FfsFileEntry->FfsHeader = Ptr;\r
-        InsertTailList (&FvDevice->FfsFileListHeader, &FfsFileEntry->Link);\r
-      }\r
-\r
-      if (IS_FFS_FILE2 (Ptr)) {\r
-        Ptr = Ptr + FFS_FILE2_SIZE (Ptr);\r
-      } else {\r
-        Ptr = Ptr + FFS_FILE_SIZE (Ptr);\r
-      }\r
-\r
-      //\r
-      // Adjust Ptr to the next 8-byte aligned boundary.\r
-      //\r
-      while (((UINTN) Ptr & 0x07) != 0) {\r
-        Ptr++;\r
-      }\r
-    } else {\r
-      //\r
-      // File system is corrupted, return\r
-      //\r
-      FreeFvDeviceResource (FvDevice);\r
-      return EFI_VOLUME_CORRUPTED;\r
-    }\r
-  }\r
-\r
-  FvDevice->CurrentFfsFile = NULL;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Entry point function does install/reinstall FV2 protocol with full functionality.\r
-\r
-  @param ImageHandle   A handle for the image that is initializing this driver\r
-  @param SystemTable   A pointer to the EFI system table\r
-\r
-  @retval EFI_SUCCESS    At least one Fv protocol install/reinstall successfully.\r
-  @retval EFI_NOT_FOUND  No FV protocol install/reinstall successfully.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FwVolDriverInit (\r
-  IN EFI_HANDLE                   ImageHandle,\r
-  IN EFI_SYSTEM_TABLE             *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_HANDLE                          *HandleBuffer;\r
-  UINTN                               HandleCount;\r
-  UINTN                               Index;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *Fvb;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL       *Fv;\r
-  FV_DEVICE                           *FvDevice;\r
-  EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
-  BOOLEAN                             Reinstall;\r
-  BOOLEAN                             InstallFlag;\r
-\r
-  DEBUG ((EFI_D_INFO, "=========FwVol writable driver installed\n"));\r
-  InstallFlag   =  FALSE;\r
-  //\r
-  // Locate all handles of Fvb protocol\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  for (Index = 0; Index < HandleCount; Index += 1) {\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                    (VOID **) &Fvb\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    FwVolHeader = NULL;\r
-    Status = GetFwVolHeader (Fvb, &FwVolHeader);\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-    ASSERT (FwVolHeader != NULL);\r
-    FreePool (FwVolHeader);\r
-\r
-    Reinstall = FALSE;\r
-    //\r
-    // Check if there is an FV protocol already installed in that handle\r
-    //\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiFirmwareVolume2ProtocolGuid,\r
-                    (VOID **) &Fv\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      Reinstall = TRUE;\r
-    }\r
-    //\r
-    // FwVol protocol on the handle so create a new one\r
-    //\r
-    FvDevice = AllocateZeroPool (sizeof (FV_DEVICE));\r
-    if (FvDevice == NULL) {\r
-      goto Done;\r
-    }\r
-\r
-    FvDevice->Signature = FV_DEVICE_SIGNATURE;\r
-    FvDevice->Fvb       = Fvb;\r
-\r
-    //\r
-    // Firmware Volume Protocol interface\r
-    //\r
-    FvDevice->Fv.GetVolumeAttributes  = FvGetVolumeAttributes;\r
-    FvDevice->Fv.SetVolumeAttributes  = FvSetVolumeAttributes;\r
-    FvDevice->Fv.ReadFile             = FvReadFile;\r
-    FvDevice->Fv.ReadSection          = FvReadFileSection;\r
-    FvDevice->Fv.WriteFile            = FvWriteFile;\r
-    FvDevice->Fv.GetNextFile          = FvGetNextFile;\r
-    FvDevice->Fv.KeySize              = KEYSIZE;\r
-    FvDevice->Fv.GetInfo              = FvGetVolumeInfo;\r
-    FvDevice->Fv.SetInfo              = FvSetVolumeInfo;\r
-    FvDevice->Fv.ParentHandle         = Fvb->ParentHandle;\r
-\r
-    Status = FvCheck (FvDevice);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // The file system is not consistence\r
-      //\r
-      FreePool (FvDevice);\r
-      continue;\r
-    }\r
-\r
-    FwVolInheritAuthenticationStatus (FvDevice);\r
-\r
-    if (Reinstall) {\r
-      //\r
-      // Reinstall an New FV protocol\r
-      //\r
-      // FvDevice = FV_DEVICE_FROM_THIS (Fv);\r
-      // FvDevice->Fvb = Fvb;\r
-      // FreeFvDeviceResource (FvDevice);\r
-      //\r
-      Status = gBS->ReinstallProtocolInterface (\r
-                      HandleBuffer[Index],\r
-                      &gEfiFirmwareVolume2ProtocolGuid,\r
-                      Fv,\r
-                      &FvDevice->Fv\r
-                      );\r
-      if (!EFI_ERROR (Status)) {\r
-        InstallFlag = TRUE;\r
-      } else {\r
-        FreePool (FvDevice);\r
-      }\r
-\r
-      DEBUG ((EFI_D_INFO, "Reinstall FV protocol as writable - %r\n", Status));\r
-      ASSERT_EFI_ERROR (Status);\r
-    } else {\r
-      //\r
-      // Install an New FV protocol\r
-      //\r
-      Status = gBS->InstallProtocolInterface (\r
-                      &FvDevice->Handle,\r
-                      &gEfiFirmwareVolume2ProtocolGuid,\r
-                      EFI_NATIVE_INTERFACE,\r
-                      &FvDevice->Fv\r
-                      );\r
-      if (!EFI_ERROR (Status)) {\r
-        InstallFlag = TRUE;\r
-      } else {\r
-        FreePool (FvDevice);\r
-      }\r
-\r
-      DEBUG ((EFI_D_INFO, "Install FV protocol as writable - %r\n", Status));\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-\r
-Done:\r
-  //\r
-  // As long as one Fv protocol install/reinstall successfully,\r
-  // success should return to ensure this image will be not unloaded.\r
-  // Otherwise, new Fv protocols are corrupted by other loaded driver.\r
-  //\r
-  if (InstallFlag) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // No FV protocol install/reinstall successfully.\r
-  // EFI_NOT_FOUND should return to ensure this image will be unloaded.\r
-  //\r
-  return EFI_NOT_FOUND;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolAttrib.c b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolAttrib.c
deleted file mode 100644 (file)
index 7af9614..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/** @file\r
-\r
-  Implements get/set firmware volume attributes.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "FwVolDriver.h"\r
-\r
-/**\r
-  Retrieves attributes, insures positive polarity of attribute bits, returns\r
-  resulting attributes in output parameter.\r
-\r
-  @param  This             Calling context\r
-  @param  Attributes       output buffer which contains attributes\r
-\r
-  @retval EFI_SUCCESS      Successfully got volume attributes\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetVolumeAttributes (\r
-  IN  CONST EFI_FIRMWARE_VOLUME2_PROTOCOL  *This,\r
-  OUT EFI_FV_ATTRIBUTES             *Attributes\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  FV_DEVICE                           *FvDevice;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *Fvb;\r
-  EFI_FVB_ATTRIBUTES_2                FvbAttributes;\r
-\r
-  FvDevice  = FV_DEVICE_FROM_THIS (This);\r
-  Fvb       = FvDevice->Fvb;\r
-\r
-  //\r
-  // First get the Firmware Volume Block Attributes\r
-  //\r
-  Status = Fvb->GetAttributes (Fvb, &FvbAttributes);\r
-  FvbAttributes &= 0xfffff0ff;\r
-\r
-  *Attributes = FvbAttributes;\r
-  *Attributes |= EFI_FV2_WRITE_POLICY_RELIABLE;\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Sets current attributes for volume.\r
-\r
-  @param  This          Calling context\r
-  @param  Attributes    On input, FvAttributes is a pointer to\r
-                        an EFI_FV_ATTRIBUTES containing the\r
-                        desired firmware volume settings. On\r
-                        successful return, it contains the new\r
-                        settings of the firmware volume. On\r
-                        unsuccessful return, FvAttributes is not\r
-                        modified and the firmware volume\r
-                        settings are not changed.\r
-\r
-  @retval EFI_SUCCESS             The requested firmware volume attributes\r
-                                  were set and the resulting\r
-                                  EFI_FV_ATTRIBUTES is returned in\r
-                                  FvAttributes.\r
-  @retval EFI_ACCESS_DENIED       Atrribute is locked down.\r
-  @retval EFI_INVALID_PARAMETER   Atrribute is not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvSetVolumeAttributes (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN OUT EFI_FV_ATTRIBUTES          *Attributes\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  FV_DEVICE                           *FvDevice;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *Fvb;\r
-  EFI_FVB_ATTRIBUTES_2                OldFvbAttributes;\r
-  EFI_FVB_ATTRIBUTES_2                NewFvbAttributes;\r
-  UINT64                              NewStatus;\r
-  UINT32                              Capabilities;\r
-\r
-  FvDevice  = FV_DEVICE_FROM_THIS (This);\r
-  Fvb       = FvDevice->Fvb;\r
-\r
-  //\r
-  // First get the current Volume Attributes\r
-  //\r
-  Status = Fvb->GetAttributes (\r
-                  Fvb,\r
-                  &OldFvbAttributes\r
-                  );\r
-\r
-  if ((OldFvbAttributes & EFI_FVB2_LOCK_STATUS) != 0) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-  //\r
-  // Only status attributes can be updated.\r
-  //\r
-  Capabilities  = OldFvbAttributes & EFI_FVB2_CAPABILITIES;\r
-  NewStatus     = (*Attributes) & EFI_FVB2_STATUS;\r
-\r
-  //\r
-  // Test read disable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_READ_DISABLED_CAP) == 0) {\r
-    if ((NewStatus & EFI_FVB2_READ_STATUS) == 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test read enable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_READ_ENABLED_CAP) == 0) {\r
-    if ((NewStatus & EFI_FVB2_READ_STATUS) != 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test write disable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_WRITE_DISABLED_CAP) == 0) {\r
-    if ((NewStatus & EFI_FVB2_WRITE_STATUS) == 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test write enable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_WRITE_ENABLED_CAP) == 0) {\r
-    if ((NewStatus & EFI_FVB2_WRITE_STATUS) != 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test lock\r
-  //\r
-  if ((Capabilities & EFI_FVB2_LOCK_CAP) == 0) {\r
-    if ((NewStatus & EFI_FVB2_LOCK_STATUS) != 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-\r
-  NewFvbAttributes = OldFvbAttributes & (0xFFFFFFFF & (~EFI_FVB2_STATUS));\r
-  NewFvbAttributes |= NewStatus;\r
-  Status = Fvb->SetAttributes (\r
-                  Fvb,\r
-                  &NewFvbAttributes\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  *Attributes = 0;\r
-\r
-  This->GetVolumeAttributes (\r
-          This,\r
-          Attributes\r
-          );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Return information of type InformationType for the requested firmware\r
-  volume.\r
-\r
-  @param This             Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
-  @param InformationType  InformationType for requested.\r
-  @param BufferSize       On input, size of Buffer.On output, the amount of\r
-                          data returned in Buffer.\r
-  @param Buffer           A poniter to the data buffer to return.\r
-\r
-  @return EFI_UNSUPPORTED Could not get.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetVolumeInfo (\r
-  IN  CONST EFI_FIRMWARE_VOLUME2_PROTOCOL       *This,\r
-  IN  CONST EFI_GUID                            *InformationType,\r
-  IN OUT UINTN                                  *BufferSize,\r
-  OUT VOID                                      *Buffer\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Set information with InformationType into the requested firmware volume.\r
-\r
-  @param  This             Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
-  @param  InformationType  InformationType for requested.\r
-  @param  BufferSize       Size of Buffer data.\r
-  @param  Buffer           A poniter to the data buffer to be set.\r
-\r
-  @retval EFI_UNSUPPORTED  Could not set.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvSetVolumeInfo (\r
-  IN  CONST EFI_FIRMWARE_VOLUME2_PROTOCOL       *This,\r
-  IN  CONST EFI_GUID                            *InformationType,\r
-  IN  UINTN                                     BufferSize,\r
-  IN CONST  VOID                                *Buffer\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDriver.h b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDriver.h
deleted file mode 100644 (file)
index 2b48520..0000000
+++ /dev/null
@@ -1,755 +0,0 @@
-/** @file\r
-  Common defines and definitions for a FwVolDxe driver.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _FWVOL_DRIVER_H_\r
-#define _FWVOL_DRIVER_H_\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Guid/FirmwareFileSystem2.h>\r
-#include <Guid/FirmwareFileSystem3.h>\r
-#include <Protocol/SectionExtraction.h>\r
-#include <Protocol/FaultTolerantWrite.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/HobLib.h>\r
-\r
-#define FV_DEVICE_SIGNATURE           SIGNATURE_32 ('_', 'F', 'V', '_')\r
-\r
-//\r
-// Define two helper macro to extract the Capability field or Status field in FVB\r
-// bit fields\r
-//\r
-#define EFI_FVB2_CAPABILITIES (EFI_FVB2_READ_DISABLED_CAP | \\r
-                              EFI_FVB2_READ_ENABLED_CAP | \\r
-                              EFI_FVB2_WRITE_DISABLED_CAP | \\r
-                              EFI_FVB2_WRITE_ENABLED_CAP | \\r
-                              EFI_FVB2_LOCK_CAP \\r
-                              )\r
-\r
-#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)\r
-\r
-#define MAX_FILES 32\r
-\r
-//\r
-// Used to calculate from address -> Lba\r
-//\r
-typedef struct {\r
-  LIST_ENTRY      Link;\r
-  EFI_LBA         LbaIndex;\r
-  UINT8           *StartingAddress;\r
-  UINTN           BlockLength;\r
-} LBA_ENTRY;\r
-\r
-//\r
-// Used to track free space in the Fv\r
-//\r
-typedef struct {\r
-  LIST_ENTRY      Link;\r
-  UINT8           *StartingAddress;\r
-  UINTN           Length;\r
-} FREE_SPACE_ENTRY;\r
-\r
-//\r
-// Used to track all non-deleted files\r
-//\r
-typedef struct {\r
-  LIST_ENTRY      Link;\r
-  UINT8           *FfsHeader;\r
-} FFS_FILE_LIST_ENTRY;\r
-\r
-typedef struct {\r
-  UINTN                               Signature;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *Fvb;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL       Fv;\r
-  EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
-  UINT8                               *Key;\r
-  EFI_HANDLE                          Handle;\r
-\r
-  UINT8                               ErasePolarity;\r
-  EFI_PHYSICAL_ADDRESS                CachedFv;\r
-  LIST_ENTRY                          LbaHeader;\r
-  LIST_ENTRY                          FreeSpaceHeader;\r
-  LIST_ENTRY                          FfsFileListHeader;\r
-\r
-  FFS_FILE_LIST_ENTRY                 *CurrentFfsFile;\r
-  BOOLEAN                             IsFfs3Fv;\r
-  UINT32                              AuthenticationStatus;\r
-} FV_DEVICE;\r
-\r
-#define FV_DEVICE_FROM_THIS(a)  CR (a, FV_DEVICE, Fv, FV_DEVICE_SIGNATURE)\r
-\r
-/**\r
-  Retrieves attributes, insures positive polarity of attribute bits, returns\r
-  resulting attributes in output parameter.\r
-\r
-  @param  This             Calling context\r
-  @param  Attributes       output buffer which contains attributes\r
-\r
-  @retval EFI_SUCCESS      Successfully got volume attributes\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetVolumeAttributes (\r
-  IN  CONST EFI_FIRMWARE_VOLUME2_PROTOCOL  *This,\r
-  OUT EFI_FV_ATTRIBUTES             *Attributes\r
-  );\r
-\r
-/**\r
-  Sets current attributes for volume.\r
-\r
-  @param  This          Calling context\r
-  @param  Attributes    On input, FvAttributes is a pointer to\r
-                        an EFI_FV_ATTRIBUTES containing the\r
-                        desired firmware volume settings. On\r
-                        successful return, it contains the new\r
-                        settings of the firmware volume. On\r
-                        unsuccessful return, FvAttributes is not\r
-                        modified and the firmware volume\r
-                        settings are not changed.\r
-\r
-  @retval EFI_SUCCESS             The requested firmware volume attributes\r
-                                  were set and the resulting\r
-                                  EFI_FV_ATTRIBUTES is returned in\r
-                                  FvAttributes.\r
-  @retval EFI_ACCESS_DENIED       Atrribute is locked down.\r
-  @retval EFI_INVALID_PARAMETER   Atrribute is not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvSetVolumeAttributes (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN OUT EFI_FV_ATTRIBUTES          *Attributes\r
-  );\r
-\r
-/**\r
-  Given the input key, search for the next matching file in the volume.\r
-\r
-  @param  This                       Indicates the calling context.\r
-  @param  Key                        Key is a pointer to a caller allocated\r
-                                     buffer that contains implementation specific\r
-                                     data that is used to track where to begin\r
-                                     the search for the next file. The size of\r
-                                     the buffer must be at least This->KeySize\r
-                                     bytes long. To reinitialize the search and\r
-                                     begin from the beginning of the firmware\r
-                                     volume, the entire buffer must be cleared to\r
-                                     zero. Other than clearing the buffer to\r
-                                     initiate a new search, the caller must not\r
-                                     modify the data in the buffer between calls\r
-                                     to GetNextFile().\r
-  @param  FileType                   FileType is a pointer to a caller allocated\r
-                                     EFI_FV_FILETYPE. The GetNextFile() API can\r
-                                     filter it's search for files based on the\r
-                                     value of *FileType input. A *FileType input\r
-                                     of 0 causes GetNextFile() to search for\r
-                                     files of all types.  If a file is found, the\r
-                                     file's type is returned in *FileType.\r
-                                     *FileType is not modified if no file is\r
-                                     found.\r
-  @param  NameGuid                   NameGuid is a pointer to a caller allocated\r
-                                     EFI_GUID. If a file is found, the file's\r
-                                     name is returned in *NameGuid.  *NameGuid is\r
-                                     not modified if no file is found.\r
-  @param  Attributes                 Attributes is a pointer to a caller\r
-                                     allocated EFI_FV_FILE_ATTRIBUTES.  If a file\r
-                                     is found, the file's attributes are returned\r
-                                     in *Attributes. *Attributes is not modified\r
-                                     if no file is found.\r
-  @param  Size                       Size is a pointer to a caller allocated\r
-                                     UINTN. If a file is found, the file's size\r
-                                     is returned in *Size. *Size is not modified\r
-                                     if no file is found.\r
-\r
-  @retval EFI_SUCCESS                Successfully find the file.\r
-  @retval EFI_DEVICE_ERROR           Device error.\r
-  @retval EFI_ACCESS_DENIED          Fv could not read.\r
-  @retval EFI_NOT_FOUND              No matching file found.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetNextFile (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN OUT VOID                       *Key,\r
-  IN OUT EFI_FV_FILETYPE            *FileType,\r
-  OUT EFI_GUID                      *NameGuid,\r
-  OUT EFI_FV_FILE_ATTRIBUTES        *Attributes,\r
-  OUT UINTN                         *Size\r
-  );\r
-\r
-/**\r
-  Locates a file in the firmware volume and\r
-  copies it to the supplied buffer.\r
-\r
-  @param  This                       Indicates the calling context.\r
-  @param  NameGuid                   Pointer to an EFI_GUID, which is the\r
-                                     filename.\r
-  @param  Buffer                     Buffer is a pointer to pointer to a buffer\r
-                                     in which the file or section contents or are\r
-                                     returned.\r
-  @param  BufferSize                 BufferSize is a pointer to caller allocated\r
-                                     UINTN. On input *BufferSize indicates the\r
-                                     size in bytes of the memory region pointed\r
-                                     to by Buffer. On output, *BufferSize\r
-                                     contains the number of bytes required to\r
-                                     read the file.\r
-  @param  FoundType                  FoundType is a pointer to a caller allocated\r
-                                     EFI_FV_FILETYPE that on successful return\r
-                                     from Read() contains the type of file read.\r
-                                     This output reflects the file type\r
-                                     irrespective of the value of the SectionType\r
-                                     input.\r
-  @param  FileAttributes             FileAttributes is a pointer to a caller\r
-                                     allocated EFI_FV_FILE_ATTRIBUTES.  On\r
-                                     successful return from Read(),\r
-                                     *FileAttributes contains the attributes of\r
-                                     the file read.\r
-  @param  AuthenticationStatus       AuthenticationStatus is a pointer to a\r
-                                     caller allocated UINTN in which the\r
-                                     authentication status is returned.\r
-\r
-  @retval EFI_SUCCESS                Successfully read to memory buffer.\r
-  @retval EFI_WARN_BUFFER_TOO_SMALL  Buffer too small.\r
-  @retval EFI_NOT_FOUND              Not found.\r
-  @retval EFI_DEVICE_ERROR           Device error.\r
-  @retval EFI_ACCESS_DENIED          Could not read.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter.\r
-  @retval EFI_OUT_OF_RESOURCES       Not enough buffer to be allocated.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvReadFile (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN CONST EFI_GUID                       *NameGuid,\r
-  IN OUT VOID                       **Buffer,\r
-  IN OUT UINTN                      *BufferSize,\r
-  OUT EFI_FV_FILETYPE               *FoundType,\r
-  OUT EFI_FV_FILE_ATTRIBUTES        *FileAttributes,\r
-  OUT UINT32                        *AuthenticationStatus\r
-  );\r
-\r
-/**\r
-  Locates a section in a given FFS File and\r
-  copies it to the supplied buffer (not including section header).\r
-\r
-  @param  This                       Indicates the calling context.\r
-  @param  NameGuid                   Pointer to an EFI_GUID, which is the\r
-                                     filename.\r
-  @param  SectionType                Indicates the section type to return.\r
-  @param  SectionInstance            Indicates which instance of sections with a\r
-                                     type of SectionType to return.\r
-  @param  Buffer                     Buffer is a pointer to pointer to a buffer\r
-                                     in which the file or section contents or are\r
-                                     returned.\r
-  @param  BufferSize                 BufferSize is a pointer to caller allocated\r
-                                     UINTN.\r
-  @param  AuthenticationStatus       AuthenticationStatus is a pointer to a\r
-                                     caller allocated UINT32 in which the\r
-                                     authentication status is returned.\r
-\r
-  @retval EFI_SUCCESS                Successfully read the file section into\r
-                                     buffer.\r
-  @retval EFI_WARN_BUFFER_TOO_SMALL  Buffer too small.\r
-  @retval EFI_NOT_FOUND              Section not found.\r
-  @retval EFI_DEVICE_ERROR           Device error.\r
-  @retval EFI_ACCESS_DENIED          Could not read.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvReadFileSection (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN CONST EFI_GUID                       *NameGuid,\r
-  IN EFI_SECTION_TYPE               SectionType,\r
-  IN UINTN                          SectionInstance,\r
-  IN OUT VOID                       **Buffer,\r
-  IN OUT UINTN                      *BufferSize,\r
-  OUT UINT32                        *AuthenticationStatus\r
-  );\r
-\r
-/**\r
-  Writes one or more files to the firmware volume.\r
-\r
-  @param  This                   Indicates the calling context.\r
-  @param  NumberOfFiles          Number of files.\r
-  @param  WritePolicy            WritePolicy indicates the level of reliability\r
-                                 for the write in the event of a power failure or\r
-                                 other system failure during the write operation.\r
-  @param  FileData               FileData is an pointer to an array of\r
-                                 EFI_FV_WRITE_DATA. Each element of array\r
-                                 FileData represents a file to be written.\r
-\r
-  @retval EFI_SUCCESS            Files successfully written to firmware volume\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough buffer to be allocated.\r
-  @retval EFI_DEVICE_ERROR       Device error.\r
-  @retval EFI_WRITE_PROTECTED    Write protected.\r
-  @retval EFI_NOT_FOUND          Not found.\r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter.\r
-  @retval EFI_UNSUPPORTED        This function not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvWriteFile (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN UINT32                         NumberOfFiles,\r
-  IN EFI_FV_WRITE_POLICY            WritePolicy,\r
-  IN EFI_FV_WRITE_FILE_DATA         *FileData\r
-  );\r
-\r
-/**\r
-  Return information of type InformationType for the requested firmware\r
-  volume.\r
-\r
-  @param This             Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
-  @param InformationType  InformationType for requested.\r
-  @param BufferSize       On input, size of Buffer.On output, the amount of\r
-                          data returned in Buffer.\r
-  @param Buffer           A poniter to the data buffer to return.\r
-\r
-  @return EFI_UNSUPPORTED Could not get.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetVolumeInfo (\r
-  IN  CONST EFI_FIRMWARE_VOLUME2_PROTOCOL       *This,\r
-  IN  CONST EFI_GUID                            *InformationType,\r
-  IN OUT UINTN                                  *BufferSize,\r
-  OUT VOID                                      *Buffer\r
-  );\r
-\r
-\r
-/**\r
-  Set information with InformationType into the requested firmware volume.\r
-\r
-  @param  This             Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
-  @param  InformationType  InformationType for requested.\r
-  @param  BufferSize       Size of Buffer data.\r
-  @param  Buffer           A poniter to the data buffer to be set.\r
-\r
-  @retval EFI_UNSUPPORTED  Could not set.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvSetVolumeInfo (\r
-  IN  CONST EFI_FIRMWARE_VOLUME2_PROTOCOL       *This,\r
-  IN  CONST EFI_GUID                            *InformationType,\r
-  IN  UINTN                                     BufferSize,\r
-  IN CONST  VOID                                *Buffer\r
-  );\r
-\r
-/**\r
-  Writes data beginning at Lba:Offset from FV. The write terminates either\r
-  when *NumBytes of data have been written, or when the firmware end is\r
-  reached.  *NumBytes is updated to reflect the actual number of bytes\r
-  written.\r
-\r
-  @param FvDevice        Cached Firmware Volume\r
-  @param Offset          Offset in the block at which to begin write\r
-  @param NumBytes        At input, indicates the requested write size.\r
-                         At output, indicates the actual number of bytes written.\r
-  @param Buffer          Buffer containing source data for the write.\r
-\r
-  @retval EFI_SUCCESS  Data is successfully written into FV.\r
-  @return error        Data is failed written.\r
-\r
-**/\r
-EFI_STATUS\r
-FvcWrite (\r
-  IN     FV_DEVICE                            *FvDevice,\r
-  IN     UINTN                                Offset,\r
-  IN OUT UINTN                                *NumBytes,\r
-  IN     UINT8                                *Buffer\r
-  );\r
-\r
-\r
-/**\r
-  Check if a block of buffer is erased.\r
-\r
-  @param  ErasePolarity  Erase polarity attribute of the firmware volume\r
-  @param  Buffer         The buffer to be checked\r
-  @param  BufferSize     Size of the buffer in bytes\r
-\r
-  @retval TRUE           The block of buffer is erased\r
-  @retval FALSE          The block of buffer is not erased\r
-\r
-**/\r
-BOOLEAN\r
-IsBufferErased (\r
-  IN UINT8    ErasePolarity,\r
-  IN UINT8    *Buffer,\r
-  IN UINTN    BufferSize\r
-  );\r
-\r
-/**\r
-  Get the FFS file state by checking the highest bit set in the header's state field.\r
-\r
-  @param  ErasePolarity  Erase polarity attribute of the firmware volume\r
-  @param  FfsHeader      Points to the FFS file header\r
-\r
-  @return FFS File state\r
-\r
-**/\r
-EFI_FFS_FILE_STATE\r
-GetFileState (\r
-  IN UINT8                ErasePolarity,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  );\r
-\r
-/**\r
-  Verify checksum of the firmware volume header.\r
-\r
-  @param  FvHeader       Points to the firmware volume header to be checked\r
-\r
-  @retval TRUE           Checksum verification passed\r
-  @retval FALSE          Checksum verification failed\r
-\r
-**/\r
-BOOLEAN\r
-VerifyFvHeaderChecksum (\r
-  IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader\r
-  );\r
-\r
-/**\r
-  Check if it's a valid FFS file header.\r
-\r
-  @param  ErasePolarity  Erase polarity attribute of the firmware volume\r
-  @param  FfsHeader      Points to the FFS file header to be checked\r
-\r
-  @retval TRUE           Valid FFS file header\r
-  @retval FALSE          Invalid FFS file header\r
-\r
-**/\r
-BOOLEAN\r
-IsValidFFSHeader (\r
-  IN UINT8                ErasePolarity,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  );\r
-\r
-/**\r
-  Check if it's a valid FFS file.\r
-  Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.\r
-\r
-  @param  FvDevice       Cached FV image.\r
-  @param  FfsHeader      Points to the FFS file to be checked\r
-\r
-  @retval TRUE           Valid FFS file\r
-  @retval FALSE          Invalid FFS file\r
-\r
-**/\r
-BOOLEAN\r
-IsValidFFSFile (\r
-  IN FV_DEVICE            *FvDevice,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  );\r
-\r
-/**\r
-  Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and\r
-  copy the real length volume header into it.\r
-\r
-  @param  Fvb                   The FW_VOL_BLOCK_PROTOCOL instance from which to\r
-                                read the volume header\r
-  @param  FwVolHeader           Pointer to pointer to allocated buffer in which\r
-                                the volume header is returned.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  No enough buffer could be allocated.\r
-  @retval EFI_SUCCESS           Successfully read volume header to the allocated\r
-                                buffer.\r
-  @retval EFI_ACCESS_DENIED     Read status of FV is not enabled.\r
-  @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
-                                the file system could not be understood.\r
-**/\r
-EFI_STATUS\r
-GetFwVolHeader (\r
-  IN     EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *Fvb,\r
-  OUT EFI_FIRMWARE_VOLUME_HEADER                **FwVolHeader\r
-  );\r
-\r
-/**\r
-  Convert the Buffer Address to LBA Entry Address.\r
-\r
-  @param FvDevice        Cached FvDevice\r
-  @param BufferAddress   Address of Buffer\r
-  @param LbaListEntry    Pointer to the got LBA entry that contains the address.\r
-\r
-  @retval EFI_NOT_FOUND  Buffer address is out of FvDevice.\r
-  @retval EFI_SUCCESS    LBA entry is found for Buffer address.\r
-\r
-**/\r
-EFI_STATUS\r
-Buffer2LbaEntry (\r
-  IN     FV_DEVICE              *FvDevice,\r
-  IN     EFI_PHYSICAL_ADDRESS   BufferAddress,\r
-  OUT LBA_ENTRY                 **LbaListEntry\r
-  );\r
-\r
-/**\r
-  Convert the Buffer Address to LBA Address & Offset.\r
-\r
-  @param FvDevice        Cached FvDevice\r
-  @param BufferAddress   Address of Buffer\r
-  @param Lba             Pointer to the gob Lba value\r
-  @param Offset          Pointer to the got Offset\r
-\r
-  @retval EFI_NOT_FOUND  Buffer address is out of FvDevice.\r
-  @retval EFI_SUCCESS    LBA and Offset is found for Buffer address.\r
-\r
-**/\r
-EFI_STATUS\r
-Buffer2Lba (\r
-  IN     FV_DEVICE              *FvDevice,\r
-  IN     EFI_PHYSICAL_ADDRESS   BufferAddress,\r
-  OUT EFI_LBA                   *Lba,\r
-  OUT UINTN                     *Offset\r
-  );\r
-\r
-/**\r
-  Set File State in the FfsHeader.\r
-\r
-  @param  State          File state to be set into FFS header.\r
-  @param  FfsHeader      Points to the FFS file header\r
-\r
-**/\r
-VOID\r
-SetFileState (\r
-  IN UINT8                State,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  );\r
-\r
-/**\r
-  Create a PAD File in the Free Space.\r
-\r
-  @param FvDevice        Firmware Volume Device.\r
-  @param FreeSpaceEntry  Indicating in which Free Space(Cache) the Pad file will be inserted.\r
-  @param Size            Pad file Size, not include the header.\r
-  @param PadFileEntry    The Ffs File Entry that points to this Pad File.\r
-\r
-  @retval EFI_SUCCESS            Successfully create a PAD file.\r
-  @retval EFI_OUT_OF_RESOURCES   No enough free space to create a PAD file.\r
-  @retval EFI_INVALID_PARAMETER  Size is not 8 byte alignment.\r
-  @retval EFI_DEVICE_ERROR       Free space is not erased.\r
-**/\r
-EFI_STATUS\r
-FvCreatePadFileInFreeSpace (\r
-  IN  FV_DEVICE           *FvDevice,\r
-  IN  FREE_SPACE_ENTRY    *FreeSpaceEntry,\r
-  IN  UINTN               Size,\r
-  OUT FFS_FILE_LIST_ENTRY **PadFileEntry\r
-  );\r
-\r
-/**\r
-  Create a new file within a PAD file area.\r
-\r
-  @param FvDevice        Firmware Volume Device.\r
-  @param FfsFileBuffer   A buffer that holds an FFS file,(it contains a File Header which is in init state).\r
-  @param BufferSize      The size of FfsFileBuffer.\r
-  @param ActualFileSize  The actual file length, it may not be multiples of 8.\r
-  @param FileName        The FFS File Name.\r
-  @param FileType        The FFS File Type.\r
-  @param FileAttributes  The Attributes of the FFS File to be created.\r
-\r
-  @retval EFI_SUCCESS           Successfully create a new file within the found PAD file area.\r
-  @retval EFI_OUT_OF_RESOURCES  No suitable PAD file is found.\r
-  @retval other errors          New file is created failed.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCreateNewFileInsidePadFile (\r
-  IN  FV_DEVICE               *FvDevice,\r
-  IN  UINT8                   *FfsFileBuffer,\r
-  IN  UINTN                   BufferSize,\r
-  IN  UINTN                   ActualFileSize,\r
-  IN  EFI_GUID                *FileName,\r
-  IN  EFI_FV_FILETYPE         FileType,\r
-  IN  EFI_FV_FILE_ATTRIBUTES  FileAttributes\r
-  );\r
-\r
-/**\r
-  Write multiple files into FV in reliable method.\r
-\r
-  @param FvDevice        Firmware Volume Device.\r
-  @param NumOfFiles      Total File number to be written.\r
-  @param FileData        The array of EFI_FV_WRITE_FILE_DATA structure,\r
-                         used to get name, attributes, type, etc\r
-  @param FileOperation   The array of operation for each file.\r
-\r
-  @retval EFI_SUCCESS            Files are added into FV.\r
-  @retval EFI_OUT_OF_RESOURCES   No enough free PAD files to add the input files.\r
-  @retval EFI_INVALID_PARAMETER  File number is less than or equal to 1.\r
-  @retval EFI_UNSUPPORTED        File number exceeds the supported max numbers of files.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCreateMultipleFiles (\r
-  IN  FV_DEVICE               *FvDevice,\r
-  IN  UINTN                   NumOfFiles,\r
-  IN  EFI_FV_WRITE_FILE_DATA  *FileData,\r
-  IN  BOOLEAN                 *FileOperation\r
-  );\r
-\r
-/**\r
-  Calculate the checksum for the FFS header.\r
-\r
-  @param FfsHeader   FFS File Header which needs to calculate the checksum\r
-\r
-**/\r
-VOID\r
-SetHeaderChecksum (\r
-  IN EFI_FFS_FILE_HEADER *FfsHeader\r
-  );\r
-\r
-/**\r
-  Calculate the checksum for the FFS File.\r
-\r
-  @param FfsHeader       FFS File Header which needs to calculate the checksum\r
-  @param ActualFileSize  The whole Ffs File Length.\r
-\r
-**/\r
-VOID\r
-SetFileChecksum (\r
-  IN EFI_FFS_FILE_HEADER *FfsHeader,\r
-  IN UINTN               ActualFileSize\r
-  );\r
-\r
-/**\r
-  Get the alignment value from File Attributes.\r
-\r
-  @param FfsAttributes  FFS attribute\r
-\r
-  @return Alignment value.\r
-\r
-**/\r
-UINTN\r
-GetRequiredAlignment (\r
-  IN EFI_FV_FILE_ATTRIBUTES FfsAttributes\r
-  );\r
-\r
-/**\r
-  Locate Pad File for writing, this is got from FV Cache.\r
-\r
-  @param FvDevice           Cached Firmware Volume.\r
-  @param Size               The required FFS file size.\r
-  @param RequiredAlignment  FFS File Data alignment requirement.\r
-  @param PadSize            Pointer to the size of leading Pad File.\r
-  @param PadFileEntry       Pointer to the Pad File Entry that meets the requirement.\r
-\r
-  @retval EFI_SUCCESS     The required pad file is found.\r
-  @retval EFI_NOT_FOUND   The required pad file can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvLocatePadFile (\r
-  IN  FV_DEVICE           *FvDevice,\r
-  IN  UINTN               Size,\r
-  IN  UINTN               RequiredAlignment,\r
-  OUT UINTN               *PadSize,\r
-  OUT FFS_FILE_LIST_ENTRY **PadFileEntry\r
-  );\r
-\r
-/**\r
-  Locate a suitable pad file for multiple file writing.\r
-\r
-  @param FvDevice          Cached Firmware Volume.\r
-  @param NumOfFiles        The number of Files that needed updating\r
-  @param BufferSize        The array of each file size.\r
-  @param RequiredAlignment The array of of FFS File Data alignment requirement.\r
-  @param PadSize           The array of size of each leading Pad File.\r
-  @param TotalSizeNeeded   The totalsize that can hold these files.\r
-  @param PadFileEntry      Pointer to the Pad File Entry that meets the requirement.\r
-\r
-  @retval EFI_SUCCESS     The required pad file is found.\r
-  @retval EFI_NOT_FOUND   The required pad file can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvSearchSuitablePadFile (\r
-  IN FV_DEVICE              *FvDevice,\r
-  IN UINTN                  NumOfFiles,\r
-  IN UINTN                  *BufferSize,\r
-  IN UINTN                  *RequiredAlignment,\r
-  OUT UINTN                 *PadSize,\r
-  OUT UINTN                 *TotalSizeNeeded,\r
-  OUT FFS_FILE_LIST_ENTRY   **PadFileEntry\r
-  );\r
-\r
-/**\r
-  Locate a Free Space entry which can hold these files, including\r
-  meeting the alignment requirements.\r
-\r
-  @param FvDevice          Cached Firmware Volume.\r
-  @param NumOfFiles        The number of Files that needed updating\r
-  @param BufferSize        The array of each file size.\r
-  @param RequiredAlignment The array of of FFS File Data alignment requirement.\r
-  @param PadSize           The array of size of each leading Pad File.\r
-  @param TotalSizeNeeded   The got total size that can hold these files.\r
-  @param FreeSpaceEntry    The Free Space Entry that can hold these files.\r
-\r
-  @retval EFI_SUCCESS     The free space entry is found.\r
-  @retval EFI_NOT_FOUND   The free space entry can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvSearchSuitableFreeSpace (\r
-  IN FV_DEVICE              *FvDevice,\r
-  IN UINTN                  NumOfFiles,\r
-  IN UINTN                  *BufferSize,\r
-  IN UINTN                  *RequiredAlignment,\r
-  OUT UINTN                 *PadSize,\r
-  OUT UINTN                 *TotalSizeNeeded,\r
-  OUT FREE_SPACE_ENTRY      **FreeSpaceEntry\r
-  );\r
-\r
-/**\r
-  Change FFS file header state and write to FV.\r
-\r
-  @param  FvDevice     Cached FV image.\r
-  @param  FfsHeader    Points to the FFS file header to be updated.\r
-  @param  State        FFS file state to be set.\r
-\r
-  @retval EFI_SUCCESS  File state is writen into FV.\r
-  @retval others       File state can't be writen into FV.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateHeaderBit (\r
-  IN FV_DEVICE            *FvDevice,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
-  IN EFI_FFS_FILE_STATE   State\r
-  );\r
-\r
-/**\r
-  Convert EFI_FV_FILE_ATTRIBUTES to FFS_FILE_ATTRIBUTES.\r
-\r
-  @param FvFileAttrib    The value of EFI_FV_FILE_ATTRIBUTES\r
-  @param FfsFileAttrib   Pointer to the got FFS_FILE_ATTRIBUTES value.\r
-\r
-**/\r
-VOID\r
-FvFileAttrib2FfsFileAttrib (\r
-  IN     EFI_FV_FILE_ATTRIBUTES  FvFileAttrib,\r
-  OUT UINT8                      *FfsFileAttrib\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxe.inf b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxe.inf
deleted file mode 100644 (file)
index 2680b54..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-## @file\r
-#  FwVolDxe Driver.\r
-#\r
-#  This driver produces Firmware Volume2 protocol with full services\r
-#  (read/write, get/set) based on Firmware Volume Block protocol.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = FwVolDxe\r
-  MODULE_UNI_FILE                = FwVolDxe.uni\r
-  FILE_GUID                      = 233C2592-1CEC-494a-A097-15DC96379777\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = FwVolDriverInit\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  FwVolDriver.h\r
-  FwPadFile.c\r
-  Ffs.c\r
-  FwVolWrite.c\r
-  FwVolRead.c\r
-  FwVolAttrib.c\r
-  FwVol.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  HobLib\r
-\r
-[Guids]\r
-  gEfiFirmwareVolumeTopFileGuid                ## CONSUMES ## File # VTF file\r
-  gEfiFirmwareFileSystem2Guid                  ## CONSUMES ## GUID # File System Guid\r
-  gEfiFirmwareFileSystem3Guid                  ## CONSUMES ## GUID # File System Guid\r
-\r
-[Protocols]\r
-  gEfiSectionExtractionProtocolGuid            ## CONSUMES\r
-  gEfiFirmwareVolumeBlockProtocolGuid          ## CONSUMES\r
-  gEfiFirmwareVolume2ProtocolGuid              ## PRODUCES\r
-\r
-[Depex]\r
-  gEfiFirmwareVolumeBlockProtocolGuid AND gEfiSectionExtractionProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  FwVolDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxe.uni b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxe.uni
deleted file mode 100644 (file)
index fca6830..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// /** @file\r
-// FwVolDxe Driver.\r
-//\r
-// This driver produces Firmware Volume2 protocol with full services\r
-// (read/write, get/set) based on Firmware Volume Block protocol.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "FwVolDxe Driver"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This driver produces the Firmware Volume2 protocol with full services (read/write, get/set) based on Firmware Volume Block protocol."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxeExtra.uni b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxeExtra.uni
deleted file mode 100644 (file)
index dc0b806..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// FwVolDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Flash Storage DXE Driver v2"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c
deleted file mode 100644 (file)
index 2e2cf7f..0000000
+++ /dev/null
@@ -1,638 +0,0 @@
-/** @file\r
-  Implements functions to read firmware file.\r
-\r
-  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "FwVolDriver.h"\r
-\r
-/**\r
-Required Alignment   Alignment Value in FFS   FFS_ATTRIB_DATA_ALIGNMENT2   Alignment Value in\r
-(bytes)              Attributes Field         in FFS Attributes Field      Firmware Volume Interfaces\r
-1                               0                          0                            0\r
-16                              1                          0                            4\r
-128                             2                          0                            7\r
-512                             3                          0                            9\r
-1 KB                            4                          0                            10\r
-4 KB                            5                          0                            12\r
-32 KB                           6                          0                            15\r
-64 KB                           7                          0                            16\r
-128 KB                          0                          1                            17\r
-256 KB                          1                          1                            18\r
-512 KB                          2                          1                            19\r
-1 MB                            3                          1                            20\r
-2 MB                            4                          1                            21\r
-4 MB                            5                          1                            22\r
-8 MB                            6                          1                            23\r
-16 MB                           7                          1                            24\r
-**/\r
-UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};\r
-UINT8 mFvAttributes2[] = {17, 18, 19, 20, 21, 22, 23, 24};\r
-\r
-/**\r
-  Convert the FFS File Attributes to FV File Attributes.\r
-\r
-  @param  FfsAttributes              The attributes of UINT8 type.\r
-\r
-  @return The attributes of EFI_FV_FILE_ATTRIBUTES\r
-\r
-**/\r
-EFI_FV_FILE_ATTRIBUTES\r
-FfsAttributes2FvFileAttributes (\r
-  IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes\r
-  )\r
-{\r
-  UINT8                     DataAlignment;\r
-  EFI_FV_FILE_ATTRIBUTES    FileAttribute;\r
-\r
-  DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);\r
-  ASSERT (DataAlignment < 8);\r
-\r
-  if ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT_2) != 0) {\r
-    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes2[DataAlignment];\r
-  } else {\r
-    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];\r
-  }\r
-\r
-  if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) {\r
-    FileAttribute |= EFI_FV_FILE_ATTRIB_FIXED;\r
-  }\r
-\r
-  return FileAttribute;\r
-}\r
-\r
-/**\r
-  Given the input key, search for the next matching file in the volume.\r
-\r
-  @param  This                       Indicates the calling context.\r
-  @param  Key                        Key is a pointer to a caller allocated\r
-                                     buffer that contains implementation specific\r
-                                     data that is used to track where to begin\r
-                                     the search for the next file. The size of\r
-                                     the buffer must be at least This->KeySize\r
-                                     bytes long. To reinitialize the search and\r
-                                     begin from the beginning of the firmware\r
-                                     volume, the entire buffer must be cleared to\r
-                                     zero. Other than clearing the buffer to\r
-                                     initiate a new search, the caller must not\r
-                                     modify the data in the buffer between calls\r
-                                     to GetNextFile().\r
-  @param  FileType                   FileType is a pointer to a caller allocated\r
-                                     EFI_FV_FILETYPE. The GetNextFile() API can\r
-                                     filter it's search for files based on the\r
-                                     value of *FileType input. A *FileType input\r
-                                     of 0 causes GetNextFile() to search for\r
-                                     files of all types.  If a file is found, the\r
-                                     file's type is returned in *FileType.\r
-                                     *FileType is not modified if no file is\r
-                                     found.\r
-  @param  NameGuid                   NameGuid is a pointer to a caller allocated\r
-                                     EFI_GUID. If a file is found, the file's\r
-                                     name is returned in *NameGuid.  *NameGuid is\r
-                                     not modified if no file is found.\r
-  @param  Attributes                 Attributes is a pointer to a caller\r
-                                     allocated EFI_FV_FILE_ATTRIBUTES.  If a file\r
-                                     is found, the file's attributes are returned\r
-                                     in *Attributes. *Attributes is not modified\r
-                                     if no file is found.\r
-  @param  Size                       Size is a pointer to a caller allocated\r
-                                     UINTN. If a file is found, the file's size\r
-                                     is returned in *Size. *Size is not modified\r
-                                     if no file is found.\r
-\r
-  @retval EFI_SUCCESS                Successfully find the file.\r
-  @retval EFI_DEVICE_ERROR           Device error.\r
-  @retval EFI_ACCESS_DENIED          Fv could not read.\r
-  @retval EFI_NOT_FOUND              No matching file found.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetNextFile (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN OUT VOID                       *Key,\r
-  IN OUT EFI_FV_FILETYPE            *FileType,\r
-  OUT EFI_GUID                      *NameGuid,\r
-  OUT EFI_FV_FILE_ATTRIBUTES        *Attributes,\r
-  OUT UINTN                         *Size\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-  FV_DEVICE           *FvDevice;\r
-  EFI_FV_ATTRIBUTES   FvAttributes;\r
-  EFI_FFS_FILE_HEADER *FfsFileHeader;\r
-  UINTN               *KeyValue;\r
-  LIST_ENTRY      *Link;\r
-  FFS_FILE_LIST_ENTRY *FfsFileEntry;\r
-\r
-  FvDevice  = FV_DEVICE_FROM_THIS (This);\r
-\r
-  Status    = This->GetVolumeAttributes (This, &FvAttributes);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  KeyValue      = (UINTN *) Key;\r
-  FfsFileHeader = NULL;\r
-\r
-  //\r
-  // Check if read operation is enabled\r
-  //\r
-  if ((FvAttributes & EFI_FV2_READ_STATUS) == 0) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-\r
-  if (*FileType > EFI_FV_FILETYPE_SMM_CORE) {\r
-    //\r
-    // File type needs to be in 0 - 0x0D\r
-    //\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  do {\r
-    if (*KeyValue == 0) {\r
-      //\r
-      // Search for 1st matching file\r
-      //\r
-      Link = &FvDevice->FfsFileListHeader;\r
-      if (Link->ForwardLink == &FvDevice->FfsFileListHeader) {\r
-        return EFI_NOT_FOUND;\r
-      }\r
-\r
-      FfsFileEntry  = (FFS_FILE_LIST_ENTRY *) Link->ForwardLink;\r
-      FfsFileHeader = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
-\r
-      //\r
-      // remember the key\r
-      //\r
-      *KeyValue = (UINTN) FfsFileEntry;\r
-\r
-      //\r
-      // we ignore pad files\r
-      //\r
-      if (FfsFileHeader->Type == EFI_FV_FILETYPE_FFS_PAD) {\r
-        continue;\r
-      }\r
-\r
-      if (*FileType == 0) {\r
-        break;\r
-      }\r
-\r
-      if (*FileType == FfsFileHeader->Type) {\r
-        break;\r
-      }\r
-\r
-    } else {\r
-      //\r
-      // Getting link from last Ffs\r
-      //\r
-      Link = (LIST_ENTRY *) (*KeyValue);\r
-      if (Link->ForwardLink == &FvDevice->FfsFileListHeader) {\r
-        return EFI_NOT_FOUND;\r
-      }\r
-\r
-      FfsFileEntry  = (FFS_FILE_LIST_ENTRY *) Link->ForwardLink;\r
-      FfsFileHeader = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
-\r
-      //\r
-      // remember the key\r
-      //\r
-      *KeyValue = (UINTN) FfsFileEntry;\r
-\r
-      //\r
-      // we ignore pad files\r
-      //\r
-      if (FfsFileHeader->Type == EFI_FV_FILETYPE_FFS_PAD) {\r
-        continue;\r
-      }\r
-\r
-      if (*FileType == EFI_FV_FILETYPE_ALL) {\r
-        break;\r
-      }\r
-\r
-      if (*FileType == FfsFileHeader->Type) {\r
-        break;\r
-      }\r
-    }\r
-  } while (Link->ForwardLink != &FvDevice->FfsFileListHeader);\r
-\r
-  //\r
-  // Cache this file entry\r
-  //\r
-  FvDevice->CurrentFfsFile  = FfsFileEntry;\r
-\r
-  *FileType                 = FfsFileHeader->Type;\r
-  CopyGuid (NameGuid, &FfsFileHeader->Name);\r
-  *Attributes = FfsAttributes2FvFileAttributes (FfsFileHeader->Attributes);\r
-   if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) {\r
-     *Attributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;\r
-   }\r
-\r
-  //\r
-  // we need to substract the header size\r
-  //\r
-  if (IS_FFS_FILE2 (FfsFileHeader)) {\r
-    *Size = FFS_FILE2_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER2);\r
-  } else {\r
-    *Size = FFS_FILE_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
-  }\r
-\r
-  if (CompareGuid (&gEfiFirmwareVolumeTopFileGuid, NameGuid)) {\r
-    //\r
-    // specially deal with VTF file\r
-    //\r
-    UINT8   *SrcPtr;\r
-    UINT32  Tmp;\r
-\r
-    if (IS_FFS_FILE2 (FfsFileHeader)) {\r
-      SrcPtr = ((UINT8 *) FfsFileHeader) + sizeof (EFI_FFS_FILE_HEADER2);\r
-    } else {\r
-      SrcPtr = ((UINT8 *) FfsFileHeader) + sizeof (EFI_FFS_FILE_HEADER);\r
-    }\r
-\r
-    while (*Size >= 4) {\r
-      Tmp = *(UINT32 *) SrcPtr;\r
-      if (Tmp == 0) {\r
-        SrcPtr += 4;\r
-        (*Size) -= 4;\r
-      } else {\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Locates a file in the firmware volume and\r
-  copies it to the supplied buffer.\r
-\r
-  @param  This                       Indicates the calling context.\r
-  @param  NameGuid                   Pointer to an EFI_GUID, which is the\r
-                                     filename.\r
-  @param  Buffer                     Buffer is a pointer to pointer to a buffer\r
-                                     in which the file or section contents or are\r
-                                     returned.\r
-  @param  BufferSize                 BufferSize is a pointer to caller allocated\r
-                                     UINTN. On input *BufferSize indicates the\r
-                                     size in bytes of the memory region pointed\r
-                                     to by Buffer. On output, *BufferSize\r
-                                     contains the number of bytes required to\r
-                                     read the file.\r
-  @param  FoundType                  FoundType is a pointer to a caller allocated\r
-                                     EFI_FV_FILETYPE that on successful return\r
-                                     from Read() contains the type of file read.\r
-                                     This output reflects the file type\r
-                                     irrespective of the value of the SectionType\r
-                                     input.\r
-  @param  FileAttributes             FileAttributes is a pointer to a caller\r
-                                     allocated EFI_FV_FILE_ATTRIBUTES.  On\r
-                                     successful return from Read(),\r
-                                     *FileAttributes contains the attributes of\r
-                                     the file read.\r
-  @param  AuthenticationStatus       AuthenticationStatus is a pointer to a\r
-                                     caller allocated UINTN in which the\r
-                                     authentication status is returned.\r
-\r
-  @retval EFI_SUCCESS                Successfully read to memory buffer.\r
-  @retval EFI_WARN_BUFFER_TOO_SMALL  Buffer too small.\r
-  @retval EFI_NOT_FOUND              Not found.\r
-  @retval EFI_DEVICE_ERROR           Device error.\r
-  @retval EFI_ACCESS_DENIED          Could not read.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter.\r
-  @retval EFI_OUT_OF_RESOURCES       Not enough buffer to be allocated.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvReadFile (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN CONST EFI_GUID                       *NameGuid,\r
-  IN OUT VOID                       **Buffer,\r
-  IN OUT UINTN                      *BufferSize,\r
-  OUT EFI_FV_FILETYPE               *FoundType,\r
-  OUT EFI_FV_FILE_ATTRIBUTES        *FileAttributes,\r
-  OUT UINT32                        *AuthenticationStatus\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  FV_DEVICE               *FvDevice;\r
-  UINTN                   Key;\r
-  EFI_GUID                SearchNameGuid;\r
-  EFI_FV_ATTRIBUTES       FvAttributes;\r
-  EFI_FV_FILETYPE         LocalFoundType;\r
-  EFI_FV_FILE_ATTRIBUTES  LocalAttributes;\r
-  UINTN                   FileSize;\r
-  UINT8                   *SrcPtr;\r
-  FFS_FILE_LIST_ENTRY     *FfsFileEntry;\r
-  EFI_FFS_FILE_HEADER     *FfsHeader;\r
-  UINT8                   *FileBuffer;\r
-\r
-  if (NULL == This || NULL == NameGuid) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  FvDevice  = FV_DEVICE_FROM_THIS (This);\r
-\r
-  Status    = This->GetVolumeAttributes (This, &FvAttributes);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // First check to see that FV is enabled for reads...\r
-  //\r
-  if (0 == (FvAttributes & EFI_FV2_READ_STATUS)) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-\r
-  FfsHeader = NULL;\r
-\r
-  //\r
-  // Check if the file was read last time.\r
-  //\r
-  FfsFileEntry = FvDevice->CurrentFfsFile;\r
-\r
-  if (FfsFileEntry != NULL) {\r
-    FfsHeader = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
-  }\r
-\r
-  if ((FfsFileEntry == NULL) || (!CompareGuid (&FfsHeader->Name, NameGuid))) {\r
-    //\r
-    // If not match or no file cached, search this file\r
-    //\r
-    Key = 0;\r
-    do {\r
-      LocalFoundType = 0;\r
-      Status = This->GetNextFile (\r
-                      This,\r
-                      &Key,\r
-                      &LocalFoundType,\r
-                      &SearchNameGuid,\r
-                      &LocalAttributes,\r
-                      &FileSize\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        return EFI_NOT_FOUND;\r
-      }\r
-    } while (!CompareGuid (&SearchNameGuid, NameGuid));\r
-\r
-    //\r
-    // Get file entry\r
-    //\r
-    FfsFileEntry = (FFS_FILE_LIST_ENTRY *) Key;\r
-\r
-    //\r
-    // Update the cache\r
-    //\r
-    FvDevice->CurrentFfsFile  = FfsFileEntry;\r
-\r
-    FfsHeader                 = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
-\r
-  } else {\r
-    //\r
-    // Get File Size of the cached file\r
-    //\r
-    if (IS_FFS_FILE2 (FfsHeader)) {\r
-      FileSize = FFS_FILE2_SIZE (FfsHeader) - sizeof (EFI_FFS_FILE_HEADER2);\r
-    } else {\r
-      FileSize = FFS_FILE_SIZE (FfsHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
-    }\r
-  }\r
-  //\r
-  // Get file info\r
-  //\r
-  *FoundType            = FfsHeader->Type;\r
-  *FileAttributes       = FfsAttributes2FvFileAttributes (FfsHeader->Attributes);\r
-   if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) {\r
-     *FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;\r
-   }\r
-  //\r
-  // Inherit the authentication status.\r
-  //\r
-  *AuthenticationStatus = FvDevice->AuthenticationStatus;\r
-\r
-  //\r
-  // If Buffer is NULL, we only want to get some information\r
-  //\r
-  if (Buffer == NULL) {\r
-    *BufferSize = FileSize;\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (IS_FFS_FILE2 (FfsHeader)) {\r
-    SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER2);\r
-  } else {\r
-    SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);\r
-  }\r
-\r
-  if (CompareGuid (&gEfiFirmwareVolumeTopFileGuid, NameGuid)) {\r
-    //\r
-    // specially deal with VTF file\r
-    //\r
-    UINT32  Tmp;\r
-\r
-    while (FileSize >= 4) {\r
-      Tmp = *(UINT32 *) SrcPtr;\r
-      if (Tmp == 0) {\r
-        SrcPtr += 4;\r
-        FileSize -= 4;\r
-      } else {\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // If we drop out of the above loop, we've found the correct file header...\r
-  //\r
-  if (*Buffer == NULL) {\r
-    FileBuffer = AllocateCopyPool (FileSize, SrcPtr);\r
-    if (FileBuffer == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    *BufferSize = FileSize;\r
-    *Buffer     = FileBuffer;\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // If the user's buffer is smaller than the file size, then copy as much\r
-  // as we can and return an appropriate status.\r
-  //\r
-  if (FileSize > *BufferSize) {\r
-    CopyMem (*Buffer, SrcPtr, *BufferSize);\r
-    *BufferSize = FileSize;\r
-    return EFI_WARN_BUFFER_TOO_SMALL;\r
-  }\r
-  //\r
-  // User's buffer size is ok, so copy the entire file to their buffer.\r
-  //\r
-  *BufferSize = FileSize;\r
-  CopyMem (*Buffer, SrcPtr, *BufferSize);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Locates a section in a given FFS File and\r
-  copies it to the supplied buffer (not including section header).\r
-\r
-  @param  This                       Indicates the calling context.\r
-  @param  NameGuid                   Pointer to an EFI_GUID, which is the\r
-                                     filename.\r
-  @param  SectionType                Indicates the section type to return.\r
-  @param  SectionInstance            Indicates which instance of sections with a\r
-                                     type of SectionType to return.\r
-  @param  Buffer                     Buffer is a pointer to pointer to a buffer\r
-                                     in which the file or section contents or are\r
-                                     returned.\r
-  @param  BufferSize                 BufferSize is a pointer to caller allocated\r
-                                     UINTN.\r
-  @param  AuthenticationStatus       AuthenticationStatus is a pointer to a\r
-                                     caller allocated UINT32 in which the\r
-                                     authentication status is returned.\r
-\r
-  @retval EFI_SUCCESS                Successfully read the file section into\r
-                                     buffer.\r
-  @retval EFI_WARN_BUFFER_TOO_SMALL  Buffer too small.\r
-  @retval EFI_NOT_FOUND              Section not found.\r
-  @retval EFI_DEVICE_ERROR           Device error.\r
-  @retval EFI_ACCESS_DENIED          Could not read.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvReadFileSection (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN CONST EFI_GUID                       *NameGuid,\r
-  IN EFI_SECTION_TYPE               SectionType,\r
-  IN UINTN                          SectionInstance,\r
-  IN OUT VOID                       **Buffer,\r
-  IN OUT UINTN                      *BufferSize,\r
-  OUT UINT32                        *AuthenticationStatus\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  FV_DEVICE                       *FvDevice;\r
-  EFI_FV_ATTRIBUTES               FvAttributes;\r
-  EFI_FV_FILETYPE                 FileType;\r
-  EFI_FV_FILE_ATTRIBUTES          FileAttributes;\r
-  UINTN                           FileSize;\r
-  UINT8                           *FileBuffer;\r
-  EFI_SECTION_EXTRACTION_PROTOCOL *Sep;\r
-  UINTN                           StreamHandle;\r
-\r
-  if (NULL == This || NULL == NameGuid || Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  FvDevice  = FV_DEVICE_FROM_THIS (This);\r
-\r
-  Status    = This->GetVolumeAttributes (This, &FvAttributes);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // First check to see that FV is enabled for reads...\r
-  //\r
-  if (0 == (FvAttributes & EFI_FV2_READ_STATUS)) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-  //\r
-  // Read the whole file into buffer\r
-  //\r
-  FileBuffer = NULL;\r
-  Status = This->ReadFile (\r
-                  This,\r
-                  NameGuid,\r
-                  (VOID **) &FileBuffer,\r
-                  &FileSize,\r
-                  &FileType,\r
-                  &FileAttributes,\r
-                  AuthenticationStatus\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check to see that the file actually HAS sections before we go any further.\r
-  //\r
-  if (FileType == EFI_FV_FILETYPE_RAW) {\r
-    FreePool (FileBuffer);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Located the protocol\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiSectionExtractionProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &Sep\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    FreePool (FileBuffer);\r
-    return Status;\r
-  }\r
-\r
-  Status = Sep->OpenSectionStream (\r
-                  Sep,\r
-                  FileSize,\r
-                  FileBuffer,\r
-                  &StreamHandle\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    FreePool (FileBuffer);\r
-    return Status;\r
-  }\r
-\r
-  if (SectionType == 0) {\r
-    //\r
-    // We need the whole section stream\r
-    //\r
-    Status = Sep->GetSection (\r
-                    Sep,\r
-                    StreamHandle,\r
-                    NULL,\r
-                    NULL,\r
-                    0,\r
-                    Buffer,\r
-                    BufferSize,\r
-                    AuthenticationStatus\r
-                    );\r
-  } else {\r
-    Status = Sep->GetSection (\r
-                    Sep,\r
-                    StreamHandle,\r
-                    &SectionType,\r
-                    NULL,\r
-                    SectionInstance,\r
-                    Buffer,\r
-                    BufferSize,\r
-                    AuthenticationStatus\r
-                    );\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Inherit the authentication status.\r
-    //\r
-    *AuthenticationStatus |= FvDevice->AuthenticationStatus;\r
-  }\r
-\r
-  //\r
-  // Handle AuthenticationStatus if necessary\r
-  //\r
-  Sep->CloseSectionStream (Sep, StreamHandle);\r
-\r
-  FreePool (FileBuffer);\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolWrite.c b/IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolWrite.c
deleted file mode 100644 (file)
index 804f966..0000000
+++ /dev/null
@@ -1,1614 +0,0 @@
-/** @file\r
-  Implements write firmware file.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "FwVolDriver.h"\r
-\r
-/**\r
-  Calculate the checksum for the FFS header.\r
-\r
-  @param FfsHeader   FFS File Header which needs to calculate the checksum\r
-\r
-**/\r
-VOID\r
-SetHeaderChecksum (\r
-  IN EFI_FFS_FILE_HEADER *FfsHeader\r
-  )\r
-{\r
-  EFI_FFS_FILE_STATE  State;\r
-  UINT8               FileChecksum;\r
-\r
-  //\r
-  // The state and the File checksum are not included\r
-  //\r
-  State = FfsHeader->State;\r
-  FfsHeader->State = 0;\r
-\r
-  FileChecksum = FfsHeader->IntegrityCheck.Checksum.File;\r
-  FfsHeader->IntegrityCheck.Checksum.File = 0;\r
-\r
-  FfsHeader->IntegrityCheck.Checksum.Header = 0;\r
-\r
-  if (IS_FFS_FILE2 (FfsHeader)) {\r
-    FfsHeader->IntegrityCheck.Checksum.Header = CalculateCheckSum8 (\r
-      (UINT8 *) FfsHeader,\r
-      sizeof (EFI_FFS_FILE_HEADER2)\r
-      );\r
-  } else {\r
-    FfsHeader->IntegrityCheck.Checksum.Header = CalculateCheckSum8 (\r
-      (UINT8 *) FfsHeader,\r
-      sizeof (EFI_FFS_FILE_HEADER)\r
-      );\r
-  }\r
-\r
-  FfsHeader->State                          = State;\r
-  FfsHeader->IntegrityCheck.Checksum.File   = FileChecksum;\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Calculate the checksum for the FFS File.\r
-\r
-  @param FfsHeader       FFS File Header which needs to calculate the checksum\r
-  @param ActualFileSize  The whole Ffs File Length.\r
-\r
-**/\r
-VOID\r
-SetFileChecksum (\r
-  IN EFI_FFS_FILE_HEADER *FfsHeader,\r
-  IN UINTN               ActualFileSize\r
-  )\r
-{\r
-  if ((FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) != 0) {\r
-\r
-    FfsHeader->IntegrityCheck.Checksum.File = 0;\r
-\r
-    if (IS_FFS_FILE2 (FfsHeader)) {\r
-      FfsHeader->IntegrityCheck.Checksum.File = CalculateCheckSum8 (\r
-        (UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER2),\r
-        ActualFileSize - sizeof (EFI_FFS_FILE_HEADER2)\r
-        );\r
-    } else {\r
-      FfsHeader->IntegrityCheck.Checksum.File = CalculateCheckSum8 (\r
-        (UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER),\r
-        ActualFileSize - sizeof (EFI_FFS_FILE_HEADER)\r
-        );\r
-    }\r
-\r
-  } else {\r
-\r
-    FfsHeader->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Get the alignment value from File Attributes.\r
-\r
-  @param FfsAttributes  FFS attribute\r
-\r
-  @return Alignment value.\r
-\r
-**/\r
-UINTN\r
-GetRequiredAlignment (\r
-  IN EFI_FV_FILE_ATTRIBUTES FfsAttributes\r
-  )\r
-{\r
-  UINTN AlignmentValue;\r
-\r
-  AlignmentValue = FfsAttributes & EFI_FV_FILE_ATTRIB_ALIGNMENT;\r
-\r
-  if (AlignmentValue <= 3) {\r
-    return 0x08;\r
-  }\r
-\r
-  if (AlignmentValue > 16) {\r
-    //\r
-    // Anyway, we won't reach this code\r
-    //\r
-    return 0x08;\r
-  }\r
-\r
-  return (UINTN)1 << AlignmentValue;\r
-\r
-}\r
-\r
-/**\r
-  Calculate the leading Pad file size to meet the alignment requirement.\r
-\r
-  @param FvDevice          Cached Firmware Volume.\r
-  @param StartAddress      The starting address to write the FFS File.\r
-  @param BufferSize        The FFS File Buffer Size.\r
-  @param RequiredAlignment FFS File Data alignment requirement.\r
-\r
-  @return The required Pad File Size.\r
-\r
-**/\r
-UINTN\r
-CalculatePadFileSize (\r
-  IN FV_DEVICE            *FvDevice,\r
-  IN EFI_PHYSICAL_ADDRESS StartAddress,\r
-  IN UINTN                BufferSize,\r
-  IN UINTN                RequiredAlignment\r
-  )\r
-{\r
-  UINTN DataStartPos;\r
-  UINTN RelativePos;\r
-  UINTN PadSize;\r
-\r
-  if (BufferSize > 0x00FFFFFF) {\r
-    DataStartPos  = (UINTN) StartAddress + sizeof (EFI_FFS_FILE_HEADER2);\r
-  } else {\r
-    DataStartPos  = (UINTN) StartAddress + sizeof (EFI_FFS_FILE_HEADER);\r
-  }\r
-  RelativePos   = DataStartPos - (UINTN) FvDevice->CachedFv;\r
-\r
-  PadSize       = 0;\r
-\r
-  while ((RelativePos & (RequiredAlignment - 1)) != 0) {\r
-    RelativePos++;\r
-    PadSize++;\r
-  }\r
-  //\r
-  // If padsize is 0, no pad file needed;\r
-  // If padsize is great than 24, then pad file can be created\r
-  //\r
-  if ((PadSize == 0) || (PadSize >= sizeof (EFI_FFS_FILE_HEADER))) {\r
-    return PadSize;\r
-  }\r
-\r
-  //\r
-  // Perhaps following method can save space\r
-  //\r
-  RelativePos = DataStartPos - (UINTN) FvDevice->CachedFv + sizeof (EFI_FFS_FILE_HEADER);\r
-  PadSize     = sizeof (EFI_FFS_FILE_HEADER);\r
-\r
-  while ((RelativePos & (RequiredAlignment - 1)) != 0) {\r
-    RelativePos++;\r
-    PadSize++;\r
-  }\r
-\r
-  return PadSize;\r
-}\r
-\r
-/**\r
-  Convert EFI_FV_FILE_ATTRIBUTES to FFS_FILE_ATTRIBUTES.\r
-\r
-  @param FvFileAttrib    The value of EFI_FV_FILE_ATTRIBUTES\r
-  @param FfsFileAttrib   Pointer to the got FFS_FILE_ATTRIBUTES value.\r
-\r
-**/\r
-VOID\r
-FvFileAttrib2FfsFileAttrib (\r
-  IN     EFI_FV_FILE_ATTRIBUTES  FvFileAttrib,\r
-  OUT UINT8                      *FfsFileAttrib\r
-  )\r
-{\r
-  UINT8 FvFileAlignment;\r
-  UINT8 FfsFileAlignment;\r
-  UINT8 FfsFileAlignment2;\r
-\r
-  FvFileAlignment   = (UINT8) (FvFileAttrib & EFI_FV_FILE_ATTRIB_ALIGNMENT);\r
-  FfsFileAlignment  = 0;\r
-  FfsFileAlignment2 = 0;\r
-\r
-  switch (FvFileAlignment) {\r
-  case 0:\r
-    //\r
-    // fall through\r
-    //\r
-  case 1:\r
-    //\r
-    // fall through\r
-    //\r
-  case 2:\r
-    //\r
-    // fall through\r
-    //\r
-  case 3:\r
-    //\r
-    // fall through\r
-    //\r
-    FfsFileAlignment = 0;\r
-    break;\r
-\r
-  case 4:\r
-    //\r
-    // fall through\r
-    //\r
-  case 5:\r
-    //\r
-    // fall through\r
-    //\r
-  case 6:\r
-    //\r
-    // fall through\r
-    //\r
-    FfsFileAlignment = 1;\r
-    break;\r
-\r
-  case 7:\r
-    //\r
-    // fall through\r
-    //\r
-  case 8:\r
-    //\r
-    // fall through\r
-    //\r
-    FfsFileAlignment = 2;\r
-    break;\r
-\r
-  case 9:\r
-    FfsFileAlignment = 3;\r
-    break;\r
-\r
-  case 10:\r
-    //\r
-    // fall through\r
-    //\r
-  case 11:\r
-    //\r
-    // fall through\r
-    //\r
-    FfsFileAlignment = 4;\r
-    break;\r
-\r
-  case 12:\r
-    //\r
-    // fall through\r
-    //\r
-  case 13:\r
-    //\r
-    // fall through\r
-    //\r
-  case 14:\r
-    //\r
-    // fall through\r
-    //\r
-    FfsFileAlignment = 5;\r
-    break;\r
-\r
-  case 15:\r
-    FfsFileAlignment = 6;\r
-    break;\r
-\r
-  case 16:\r
-    FfsFileAlignment = 7;\r
-    break;\r
-\r
-  case 17:\r
-    FfsFileAlignment = 0;\r
-    FfsFileAlignment2 = 1;\r
-    break;\r
-  case 18:\r
-    FfsFileAlignment = 1;\r
-    FfsFileAlignment2 = 1;\r
-    break;\r
-  case 19:\r
-    FfsFileAlignment = 2;\r
-    FfsFileAlignment2 = 1;\r
-    break;\r
-  case 20:\r
-    FfsFileAlignment = 3;\r
-    FfsFileAlignment2 = 1;\r
-    break;\r
-  case 21:\r
-    FfsFileAlignment = 4;\r
-    FfsFileAlignment2 = 1;\r
-    break;\r
-  case 22:\r
-    FfsFileAlignment = 5;\r
-    FfsFileAlignment2 = 1;\r
-    break;\r
-  case 23:\r
-    FfsFileAlignment = 6;\r
-    FfsFileAlignment2 = 1;\r
-    break;\r
-  case 24:\r
-    FfsFileAlignment = 7;\r
-    FfsFileAlignment2 = 1;\r
-    break;\r
-  }\r
-\r
-  *FfsFileAttrib = (UINT8) ((FfsFileAlignment << 3) | (FfsFileAlignment2 << 1));\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Locate a free space entry that can hold this FFS file.\r
-\r
-  @param FvDevice          Cached Firmware Volume.\r
-  @param Size              The FFS file size.\r
-  @param RequiredAlignment FFS File Data alignment requirement.\r
-  @param PadSize           Pointer to the size of leading Pad File.\r
-  @param FreeSpaceEntry    Pointer to the Free Space Entry that meets the requirement.\r
-\r
-  @retval EFI_SUCCESS     The free space entry is found.\r
-  @retval EFI_NOT_FOUND   The free space entry can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvLocateFreeSpaceEntry (\r
-  IN  FV_DEVICE             *FvDevice,\r
-  IN  UINTN                 Size,\r
-  IN  UINTN                 RequiredAlignment,\r
-  OUT UINTN                 *PadSize,\r
-  OUT FREE_SPACE_ENTRY      **FreeSpaceEntry\r
-  )\r
-{\r
-  FREE_SPACE_ENTRY  *FreeSpaceListEntry;\r
-  LIST_ENTRY        *Link;\r
-  UINTN             PadFileSize;\r
-\r
-  Link                = FvDevice->FreeSpaceHeader.ForwardLink;\r
-  FreeSpaceListEntry  = (FREE_SPACE_ENTRY *) Link;\r
-\r
-  //\r
-  // Loop the free space entry list to find one that can hold the\r
-  // required the file size\r
-  //\r
-  while ((LIST_ENTRY *) FreeSpaceListEntry != &FvDevice->FreeSpaceHeader) {\r
-    PadFileSize = CalculatePadFileSize (\r
-                    FvDevice,\r
-                    (EFI_PHYSICAL_ADDRESS) (UINTN) FreeSpaceListEntry->StartingAddress,\r
-                    Size,\r
-                    RequiredAlignment\r
-                    );\r
-    if (FreeSpaceListEntry->Length >= Size + PadFileSize) {\r
-      *FreeSpaceEntry = FreeSpaceListEntry;\r
-      *PadSize        = PadFileSize;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    FreeSpaceListEntry = (FREE_SPACE_ENTRY *) FreeSpaceListEntry->Link.ForwardLink;\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-\r
-}\r
-\r
-/**\r
-  Locate Pad File for writing, this is got from FV Cache.\r
-\r
-  @param FvDevice           Cached Firmware Volume.\r
-  @param Size               The required FFS file size.\r
-  @param RequiredAlignment  FFS File Data alignment requirement.\r
-  @param PadSize            Pointer to the size of leading Pad File.\r
-  @param PadFileEntry       Pointer to the Pad File Entry that meets the requirement.\r
-\r
-  @retval EFI_SUCCESS     The required pad file is found.\r
-  @retval EFI_NOT_FOUND   The required pad file can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvLocatePadFile (\r
-  IN  FV_DEVICE           *FvDevice,\r
-  IN  UINTN               Size,\r
-  IN  UINTN               RequiredAlignment,\r
-  OUT UINTN               *PadSize,\r
-  OUT FFS_FILE_LIST_ENTRY **PadFileEntry\r
-  )\r
-{\r
-  FFS_FILE_LIST_ENTRY *FileEntry;\r
-  EFI_FFS_FILE_STATE  FileState;\r
-  EFI_FFS_FILE_HEADER *FileHeader;\r
-  UINTN               PadAreaLength;\r
-  UINTN               PadFileSize;\r
-  UINTN               HeaderSize;\r
-\r
-  FileEntry = (FFS_FILE_LIST_ENTRY *) FvDevice->FfsFileListHeader.ForwardLink;\r
-\r
-  //\r
-  // travel through the whole file list to get the pad file entry\r
-  //\r
-  while (FileEntry != (FFS_FILE_LIST_ENTRY *) &FvDevice->FfsFileListHeader) {\r
-\r
-    FileHeader  = (EFI_FFS_FILE_HEADER *) FileEntry->FfsHeader;\r
-    FileState   = GetFileState (FvDevice->ErasePolarity, FileHeader);\r
-\r
-    if ((FileHeader->Type == EFI_FV_FILETYPE_FFS_PAD) && (FileState == EFI_FILE_DATA_VALID)) {\r
-      //\r
-      // we find one valid pad file, check its free area length\r
-      //\r
-      if (IS_FFS_FILE2 (FileHeader)) {\r
-        HeaderSize = sizeof (EFI_FFS_FILE_HEADER2);\r
-        PadAreaLength = FFS_FILE2_SIZE (FileHeader) - HeaderSize;\r
-      } else {\r
-        HeaderSize = sizeof (EFI_FFS_FILE_HEADER);\r
-        PadAreaLength = FFS_FILE_SIZE (FileHeader) - HeaderSize;\r
-      }\r
-\r
-      PadFileSize = CalculatePadFileSize (\r
-                      FvDevice,\r
-                      (EFI_PHYSICAL_ADDRESS) (UINTN) FileHeader + HeaderSize,\r
-                      Size,\r
-                      RequiredAlignment\r
-                      );\r
-      if (PadAreaLength >= (Size + PadFileSize)) {\r
-        *PadSize      = PadFileSize;\r
-        *PadFileEntry = FileEntry;\r
-        return EFI_SUCCESS;\r
-      }\r
-    }\r
-\r
-    FileEntry = (FFS_FILE_LIST_ENTRY *) (FileEntry->Link.ForwardLink);\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Locate a suitable pad file for multiple file writing.\r
-\r
-  @param FvDevice          Cached Firmware Volume.\r
-  @param NumOfFiles        The number of Files that needed updating\r
-  @param BufferSize        The array of each file size.\r
-  @param RequiredAlignment The array of of FFS File Data alignment requirement.\r
-  @param PadSize           The array of size of each leading Pad File.\r
-  @param TotalSizeNeeded   The totalsize that can hold these files.\r
-  @param PadFileEntry      Pointer to the Pad File Entry that meets the requirement.\r
-\r
-  @retval EFI_SUCCESS     The required pad file is found.\r
-  @retval EFI_NOT_FOUND   The required pad file can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvSearchSuitablePadFile (\r
-  IN FV_DEVICE              *FvDevice,\r
-  IN UINTN                  NumOfFiles,\r
-  IN UINTN                  *BufferSize,\r
-  IN UINTN                  *RequiredAlignment,\r
-  OUT UINTN                 *PadSize,\r
-  OUT UINTN                 *TotalSizeNeeded,\r
-  OUT FFS_FILE_LIST_ENTRY   **PadFileEntry\r
-  )\r
-{\r
-  FFS_FILE_LIST_ENTRY *FileEntry;\r
-  EFI_FFS_FILE_STATE  FileState;\r
-  EFI_FFS_FILE_HEADER *FileHeader;\r
-  UINTN               PadAreaLength;\r
-  UINTN               TotalSize;\r
-  UINTN               Index;\r
-  UINTN               HeaderSize;\r
-\r
-  FileEntry = (FFS_FILE_LIST_ENTRY *) FvDevice->FfsFileListHeader.ForwardLink;\r
-\r
-  //\r
-  // travel through the whole file list to get the pad file entry\r
-  //\r
-  while (FileEntry != (FFS_FILE_LIST_ENTRY *) &FvDevice->FfsFileListHeader) {\r
-\r
-    FileHeader  = (EFI_FFS_FILE_HEADER *) FileEntry->FfsHeader;\r
-    FileState   = GetFileState (FvDevice->ErasePolarity, FileHeader);\r
-\r
-    if ((FileHeader->Type == EFI_FV_FILETYPE_FFS_PAD) && (FileState == EFI_FILE_DATA_VALID)) {\r
-      //\r
-      // we find one valid pad file, check its length\r
-      //\r
-      if (IS_FFS_FILE2 (FileHeader)) {\r
-        HeaderSize = sizeof (EFI_FFS_FILE_HEADER2);\r
-        PadAreaLength = FFS_FILE2_SIZE (FileHeader) - HeaderSize;\r
-      } else {\r
-        HeaderSize = sizeof (EFI_FFS_FILE_HEADER);\r
-        PadAreaLength = FFS_FILE_SIZE (FileHeader) - HeaderSize;\r
-      }\r
-      TotalSize     = 0;\r
-\r
-      for (Index = 0; Index < NumOfFiles; Index++) {\r
-        PadSize[Index] = CalculatePadFileSize (\r
-                      FvDevice,\r
-                      (EFI_PHYSICAL_ADDRESS) (UINTN) FileHeader + HeaderSize + TotalSize,\r
-                      BufferSize[Index],\r
-                      RequiredAlignment[Index]\r
-                      );\r
-        TotalSize += PadSize[Index];\r
-        TotalSize += BufferSize[Index];\r
-\r
-        if (TotalSize > PadAreaLength) {\r
-          break;\r
-        }\r
-      }\r
-\r
-      if (PadAreaLength >= TotalSize) {\r
-        *PadFileEntry     = FileEntry;\r
-        *TotalSizeNeeded  = TotalSize;\r
-        return EFI_SUCCESS;\r
-      }\r
-    }\r
-\r
-    FileEntry = (FFS_FILE_LIST_ENTRY *) (FileEntry->Link.ForwardLink);\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Locate a Free Space entry which can hold these files, including\r
-  meeting the alignment requirements.\r
-\r
-  @param FvDevice          Cached Firmware Volume.\r
-  @param NumOfFiles        The number of Files that needed updating\r
-  @param BufferSize        The array of each file size.\r
-  @param RequiredAlignment The array of of FFS File Data alignment requirement.\r
-  @param PadSize           The array of size of each leading Pad File.\r
-  @param TotalSizeNeeded   The got total size that can hold these files.\r
-  @param FreeSpaceEntry    The Free Space Entry that can hold these files.\r
-\r
-  @retval EFI_SUCCESS     The free space entry is found.\r
-  @retval EFI_NOT_FOUND   The free space entry can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvSearchSuitableFreeSpace (\r
-  IN FV_DEVICE              *FvDevice,\r
-  IN UINTN                  NumOfFiles,\r
-  IN UINTN                  *BufferSize,\r
-  IN UINTN                  *RequiredAlignment,\r
-  OUT UINTN                 *PadSize,\r
-  OUT UINTN                 *TotalSizeNeeded,\r
-  OUT FREE_SPACE_ENTRY      **FreeSpaceEntry\r
-  )\r
-{\r
-  FREE_SPACE_ENTRY  *FreeSpaceListEntry;\r
-  LIST_ENTRY        *Link;\r
-  UINTN             TotalSize;\r
-  UINTN             Index;\r
-  UINT8             *StartAddr;\r
-\r
-  Link                = FvDevice->FreeSpaceHeader.ForwardLink;\r
-\r
-  FreeSpaceListEntry  = (FREE_SPACE_ENTRY *) Link;\r
-\r
-  while ((LIST_ENTRY *) FreeSpaceListEntry != &FvDevice->FreeSpaceHeader) {\r
-    TotalSize = 0;\r
-    StartAddr = FreeSpaceListEntry->StartingAddress;\r
-\r
-    //\r
-    // Calculate the totalsize we need\r
-    //\r
-    for (Index = 0; Index < NumOfFiles; Index++) {\r
-      //\r
-      // Perhaps we don't need an EFI_FFS_FILE_HEADER, the first file\r
-      // have had its leading pad file.\r
-      //\r
-      PadSize[Index] = CalculatePadFileSize (\r
-                    FvDevice,\r
-                    (EFI_PHYSICAL_ADDRESS) (UINTN) StartAddr + TotalSize,\r
-                    BufferSize[Index],\r
-                    RequiredAlignment[Index]\r
-                    );\r
-\r
-      TotalSize += PadSize[Index];\r
-      TotalSize += BufferSize[Index];\r
-\r
-      if (TotalSize > FreeSpaceListEntry->Length) {\r
-        break;\r
-      }\r
-    }\r
-\r
-    if (FreeSpaceListEntry->Length >= TotalSize) {\r
-      *FreeSpaceEntry   = FreeSpaceListEntry;\r
-      *TotalSizeNeeded  = TotalSize;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    FreeSpaceListEntry = (FREE_SPACE_ENTRY *) FreeSpaceListEntry->Link.ForwardLink;\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Calculate the length of the remaining space in FV.\r
-\r
-  @param FvDevice        Cached Firmware Volume\r
-  @param Offset          Current offset to FV base address.\r
-  @param Lba             LBA number for the current offset.\r
-  @param LOffset         Offset in block for the current offset.\r
-\r
-  @return the length of remaining space.\r
-\r
-**/\r
-UINTN\r
-CalculateRemainingLength (\r
-  IN     FV_DEVICE                            *FvDevice,\r
-  IN     UINTN                                Offset,\r
-  OUT  EFI_LBA                                *Lba,\r
-  OUT  UINTN                                  *LOffset\r
-  )\r
-{\r
-  LIST_ENTRY      *Link;\r
-  LBA_ENTRY       *LbaEntry;\r
-  UINTN           Count;\r
-\r
-  Count     = 0;\r
-  *Lba      = 0;\r
-  Link      = FvDevice->LbaHeader.ForwardLink;\r
-  LbaEntry  = (LBA_ENTRY *) Link;\r
-\r
-  while (&LbaEntry->Link != &FvDevice->LbaHeader) {\r
-    if (Count > Offset) {\r
-      break;\r
-    }\r
-\r
-    Count += LbaEntry->BlockLength;\r
-    (*Lba)++;\r
-    Link      = LbaEntry->Link.ForwardLink;\r
-    LbaEntry  = (LBA_ENTRY *) Link;\r
-  }\r
-\r
-  if (Count <= Offset) {\r
-    return 0;\r
-  }\r
-\r
-  Link      = LbaEntry->Link.BackLink;\r
-  LbaEntry  = (LBA_ENTRY *) Link;\r
-\r
-  (*Lba)--;\r
-  *LOffset  = (UINTN) (LbaEntry->BlockLength - (Count - Offset));\r
-\r
-  Count     = 0;\r
-  while (&LbaEntry->Link != &FvDevice->LbaHeader) {\r
-\r
-    Count += LbaEntry->BlockLength;\r
-\r
-    Link      = LbaEntry->Link.ForwardLink;\r
-    LbaEntry  = (LBA_ENTRY *) Link;\r
-  }\r
-\r
-  Count -= *LOffset;\r
-\r
-  return Count;\r
-}\r
-\r
-/**\r
-  Writes data beginning at Lba:Offset from FV. The write terminates either\r
-  when *NumBytes of data have been written, or when the firmware end is\r
-  reached.  *NumBytes is updated to reflect the actual number of bytes\r
-  written.\r
-\r
-  @param FvDevice        Cached Firmware Volume\r
-  @param Offset          Offset in the block at which to begin write\r
-  @param NumBytes        At input, indicates the requested write size.\r
-                         At output, indicates the actual number of bytes written.\r
-  @param Buffer          Buffer containing source data for the write.\r
-\r
-  @retval EFI_SUCCESS  Data is successfully written into FV.\r
-  @return error        Data is failed written.\r
-\r
-**/\r
-EFI_STATUS\r
-FvcWrite (\r
-  IN     FV_DEVICE                            *FvDevice,\r
-  IN     UINTN                                Offset,\r
-  IN OUT UINTN                                *NumBytes,\r
-  IN     UINT8                                *Buffer\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *Fvb;\r
-  EFI_LBA                             Lba;\r
-  UINTN                               LOffset;\r
-  EFI_FVB_ATTRIBUTES_2                FvbAttributes;\r
-  UINTN                               RemainingLength;\r
-  UINTN                               WriteLength;\r
-  UINT8                               *TmpBuffer;\r
-\r
-  LOffset = 0;\r
-  RemainingLength = CalculateRemainingLength (FvDevice, Offset, &Lba, &LOffset);\r
-  if ((UINTN) (*NumBytes) > RemainingLength) {\r
-    *NumBytes = (UINTN) RemainingLength;\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Fvb = FvDevice->Fvb;\r
-\r
-  Status = Fvb->GetAttributes (\r
-                  Fvb,\r
-                  &FvbAttributes\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if ((FvbAttributes & EFI_FV2_WRITE_STATUS) == 0) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-\r
-  RemainingLength = *NumBytes;\r
-  WriteLength     = RemainingLength;\r
-  TmpBuffer       = Buffer;\r
-\r
-  do {\r
-    Status = Fvb->Write (\r
-                    Fvb,\r
-                    Lba,\r
-                    LOffset,\r
-                    &WriteLength,\r
-                    TmpBuffer\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-\r
-    if (Status == EFI_BAD_BUFFER_SIZE) {\r
-      Lba++;\r
-      LOffset = 0;\r
-      TmpBuffer += WriteLength;\r
-      RemainingLength -= WriteLength;\r
-      WriteLength = (UINTN) RemainingLength;\r
-\r
-      continue;\r
-    } else {\r
-      return Status;\r
-    }\r
-  } while (1);\r
-\r
-Done:\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Create a new FFS file into Firmware Volume device.\r
-\r
-  @param FvDevice        Cached Firmware Volume.\r
-  @param FfsFileBuffer   A buffer that holds an FFS file,(it contains\r
-                         a File Header which is in init state).\r
-  @param BufferSize      The size of FfsFileBuffer.\r
-  @param ActualFileSize  The actual file length, it may not be multiples of 8.\r
-  @param FileName        The FFS File Name.\r
-  @param FileType        The FFS File Type.\r
-  @param FileAttributes  The Attributes of the FFS File to be created.\r
-\r
-  @retval EFI_SUCCESS           FFS fle is added into FV.\r
-  @retval EFI_INVALID_PARAMETER File type is not valid.\r
-  @retval EFI_DEVICE_ERROR      FV doesn't set writable attribute.\r
-  @retval EFI_NOT_FOUND         FV has no enough space for the added file.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCreateNewFile (\r
-  IN FV_DEVICE                *FvDevice,\r
-  IN UINT8                    *FfsFileBuffer,\r
-  IN UINTN                    BufferSize,\r
-  IN UINTN                    ActualFileSize,\r
-  IN EFI_GUID                 *FileName,\r
-  IN EFI_FV_FILETYPE          FileType,\r
-  IN EFI_FV_FILE_ATTRIBUTES   FileAttributes\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_FFS_FILE_HEADER                 *FileHeader;\r
-  EFI_PHYSICAL_ADDRESS                BufferPtr;\r
-  UINTN                               Offset;\r
-  UINTN                               NumBytesWritten;\r
-  UINTN                               StateOffset;\r
-  FREE_SPACE_ENTRY                    *FreeSpaceEntry;\r
-  UINTN                               RequiredAlignment;\r
-  UINTN                               PadFileSize;\r
-  FFS_FILE_LIST_ENTRY                 *PadFileEntry;\r
-  EFI_FFS_FILE_ATTRIBUTES             TmpFileAttribute;\r
-  FFS_FILE_LIST_ENTRY                 *FfsFileEntry;\r
-  UINTN                               HeaderSize;\r
-\r
-  //\r
-  // File Type: 0x0E~0xE0 are reserved\r
-  //\r
-  if ((FileType > EFI_FV_FILETYPE_SMM_CORE) && (FileType < 0xE0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // First find a free space that can hold this image.\r
-  // Check alignment, FFS at least must be aligned at 8-byte boundary\r
-  //\r
-  RequiredAlignment = GetRequiredAlignment (FileAttributes);\r
-\r
-  Status = FvLocateFreeSpaceEntry (\r
-            FvDevice,\r
-            BufferSize,\r
-            RequiredAlignment,\r
-            &PadFileSize,\r
-            &FreeSpaceEntry\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Maybe we need to find a PAD file that can hold this image\r
-    //\r
-    Status = FvCreateNewFileInsidePadFile (\r
-              FvDevice,\r
-              FfsFileBuffer,\r
-              BufferSize,\r
-              ActualFileSize,\r
-              FileName,\r
-              FileType,\r
-              FileAttributes\r
-              );\r
-\r
-    return Status;\r
-  }\r
-\r
-  BufferPtr     = (EFI_PHYSICAL_ADDRESS) (UINTN) FreeSpaceEntry->StartingAddress;\r
-\r
-  //\r
-  // If we need a leading PAD File, create it first.\r
-  //\r
-  if (PadFileSize != 0) {\r
-    Status = FvCreatePadFileInFreeSpace (\r
-              FvDevice,\r
-              FreeSpaceEntry,\r
-              PadFileSize - sizeof (EFI_FFS_FILE_HEADER),\r
-              &PadFileEntry\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-  //\r
-  // Maybe we create a pad file, so re-get the free space starting address\r
-  // and length\r
-  //\r
-  BufferPtr     = (EFI_PHYSICAL_ADDRESS) (UINTN) FreeSpaceEntry->StartingAddress;\r
-\r
-  //\r
-  // File creation step 1: Allocate File Header,\r
-  // Mark EFI_FILE_HEADER_CONSTRUCTION bit to TRUE,\r
-  // Write Name, IntegrityCheck.Header, Type, Attributes, and Size\r
-  //\r
-  FileHeader = (EFI_FFS_FILE_HEADER *) FfsFileBuffer;\r
-  if (ActualFileSize > 0x00FFFFFF) {\r
-    HeaderSize = sizeof (EFI_FFS_FILE_HEADER2);\r
-  } else {\r
-    HeaderSize = sizeof (EFI_FFS_FILE_HEADER);\r
-  }\r
-  SetFileState (EFI_FILE_HEADER_CONSTRUCTION, FileHeader);\r
-\r
-  Offset          = (UINTN) (BufferPtr - FvDevice->CachedFv);\r
-  StateOffset     = Offset + (UINT8 *) &FileHeader->State - (UINT8 *) FileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            StateOffset,\r
-            &NumBytesWritten,\r
-            &FileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // update header 2 cache\r
-  //\r
-  CopyMem (\r
-    (UINT8 *) (UINTN) BufferPtr,\r
-    FileHeader,\r
-    HeaderSize\r
-    );\r
-\r
-  //\r
-  // update Free Space Entry, now need to substract the file header length\r
-  //\r
-  FreeSpaceEntry->StartingAddress += HeaderSize;\r
-  FreeSpaceEntry->Length -= HeaderSize;\r
-\r
-  CopyGuid (&FileHeader->Name, FileName);\r
-  FileHeader->Type = FileType;\r
-\r
-  //\r
-  // Convert FvFileAttribute to FfsFileAttributes\r
-  //\r
-  FvFileAttrib2FfsFileAttrib (FileAttributes, &TmpFileAttribute);\r
-\r
-  FileHeader->Attributes = TmpFileAttribute;\r
-\r
-  //\r
-  // File size is including the FFS File Header.\r
-  //\r
-  if (ActualFileSize > 0x00FFFFFF) {\r
-    ((EFI_FFS_FILE_HEADER2 *) FileHeader)->ExtendedSize = (UINT32) ActualFileSize;\r
-    *(UINT32 *) FileHeader->Size &= 0xFF000000;\r
-    FileHeader->Attributes |= FFS_ATTRIB_LARGE_FILE;\r
-  } else {\r
-    *(UINT32 *) FileHeader->Size &= 0xFF000000;\r
-    *(UINT32 *) FileHeader->Size |= ActualFileSize;\r
-  }\r
-\r
-  SetHeaderChecksum (FileHeader);\r
-\r
-  Offset          = (UINTN) (BufferPtr - FvDevice->CachedFv);\r
-\r
-  NumBytesWritten = HeaderSize;\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            Offset,\r
-            &NumBytesWritten,\r
-            (UINT8 *) FileHeader\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // update header 2 cache\r
-  //\r
-  CopyMem (\r
-    (UINT8 *) (UINTN) BufferPtr,\r
-    FileHeader,\r
-    HeaderSize\r
-    );\r
-\r
-  //\r
-  // end of step 1\r
-  //\r
-  // File creation step 2:\r
-  // MARK EFI_FILE_HEADER_VALID bit to TRUE,\r
-  // Write IntegrityCheck.File, File Data\r
-  //\r
-  SetFileState (EFI_FILE_HEADER_VALID, FileHeader);\r
-\r
-  Offset          = (UINTN) (BufferPtr - FvDevice->CachedFv);\r
-  StateOffset     = Offset + (UINT8 *) &FileHeader->State - (UINT8 *) FileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            StateOffset,\r
-            &NumBytesWritten,\r
-            &FileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // update header 2 cache\r
-  //\r
-  CopyMem (\r
-    (UINT8 *) (UINTN) BufferPtr,\r
-    FileHeader,\r
-    HeaderSize\r
-    );\r
-\r
-  //\r
-  // update Free Space Entry, now need to substract the file data length\r
-  //\r
-  FreeSpaceEntry->StartingAddress += (BufferSize - HeaderSize);\r
-  FreeSpaceEntry->Length -= (BufferSize - HeaderSize);\r
-\r
-  //\r
-  // Calculate File Checksum\r
-  //\r
-  SetFileChecksum (FileHeader, ActualFileSize);\r
-\r
-  Offset          = (UINTN) (BufferPtr - FvDevice->CachedFv);\r
-\r
-  NumBytesWritten = BufferSize;\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            Offset,\r
-            &NumBytesWritten,\r
-            FfsFileBuffer\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // each time write block successfully, write also to cache\r
-  //\r
-  CopyMem (\r
-    (UINT8 *) (UINTN) BufferPtr,\r
-    FfsFileBuffer,\r
-    NumBytesWritten\r
-    );\r
-\r
-  //\r
-  // Step 3: Mark EFI_FILE_DATA_VALID to TRUE\r
-  //\r
-  SetFileState (EFI_FILE_DATA_VALID, FileHeader);\r
-\r
-  Offset          = (UINTN) (BufferPtr - FvDevice->CachedFv);\r
-  StateOffset     = Offset + (UINT8 *) &FileHeader->State - (UINT8 *) FileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            StateOffset,\r
-            &NumBytesWritten,\r
-            &FileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // update header 2 cache\r
-  //\r
-  CopyMem (\r
-    (UINT8 *) (UINTN) BufferPtr,\r
-    FileHeader,\r
-    HeaderSize\r
-    );\r
-\r
-  //\r
-  // If successfully, insert an FfsFileEntry at the end of ffs file list\r
-  //\r
-\r
-  FfsFileEntry            = AllocateZeroPool (sizeof (FFS_FILE_LIST_ENTRY));\r
-  ASSERT (FfsFileEntry   != NULL);\r
-  FfsFileEntry->FfsHeader = (UINT8 *) (UINTN) BufferPtr;\r
-  InsertTailList (&FvDevice->FfsFileListHeader, &FfsFileEntry->Link);\r
-\r
-  //\r
-  // Set cache file to this file\r
-  //\r
-  FvDevice->CurrentFfsFile = FfsFileEntry;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Update a File, so after successful update, there are 2 files existing\r
-  in FV, one is marked for deleted, and another one is valid.\r
-\r
-  @param FvDevice          Cached Firmware Volume.\r
-  @param FfsFileBuffer     A buffer that holds an FFS file,(it contains\r
-                           a File Header which is in init state).\r
-  @param BufferSize        The size of FfsFileBuffer.\r
-  @param ActualFileSize    The actual file length, it may not be multiples of 8.\r
-  @param FileName          The FFS File Name.\r
-  @param NewFileType       The FFS File Type.\r
-  @param NewFileAttributes The Attributes of the FFS File to be created.\r
-\r
-  @retval EFI_SUCCESS           FFS fle is updated into FV.\r
-  @retval EFI_INVALID_PARAMETER File type is not valid.\r
-  @retval EFI_DEVICE_ERROR      FV doesn't set writable attribute.\r
-  @retval EFI_NOT_FOUND         FV has no enough space for the added file.\r
-                                FFS with same file name is not found in FV.\r
-\r
-**/\r
-EFI_STATUS\r
-FvUpdateFile (\r
-  IN FV_DEVICE                *FvDevice,\r
-  IN UINT8                    *FfsFileBuffer,\r
-  IN UINTN                    BufferSize,\r
-  IN UINTN                    ActualFileSize,\r
-  IN EFI_GUID                 *FileName,\r
-  IN EFI_FV_FILETYPE          NewFileType,\r
-  IN EFI_FV_FILE_ATTRIBUTES   NewFileAttributes\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL       *Fv;\r
-  UINTN                               NumBytesWritten;\r
-  EFI_FV_FILETYPE                     OldFileType;\r
-  EFI_FV_FILE_ATTRIBUTES              OldFileAttributes;\r
-  UINTN                               OldFileSize;\r
-  EFI_FFS_FILE_HEADER                 *OldFileHeader;\r
-  UINTN                               OldOffset;\r
-  UINTN                               OldStateOffset;\r
-  FFS_FILE_LIST_ENTRY                 *OldFfsFileEntry;\r
-  UINTN                               Key;\r
-  EFI_GUID                            FileNameGuid;\r
-\r
-  Fv  = &FvDevice->Fv;\r
-\r
-  //\r
-  // Step 1, find old file,\r
-  // Mark EFI_FILE_MARKED_FOR_UPDATE to TRUE in the older header\r
-  //\r
-\r
-  //\r
-  // Check if the file was read last time.\r
-  //\r
-  OldFileHeader   = NULL;\r
-  OldFfsFileEntry = FvDevice->CurrentFfsFile;\r
-\r
-  if (OldFfsFileEntry != NULL) {\r
-    OldFileHeader = (EFI_FFS_FILE_HEADER *) OldFfsFileEntry->FfsHeader;\r
-  }\r
-\r
-  if ((OldFfsFileEntry == NULL) || (!CompareGuid (&OldFileHeader->Name, FileName))) {\r
-    Key = 0;\r
-    do {\r
-      OldFileType = 0;\r
-      Status = Fv->GetNextFile (\r
-                    Fv,\r
-                    &Key,\r
-                    &OldFileType,\r
-                    &FileNameGuid,\r
-                    &OldFileAttributes,\r
-                    &OldFileSize\r
-                    );\r
-      if (EFI_ERROR (Status)) {\r
-        return Status;\r
-      }\r
-    } while (!CompareGuid (&FileNameGuid, FileName));\r
-\r
-    //\r
-    // Get FfsFileEntry from the search key\r
-    //\r
-    OldFfsFileEntry = (FFS_FILE_LIST_ENTRY *) Key;\r
-\r
-    //\r
-    // Double check file state before being ready to be removed\r
-    //\r
-    OldFileHeader = (EFI_FFS_FILE_HEADER *) OldFfsFileEntry->FfsHeader;\r
-  } else {\r
-    //\r
-    // Mark the cache file to invalid\r
-    //\r
-    FvDevice->CurrentFfsFile = NULL;\r
-  }\r
-  //\r
-  // Update File: Mark EFI_FILE_MARKED_FOR_UPDATE to TRUE\r
-  //\r
-  SetFileState (EFI_FILE_MARKED_FOR_UPDATE, OldFileHeader);\r
-\r
-  OldOffset       = (UINTN) ((EFI_PHYSICAL_ADDRESS) (UINTN) OldFileHeader - FvDevice->CachedFv);\r
-  OldStateOffset  = OldOffset + (UINT8 *) &OldFileHeader->State - (UINT8 *) OldFileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            OldStateOffset,\r
-            &NumBytesWritten,\r
-            &OldFileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // if failed, write the bit back in the cache, its XOR operation.\r
-    //\r
-    SetFileState (EFI_FILE_MARKED_FOR_UPDATE, OldFileHeader);\r
-\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Step 2, Create New Files\r
-  //\r
-  Status = FvCreateNewFile (\r
-            FvDevice,\r
-            FfsFileBuffer,\r
-            BufferSize,\r
-            ActualFileSize,\r
-            FileName,\r
-            NewFileType,\r
-            NewFileAttributes\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // If successfully, remove this file entry,\r
-  // although delete file may fail.\r
-  //\r
-  (OldFfsFileEntry->Link.BackLink)->ForwardLink = OldFfsFileEntry->Link.ForwardLink;\r
-  (OldFfsFileEntry->Link.ForwardLink)->BackLink = OldFfsFileEntry->Link.BackLink;\r
-  FreePool (OldFfsFileEntry);\r
-\r
-  //\r
-  // Step 3: Delete old files,\r
-  // by marking EFI_FILE_DELETED to TRUE\r
-  //\r
-  SetFileState (EFI_FILE_DELETED, OldFileHeader);\r
-\r
-  OldOffset       = (UINTN) ((EFI_PHYSICAL_ADDRESS) (UINTN) OldFileHeader - FvDevice->CachedFv);\r
-  OldStateOffset  = OldOffset + (UINT8 *) &OldFileHeader->State - (UINT8 *) OldFileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            OldStateOffset,\r
-            &NumBytesWritten,\r
-            &OldFileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // if failed, write the bit back in the cache, its XOR operation.\r
-    //\r
-    SetFileState (EFI_FILE_DELETED, OldFileHeader);\r
-\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Deleted a given file from FV device.\r
-\r
-  @param FvDevice        Cached Firmware Volume.\r
-  @param NameGuid        The FFS File Name.\r
-\r
-  @retval EFI_SUCCESS    FFS file with the specified FFS name is removed.\r
-  @retval EFI_NOT_FOUND  FFS file with the specified FFS name is not found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvDeleteFile (\r
-  IN FV_DEVICE  *FvDevice,\r
-  IN EFI_GUID   *NameGuid\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  UINTN                               Key;\r
-  EFI_GUID                            FileNameGuid;\r
-  EFI_FV_FILETYPE                     FileType;\r
-  EFI_FV_FILE_ATTRIBUTES              FileAttributes;\r
-  UINTN                               FileSize;\r
-  EFI_FFS_FILE_HEADER                 *FileHeader;\r
-  FFS_FILE_LIST_ENTRY                 *FfsFileEntry;\r
-  EFI_FFS_FILE_STATE                  FileState;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL        *Fv;\r
-  UINTN                               Offset;\r
-  UINTN                               StateOffset;\r
-  UINTN                               NumBytesWritten;\r
-\r
-  Fv  = &FvDevice->Fv;\r
-\r
-  //\r
-  // Check if the file was read last time.\r
-  //\r
-  FileHeader    = NULL;\r
-  FfsFileEntry  = FvDevice->CurrentFfsFile;\r
-\r
-  if (FfsFileEntry != NULL) {\r
-    FileHeader = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
-  }\r
-\r
-  if ((FfsFileEntry == NULL) || (!CompareGuid (&FileHeader->Name, NameGuid))) {\r
-    //\r
-    // Next search for the file using GetNextFile\r
-    //\r
-    Key = 0;\r
-    do {\r
-      FileType = 0;\r
-      Status = Fv->GetNextFile (\r
-                    Fv,\r
-                    &Key,\r
-                    &FileType,\r
-                    &FileNameGuid,\r
-                    &FileAttributes,\r
-                    &FileSize\r
-                    );\r
-      if (EFI_ERROR (Status)) {\r
-        return Status;\r
-      }\r
-    } while (!CompareGuid (&FileNameGuid, NameGuid));\r
-\r
-    //\r
-    // Get FfsFileEntry from the search key\r
-    //\r
-    FfsFileEntry = (FFS_FILE_LIST_ENTRY *) Key;\r
-\r
-    //\r
-    // Double check file state before being ready to be removed\r
-    //\r
-    FileHeader = (EFI_FFS_FILE_HEADER *) FfsFileEntry->FfsHeader;\r
-  } else {\r
-    //\r
-    // Mark the cache file to NULL\r
-    //\r
-    FvDevice->CurrentFfsFile = NULL;\r
-  }\r
-\r
-  FileState = GetFileState (FvDevice->ErasePolarity, FileHeader);\r
-\r
-  if (FileState == EFI_FILE_HEADER_INVALID) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if (FileState == EFI_FILE_DELETED) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Delete File: Mark EFI_FILE_DELETED to TRUE\r
-  //\r
-  SetFileState (EFI_FILE_DELETED, FileHeader);\r
-\r
-  Offset          = (UINTN) ((EFI_PHYSICAL_ADDRESS) (UINTN) FileHeader - FvDevice->CachedFv);\r
-  StateOffset     = Offset + (UINT8 *) &FileHeader->State - (UINT8 *) FileHeader;\r
-\r
-  NumBytesWritten = sizeof (EFI_FFS_FILE_STATE);\r
-  Status = FvcWrite (\r
-            FvDevice,\r
-            StateOffset,\r
-            &NumBytesWritten,\r
-            &FileHeader->State\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // if failed, write the bit back in the cache, its XOR operation.\r
-    //\r
-    SetFileState (EFI_FILE_DELETED, FileHeader);\r
-\r
-    return Status;\r
-  }\r
-  //\r
-  // If successfully, remove this file entry\r
-  //\r
-  FvDevice->CurrentFfsFile                    = NULL;\r
-\r
-  (FfsFileEntry->Link.BackLink)->ForwardLink  = FfsFileEntry->Link.ForwardLink;\r
-  (FfsFileEntry->Link.ForwardLink)->BackLink  = FfsFileEntry->Link.BackLink;\r
-  FreePool (FfsFileEntry);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Writes one or more files to the firmware volume.\r
-\r
-  @param  This                   Indicates the calling context.\r
-  @param  NumberOfFiles          Number of files.\r
-  @param  WritePolicy            WritePolicy indicates the level of reliability\r
-                                 for the write in the event of a power failure or\r
-                                 other system failure during the write operation.\r
-  @param  FileData               FileData is an pointer to an array of\r
-                                 EFI_FV_WRITE_DATA. Each element of array\r
-                                 FileData represents a file to be written.\r
-\r
-  @retval EFI_SUCCESS            Files successfully written to firmware volume\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough buffer to be allocated.\r
-  @retval EFI_DEVICE_ERROR       Device error.\r
-  @retval EFI_WRITE_PROTECTED    Write protected.\r
-  @retval EFI_NOT_FOUND          Not found.\r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter.\r
-  @retval EFI_UNSUPPORTED        This function not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvWriteFile (\r
-  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
-  IN UINT32                         NumberOfFiles,\r
-  IN EFI_FV_WRITE_POLICY            WritePolicy,\r
-  IN EFI_FV_WRITE_FILE_DATA         *FileData\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  UINTN                               Index1;\r
-  UINTN                               Index2;\r
-  UINT8                               *FileBuffer;\r
-  UINTN                               BufferSize;\r
-  UINTN                               ActualSize;\r
-  UINT8                               ErasePolarity;\r
-  FV_DEVICE                           *FvDevice;\r
-  EFI_FV_FILETYPE                     FileType;\r
-  EFI_FV_FILE_ATTRIBUTES              FileAttributes;\r
-  UINTN                               Size;\r
-  BOOLEAN                             CreateNewFile[MAX_FILES];\r
-  UINTN                               NumDelete;\r
-  EFI_FV_ATTRIBUTES                   FvAttributes;\r
-  UINT32                              AuthenticationStatus;\r
-  UINTN                               HeaderSize;\r
-\r
-  if (NumberOfFiles > MAX_FILES) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  SetMem (CreateNewFile, NumberOfFiles, TRUE);\r
-\r
-  FvDevice  = FV_DEVICE_FROM_THIS (This);\r
-\r
-  //\r
-  // First check the volume attributes.\r
-  //\r
-  Status = This->GetVolumeAttributes (\r
-                  This,\r
-                  &FvAttributes\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Can we have write right?\r
-  //\r
-  if ((FvAttributes & EFI_FV2_WRITE_STATUS) == 0) {\r
-    return EFI_WRITE_PROTECTED;\r
-  }\r
-\r
-  ErasePolarity = FvDevice->ErasePolarity;\r
-\r
-  //\r
-  // Loop for all files\r
-  //\r
-  NumDelete = 0;\r
-  for (Index1 = 0; Index1 < NumberOfFiles; Index1++) {\r
-\r
-    if ((FileData[Index1].BufferSize + sizeof (EFI_FFS_FILE_HEADER) > 0x00FFFFFF) && !FvDevice->IsFfs3Fv) {\r
-      //\r
-      // Found a file needs a FFS3 formatted file to store it, but it is in a non-FFS3 formatted FV.\r
-      //\r
-      DEBUG ((EFI_D_ERROR, "FFS3 formatted file can't be written in a non-FFS3 formatted FV.\n"));\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (FileData[Index1].BufferSize == 0) {\r
-      //\r
-      // Here we will delete this file\r
-      //\r
-      Status = This->ReadFile (\r
-                      This,\r
-                      FileData[Index1].NameGuid,\r
-                      NULL,\r
-                      &Size,\r
-                      &FileType,\r
-                      &FileAttributes,\r
-                      &AuthenticationStatus\r
-                      );\r
-      if (!EFI_ERROR (Status)) {\r
-        NumDelete++;\r
-      } else {\r
-        return Status;\r
-      }\r
-    }\r
-\r
-    if (FileData[Index1].Type == EFI_FV_FILETYPE_FFS_PAD) {\r
-      //\r
-      // According to PI spec, on EFI_FV_FILETYPE_FFS_PAD:\r
-      // "Standard firmware file system services will not return the handle of any pad files,\r
-      // nor will they permit explicit creation of such files."\r
-      //\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-\r
-  if ((NumDelete != NumberOfFiles) && (NumDelete != 0)) {\r
-    //\r
-    // A delete was request with a multiple file write\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (NumDelete == NumberOfFiles) {\r
-    for (Index1 = 0; Index1 < NumberOfFiles; Index1++) {\r
-      //\r
-      // Delete Files\r
-      //\r
-      Status = FvDeleteFile (FvDevice, FileData[Index1].NameGuid);\r
-      if (EFI_ERROR (Status)) {\r
-        return Status;\r
-      }\r
-    }\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  for (Index1 = 0; Index1 < NumberOfFiles; Index1++) {\r
-    Status = This->ReadFile (\r
-                    This,\r
-                    FileData[Index1].NameGuid,\r
-                    NULL,\r
-                    &Size,\r
-                    &FileType,\r
-                    &FileAttributes,\r
-                    &AuthenticationStatus\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      CreateNewFile[Index1] = FALSE;\r
-    } else if (Status == EFI_NOT_FOUND) {\r
-      CreateNewFile[Index1] = TRUE;\r
-    } else {\r
-      return Status;\r
-    }\r
-    //\r
-    // Checking alignment\r
-    //\r
-    if ((FileData[Index1].FileAttributes & EFI_FV_FILE_ATTRIB_ALIGNMENT) != 0) {\r
-      UINT8 FFSAlignmentValue;\r
-      UINT8 FvAlignmentValue;\r
-\r
-      FFSAlignmentValue = (UINT8) (FileData[Index1].FileAttributes & EFI_FV_FILE_ATTRIB_ALIGNMENT);\r
-      FvAlignmentValue = (UINT8) (((UINT32) (FvAttributes & EFI_FV2_ALIGNMENT)) >> 16);\r
-\r
-      if (FFSAlignmentValue > FvAlignmentValue) {\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-  }\r
-\r
-  if ((WritePolicy != EFI_FV_RELIABLE_WRITE) && (WritePolicy != EFI_FV_UNRELIABLE_WRITE)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Checking the reliable write is supported by FV\r
-  //\r
-\r
-  if ((WritePolicy == EFI_FV_RELIABLE_WRITE) && (NumberOfFiles > 1)) {\r
-    //\r
-    // Only for multiple files, reliable write is meaningful\r
-    //\r
-    Status = FvCreateMultipleFiles (\r
-              FvDevice,\r
-              NumberOfFiles,\r
-              FileData,\r
-              CreateNewFile\r
-              );\r
-\r
-    return Status;\r
-  }\r
-\r
-  for (Index1 = 0; Index1 < NumberOfFiles; Index1++) {\r
-    //\r
-    // Making Buffersize QWORD boundary, and add file tail.\r
-    //\r
-    HeaderSize = sizeof (EFI_FFS_FILE_HEADER);\r
-    ActualSize = FileData[Index1].BufferSize + HeaderSize;\r
-    if (ActualSize > 0x00FFFFFF) {\r
-      HeaderSize = sizeof (EFI_FFS_FILE_HEADER2);\r
-      ActualSize = FileData[Index1].BufferSize + HeaderSize;\r
-    }\r
-    BufferSize  = ActualSize;\r
-\r
-    while ((BufferSize & 0x07) != 0) {\r
-      BufferSize++;\r
-    }\r
-\r
-    FileBuffer = AllocateZeroPool (BufferSize);\r
-    if (FileBuffer == NULL) {\r
-      return Status;\r
-    }\r
-    //\r
-    // Copy File Data into FileBuffer\r
-    //\r
-    CopyMem (\r
-      FileBuffer + HeaderSize,\r
-      FileData[Index1].Buffer,\r
-      FileData[Index1].BufferSize\r
-      );\r
-\r
-    if (ErasePolarity == 1) {\r
-      //\r
-      // Fill the file header and padding byte with Erase Byte\r
-      //\r
-      for (Index2 = 0; Index2 < HeaderSize; Index2++) {\r
-        FileBuffer[Index2] = (UINT8)~FileBuffer[Index2];\r
-      }\r
-\r
-      for (Index2 = ActualSize; Index2 < BufferSize; Index2++) {\r
-        FileBuffer[Index2] = (UINT8)~FileBuffer[Index2];\r
-      }\r
-    }\r
-\r
-    if (CreateNewFile[Index1]) {\r
-      Status = FvCreateNewFile (\r
-                FvDevice,\r
-                FileBuffer,\r
-                BufferSize,\r
-                ActualSize,\r
-                FileData[Index1].NameGuid,\r
-                FileData[Index1].Type,\r
-                FileData[Index1].FileAttributes\r
-                );\r
-    } else {\r
-      Status = FvUpdateFile (\r
-                FvDevice,\r
-                FileBuffer,\r
-                BufferSize,\r
-                ActualSize,\r
-                FileData[Index1].NameGuid,\r
-                FileData[Index1].Type,\r
-                FileData[Index1].FileAttributes\r
-                );\r
-    }\r
-\r
-    FreePool (FileBuffer);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/FlashUpdate.c b/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/FlashUpdate.c
deleted file mode 100644 (file)
index e877c05..0000000
+++ /dev/null
@@ -1,1211 +0,0 @@
-/** @file\r
-  Functions in this file will program the image into flash area.\r
-\r
-  Copyright (c) 2002 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "UpdateDriver.h"\r
-\r
-/**\r
-  Write a block size data into flash.\r
-\r
-  @param FvbProtocol     Pointer to FVB protocol.\r
-  @param Lba             Logic block index to be updated.\r
-  @param BlockSize       Block size\r
-  @param Buffer          Buffer data to be written.\r
-\r
-  @retval EFI_SUCCESS   Write data successfully.\r
-  @retval other errors  Write data failed.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateOneBlock (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN EFI_LBA                            Lba,\r
-  IN UINTN                              BlockSize,\r
-  IN UINT8                              *Buffer\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  UINTN                                 Size;\r
-\r
-  //\r
-  // First erase the block\r
-  //\r
-  Status                = FvbProtocol->EraseBlocks (\r
-                                         FvbProtocol,\r
-                                         Lba,                        // Lba\r
-                                         1,                          // NumOfBlocks\r
-                                         EFI_LBA_LIST_TERMINATOR\r
-                                         );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Write the block\r
-  //\r
-  Size                  = BlockSize;\r
-  Status                = FvbProtocol->Write (\r
-                                         FvbProtocol,\r
-                                         Lba,                        // Lba\r
-                                         0,                          // Offset\r
-                                         &Size,                      // Size\r
-                                         Buffer                      // Buffer\r
-                                         );\r
-  if ((EFI_ERROR (Status)) || (Size != BlockSize)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write buffer data in a flash block.\r
-\r
-  @param FvbProtocol     Pointer to FVB protocol.\r
-  @param Lba             Logic block index to be updated.\r
-  @param Offset          The offset within the block.\r
-  @param Length          Size of buffer to be updated.\r
-  @param BlockSize       Block size.\r
-  @param Buffer          Buffer data to be updated.\r
-\r
-  @retval EFI_SUCCESS   Write data successfully.\r
-  @retval other errors  Write data failed.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateBufferInOneBlock (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN EFI_LBA                            Lba,\r
-  IN UINTN                              Offset,\r
-  IN UINTN                              Length,\r
-  IN UINTN                              BlockSize,\r
-  IN UINT8                              *Buffer\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  UINTN                                 Size;\r
-  UINT8                                 *ReservedBuffer;\r
-\r
-  //\r
-  // If we are going to update a whole block\r
-  //\r
-  if ((Offset == 0) && (Length == BlockSize)) {\r
-    Status              = UpdateOneBlock (\r
-                            FvbProtocol,\r
-                            Lba,\r
-                            BlockSize,\r
-                            Buffer\r
-                            );\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // If it is not a full block update, we need to coalesce data in\r
-  // the block that is not going to be updated and new data together.\r
-  //\r
-\r
-  //\r
-  // Allocate a reserved buffer to make up the final buffer for update\r
-  //\r
-  ReservedBuffer        = NULL;\r
-  ReservedBuffer = AllocatePool (BlockSize);\r
-  if (ReservedBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // First get the original content of the block\r
-  //\r
-  Size                  = BlockSize;\r
-  Status                = FvbProtocol->Read (\r
-                                         FvbProtocol,\r
-                                         Lba,\r
-                                         0,\r
-                                         &Size,\r
-                                         ReservedBuffer\r
-                                         );\r
-  if ((EFI_ERROR (Status)) || (Size != BlockSize)) {\r
-    FreePool (ReservedBuffer);\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Overwrite the reserved buffer with new content\r
-  //\r
-  CopyMem (ReservedBuffer + Offset, Buffer, Length);\r
-\r
-  Status                = UpdateOneBlock (\r
-                            FvbProtocol,\r
-                            Lba,\r
-                            BlockSize,\r
-                            ReservedBuffer\r
-                            );\r
-\r
-  FreePool (ReservedBuffer);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Get the last write log, and check the status of last write.\r
-  If not complete, restart will be taken.\r
-\r
-  @param FvbHandle       Handle of FVB protocol.\r
-  @param FtwProtocol     FTW protocol instance.\r
-  @param ConfigData      Config data on updating driver.\r
-  @param PrivateDataSize bytes from the private data\r
-                         stored for this write.\r
-  @param PrivateData     A pointer to a buffer. The function will copy.\r
-  @param Lba             The logical block address of the last write.\r
-  @param Offset          The offset within the block of the last write.\r
-  @param Length          The length of the last write.\r
-  @param Pending         A Boolean value with TRUE indicating\r
-                         that the write was completed.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.\r
-  @retval EFI_ABORTED           The FTW work space is damaged.\r
-  @retval EFI_NOT_FOUND         The last write is not done by this driver.\r
-  @retval EFI_SUCCESS           Last write log is got.\r
-\r
-**/\r
-EFI_STATUS\r
-RetrieveLastWrite (\r
-  IN EFI_HANDLE                         FvbHandle,\r
-  IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL  *FtwProtocol,\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
-  IN UINTN                              PrivateDataSize,\r
-  IN OUT UPDATE_PRIVATE_DATA            *PrivateData,\r
-  IN OUT EFI_LBA                        *Lba,\r
-  IN OUT UINTN                          *Offset,\r
-  IN OUT UINTN                          *Length,\r
-  IN OUT BOOLEAN                        *Pending\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_GUID                              CallerId;\r
-  UINTN                                 PrivateBufferSize;\r
-  BOOLEAN                               Complete;\r
-  VOID                                  *PrivateDataBuffer;\r
-\r
-  //\r
-  // Get the last write\r
-  //\r
-  *Pending              = FALSE;\r
-  PrivateBufferSize     = PrivateDataSize;\r
-  PrivateDataBuffer     = NULL;\r
-  Status                = FtwProtocol->GetLastWrite (\r
-                                         FtwProtocol,\r
-                                         &CallerId,\r
-                                         Lba,\r
-                                         Offset,\r
-                                         Length,\r
-                                         &PrivateBufferSize,\r
-                                         PrivateData,\r
-                                         &Complete\r
-                                         );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // If there is no incompleted record, return success.\r
-    //\r
-    if ((Status == EFI_NOT_FOUND) && Complete) {\r
-      return EFI_SUCCESS;\r
-    } else if (Status == EFI_BUFFER_TOO_SMALL) {\r
-      //\r
-      // If buffer too small, reallocate buffer and call getlastwrite again\r
-      //\r
-      PrivateDataBuffer = AllocatePool (PrivateBufferSize);\r
-\r
-      if (PrivateDataBuffer == NULL) {\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      Status            = FtwProtocol->GetLastWrite (\r
-                                         FtwProtocol,\r
-                                         &CallerId,\r
-                                         Lba,\r
-                                         Offset,\r
-                                         Length,\r
-                                         &PrivateBufferSize,\r
-                                         PrivateDataBuffer,\r
-                                         &Complete\r
-                                         );\r
-      if (EFI_ERROR (Status)) {\r
-        FreePool ( PrivateDataBuffer);\r
-        return EFI_ABORTED;\r
-      } else {\r
-        CopyMem (PrivateData, PrivateDataBuffer, PrivateDataSize);\r
-        FreePool (PrivateDataBuffer);\r
-        PrivateDataBuffer = NULL;\r
-      }\r
-    } else {\r
-      return EFI_ABORTED;\r
-    }\r
-  }\r
-\r
-  *Pending              = TRUE;\r
-\r
-  //\r
-  // If the caller is not the update driver, then return.\r
-  // The update driver cannot continue to perform the update\r
-  //\r
-  if (CompareMem (&CallerId, &gEfiCallerIdGuid, sizeof (EFI_GUID)) != 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Check the private data and see if it is the one I need.\r
-  //\r
-  if (CompareMem (&(PrivateData->FileGuid), &(ConfigData->FileGuid), sizeof(EFI_GUID)) != 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // If the caller is the update driver and complete is not true, then restart().\r
-  //\r
-  if (!Complete) {\r
-    //\r
-    //  Re-start the update\r
-    //\r
-    Status              = FtwProtocol->Restart (\r
-                                         FtwProtocol,\r
-                                         FvbHandle\r
-                                         );\r
-    //\r
-    // If restart() error, then abort().\r
-    //\r
-    if (EFI_ERROR (Status)) {\r
-      FtwProtocol->Abort (FtwProtocol);\r
-      //\r
-      // Now set Pending as FALSE as this record has been cleared\r
-      //\r
-      *Pending          = FALSE;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Update the whole FV image in fault tolerant write method.\r
-\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param BlockMap        Block array to specify flash area.\r
-  @param ConfigData      Config data on updating driver.\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param ImageSize       Image size.\r
-\r
-  @retval EFI_SUCCESS            FV image is writed into flash.\r
-  @retval EFI_INVALID_PARAMETER  Config data is not valid.\r
-  @retval EFI_NOT_FOUND          FTW protocol doesn't exist.\r
-  @retval EFI_OUT_OF_RESOURCES   No enough backup space.\r
-  @retval EFI_ABORTED            Error happen when update FV.\r
-\r
-**/\r
-EFI_STATUS\r
-FaultTolerantUpdateOnWholeFv (\r
-  IN EFI_HANDLE                         FvbHandle,\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN EFI_FV_BLOCK_MAP_ENTRY             *BlockMap,\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
-  IN UINT8                              *ImageBuffer,\r
-  IN UINTN                              ImageSize\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_FAULT_TOLERANT_WRITE_PROTOCOL     *FtwProtocol;\r
-  UINTN                                 MaxBlockSize;\r
-  UINTN                                 FtwMaxBlockSize;\r
-  BOOLEAN                               Pending;\r
-  UPDATE_PRIVATE_DATA                   PrivateData;\r
-  EFI_LBA                               PendingLba;\r
-  EFI_LBA                               Lba;\r
-  UINTN                                 PendingOffset;\r
-  UINTN                                 Offset;\r
-  UINTN                                 PendingLength;\r
-  UINTN                                 Length;\r
-  EFI_FV_BLOCK_MAP_ENTRY                *PtrMap;\r
-  UINTN                                 NumOfBlocks;\r
-  UINTN                                 Index;\r
-  UINT8                                 *UpdateBuffer;\r
-\r
-  if ((ConfigData->UpdateType != UpdateWholeFV)\r
-    || (!ConfigData->FaultTolerant)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Get the FTW protocol\r
-  //\r
-  Status                = gBS->LocateProtocol (\r
-                                 &gEfiFaultTolerantWriteProtocolGuid,\r
-                                 NULL,\r
-                                 (VOID **) &FtwProtocol\r
-                                 );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Get the maximum block size of the FV, and number of blocks\r
-  // NumOfBlocks will be the NumOfUdpates.\r
-  //\r
-  MaxBlockSize          = 0;\r
-  NumOfBlocks           = 0;\r
-  PtrMap                = BlockMap;\r
-  while (TRUE) {\r
-    if ((PtrMap->NumBlocks == 0) || (PtrMap->Length == 0)) {\r
-      break;\r
-    }\r
-    if (MaxBlockSize < PtrMap->Length) {\r
-      MaxBlockSize      = PtrMap->Length;\r
-    }\r
-    NumOfBlocks         = NumOfBlocks + PtrMap->NumBlocks;\r
-    PtrMap++;\r
-  }\r
-\r
-  FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);\r
-  //\r
-  // Not enough backup space. return directly\r
-  //\r
-  if (FtwMaxBlockSize < MaxBlockSize) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  PendingLba            = 0;\r
-  PendingOffset         = 0;\r
-  PendingLength         = 0;\r
-  Pending               = FALSE;\r
-\r
-  //\r
-  // Fault Tolerant Write can only support actual fault tolerance if the write\r
-  // is a reclaim operation, which means the data buffer (new and old) are\r
-  // acutally both stored in flash. But for component update write, the data\r
-  // are now in memory. So we cannot actually recover the data after power\r
-  // failure.\r
-  //\r
-  Status                = RetrieveLastWrite (\r
-                            FvbHandle,\r
-                            FtwProtocol,\r
-                            ConfigData,\r
-                            sizeof (UPDATE_PRIVATE_DATA),\r
-                            &PrivateData,\r
-                            &PendingLba,\r
-                            &PendingOffset,\r
-                            &PendingLength,\r
-                            &Pending\r
-                            );\r
-\r
-  if (Pending && (Status == EFI_NOT_FOUND)) {\r
-    //\r
-    // Cannot continue with the write operation\r
-    //\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  if (EFI_ERROR(Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  //\r
-  // Currently we start from the pending write if there is any. But as we\r
-  // are going to update a whole FV, we can just abort last write and start\r
-  // from the very begining.\r
-  //\r
-  if (!Pending) {\r
-    //\r
-    // Now allocte the update private data in FTW. If there is pending\r
-    // write, it has already been allocated and no need to allocate here.\r
-    //\r
-    Status              = FtwProtocol->Allocate (\r
-                                         FtwProtocol,\r
-                                         &gEfiCallerIdGuid,\r
-                                         sizeof (UPDATE_PRIVATE_DATA),\r
-                                         NumOfBlocks\r
-                                         );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Perform the update now. If there are pending writes, we need to\r
-  // start from the pending write instead of the very beginning.\r
-  //\r
-  PtrMap                = BlockMap;\r
-  Lba                   = 0;\r
-  Offset                = 0;\r
-  UpdateBuffer          = ImageBuffer;\r
-  CopyMem (\r
-    (VOID *) &PrivateData.FileGuid,\r
-    (VOID *) &ConfigData->FileGuid,\r
-     sizeof (EFI_GUID)\r
-  );\r
-\r
-  while (TRUE) {\r
-    if ((PtrMap->NumBlocks == 0) || (PtrMap->Length == 0)) {\r
-      break;\r
-    }\r
-    Length              = (UINTN)PtrMap->Length;\r
-    for (Index = 0; Index < PtrMap->NumBlocks; Index++) {\r
-\r
-      //\r
-      // Add an extra check here to see if the pending record is correct\r
-      //\r
-      if (Pending && (Lba == PendingLba)) {\r
-        if ((PendingOffset != Offset) || (PendingLength != Length)) {\r
-          //\r
-          // Error.\r
-          //\r
-          Status          = EFI_ABORTED;\r
-          break;\r
-        }\r
-      }\r
-\r
-      if ((!Pending) || (Lba >= PendingLba)) {\r
-        Status            = FtwProtocol->Write (\r
-                                           FtwProtocol,\r
-                                           Lba,                  // Lba\r
-                                           Offset,               // Offset\r
-                                           Length,               // Size\r
-                                           &PrivateData,         // Private Data\r
-                                           FvbHandle,            // FVB handle\r
-                                           UpdateBuffer          // Buffer\r
-                                           );\r
-      }\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        break;\r
-      }\r
-      Lba++;\r
-      UpdateBuffer      = (UINT8 *) ((UINTN)UpdateBuffer + Length);\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    PtrMap++;\r
-  }\r
-\r
-  return Status;\r
-\r
-}\r
-\r
-/**\r
-  Directly update the whole FV image without fault tolerant write method.\r
-\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param BlockMap        Block array to specify flash area.\r
-  @param ConfigData      Config data on updating driver.\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param ImageSize       Image size.\r
-\r
-  @retval EFI_SUCCESS            FV image is writed into flash.\r
-  @retval EFI_INVALID_PARAMETER  Config data is not valid.\r
-  @retval EFI_ABORTED            Error happen when update FV.\r
-\r
-**/\r
-EFI_STATUS\r
-NonFaultTolerantUpdateOnWholeFv (\r
-  IN EFI_HANDLE                         FvbHandle,\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN EFI_FV_BLOCK_MAP_ENTRY             *BlockMap,\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
-  IN UINT8                              *ImageBuffer,\r
-  IN UINTN                              ImageSize\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_FV_BLOCK_MAP_ENTRY                *PtrMap;\r
-  UINTN                                 Index;\r
-  EFI_LBA                               UpdateLba;\r
-  UINT8                                 *UpdateBuffer;\r
-  UINTN                                 UpdateSize;\r
-\r
-  if ((ConfigData->UpdateType != UpdateWholeFV )\r
-    || (ConfigData->FaultTolerant)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status                = EFI_SUCCESS;\r
-  PtrMap                = BlockMap;\r
-  UpdateLba             = 0;\r
-  UpdateBuffer          = ImageBuffer;\r
-\r
-  //\r
-  // Perform the update now\r
-  //\r
-  while (TRUE) {\r
-    if ((PtrMap->NumBlocks == 0) || (PtrMap->Length == 0)) {\r
-      break;\r
-    }\r
-    UpdateSize          = (UINTN)PtrMap->Length;\r
-    for (Index = 0; Index < PtrMap->NumBlocks; Index++) {\r
-      Status            = UpdateOneBlock (\r
-                            FvbProtocol,\r
-                            UpdateLba,\r
-                            UpdateSize,\r
-                            UpdateBuffer\r
-                            );\r
-      if (EFI_ERROR (Status)) {\r
-        break;\r
-      }\r
-\r
-      UpdateLba++;\r
-      UpdateBuffer      = (UINT8 *) ((UINTN)UpdateBuffer + UpdateSize);\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    PtrMap++;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Update the whole FV image, and reinsall FVB protocol for the updated FV image.\r
-\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param ConfigData      Config data on updating driver.\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param ImageSize       Image size.\r
-\r
-  @retval EFI_INVALID_PARAMETER  Update type is not UpdateWholeFV.\r
-                                 Or Image size is not same to the size of whole FV.\r
-  @retval EFI_OUT_OF_RESOURCES   No enoug memory is allocated.\r
-  @retval EFI_SUCCESS            FV image is updated, and its FVB protocol is reinstalled.\r
-\r
-**/\r
-EFI_STATUS\r
-PerformUpdateOnWholeFv (\r
-  IN EFI_HANDLE                         FvbHandle,\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
-  IN UINT8                              *ImageBuffer,\r
-  IN UINTN                              ImageSize\r
-)\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader;\r
-  EFI_FV_BLOCK_MAP_ENTRY                *BlockMap;\r
-  CHAR16                                *TmpStr;\r
-\r
-  if (ConfigData->UpdateType != UpdateWholeFV) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Get the header of the firmware volume\r
-  //\r
-  FwVolHeader           = NULL;\r
-  FwVolHeader = AllocatePool (((EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) (ConfigData->BaseAddress)))->HeaderLength);\r
-  if (FwVolHeader == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (\r
-    FwVolHeader,\r
-    (VOID *) ((UINTN) (ConfigData->BaseAddress)),\r
-    ((EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) (ConfigData->BaseAddress)))->HeaderLength\r
-    );\r
-\r
-  //\r
-  // Check if ImageSize is the same as the size of the whole FV\r
-  //\r
-  if ((UINT64)ImageSize != FwVolHeader->FvLength) {\r
-    FreePool (FwVolHeader);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Print on screen\r
-  //\r
-  TmpStr  = HiiGetString (gHiiHandle, STRING_TOKEN(UPDATE_FIRMWARE_VOLUME), NULL);\r
-  if (TmpStr != NULL) {\r
-    Print (TmpStr, ConfigData->BaseAddress, (FwVolHeader->FvLength + ConfigData->BaseAddress));\r
-    FreePool (TmpStr);\r
-  }\r
-\r
-  DEBUG ((EFI_D_UPDATE, "UpdateDriver: updating whole FV from %08LX to %08LX\n",\r
-    ConfigData->BaseAddress, (FwVolHeader->FvLength + ConfigData->BaseAddress)));\r
-\r
-  //\r
-  // Get the block map of the firmware volume\r
-  //\r
-  BlockMap              = &(FwVolHeader->BlockMap[0]);\r
-\r
-  //\r
-  // It is about the same if we are going to fault tolerantly update\r
-  // a certain FV in our current design. But we divide non-fault tolerant\r
-  // and fault tolerant udpate here for better maintenance as fault\r
-  // tolerance may change and may be done more wisely if we have space.\r
-  //\r
-  if (ConfigData->FaultTolerant) {\r
-    Status              = FaultTolerantUpdateOnWholeFv (\r
-                            FvbHandle,\r
-                            FvbProtocol,\r
-                            BlockMap,\r
-                            ConfigData,\r
-                            ImageBuffer,\r
-                            ImageSize\r
-                            );\r
-  } else {\r
-    Status              = NonFaultTolerantUpdateOnWholeFv (\r
-                            FvbHandle,\r
-                            FvbProtocol,\r
-                            BlockMap,\r
-                            ConfigData,\r
-                            ImageBuffer,\r
-                            ImageSize\r
-                            );\r
-  }\r
-\r
-  FreePool (FwVolHeader);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // As the whole FV has been replaced, the FV driver shall re-parse the\r
-  // firmware volume. So re-install FVB protocol here\r
-  //\r
-  Status                =  gBS->ReinstallProtocolInterface (\r
-                                   FvbHandle,\r
-                                   &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                                   FvbProtocol,\r
-                                   FvbProtocol\r
-                                   );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Update certain file in the FV.\r
-\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param ConfigData      Config data on updating driver.\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param ImageSize       Image size.\r
-  @param FileType        FFS file type.\r
-  @param FileAttributes  FFS file attribute\r
-\r
-  @retval EFI_INVALID_PARAMETER  Update type is not UpdateFvFile.\r
-                                 Or Image size is not same to the size of whole FV.\r
-  @retval EFI_UNSUPPORTED        PEIM FFS is unsupported to be updated.\r
-  @retval EFI_SUCCESS            The FFS file is added into FV.\r
-\r
-**/\r
-EFI_STATUS\r
-PerformUpdateOnFvFile (\r
-  IN EFI_HANDLE                         FvbHandle,\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
-  IN UINT8                              *ImageBuffer,\r
-  IN UINTN                              ImageSize,\r
-  IN EFI_FV_FILETYPE                    FileType,\r
-  IN EFI_FV_FILE_ATTRIBUTES             FileAttributes\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL          *FwVolProtocol;\r
-  EFI_FV_WRITE_FILE_DATA                FileData;\r
-  CHAR16                                *TmpStr;\r
-\r
-  if (ConfigData->UpdateType != UpdateFvFile) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Print on screen\r
-  //\r
-  TmpStr  = HiiGetString (gHiiHandle, STRING_TOKEN(UPDATE_FIRMWARE_VOLUME_FILE), NULL);\r
-  if (TmpStr != NULL) {\r
-    Print (TmpStr, &(ConfigData->FileGuid));\r
-    FreePool (TmpStr);\r
-  }\r
-\r
-  DEBUG ((EFI_D_UPDATE, "UpdateDriver: updating file: %g\n",\r
-    &(ConfigData->FileGuid)));\r
-\r
-  //\r
-  // Get Firmware volume protocol on this FVB protocol\r
-  //\r
-  Status                = gBS->HandleProtocol (\r
-                                  FvbHandle,\r
-                                  &gEfiFirmwareVolume2ProtocolGuid,\r
-                                  (VOID **) &FwVolProtocol\r
-                                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // If it is a PEIM, we need first to rebase it before committing\r
-  // the write to target\r
-  //\r
-  if ((FileType == EFI_FV_FILETYPE_PEI_CORE) || (FileType == EFI_FV_FILETYPE_PEIM )\r
-    || (FileType == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  FileData.NameGuid         = &(ConfigData->FileGuid);\r
-  FileData.Type             = FileType;\r
-  FileData.FileAttributes   = FileAttributes;\r
-  FileData.Buffer           = ImageBuffer;\r
-  FileData.BufferSize       = (UINT32) ImageSize;\r
-\r
-  Status                    = FwVolProtocol->WriteFile (\r
-                                                FwVolProtocol,\r
-                                                1,                        // NumberOfFiles\r
-                                                (EFI_FV_WRITE_POLICY)ConfigData->FaultTolerant,\r
-                                                &FileData\r
-                                                );\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Update the buffer into flash area in fault tolerant write method.\r
-\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param SizeLeft        Size of the image buffer.\r
-  @param UpdatedSize     Size of the updated buffer.\r
-  @param ConfigData      Config data on updating driver.\r
-  @param FlashAddress    Flash address to be updated as start address.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-\r
-  @retval EFI_SUCCESS            Buffer data is updated into flash.\r
-  @retval EFI_INVALID_PARAMETER  Base flash address is not in FVB flash area.\r
-  @retval EFI_NOT_FOUND          FTW protocol doesn't exist.\r
-  @retval EFI_OUT_OF_RESOURCES   No enough backup space.\r
-  @retval EFI_ABORTED            Error happen when update flash area.\r
-\r
-**/\r
-EFI_STATUS\r
-FaultTolerantUpdateOnPartFv (\r
-  IN       UINT8                         *ImageBuffer,\r
-  IN       UINTN                         SizeLeft,\r
-  IN OUT   UINTN                         *UpdatedSize,\r
-  IN       UPDATE_CONFIG_DATA            *ConfigData,\r
-  IN       EFI_PHYSICAL_ADDRESS          FlashAddress,\r
-  IN       EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN       EFI_HANDLE                    FvbHandle\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader;\r
-  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeaderTmp;\r
-  EFI_PHYSICAL_ADDRESS                  BaseAddress;\r
-  EFI_PHYSICAL_ADDRESS                  FvBase;\r
-  EFI_PHYSICAL_ADDRESS                  NextBlock;\r
-  EFI_FV_BLOCK_MAP_ENTRY                *BlockMap;\r
-  EFI_FV_BLOCK_MAP_ENTRY                *PtrMap;\r
-  UINTN                                 NumOfUpdates;\r
-  UINTN                                 TotalSize;\r
-  EFI_PHYSICAL_ADDRESS                  StartAddress;\r
-  EFI_FAULT_TOLERANT_WRITE_PROTOCOL     *FtwProtocol;\r
-  UINTN                                 MaxBlockSize;\r
-  UINTN                                 FtwMaxBlockSize;\r
-  BOOLEAN                               Pending;\r
-  UPDATE_PRIVATE_DATA                   PrivateData;\r
-  EFI_LBA                               PendingLba;\r
-  EFI_LBA                               Lba;\r
-  UINTN                                 BlockSize;\r
-  UINTN                                 PendingOffset;\r
-  UINTN                                 Offset;\r
-  UINTN                                 PendingLength;\r
-  UINTN                                 Length;\r
-  UINTN                                 Index;\r
-  UINT8                                 *Image;\r
-\r
-  //\r
-  // Get the block map to update the block one by one\r
-  //\r
-  Status = FvbProtocol->GetPhysicalAddress (\r
-                          FvbProtocol,\r
-                          &FvBase\r
-                          );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  FwVolHeaderTmp = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvBase;\r
-  if ((FlashAddress < FvBase) || (FlashAddress > (FvBase + FwVolHeaderTmp->FvLength))) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)AllocateCopyPool (\r
-                                                FwVolHeaderTmp->HeaderLength,\r
-                                                FwVolHeaderTmp\r
-                                                );\r
-  if (FwVolHeader == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // For fault tolerant write, we have to know how many blocks we need to\r
-  // update. So we will calculate number of updates and max block size first\r
-  //\r
-  NumOfUpdates          = 0;\r
-  MaxBlockSize          = 0;\r
-  TotalSize             = SizeLeft;\r
-  StartAddress          = FlashAddress;\r
-  BaseAddress           = FvBase;\r
-  BlockMap              = &(FwVolHeader->BlockMap[0]);\r
-  PtrMap                = BlockMap;\r
-\r
-  while (TotalSize > 0) {\r
-    if ((PtrMap->NumBlocks == 0) || (PtrMap->Length == 0)) {\r
-      break;\r
-    }\r
-\r
-    BlockSize           = PtrMap->Length;\r
-    for (Index = 0; Index < PtrMap->NumBlocks; Index++) {\r
-      NextBlock         = BaseAddress + BlockSize;\r
-      //\r
-      // Check if this block need to be updated\r
-      //\r
-      if ((StartAddress >= BaseAddress) && (StartAddress < NextBlock)) {\r
-        //\r
-        // Get the maximum block size\r
-        //\r
-        if (MaxBlockSize < BlockSize) {\r
-          MaxBlockSize  = BlockSize;\r
-        }\r
-\r
-        //\r
-        // This block shall be udpated. So increment number of updates\r
-        //\r
-        NumOfUpdates++;\r
-        Offset          = (UINTN) (StartAddress - BaseAddress);\r
-        Length          = TotalSize;\r
-        if ((Length + Offset ) > BlockSize) {\r
-          Length        = BlockSize - Offset;\r
-        }\r
-\r
-        StartAddress    = StartAddress + Length;\r
-        TotalSize       = TotalSize - Length;\r
-        if (TotalSize <= 0) {\r
-          break;\r
-        }\r
-      }\r
-      BaseAddress       = NextBlock;\r
-    }\r
-    PtrMap++;\r
-  }\r
-\r
-  //\r
-  // Get the FTW protocol\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiFaultTolerantWriteProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &FtwProtocol\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    FreePool (FwVolHeader);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);\r
-\r
-  //\r
-  // Not enough backup space. return directly\r
-  //\r
-  if (FtwMaxBlockSize < MaxBlockSize) {\r
-    FreePool (FwVolHeader);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  PendingLba            = 0;\r
-  PendingOffset         = 0;\r
-  PendingLength         = 0;\r
-  Pending               = FALSE;\r
-\r
-  //\r
-  // Fault Tolerant Write can only support actual fault tolerance if the write\r
-  // is a reclaim operation, which means the data buffer (new and old) are\r
-  // acutally both stored in flash. But for component update write, the data\r
-  // are now in memory. So we cannot actually recover the data after power\r
-  // failure.\r
-  //\r
-  Status = RetrieveLastWrite (\r
-             FvbHandle,\r
-             FtwProtocol,\r
-             ConfigData,\r
-             sizeof (UPDATE_PRIVATE_DATA),\r
-             &PrivateData,\r
-             &PendingLba,\r
-             &PendingOffset,\r
-             &PendingLength,\r
-             &Pending\r
-             );\r
-  if (Pending && (Status == EFI_NOT_FOUND)) {\r
-    //\r
-    // I'm not the owner of the pending fault tolerant write record\r
-    // Cannot continue with the write operation\r
-    //\r
-    FreePool (FwVolHeader);\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  if (EFI_ERROR(Status)) {\r
-    FreePool (FwVolHeader);\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  //\r
-  // Currently we start from the pending write if there is any. But if the\r
-  // caller is exactly the same, and the new data is already a in memory, (it\r
-  // cannot be stored in flash in last write,) we can just abort last write\r
-  // and start from the very begining.\r
-  //\r
-  if (!Pending) {\r
-    //\r
-    // Now allocte the update private data in FTW. If there is pending\r
-    // write, it has already been allocated and no need to allocate here.\r
-    //\r
-    Status = FtwProtocol->Allocate (\r
-                            FtwProtocol,\r
-                            &gEfiCallerIdGuid,\r
-                            sizeof (UPDATE_PRIVATE_DATA),\r
-                            NumOfUpdates\r
-                            );\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (FwVolHeader);\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Perform the update now. If there are pending writes, we need to\r
-  // start from the pending write instead of the very beginning.\r
-  //\r
-  TotalSize             = SizeLeft;\r
-  Lba                   = 0;\r
-  StartAddress          = FlashAddress;\r
-  BaseAddress           = FvBase;\r
-  PtrMap                = BlockMap;\r
-  Image                 = ImageBuffer;\r
-  CopyMem (\r
-    (VOID *) &PrivateData.FileGuid,\r
-    (VOID *) &ConfigData->FileGuid,\r
-     sizeof (EFI_GUID)\r
-  );\r
-\r
-  while (TotalSize > 0) {\r
-    if ((PtrMap->NumBlocks == 0) || (PtrMap->Length == 0)) {\r
-      break;\r
-    }\r
-\r
-    BlockSize           = (UINTN)PtrMap->Length;\r
-    for (Index = 0;  Index < PtrMap->NumBlocks; Index++) {\r
-      NextBlock         = BaseAddress + BlockSize;\r
-      if ((StartAddress >= BaseAddress) && (StartAddress < NextBlock)) {\r
-        //\r
-        // So we need to update this block\r
-        //\r
-        Offset          = (UINTN) (StartAddress - BaseAddress);\r
-        Length          = TotalSize;\r
-        if ((Length + Offset ) > BlockSize) {\r
-          Length        = BlockSize - Offset;\r
-        }\r
-\r
-        //\r
-        // Add an extra check here to see if the pending record is correct\r
-        //\r
-        if (Pending && (Lba == PendingLba)) {\r
-          if ((PendingOffset != Offset) || (PendingLength != Length)) {\r
-            //\r
-            // Error.\r
-            //\r
-            Status          = EFI_ABORTED;\r
-            break;\r
-          }\r
-        }\r
-\r
-        if ((!Pending) || (Lba >= PendingLba)) {\r
-          DEBUG ((EFI_D_UPDATE, "Update Flash area from %08LX to %08LX\n", StartAddress, (UINT64)StartAddress + Length));\r
-          Status            = FtwProtocol->Write (\r
-                                             FtwProtocol,\r
-                                             Lba,                  // Lba\r
-                                             Offset,               // Offset\r
-                                             Length,               // Size\r
-                                             &PrivateData,         // Private Data\r
-                                             FvbHandle,            // FVB handle\r
-                                             Image                 // Buffer\r
-                                             );\r
-          if (EFI_ERROR (Status)) {\r
-            break;\r
-          }\r
-        }\r
-\r
-        //\r
-        // Now increment StartAddress, ImageBuffer and decrease the\r
-        // left size to prepare for the next block update.\r
-        //\r
-        StartAddress    = StartAddress + Length;\r
-        Image           = Image + Length;\r
-        TotalSize       = TotalSize - Length;\r
-        if (TotalSize <= 0) {\r
-          break;\r
-        }\r
-      }\r
-      BaseAddress       = NextBlock;\r
-      Lba++;\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    PtrMap++;\r
-  }\r
-\r
-  FreePool (FwVolHeader);\r
-\r
-  *UpdatedSize = SizeLeft - TotalSize;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Directly update the buffer into flash area without fault tolerant write method.\r
-\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param SizeLeft        Size of the image buffer.\r
-  @param UpdatedSize     Size of the updated buffer.\r
-  @param FlashAddress    Flash address to be updated as start address.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-\r
-  @retval EFI_SUCCESS            Buffer data is updated into flash.\r
-  @retval EFI_INVALID_PARAMETER  Base flash address is not in FVB flash area.\r
-  @retval EFI_OUT_OF_RESOURCES   No enough backup space.\r
-\r
-**/\r
-EFI_STATUS\r
-NonFaultTolerantUpdateOnPartFv (\r
-  IN      UINT8                         *ImageBuffer,\r
-  IN      UINTN                         SizeLeft,\r
-  IN OUT  UINTN                         *UpdatedSize,\r
-  IN      EFI_PHYSICAL_ADDRESS          FlashAddress,\r
-  IN      EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN      EFI_HANDLE                    FvbHandle\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader;\r
-  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeaderTmp;\r
-  EFI_PHYSICAL_ADDRESS                  BaseAddress;\r
-  EFI_PHYSICAL_ADDRESS                  NextBlock;\r
-  EFI_FV_BLOCK_MAP_ENTRY                *BlockMap;\r
-  UINTN                                 Index;\r
-  UINTN                                 TotalSize;\r
-  UINTN                                 BlockSize;\r
-  EFI_LBA                               Lba;\r
-  UINTN                                 Offset;\r
-  UINTN                                 Length;\r
-  UINT8                                 *Image;\r
-\r
-  //\r
-  // Get the block map to update the block one by one\r
-  //\r
-  Status                = FvbProtocol->GetPhysicalAddress (\r
-                                         FvbProtocol,\r
-                                         &BaseAddress\r
-                                         );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  FwVolHeaderTmp = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;\r
-  if ((FlashAddress < BaseAddress) || (FlashAddress > ( BaseAddress + FwVolHeaderTmp->FvLength ))) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)AllocateCopyPool (\r
-                                                FwVolHeaderTmp->HeaderLength,\r
-                                                FwVolHeaderTmp\r
-                                                );\r
-  if (FwVolHeader == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Image                 = ImageBuffer;\r
-  TotalSize             = SizeLeft;\r
-  BlockMap              = &(FwVolHeader->BlockMap[0]);\r
-  Lba                   = 0;\r
-\r
-  while (TotalSize > 0) {\r
-    if ((BlockMap->NumBlocks == 0) || (BlockMap->Length == 0)) {\r
-      break;\r
-    }\r
-\r
-    BlockSize           = BlockMap->Length;\r
-    for (Index = 0 ; Index < BlockMap->NumBlocks ; Index++) {\r
-      NextBlock         = BaseAddress + BlockSize;\r
-      if ((FlashAddress >= BaseAddress) && (FlashAddress < NextBlock)) {\r
-        //\r
-        // So we need to update this block\r
-        //\r
-        Offset          = (UINTN) FlashAddress - (UINTN) BaseAddress;\r
-        Length          = TotalSize;\r
-        if ((Length + Offset ) > BlockSize) {\r
-          Length        = BlockSize - Offset;\r
-        }\r
-\r
-        DEBUG ((EFI_D_UPDATE, "Update Flash area from %08LX to %08LX\n", FlashAddress, (UINT64)FlashAddress + Length));\r
-        //\r
-        // Update the block\r
-        //\r
-        Status          = UpdateBufferInOneBlock (\r
-                            FvbProtocol,\r
-                            Lba,\r
-                            Offset,\r
-                            Length,\r
-                            BlockSize,\r
-                            Image\r
-                            );\r
-        if (EFI_ERROR (Status)) {\r
-          FreePool (FwVolHeader);\r
-          return Status;\r
-        }\r
-\r
-        //\r
-        // Now increment FlashAddress, ImageBuffer and decrease the\r
-        // left size to prepare for the next block update.\r
-        //\r
-        FlashAddress    = FlashAddress + Length;\r
-        Image           = Image + Length;\r
-        TotalSize       = TotalSize - Length;\r
-        if (TotalSize <= 0) {\r
-          break;\r
-        }\r
-      }\r
-      BaseAddress       = NextBlock;\r
-      Lba++;\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    BlockMap++;\r
-  }\r
-\r
-  FreePool (FwVolHeader);\r
-\r
-  *UpdatedSize          = SizeLeft - TotalSize;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/ParseUpdateProfile.c b/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/ParseUpdateProfile.c
deleted file mode 100644 (file)
index 23ba044..0000000
+++ /dev/null
@@ -1,1126 +0,0 @@
-/** @file\r
-  Source file for the component update driver. It parse the update\r
-  configuration file and pass the information to the update driver\r
-  so that the driver can perform updates accordingly.\r
-\r
-  Copyright (c) 2002 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "UpdateDriver.h"\r
-\r
-/**\r
-  Copy one line data from buffer data to the line buffer.\r
-\r
-  @param Buffer          Buffer data.\r
-  @param BufferSize      Buffer Size.\r
-  @param LineBuffer      Line buffer to store the found line data.\r
-  @param LineSize        On input, size of the input line buffer.\r
-                         On output, size of the actual line buffer.\r
-\r
-  @retval EFI_BUFFER_TOO_SMALL  The size of input line buffer is not enough.\r
-  @retval EFI_SUCCESS           Copy line data into the line buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-ProfileGetLine (\r
-  IN      UINT8                         *Buffer,\r
-  IN      UINTN                         BufferSize,\r
-  IN OUT  UINT8                         *LineBuffer,\r
-  IN OUT  UINTN                         *LineSize\r
-  )\r
-{\r
-  UINTN                                 Length;\r
-  UINT8                                 *PtrBuf;\r
-  UINTN                                 PtrEnd;\r
-\r
-  PtrBuf      = Buffer;\r
-  PtrEnd      = (UINTN)Buffer + BufferSize;\r
-\r
-  //\r
-  // 0x0D indicates a line break. Otherwise there is no line break\r
-  //\r
-  while ((UINTN)PtrBuf < PtrEnd) {\r
-    if (*PtrBuf == 0x0D) {\r
-      break;\r
-    }\r
-    PtrBuf++;\r
-  }\r
-\r
-  if ((UINTN)PtrBuf >= (PtrEnd - 1)) {\r
-    //\r
-    // The buffer ends without any line break\r
-    // or it is the last character of the buffer\r
-    //\r
-    Length    = BufferSize;\r
-  } else if (*(PtrBuf + 1) == 0x0A) {\r
-    //\r
-    // Further check if a 0x0A follows. If yes, count 0xA\r
-    //\r
-    Length    = (UINTN) PtrBuf - (UINTN) Buffer + 2;\r
-  } else {\r
-    Length    = (UINTN) PtrBuf - (UINTN) Buffer + 1;\r
-  }\r
-\r
-  if (Length > (*LineSize)) {\r
-    *LineSize = Length;\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  }\r
-\r
-  SetMem (LineBuffer, *LineSize, 0x0);\r
-  *LineSize   = Length;\r
-  CopyMem (LineBuffer, Buffer, Length);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Trim Buffer by removing all CR, LF, TAB, and SPACE chars in its head and tail.\r
-\r
-  @param Buffer          On input,  buffer data to be trimed.\r
-                         On output, the trimmed buffer.\r
-  @param BufferSize      On input,  size of original buffer data.\r
-                         On output, size of the trimmed buffer.\r
-\r
-**/\r
-VOID\r
-ProfileTrim (\r
-  IN OUT  UINT8                         *Buffer,\r
-  IN OUT  UINTN                         *BufferSize\r
-  )\r
-{\r
-  UINTN                                 Length;\r
-  UINT8                                 *PtrBuf;\r
-  UINT8                                 *PtrEnd;\r
-\r
-  if (*BufferSize == 0) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Trim the tail first, include CR, LF, TAB, and SPACE.\r
-  //\r
-  Length          = *BufferSize;\r
-  PtrBuf          = (UINT8 *) ((UINTN) Buffer + Length - 1);\r
-  while (PtrBuf >= Buffer) {\r
-    if ((*PtrBuf != 0x0D) && (*PtrBuf != 0x0A )\r
-      && (*PtrBuf != 0x20) && (*PtrBuf != 0x09)) {\r
-      break;\r
-    }\r
-    PtrBuf --;\r
-  }\r
-\r
-  //\r
-  // all spaces, a blank line, return directly;\r
-  //\r
-  if (PtrBuf < Buffer) {\r
-    *BufferSize   = 0;\r
-    return;\r
-  }\r
-\r
-  Length          = (UINTN)PtrBuf - (UINTN)Buffer + 1;\r
-  PtrEnd          = PtrBuf;\r
-  PtrBuf          = Buffer;\r
-\r
-  //\r
-  // Now skip the heading CR, LF, TAB and SPACE\r
-  //\r
-  while (PtrBuf <= PtrEnd) {\r
-    if ((*PtrBuf != 0x0D) && (*PtrBuf != 0x0A )\r
-      && (*PtrBuf != 0x20) && (*PtrBuf != 0x09)) {\r
-      break;\r
-    }\r
-    PtrBuf++;\r
-  }\r
-\r
-  //\r
-  // If no heading CR, LF, TAB or SPACE, directly return\r
-  //\r
-  if (PtrBuf == Buffer) {\r
-    *BufferSize   = Length;\r
-    return;\r
-  }\r
-\r
-  *BufferSize     = (UINTN)PtrEnd - (UINTN)PtrBuf + 1;\r
-\r
-  //\r
-  // The first Buffer..PtrBuf characters are CR, LF, TAB or SPACE.\r
-  // Now move out all these characters.\r
-  //\r
-  while (PtrBuf <= PtrEnd) {\r
-    *Buffer       = *PtrBuf;\r
-    Buffer++;\r
-    PtrBuf++;\r
-  }\r
-\r
-  return;\r
-}\r
-\r
-/**\r
-  Insert new comment item into comment head.\r
-\r
-  @param Buffer          Comment buffer to be added.\r
-  @param BufferSize      Size of comment buffer.\r
-  @param CommentHead     Comment Item head entry.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES   No enough memory is allocated.\r
-  @retval EFI_SUCCESS            New comment item is inserted.\r
-\r
-**/\r
-EFI_STATUS\r
-ProfileGetComments (\r
-  IN      UINT8                         *Buffer,\r
-  IN      UINTN                         BufferSize,\r
-  IN OUT  COMMENT_LINE                  **CommentHead\r
-  )\r
-{\r
-  COMMENT_LINE                          *CommentItem;\r
-\r
-  CommentItem = NULL;\r
-  CommentItem = AllocatePool (sizeof (COMMENT_LINE));\r
-  if (CommentItem == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  CommentItem->ptrNext  = *CommentHead;\r
-  *CommentHead          = CommentItem;\r
-\r
-  //\r
-  // Add a trailing '\0'\r
-  //\r
-  CommentItem->ptrComment = AllocatePool (BufferSize + 1);\r
-  if (CommentItem->ptrComment == NULL) {\r
-    FreePool (CommentItem);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (CommentItem->ptrComment, Buffer, BufferSize);\r
-  *(CommentItem->ptrComment + BufferSize) = '\0';\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Add new section item into Section head.\r
-\r
-  @param Buffer          Section item data buffer.\r
-  @param BufferSize      Size of section item.\r
-  @param SectionHead     Section item head entry.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES   No enough memory is allocated.\r
-  @retval EFI_SUCCESS            Section item is NULL or Section item is added.\r
-\r
-**/\r
-EFI_STATUS\r
-ProfileGetSection (\r
-  IN      UINT8                         *Buffer,\r
-  IN      UINTN                         BufferSize,\r
-  IN OUT  SECTION_ITEM                  **SectionHead\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  SECTION_ITEM                          *SectionItem;\r
-  UINTN                                 Length;\r
-  UINT8                                 *PtrBuf;\r
-\r
-  Status      = EFI_SUCCESS;\r
-  //\r
-  // The first character of Buffer is '[', now we want for ']'\r
-  //\r
-  PtrBuf      = (UINT8 *)((UINTN)Buffer + BufferSize - 1);\r
-  while (PtrBuf > Buffer) {\r
-    if (*PtrBuf == ']') {\r
-      break;\r
-    }\r
-    PtrBuf --;\r
-  }\r
-  if (PtrBuf <= Buffer) {\r
-    //\r
-    // Not found. Omit this line\r
-    //\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // excluding the heading '[' and tailing ']'\r
-  //\r
-  Length      = PtrBuf - Buffer - 1;\r
-  ProfileTrim (\r
-    Buffer + 1,\r
-    &Length\r
-  );\r
-\r
-  //\r
-  // omit this line if the section name is null\r
-  //\r
-  if (Length == 0) {\r
-    return Status;\r
-  }\r
-\r
-  SectionItem = AllocatePool (sizeof (SECTION_ITEM));\r
-  if (SectionItem == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  SectionItem->ptrSection = NULL;\r
-  SectionItem->SecNameLen = Length;\r
-  SectionItem->ptrEntry   = NULL;\r
-  SectionItem->ptrValue   = NULL;\r
-  SectionItem->ptrNext    = *SectionHead;\r
-  *SectionHead            = SectionItem;\r
-\r
-  //\r
-  // Add a trailing '\0'\r
-  //\r
-  SectionItem->ptrSection = AllocatePool (Length + 1);\r
-  if (SectionItem->ptrSection == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // excluding the heading '['\r
-  //\r
-  CopyMem (SectionItem->ptrSection, Buffer + 1, Length);\r
-  *(SectionItem->ptrSection + Length) = '\0';\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Add new section entry and entry value into Section head.\r
-\r
-  @param Buffer          Section entry data buffer.\r
-  @param BufferSize      Size of section entry.\r
-  @param SectionHead     Section item head entry.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES   No enough memory is allocated.\r
-  @retval EFI_SUCCESS            Section entry is NULL or Section entry is added.\r
-\r
-**/\r
-EFI_STATUS\r
-ProfileGetEntry (\r
-  IN      UINT8                         *Buffer,\r
-  IN      UINTN                         BufferSize,\r
-  IN OUT  SECTION_ITEM                  **SectionHead\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  SECTION_ITEM                          *SectionItem;\r
-  SECTION_ITEM                          *PtrSection;\r
-  UINTN                                 Length;\r
-  UINT8                                 *PtrBuf;\r
-  UINT8                                 *PtrEnd;\r
-\r
-  Status      = EFI_SUCCESS;\r
-  PtrBuf      = Buffer;\r
-  PtrEnd      = (UINT8 *) ((UINTN)Buffer + BufferSize - 1);\r
-\r
-  //\r
-  // First search for '='\r
-  //\r
-  while (PtrBuf <= PtrEnd) {\r
-    if (*PtrBuf == '=') {\r
-      break;\r
-    }\r
-    PtrBuf++;\r
-  }\r
-  if (PtrBuf > PtrEnd) {\r
-    //\r
-    // Not found. Omit this line\r
-    //\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // excluding the tailing '='\r
-  //\r
-  Length      = PtrBuf - Buffer;\r
-  ProfileTrim (\r
-    Buffer,\r
-    &Length\r
-  );\r
-\r
-  //\r
-  // Omit this line if the entry name is null\r
-  //\r
-  if (Length == 0) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Omit this line if no section header has been found before\r
-  //\r
-  if (*SectionHead == NULL) {\r
-    return Status;\r
-  }\r
-  PtrSection  = *SectionHead;\r
-\r
-  SectionItem = AllocatePool (sizeof (SECTION_ITEM));\r
-  if (SectionItem == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  SectionItem->ptrSection = NULL;\r
-  SectionItem->ptrEntry   = NULL;\r
-  SectionItem->ptrValue   = NULL;\r
-  SectionItem->SecNameLen = PtrSection->SecNameLen;\r
-  SectionItem->ptrNext    = *SectionHead;\r
-  *SectionHead            = SectionItem;\r
-\r
-  //\r
-  // SectionName, add a trailing '\0'\r
-  //\r
-  SectionItem->ptrSection = AllocatePool (PtrSection->SecNameLen + 1);\r
-  if (SectionItem->ptrSection == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (SectionItem->ptrSection, PtrSection->ptrSection, PtrSection->SecNameLen + 1);\r
-\r
-  //\r
-  // EntryName, add a trailing '\0'\r
-  //\r
-  SectionItem->ptrEntry = AllocatePool (Length + 1);\r
-  if (SectionItem->ptrEntry == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (SectionItem->ptrEntry, Buffer, Length);\r
-  *(SectionItem->ptrEntry + Length) = '\0';\r
-\r
-  //\r
-  // Next search for '#'\r
-  //\r
-  PtrBuf      = PtrBuf + 1;\r
-  Buffer      = PtrBuf;\r
-  while (PtrBuf <= PtrEnd) {\r
-    if (*PtrBuf == '#') {\r
-      break;\r
-    }\r
-    PtrBuf++;\r
-  }\r
-  Length      = PtrBuf - Buffer;\r
-  ProfileTrim (\r
-    Buffer,\r
-    &Length\r
-  );\r
-\r
-  if (Length > 0) {\r
-    //\r
-    // EntryValue, add a trailing '\0'\r
-    //\r
-    SectionItem->ptrValue = AllocatePool (Length + 1);\r
-    if (SectionItem->ptrValue == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    CopyMem (SectionItem->ptrValue, Buffer, Length);\r
-    *(SectionItem->ptrValue + Length) = '\0';\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Free all comment entry and section entry.\r
-\r
-  @param Section         Section entry list.\r
-  @param Comment         Comment entry list.\r
-\r
-**/\r
-VOID\r
-FreeAllList (\r
-  IN      SECTION_ITEM                  *Section,\r
-  IN      COMMENT_LINE                  *Comment\r
-  )\r
-{\r
-  SECTION_ITEM                          *PtrSection;\r
-  COMMENT_LINE                          *PtrComment;\r
-\r
-  while (Section != NULL) {\r
-    PtrSection    = Section;\r
-    Section       = Section->ptrNext;\r
-    if (PtrSection->ptrEntry != NULL) {\r
-      FreePool (PtrSection->ptrEntry);\r
-    }\r
-    if (PtrSection->ptrSection != NULL) {\r
-      FreePool (PtrSection->ptrSection);\r
-    }\r
-    if (PtrSection->ptrValue != NULL) {\r
-      FreePool (PtrSection->ptrValue);\r
-    }\r
-    FreePool (PtrSection);\r
-  }\r
-\r
-  while (Comment != NULL) {\r
-    PtrComment    = Comment;\r
-    Comment       = Comment->ptrNext;\r
-    if (PtrComment->ptrComment != NULL) {\r
-      FreePool (PtrComment->ptrComment);\r
-    }\r
-    FreePool (PtrComment);\r
-  }\r
-\r
-  return;\r
-}\r
-\r
-/**\r
-  Get section entry value.\r
-\r
-  @param Section         Section entry list.\r
-  @param SectionName     Section name.\r
-  @param EntryName       Section entry name.\r
-  @param EntryValue      Point to the got entry value.\r
-\r
-  @retval EFI_NOT_FOUND  Section is not found.\r
-  @retval EFI_SUCCESS    Section entry value is got.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateGetProfileString (\r
-  IN      SECTION_ITEM                  *Section,\r
-  IN      UINT8                         *SectionName,\r
-  IN      UINT8                         *EntryName,\r
-  OUT     UINT8                         **EntryValue\r
-  )\r
-{\r
-  *EntryValue   = NULL;\r
-\r
-  while (Section != NULL) {\r
-    if (AsciiStrCmp ((CONST CHAR8 *) Section->ptrSection, (CONST CHAR8 *) SectionName) == 0) {\r
-      if (Section->ptrEntry != NULL) {\r
-        if (AsciiStrCmp ((CONST CHAR8 *) Section->ptrEntry, (CONST CHAR8 *) EntryName) == 0) {\r
-          break;\r
-        }\r
-      }\r
-    }\r
-    Section     = Section->ptrNext;\r
-  }\r
-\r
-  if (Section == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  *EntryValue   = (UINT8 *) Section->ptrValue;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Convert the dec or hex ascii string to value.\r
-\r
-  @param Str             ascii string to be converted.\r
-\r
-  @return the converted value.\r
-\r
-**/\r
-UINTN\r
-UpdateAtoi (\r
-  IN      UINT8                         *Str\r
-  )\r
-{\r
-  UINTN Number;\r
-\r
-  Number = 0;\r
-\r
-  //\r
-  // Skip preceeding while spaces\r
-  //\r
-  while (*Str != '\0') {\r
-    if (*Str != 0x20) {\r
-      break;\r
-    }\r
-    Str++;\r
-  }\r
-\r
-  if (*Str == '\0') {\r
-    return Number;\r
-  }\r
-\r
-  //\r
-  // Find whether the string is prefixed by 0x.\r
-  // That is, it should be xtoi or atoi.\r
-  //\r
-  if (*Str == '0') {\r
-    if ((*(Str+1) == 'x' ) || ( *(Str+1) == 'X')) {\r
-      return AsciiStrHexToUintn ((CONST CHAR8 *) Str);\r
-    }\r
-  }\r
-\r
-  while (*Str != '\0') {\r
-    if ((*Str >= '0') && (*Str <= '9')) {\r
-      Number  = Number * 10 + *Str - '0';\r
-    } else {\r
-      break;\r
-    }\r
-    Str++;\r
-  }\r
-\r
-  return Number;\r
-}\r
-\r
-/**\r
-  Converts a decimal value to a Null-terminated ascii string.\r
-\r
-  @param  Buffer  Pointer to the output buffer for the produced Null-terminated\r
-                  ASCII string.\r
-  @param  Value   The 64-bit sgned value to convert to a string.\r
-\r
-  @return The number of ASCII characters in Buffer not including the Null-terminator.\r
-\r
-**/\r
-UINTN\r
-UpdateValueToString (\r
-  IN  OUT UINT8                         *Buffer,\r
-  IN      INT64                         Value\r
-  )\r
-{\r
-  UINT8                                 TempBuffer[30];\r
-  UINT8                                 *TempStr;\r
-  UINT8                                 *BufferPtr;\r
-  UINTN                                 Count;\r
-  UINT32                                Remainder;\r
-\r
-  TempStr           = TempBuffer;\r
-  BufferPtr         = Buffer;\r
-  Count             = 0;\r
-\r
-  if (Value < 0) {\r
-    *BufferPtr      = '-';\r
-    BufferPtr++;\r
-    Value           = -Value;\r
-    Count++;\r
-  }\r
-\r
-  do {\r
-    Value = (INT64) DivU64x32Remainder  ((UINT64)Value, 10, &Remainder);\r
-    //\r
-    // The first item of TempStr is not occupied. It's kind of flag\r
-    //\r
-    TempStr++;\r
-    Count++;\r
-    *TempStr        = (UINT8) ((UINT8)Remainder + '0');\r
-  } while (Value != 0);\r
-\r
-  //\r
-  // Reverse temp string into Buffer.\r
-  //\r
-  while (TempStr != TempBuffer) {\r
-    *BufferPtr      = *TempStr;\r
-    BufferPtr++;\r
-    TempStr --;\r
-  }\r
-\r
-  *BufferPtr = 0;\r
-\r
-  return Count;\r
-}\r
-\r
-/**\r
-  Convert the input value to a ascii string,\r
-  and concatenates this string to the input string.\r
-\r
-  @param Str             Pointer to a Null-terminated ASCII string.\r
-  @param Number          The unsgned value to convert to a string.\r
-\r
-**/\r
-VOID\r
-UpdateStrCatNumber (\r
-  IN OUT  UINT8                         *Str,\r
-  IN      UINTN                         Number\r
-  )\r
-{\r
-  UINTN                                 Count;\r
-\r
-  while (*Str != '\0') {\r
-    Str++;\r
-  }\r
-\r
-  Count = UpdateValueToString (Str, (INT64)Number);\r
-\r
-  *(Str + Count) = '\0';\r
-\r
-  return;\r
-}\r
-\r
-/**\r
-  Convert the input ascii string into GUID value.\r
-\r
-  @param Str             Ascii GUID string to be converted.\r
-  @param Guid            Pointer to the converted GUID value.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.\r
-  @retval EFI_NOT_FOUND         The input ascii string is not a valid GUID format string.\r
-  @retval EFI_SUCCESS           GUID value is got.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateStringToGuid (\r
-  IN      UINT8                         *Str,\r
-  IN OUT  EFI_GUID                      *Guid\r
-  )\r
-{\r
-  UINT8                                 *PtrBuffer;\r
-  UINT8                                 *PtrPosition;\r
-  UINT8                                 *Buffer;\r
-  UINTN                                 Data;\r
-  UINTN                                 StrLen;\r
-  UINTN                                 Index;\r
-  UINT8                                 Digits[3];\r
-\r
-  StrLen          = AsciiStrLen  ((CONST CHAR8 *) Str);\r
-  Buffer          = AllocateCopyPool (StrLen + 1, Str);\r
-  if (Buffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Data1\r
-  //\r
-  PtrBuffer       = Buffer;\r
-  PtrPosition     = PtrBuffer;\r
-  while (*PtrBuffer != '\0') {\r
-    if (*PtrBuffer == '-') {\r
-      break;\r
-    }\r
-    PtrBuffer++;\r
-  }\r
-  if (*PtrBuffer == '\0') {\r
-    FreePool (Buffer);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  *PtrBuffer      = '\0';\r
-  Data            = AsciiStrHexToUintn ((CONST CHAR8 *) PtrPosition);\r
-  Guid->Data1     = (UINT32)Data;\r
-\r
-  //\r
-  // Data2\r
-  //\r
-  PtrBuffer++;\r
-  PtrPosition     = PtrBuffer;\r
-  while (*PtrBuffer != '\0') {\r
-    if (*PtrBuffer == '-') {\r
-      break;\r
-    }\r
-    PtrBuffer++;\r
-  }\r
-  if (*PtrBuffer == '\0') {\r
-    FreePool (Buffer);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  *PtrBuffer      = '\0';\r
-  Data            = AsciiStrHexToUintn ((CONST CHAR8 *) PtrPosition);\r
-  Guid->Data2     = (UINT16)Data;\r
-\r
-  //\r
-  // Data3\r
-  //\r
-  PtrBuffer++;\r
-  PtrPosition     = PtrBuffer;\r
-  while (*PtrBuffer != '\0') {\r
-    if (*PtrBuffer == '-') {\r
-      break;\r
-    }\r
-    PtrBuffer++;\r
-  }\r
-  if (*PtrBuffer == '\0') {\r
-    FreePool (Buffer);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  *PtrBuffer      = '\0';\r
-  Data            = AsciiStrHexToUintn ((CONST CHAR8 *) PtrPosition);\r
-  Guid->Data3     = (UINT16)Data;\r
-\r
-  //\r
-  // Data4[0..1]\r
-  //\r
-  for ( Index = 0 ; Index < 2 ; Index++) {\r
-    PtrBuffer++;\r
-    if ((*PtrBuffer == '\0') || ( *(PtrBuffer + 1) == '\0')) {\r
-      FreePool (Buffer);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-    Digits[0]     = *PtrBuffer;\r
-    PtrBuffer++;\r
-    Digits[1]     = *PtrBuffer;\r
-    Digits[2]     = '\0';\r
-    Data          = AsciiStrHexToUintn ((CONST CHAR8 *) Digits);\r
-    Guid->Data4[Index] = (UINT8)Data;\r
-  }\r
-\r
-  //\r
-  // skip the '-'\r
-  //\r
-  PtrBuffer++;\r
-  if ((*PtrBuffer != '-' ) || ( *PtrBuffer == '\0')) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Data4[2..7]\r
-  //\r
-  for ( ; Index < 8; Index++) {\r
-    PtrBuffer++;\r
-    if ((*PtrBuffer == '\0') || ( *(PtrBuffer + 1) == '\0')) {\r
-      FreePool (Buffer);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-    Digits[0]     = *PtrBuffer;\r
-    PtrBuffer++;\r
-    Digits[1]     = *PtrBuffer;\r
-    Digits[2]     = '\0';\r
-    Data          = AsciiStrHexToUintn ((CONST CHAR8 *) Digits);\r
-    Guid->Data4[Index] = (UINT8)Data;\r
-  }\r
-\r
-  FreePool (Buffer);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Pre process config data buffer into Section entry list and Comment entry list.\r
-\r
-  @param DataBuffer      Config raw file buffer.\r
-  @param BufferSize      Size of raw buffer.\r
-  @param SectionHead     Pointer to the section entry list.\r
-  @param CommentHead     Pointer to the comment entry list.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.\r
-  @retval EFI_SUCCESS           Config data buffer is preprocessed.\r
-\r
-**/\r
-EFI_STATUS\r
-PreProcessDataFile (\r
-  IN      UINT8                         *DataBuffer,\r
-  IN      UINTN                         BufferSize,\r
-  IN OUT  SECTION_ITEM                  **SectionHead,\r
-  IN OUT  COMMENT_LINE                  **CommentHead\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  CHAR8                                 *Source;\r
-  CHAR8                                 *CurrentPtr;\r
-  CHAR8                                 *BufferEnd;\r
-  CHAR8                                 *PtrLine;\r
-  UINTN                                 LineLength;\r
-  UINTN                                 SourceLength;\r
-  UINTN                                 MaxLineLength;\r
-\r
-  *SectionHead          = NULL;\r
-  *CommentHead          = NULL;\r
-  BufferEnd             = (CHAR8 *) ( (UINTN) DataBuffer + BufferSize);\r
-  CurrentPtr            = (CHAR8 *) DataBuffer;\r
-  MaxLineLength         = MAX_LINE_LENGTH;\r
-  Status                = EFI_SUCCESS;\r
-\r
-  PtrLine = AllocatePool (MaxLineLength);\r
-  if (PtrLine == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  while (CurrentPtr < BufferEnd) {\r
-    Source              = CurrentPtr;\r
-    SourceLength        = (UINTN)BufferEnd - (UINTN)CurrentPtr;\r
-    LineLength          = MaxLineLength;\r
-    //\r
-    // With the assumption that line length is less than 512\r
-    // characters. Otherwise BUFFER_TOO_SMALL will be returned.\r
-    //\r
-    Status              = ProfileGetLine (\r
-                            (UINT8 *) Source,\r
-                            SourceLength,\r
-                            (UINT8 *) PtrLine,\r
-                            &LineLength\r
-                            );\r
-    if (EFI_ERROR (Status)) {\r
-      if (Status == EFI_BUFFER_TOO_SMALL) {\r
-        //\r
-        // If buffer too small, re-allocate the buffer according\r
-        // to the returned LineLength and try again.\r
-        //\r
-        FreePool (PtrLine);\r
-        PtrLine         = NULL;\r
-        PtrLine = AllocatePool (LineLength);\r
-        if (PtrLine == NULL) {\r
-          Status        = EFI_OUT_OF_RESOURCES;\r
-          break;\r
-        }\r
-        SourceLength    = LineLength;\r
-        Status          = ProfileGetLine (\r
-                            (UINT8 *) Source,\r
-                            SourceLength,\r
-                            (UINT8 *) PtrLine,\r
-                            &LineLength\r
-                            );\r
-        if (EFI_ERROR (Status)) {\r
-          break;\r
-        }\r
-        MaxLineLength   = LineLength;\r
-      } else {\r
-        break;\r
-      }\r
-    }\r
-    CurrentPtr          = (CHAR8 *) ( (UINTN) CurrentPtr + LineLength);\r
-\r
-    //\r
-    // Line got. Trim the line before processing it.\r
-    //\r
-    ProfileTrim (\r
-      (UINT8 *) PtrLine,\r
-      &LineLength\r
-   );\r
-\r
-    //\r
-    // Blank line\r
-    //\r
-    if (LineLength == 0) {\r
-      continue;\r
-    }\r
-\r
-    if (PtrLine[0] == '#') {\r
-      Status            = ProfileGetComments (\r
-                            (UINT8 *) PtrLine,\r
-                            LineLength,\r
-                            CommentHead\r
-                            );\r
-    } else if (PtrLine[0] == '[') {\r
-      Status            = ProfileGetSection (\r
-                            (UINT8 *) PtrLine,\r
-                            LineLength,\r
-                            SectionHead\r
-                            );\r
-    } else {\r
-      Status            = ProfileGetEntry (\r
-                            (UINT8 *) PtrLine,\r
-                            LineLength,\r
-                            SectionHead\r
-                            );\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Free buffer\r
-  //\r
-  FreePool (PtrLine);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Parse Config data file to get the updated data array.\r
-\r
-  @param DataBuffer      Config raw file buffer.\r
-  @param BufferSize      Size of raw buffer.\r
-  @param NumOfUpdates    Pointer to the number of update data.\r
-  @param UpdateArray     Pointer to the config of update data.\r
-\r
-  @retval EFI_NOT_FOUND         No config data is found.\r
-  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.\r
-  @retval EFI_SUCCESS           Parse the config file successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ParseUpdateDataFile (\r
-  IN      UINT8                         *DataBuffer,\r
-  IN      UINTN                         BufferSize,\r
-  IN OUT  UINTN                         *NumOfUpdates,\r
-  IN OUT  UPDATE_CONFIG_DATA            **UpdateArray\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  CHAR8                                 *Value;\r
-  CHAR8                                 *SectionName;\r
-  CHAR8                                 Entry[MAX_LINE_LENGTH];\r
-  SECTION_ITEM                          *SectionHead;\r
-  COMMENT_LINE                          *CommentHead;\r
-  UINTN                                 Num;\r
-  UINTN                                 Index;\r
-  EFI_GUID                              FileGuid;\r
-\r
-  SectionHead           = NULL;\r
-  CommentHead           = NULL;\r
-\r
-  //\r
-  // First process the data buffer and get all sections and entries\r
-  //\r
-  Status                = PreProcessDataFile (\r
-                            DataBuffer,\r
-                            BufferSize,\r
-                            &SectionHead,\r
-                            &CommentHead\r
-                            );\r
-  if (EFI_ERROR (Status)) {\r
-    FreeAllList (SectionHead, CommentHead);\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Now get NumOfUpdate\r
-  //\r
-  Value                 = NULL;\r
-  Status                = UpdateGetProfileString (\r
-                            SectionHead,\r
-                            (UINT8 *) "Head",\r
-                            (UINT8 *) "NumOfUpdate",\r
-                            (UINT8 **) &Value\r
-                            );\r
-  if (Value == NULL) {\r
-    FreeAllList (SectionHead, CommentHead);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  Num                   = UpdateAtoi((UINT8 *) Value);\r
-  if (Num <= 0) {\r
-    FreeAllList (SectionHead, CommentHead);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  *NumOfUpdates         = Num;\r
-  *UpdateArray = AllocatePool ((sizeof (UPDATE_CONFIG_DATA) * Num));\r
-  if (*UpdateArray == NULL) {\r
-    FreeAllList (SectionHead, CommentHead);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  for ( Index = 0 ; Index < *NumOfUpdates ; Index++) {\r
-    //\r
-    // Get the section name of each update\r
-    //\r
-    AsciiStrCpyS (Entry, MAX_LINE_LENGTH, "Update");\r
-    UpdateStrCatNumber ((UINT8 *) Entry, Index);\r
-    Value               = NULL;\r
-    Status              = UpdateGetProfileString (\r
-                            SectionHead,\r
-                            (UINT8 *) "Head",\r
-                            (UINT8 *) Entry,\r
-                            (UINT8 **) &Value\r
-                            );\r
-    if (Value == NULL) {\r
-      FreeAllList (SectionHead, CommentHead);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    //\r
-    // The section name of this update has been found.\r
-    // Now looks for all the config data of this update\r
-    //\r
-    SectionName         = Value;\r
-\r
-    //\r
-    // UpdateType\r
-    //\r
-    Value               = NULL;\r
-    Status              = UpdateGetProfileString (\r
-                            SectionHead,\r
-                            (UINT8 *) SectionName,\r
-                            (UINT8 *) "UpdateType",\r
-                            (UINT8 **) &Value\r
-                            );\r
-    if (Value == NULL) {\r
-      FreeAllList (SectionHead, CommentHead);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    Num                 = UpdateAtoi((UINT8 *) Value);\r
-    if (( Num >= (UINTN) UpdateOperationMaximum)) {\r
-      FreeAllList (SectionHead, CommentHead);\r
-      return Status;\r
-    }\r
-    (*UpdateArray)[Index].Index       = Index;\r
-    (*UpdateArray)[Index].UpdateType  = (UPDATE_OPERATION_TYPE) Num;\r
-\r
-    //\r
-    // FvBaseAddress\r
-    //\r
-    Value               = NULL;\r
-    Status              = UpdateGetProfileString (\r
-                            SectionHead,\r
-                            (UINT8 *) SectionName,\r
-                            (UINT8 *) "FvBaseAddress",\r
-                            (UINT8 **) &Value\r
-                            );\r
-    if (Value == NULL) {\r
-      FreeAllList (SectionHead, CommentHead);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    Num                 = AsciiStrHexToUintn ((CONST CHAR8 *) Value);\r
-    (*UpdateArray)[Index].BaseAddress = (EFI_PHYSICAL_ADDRESS) Num;\r
-\r
-    //\r
-    // FileBuid\r
-    //\r
-    Value               = NULL;\r
-    Status              = UpdateGetProfileString (\r
-                            SectionHead,\r
-                            (UINT8 *) SectionName,\r
-                            (UINT8 *) "FileGuid",\r
-                            (UINT8 **) &Value\r
-                            );\r
-    if (Value == NULL) {\r
-      FreeAllList (SectionHead, CommentHead);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    Status              = UpdateStringToGuid ((UINT8 *) Value, &FileGuid);\r
-    if (EFI_ERROR (Status)) {\r
-      FreeAllList (SectionHead, CommentHead);\r
-      return Status;\r
-    }\r
-    CopyMem (&((*UpdateArray)[Index].FileGuid), &FileGuid, sizeof(EFI_GUID));\r
-\r
-    //\r
-    // FaultTolerant\r
-    // Default value is FALSE\r
-    //\r
-    Value               = NULL;\r
-    (*UpdateArray)[Index].FaultTolerant = FALSE;\r
-    Status              = UpdateGetProfileString (\r
-                            SectionHead,\r
-                            (UINT8 *) SectionName,\r
-                            (UINT8 *) "FaultTolerant",\r
-                            (UINT8 **) &Value\r
-                           );\r
-    if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {\r
-      FreeAllList (SectionHead, CommentHead);\r
-      return Status;\r
-    } else if (Value != NULL) {\r
-      if (AsciiStriCmp ((CONST CHAR8 *) Value, (CONST CHAR8 *) "TRUE") == 0) {\r
-        (*UpdateArray)[Index].FaultTolerant = TRUE;\r
-      } else if (AsciiStriCmp ((CONST CHAR8 *) Value, (CONST CHAR8 *) "FALSE") == 0) {\r
-        (*UpdateArray)[Index].FaultTolerant = FALSE;\r
-      }\r
-    }\r
-\r
-    if ((*UpdateArray)[Index].UpdateType == UpdateFvRange) {\r
-      //\r
-      // Length\r
-      //\r
-      Value             = NULL;\r
-      Status            = UpdateGetProfileString (\r
-                            SectionHead,\r
-                            (UINT8 *) SectionName,\r
-                            (UINT8 *) "Length",\r
-                            (UINT8 **) &Value\r
-                            );\r
-      if (Value == NULL) {\r
-        FreeAllList (SectionHead, CommentHead);\r
-        return EFI_NOT_FOUND;\r
-      }\r
-\r
-      Num               = AsciiStrHexToUintn ((CONST CHAR8 *) Value);\r
-      (*UpdateArray)[Index].Length = (UINTN) Num;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Now all configuration data got. Free those temporary buffers\r
-  //\r
-  FreeAllList (SectionHead, CommentHead);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDispatcher.c b/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDispatcher.c
deleted file mode 100644 (file)
index aaab249..0000000
+++ /dev/null
@@ -1,839 +0,0 @@
-/** @file\r
-  Functions in this file will mainly focus on looking through the capsule\r
-  for the image to be programmed, and the flash area that is going to be\r
-  programed.\r
-\r
-  Copyright (c) 2002 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "UpdateDriver.h"\r
-\r
-EFI_HII_HANDLE  gHiiHandle;\r
-\r
-/**\r
-  Update the whole FV, or certain files in the FV.\r
-\r
-  @param ConfigData      Pointer to the config data on updating file.\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param ImageSize       Image size.\r
-  @param FileType        FFS file type.\r
-  @param FileAttributes  FFS file attribute.\r
-\r
-  @retval EFI_NOT_FOUND  The matched FVB protocol is not found.\r
-  @retval EFI_SUCCESS    The image buffer is updated into FV.\r
-\r
-**/\r
-EFI_STATUS\r
-PerformUpdateOnFirmwareVolume (\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
-  IN UINT8                              *ImageBuffer,\r
-  IN UINTN                              ImageSize,\r
-  IN EFI_FV_FILETYPE                    FileType,\r
-  IN EFI_FV_FILE_ATTRIBUTES             FileAttributes\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  BOOLEAN                               Found;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *FvbProtocol;\r
-  UINTN                                 Index;\r
-  UINTN                                 NumOfHandles;\r
-  EFI_HANDLE                            *HandleBuffer;\r
-  EFI_PHYSICAL_ADDRESS                  BaseAddress;\r
-  EFI_FVB_ATTRIBUTES_2                  Attributes;\r
-\r
-  //\r
-  // Locate all Fvb protocol\r
-  //\r
-  HandleBuffer = NULL;\r
-  Status          = gBS->LocateHandleBuffer (\r
-                           ByProtocol,\r
-                           &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                           NULL,\r
-                           &NumOfHandles,\r
-                           &HandleBuffer\r
-                           );\r
-  if ((EFI_ERROR (Status)) || (NumOfHandles == 0) || (HandleBuffer == NULL)) {\r
-    if (HandleBuffer != NULL) {\r
-      FreePool (HandleBuffer);\r
-    }\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Check the FVB protocol one by one\r
-  //\r
-  Found               = FALSE;\r
-  FvbProtocol         = NULL;\r
-  for (Index = 0; Index < NumOfHandles; Index++) {\r
-    Status            = gBS->HandleProtocol (\r
-                               HandleBuffer[Index],\r
-                               &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                               (VOID **) &FvbProtocol\r
-                               );\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    //\r
-    // Ensure this FVB protocol supported Write operation.\r
-    //\r
-    Status = FvbProtocol->GetAttributes (FvbProtocol, &Attributes);\r
-    if (EFI_ERROR (Status) || ((Attributes & EFI_FVB2_WRITE_STATUS) == 0)) {\r
-      continue;\r
-    }\r
-\r
-    Status            = FvbProtocol->GetPhysicalAddress (\r
-                                       FvbProtocol,\r
-                                       &BaseAddress\r
-                                      );\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    if (BaseAddress == ConfigData->BaseAddress) {\r
-      Found           = TRUE;\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (!Found) {\r
-    if (HandleBuffer != NULL) {\r
-      FreePool (HandleBuffer);\r
-      HandleBuffer = NULL;\r
-    }\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Now we have got the corresponding FVB protocol. Use the FVB protocol\r
-  // to update the whole FV, or certain files in the FV.\r
-  //\r
-  if (ConfigData->UpdateType == UpdateWholeFV) {\r
-    if (FileType != EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r
-      Status    = EFI_INVALID_PARAMETER;\r
-    } else {\r
-      Status    = PerformUpdateOnWholeFv (\r
-                    HandleBuffer[Index],\r
-                    FvbProtocol,\r
-                    ConfigData,\r
-                    ImageBuffer,\r
-                    ImageSize\r
-                    );\r
-    }\r
-  } else if (ConfigData->UpdateType == UpdateFvFile) {\r
-    Status = PerformUpdateOnFvFile (\r
-               HandleBuffer[Index],\r
-               FvbProtocol,\r
-               ConfigData,\r
-               ImageBuffer,\r
-               ImageSize,\r
-               FileType,\r
-               FileAttributes\r
-               );\r
-  }\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool (HandleBuffer);\r
-    HandleBuffer = NULL;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Update the file directly into flash area.\r
-\r
-  @param ConfigData      Pointer to the config data on updating file.\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param ImageSize       Image size.\r
-\r
-  @retval EFI_SUCCESS    The file is updated into flash area.\r
-  @retval EFI_NOT_FOUND  The FVB protocol for the updated flash area is not found.\r
-\r
-**/\r
-EFI_STATUS\r
-PerformUpdateOnFlashArea (\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
-  IN UINT8                              *ImageBuffer,\r
-  IN UINTN                              ImageSize\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  UINTN                                 SizeLeft;\r
-  EFI_PHYSICAL_ADDRESS                  FlashAddress;\r
-  UINT8                                 *PtrImage;\r
-  BOOLEAN                               Found;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *FvbProtocol;\r
-  UINTN                                 Index;\r
-  UINTN                                 NumOfHandles;\r
-  EFI_HANDLE                            *HandleBuffer;\r
-  EFI_PHYSICAL_ADDRESS                  BaseAddress;\r
-  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader;\r
-  EFI_HANDLE                            FvbHandle;\r
-  UINTN                                 SizeUpdated;\r
-  CHAR16                                *TmpStr;\r
-  EFI_FVB_ATTRIBUTES_2                  Attributes;\r
-\r
-  SizeLeft              = ImageSize;\r
-  PtrImage              = ImageBuffer;\r
-  FlashAddress          = ConfigData->BaseAddress;\r
-  Status                = EFI_SUCCESS;\r
-  HandleBuffer          = NULL;\r
-\r
-  //\r
-  // Print on screen\r
-  //\r
-  TmpStr = HiiGetString (gHiiHandle, STRING_TOKEN(UPDATE_FLASH_RANGE), NULL);\r
-  if (TmpStr != NULL) {\r
-    Print (TmpStr, FlashAddress, ((UINT64)SizeLeft + FlashAddress));\r
-    FreePool (TmpStr);\r
-  }\r
-\r
-  //\r
-  // Locate all Fvb protocol\r
-  //\r
-  Status          = gBS->LocateHandleBuffer (\r
-                           ByProtocol,\r
-                           &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                           NULL,\r
-                           &NumOfHandles,\r
-                           &HandleBuffer\r
-                           );\r
-  if ((EFI_ERROR (Status)) || (NumOfHandles == 0) || (HandleBuffer == NULL)) {\r
-    if (HandleBuffer != NULL) {\r
-      FreePool (HandleBuffer);\r
-    }\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  while (SizeLeft > 0) {\r
-    //\r
-    // First get the FVB protocols. If the flash area is a FV, or sub FV,\r
-    // we can directly locate all the FVB protocol. Otherwise we should use\r
-    // implementation specific method to get the alternate FVB protocol\r
-    //\r
-    Found               = FALSE;\r
-    FvbProtocol         = NULL;\r
-\r
-    //\r
-    // Check the FVB protocol one by one\r
-    //\r
-    for (Index = 0; Index < NumOfHandles; Index++) {\r
-      Status        = gBS->HandleProtocol (\r
-                             HandleBuffer[Index],\r
-                             &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                             (VOID **) &FvbProtocol\r
-                             );\r
-      if (EFI_ERROR (Status)) {\r
-        break;\r
-      }\r
-\r
-      //\r
-      // Ensure this FVB protocol supported Write operation.\r
-      //\r
-      Status = FvbProtocol->GetAttributes (FvbProtocol, &Attributes);\r
-      if (EFI_ERROR (Status) || ((Attributes & EFI_FVB2_WRITE_STATUS) == 0)) {\r
-        continue;\r
-      }\r
-\r
-      Status        = FvbProtocol->GetPhysicalAddress (\r
-                                     FvbProtocol,\r
-                                     &BaseAddress\r
-                                     );\r
-      if (EFI_ERROR (Status)) {\r
-        break;\r
-      }\r
-      FwVolHeader   = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;\r
-\r
-      //\r
-      // This sub area entry falls in the range of the FV\r
-      //\r
-      if ((FlashAddress >= BaseAddress) && (FlashAddress < (BaseAddress + FwVolHeader->FvLength))) {\r
-        Found       = TRUE;\r
-        break;\r
-      }\r
-    }\r
-\r
-    if (!Found) {\r
-      if (HandleBuffer != NULL) {\r
-        FreePool (HandleBuffer);\r
-        HandleBuffer    = NULL;\r
-      }\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    FvbHandle           = HandleBuffer[Index];\r
-    SizeUpdated         = 0;\r
-\r
-    //\r
-    // If the flash area is boot required, the update must be fault tolerant\r
-    //\r
-    if (ConfigData->FaultTolerant) {\r
-      //\r
-      // Finally we are here. We have got the corresponding FVB protocol. Now\r
-      // we need to convert the physical address to LBA and offset and call\r
-      // FTW write. Also check if the flash range is larger than the FV.\r
-      //\r
-      Status            = FaultTolerantUpdateOnPartFv (\r
-                            PtrImage,\r
-                            SizeLeft,\r
-                            &SizeUpdated,\r
-                            ConfigData,\r
-                            FlashAddress,\r
-                            FvbProtocol,\r
-                            FvbHandle\r
-                            );\r
-    } else {\r
-      //\r
-      // Finally we are here. We have got the corresponding FVB protocol. Now\r
-      // we need to convert the physical address to LBA and offset and call\r
-      // FVB write. Also check if the flash range is larger than the FV.\r
-      //\r
-      Status            = NonFaultTolerantUpdateOnPartFv (\r
-                            PtrImage,\r
-                            SizeLeft,\r
-                            &SizeUpdated,\r
-                            FlashAddress,\r
-                            FvbProtocol,\r
-                            FvbHandle\r
-                            );\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    //\r
-    // As part of the FV has been replaced, the FV driver shall re-parse\r
-    // the firmware volume. So re-install FVB protocol here\r
-    //\r
-    Status                =  gBS->ReinstallProtocolInterface (\r
-                                    FvbHandle,\r
-                                    &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                                    FvbProtocol,\r
-                                    FvbProtocol\r
-                                    );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    //\r
-    // Check if we are done with the update\r
-    //\r
-    SizeLeft            = SizeLeft - SizeUpdated;\r
-    FlashAddress        = FlashAddress + SizeUpdated;\r
-    PtrImage            = PtrImage + SizeUpdated;\r
-  }\r
-\r
-  if (HandleBuffer != NULL) {\r
-    FreePool (HandleBuffer);\r
-    HandleBuffer = NULL;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Find the updated file, and program it into the flash area based on the config data.\r
-\r
-  @param FwVolProtocol   Pointer to FV protocol that contains the updated file.\r
-  @param ConfigData      Pointer to the Config Data on updating file.\r
-\r
-  @retval EFI_INVALID_PARAMETER  The update operation is not valid.\r
-  @retval EFI_NOT_FOUND          The updated file is not found.\r
-  @retval EFI_SUCCESS            The file is updated into the flash area.\r
-\r
-**/\r
-EFI_STATUS\r
-PerformUpdate (\r
-  IN EFI_FIRMWARE_VOLUME2_PROTOCOL      *FwVolProtocol,\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  UINT8                                 *FileBuffer;\r
-  UINTN                                 FileBufferSize;\r
-  EFI_FV_FILETYPE                       FileType;\r
-  EFI_FV_FILE_ATTRIBUTES                Attrib;\r
-  EFI_SECTION_TYPE                      SectionType;\r
-  UINT32                                AuthenticationStatus;\r
-  CHAR16                                *TmpStr;\r
-  BOOLEAN                               StartToUpdate;\r
-\r
-  Status            = EFI_SUCCESS;\r
-  FileBuffer        = NULL;\r
-  FileBufferSize    = 0;\r
-  Status            = FwVolProtocol->ReadFile (\r
-                                       FwVolProtocol,\r
-                                       &(ConfigData->FileGuid),\r
-                                       (VOID **) &FileBuffer,\r
-                                       &FileBufferSize,\r
-                                       &FileType,\r
-                                       &Attrib,\r
-                                       &AuthenticationStatus\r
-                                       );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  StartToUpdate = FALSE;\r
-\r
-  //\r
-  // Check if the update image is the one we require\r
-  // and then perform the update\r
-  //\r
-  switch (ConfigData->UpdateType) {\r
-\r
-    case UpdateWholeFV:\r
-\r
-      //\r
-      // For UpdateWholeFv, the update file shall be a firmware volume\r
-      // image file.\r
-      //\r
-      if (FileType != EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r
-        DEBUG ((EFI_D_UPDATE, "UpdateDriver: Data file should be of TYPE EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\n"));\r
-        Status          = EFI_INVALID_PARAMETER;\r
-      } else {\r
-        if (FileBuffer != NULL) {\r
-          FreePool (FileBuffer);\r
-        }\r
-        SectionType     = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r
-        FileBuffer      = NULL;\r
-        FileBufferSize  = 0;\r
-        Status          = FwVolProtocol->ReadSection (\r
-                                           FwVolProtocol,\r
-                                           &(ConfigData->FileGuid),\r
-                                           SectionType,\r
-                                           0,\r
-                                           (VOID **) &FileBuffer,\r
-                                           &FileBufferSize,\r
-                                           &AuthenticationStatus\r
-                                           );\r
-        if (!EFI_ERROR (Status)) {\r
-          //\r
-          // Execute the update. For UpdateWholeFv, the update\r
-          // will always execute on a whole FV\r
-          //\r
-          StartToUpdate = TRUE;\r
-          Status        = PerformUpdateOnFirmwareVolume (\r
-                            ConfigData,\r
-                            FileBuffer,\r
-                            FileBufferSize,\r
-                            FileType,\r
-                            Attrib\r
-                            );\r
-\r
-        } else {\r
-          DEBUG ((EFI_D_UPDATE, "UpdateDriver: Data file should be sectioned with TYPE EFI_SECTION_FIRMWARE_VOLUME_IMAGE\n"));\r
-        }\r
-      }\r
-      break;\r
-\r
-    case UpdateFvRange:\r
-\r
-      //\r
-      // For UpdateFvRange, the update file shall be a raw file\r
-      // which does not contain any sections. The contents of the file\r
-      // will be directly programmed.\r
-      //\r
-      if (FileType != EFI_FV_FILETYPE_RAW) {\r
-        DEBUG ((EFI_D_UPDATE, "UpdateDriver: Data file should of TYPE EFI_FV_FILETYPE_RAW\n"));\r
-        Status          = EFI_INVALID_PARAMETER;\r
-      } else {\r
-        //\r
-        // For UpdateFvRange, the update may be performed on a sub area\r
-        // of a certain FV, or a flash area that is not FV, or part of FV.\r
-        // The update may also go across more than one FVs.\r
-        //\r
-        StartToUpdate   = TRUE;\r
-        Status          = PerformUpdateOnFlashArea (\r
-                            ConfigData,\r
-                            FileBuffer,\r
-                            FileBufferSize\r
-                          );\r
-      }\r
-      break;\r
-\r
-    case UpdateFvFile:\r
-\r
-      //\r
-      // No check will be done the the file got. The contents of the file\r
-      // will be directly programmed.\r
-      // Though UpdateFvFile will only update a single file, but the update\r
-      // will always execute on a FV\r
-      //\r
-      StartToUpdate = TRUE;\r
-      Status        = PerformUpdateOnFirmwareVolume (\r
-                        ConfigData,\r
-                        FileBuffer,\r
-                        FileBufferSize,\r
-                        FileType,\r
-                        Attrib\r
-                        );\r
-      break;\r
-\r
-    default:\r
-      Status        = EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (StartToUpdate) {\r
-    if (EFI_ERROR (Status)) {\r
-      TmpStr  = HiiGetString (gHiiHandle, STRING_TOKEN(UPDATE_DRIVER_ABORTED), NULL);\r
-    } else {\r
-      TmpStr  = HiiGetString (gHiiHandle, STRING_TOKEN(UPDATE_DRIVER_DONE), NULL);\r
-    }\r
-    if (TmpStr != NULL) {\r
-      Print (TmpStr);\r
-      FreePool (TmpStr);\r
-    }\r
-  }\r
-\r
-  if (FileBuffer != NULL) {\r
-    FreePool(FileBuffer);\r
-    FileBuffer = NULL;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Process the input firmware volume by using DXE service ProcessFirmwareVolume.\r
-\r
-  @param DataBuffer      Point to the FV image to be processed.\r
-  @param BufferSize      Size of the FV image buffer.\r
-  @param FwVolProtocol   Point to the installed FV protocol for the input FV image.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES   No enough memory is allocated.\r
-  @retval EFI_VOLUME_CORRUPTED   FV image is corrupted.\r
-  @retval EFI_SUCCESS            FV image is processed and FV protocol is installed.\r
-\r
-**/\r
-EFI_STATUS\r
-ProcessUpdateImage (\r
-  UINT8                                 *DataBuffer,\r
-  UINTN                                 BufferSize,\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL          **FwVolProtocol\r
-  )\r
-{\r
-  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader;\r
-  EFI_HANDLE                            FwVolHandle;\r
-  EFI_STATUS                            Status;\r
-  UINT8                                 *ProcessedDataBuffer;\r
-  UINT32                                FvAlignment;\r
-\r
-  ProcessedDataBuffer = NULL;\r
-  FwVolHeader   = (EFI_FIRMWARE_VOLUME_HEADER *) DataBuffer;\r
-  if (FwVolHeader->FvLength != BufferSize) {\r
-    return EFI_VOLUME_CORRUPTED;\r
-  }\r
-\r
-  FvAlignment = 1 << ((FwVolHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
-  //\r
-  // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.\r
-  //\r
-  if (FvAlignment < 8) {\r
-    FvAlignment = 8;\r
-  }\r
-  //\r
-  // Check FvImage Align is required.\r
-  //\r
-  if (((UINTN) FwVolHeader % FvAlignment) == 0) {\r
-    ProcessedDataBuffer = DataBuffer;\r
-  } else {\r
-    //\r
-    // Allocate new aligned buffer to store DataBuffer.\r
-    //\r
-    ProcessedDataBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);\r
-    if (ProcessedDataBuffer == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    CopyMem (ProcessedDataBuffer, DataBuffer, BufferSize);\r
-  }\r
-  //\r
-  // Process the firmware volume\r
-  //\r
-  gDS->ProcessFirmwareVolume (\r
-         ProcessedDataBuffer,\r
-         BufferSize,\r
-         &FwVolHandle\r
-         );\r
-\r
-  //\r
-  // Get the FwVol protocol\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  FwVolHandle,\r
-                  &gEfiFirmwareVolume2ProtocolGuid,\r
-                  (VOID **) FwVolProtocol\r
-                  );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Find the image in the same FV and program it in a target Firmware Volume device.\r
-  After update image, it will reset system and no return.\r
-\r
-  @param ImageHandle   A handle for the image that is initializing this driver\r
-  @param SystemTable   A pointer to the EFI system table\r
-\r
-  @retval EFI_ABORTED    System reset failed.\r
-  @retval EFI_NOT_FOUND  The updated image is not found in the same FV.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeUpdateDriver (\r
-  IN EFI_HANDLE                         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_LOADED_IMAGE_PROTOCOL             *LoadedImageProtocol;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL         *FwVolProtocol;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL         *DataFwVolProtocol;\r
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH     *FwVolFilePathNode;\r
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH     *AlignedDevPathNode;\r
-  EFI_DEVICE_PATH_PROTOCOL              *FilePathNode;\r
-  EFI_SECTION_TYPE                      SectionType;\r
-  UINT8                                 *FileBuffer;\r
-  UINTN                                 FileBufferSize;\r
-  EFI_FV_FILETYPE                       FileType;\r
-  EFI_FV_FILE_ATTRIBUTES                Attrib;\r
-  UINT32                                AuthenticationStatus;\r
-  UPDATE_CONFIG_DATA                    *ConfigData;\r
-  UPDATE_CONFIG_DATA                    *UpdateConfigData;\r
-  UINTN                                 NumOfUpdates;\r
-  UINTN                                 Index;\r
-  CHAR16                                *TmpStr;\r
-\r
-  //\r
-  // Clear screen\r
-  //\r
-  if (gST->ConOut != NULL) {\r
-    gST->ConOut->ClearScreen (gST->ConOut);\r
-    gST->ConOut->SetAttribute (gST->ConOut, EFI_YELLOW | EFI_BRIGHT);\r
-    gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r
-  }\r
-\r
-  gHiiHandle = HiiAddPackages (\r
-                 &gEfiCallerIdGuid,\r
-                 NULL,\r
-                 UpdateDriverDxeStrings,\r
-                 NULL\r
-                 );\r
-  ASSERT (gHiiHandle != NULL);\r
-\r
-  //\r
-  // In order to look for the update data file and programmed image file\r
-  // from the same volume which this driver is dispatched from, we need\r
-  // to get the device path of this driver image. It is done by first\r
-  // locate the LoadedImageProtocol and then get its device path\r
-  //\r
-  Status            = gBS->OpenProtocol (\r
-                             ImageHandle,\r
-                             &gEfiLoadedImageProtocolGuid,\r
-                             (VOID **)&LoadedImageProtocol,\r
-                             ImageHandle,\r
-                             NULL,\r
-                             EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Get the firmware volume protocol where this file resides\r
-  //\r
-  Status            = gBS->HandleProtocol (\r
-                             LoadedImageProtocol->DeviceHandle,\r
-                             &gEfiFirmwareVolume2ProtocolGuid,\r
-                             (VOID **)  &FwVolProtocol\r
-                             );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Shall do some extra check to see if it is really contained in the FV?\r
-  // Should be able to find the section of this driver in the the FV.\r
-  //\r
-  FilePathNode      = LoadedImageProtocol->FilePath;\r
-  FwVolFilePathNode = NULL;\r
-  while (!IsDevicePathEnd (FilePathNode)) {\r
-    if (EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)FilePathNode)!= NULL) {\r
-      FwVolFilePathNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) FilePathNode;\r
-      break;\r
-    }\r
-    FilePathNode    = NextDevicePathNode (FilePathNode);\r
-  }\r
-\r
-  if (FwVolFilePathNode != NULL) {\r
-    AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (FwVolFilePathNode), FwVolFilePathNode);\r
-\r
-    SectionType     = EFI_SECTION_PE32;\r
-    FileBuffer      = NULL;\r
-    FileBufferSize  = 0;\r
-    Status          = FwVolProtocol->ReadSection (\r
-                                       FwVolProtocol,\r
-                                       &(AlignedDevPathNode->FvFileName),\r
-                                       SectionType,\r
-                                       0,\r
-                                       (VOID **) &FileBuffer,\r
-                                       &FileBufferSize,\r
-                                       &AuthenticationStatus\r
-                                       );\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (AlignedDevPathNode);\r
-      return Status;\r
-    }\r
-\r
-    if (FileBuffer != NULL) {\r
-      FreePool(FileBuffer);\r
-      FileBuffer = NULL;\r
-    }\r
-\r
-    //\r
-    // Check the NameGuid of the udpate driver so that it can be\r
-    // used as the CallerId in fault tolerant write protocol\r
-    //\r
-    if (!CompareGuid (&gEfiCallerIdGuid, &(AlignedDevPathNode->FvFileName))) {\r
-      FreePool (AlignedDevPathNode);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-    FreePool (AlignedDevPathNode);\r
-  } else {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Now try to find the script file. The script file is usually\r
-  // a raw data file which does not contain any sections.\r
-  //\r
-  FileBuffer        = NULL;\r
-  FileBufferSize    = 0;\r
-  Status            = FwVolProtocol->ReadFile (\r
-                                       FwVolProtocol,\r
-                                       &gEfiConfigFileNameGuid,\r
-                                       (VOID **) &FileBuffer,\r
-                                       &FileBufferSize,\r
-                                       &FileType,\r
-                                       &Attrib,\r
-                                       &AuthenticationStatus\r
-                                       );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  if (FileType != EFI_FV_FILETYPE_RAW) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Parse the configuration file.\r
-  //\r
-  ConfigData        = NULL;\r
-  NumOfUpdates      = 0;\r
-  Status            = ParseUpdateDataFile (\r
-                        FileBuffer,\r
-                        FileBufferSize,\r
-                        &NumOfUpdates,\r
-                        &ConfigData\r
-                        );\r
-  if (FileBuffer != NULL) {\r
-    FreePool (FileBuffer);\r
-    FileBuffer = NULL;\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  ASSERT (ConfigData != NULL);\r
-\r
-  //\r
-  // Now find the update image. The update image should be put in a FV, and then\r
-  // encapsulated as a raw FFS file. This is to prevent the update image from\r
-  // being dispatched. So the raw data we get here should be an FV. We need to\r
-  // process this FV and read the files that is going to be updated.\r
-  //\r
-  FileBuffer        = NULL;\r
-  FileBufferSize    = 0;\r
-  Status            = FwVolProtocol->ReadFile (\r
-                                       FwVolProtocol,\r
-                                       &gEfiUpdateDataFileGuid,\r
-                                       (VOID **) &FileBuffer,\r
-                                       &FileBufferSize,\r
-                                       &FileType,\r
-                                       &Attrib,\r
-                                       &AuthenticationStatus\r
-                                       );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  if (FileType != EFI_FV_FILETYPE_RAW) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // FileBuffer should be an FV. Process the FV\r
-  //\r
-  DataFwVolProtocol = NULL;\r
-  Status            = ProcessUpdateImage (\r
-                        FileBuffer,\r
-                        FileBufferSize,\r
-                        &DataFwVolProtocol\r
-                        );\r
-  if (EFI_ERROR (Status)) {\r
-    FreePool (FileBuffer);\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Print on screen\r
-  //\r
-  TmpStr  = HiiGetString (gHiiHandle, STRING_TOKEN(UPDATE_PROCESS_DATA), NULL);\r
-  if (TmpStr != NULL) {\r
-    Print (TmpStr);\r
-    FreePool(TmpStr);\r
-  }\r
-\r
-  //\r
-  // Execute the update\r
-  //\r
-  Index = 0;\r
-  UpdateConfigData = ConfigData;\r
-  while (Index < NumOfUpdates) {\r
-    Status = PerformUpdate (\r
-               DataFwVolProtocol,\r
-               UpdateConfigData\r
-               );\r
-    //\r
-    // Shall updates be serialized so that if an update is not successfully completed,\r
-    // the remaining updates won't be performed.\r
-    //\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    Index++;\r
-    UpdateConfigData++;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    if (ConfigData != NULL) {\r
-      FreePool(ConfigData);\r
-      ConfigData = NULL;\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Call system reset\r
-  //\r
-  gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
-\r
-  //\r
-  // Hopefully it won't be reached\r
-  //\r
-  return EFI_ABORTED;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriver.h b/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriver.h
deleted file mode 100644 (file)
index 27778e1..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/** @file\r
-  Common defines and definitions for a component update driver.\r
-\r
-  Copyright (c) 2002 - 2010, Intel Corporation. All rights reserved.<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _EFI_UPDATE_DRIVER_H_\r
-#define _EFI_UPDATE_DRIVER_H_\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/LoadedImage.h>\r
-#include <Guid/Capsule.h>\r
-#include <Guid/CapsuleDataFile.h>\r
-#include <Protocol/FaultTolerantWrite.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-extern EFI_HII_HANDLE gHiiHandle;\r
-\r
-typedef enum {\r
-  UpdateWholeFV = 0,              // 0, update whole FV\r
-  UpdateFvFile,                   // 1, update a set of FV files asynchronously\r
-  UpdateFvRange,                  // 2, update part of FV or flash\r
-  UpdateOperationMaximum          // 3\r
-} UPDATE_OPERATION_TYPE;\r
-\r
-typedef struct {\r
-  UINTN                           Index;\r
-  UPDATE_OPERATION_TYPE           UpdateType;\r
-  EFI_DEVICE_PATH_PROTOCOL        DevicePath;\r
-  EFI_PHYSICAL_ADDRESS            BaseAddress;\r
-  EFI_GUID                        FileGuid;\r
-  UINTN                           Length;\r
-  BOOLEAN                         FaultTolerant;\r
-} UPDATE_CONFIG_DATA;\r
-\r
-typedef struct _SECTION_ITEM SECTION_ITEM;\r
-struct _SECTION_ITEM {\r
-  CHAR8                           *ptrSection;\r
-  UINTN                           SecNameLen;\r
-  CHAR8                           *ptrEntry;\r
-  CHAR8                           *ptrValue;\r
-  SECTION_ITEM                    *ptrNext;\r
-};\r
-\r
-typedef struct _COMMENT_LINE COMMENT_LINE;\r
-struct _COMMENT_LINE {\r
-  CHAR8                           *ptrComment;\r
-  COMMENT_LINE                    *ptrNext;\r
-};\r
-\r
-typedef struct {\r
-  EFI_GUID                        FileGuid;\r
-} UPDATE_PRIVATE_DATA;\r
-\r
-#define MAX_LINE_LENGTH           512\r
-#define EFI_D_UPDATE              EFI_D_ERROR\r
-\r
-#define MIN_ALIGNMENT_SIZE        4\r
-#define ALIGN_SIZE(a)   ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)\r
-\r
-/**\r
-  Parse Config data file to get the updated data array.\r
-\r
-  @param DataBuffer      Config raw file buffer.\r
-  @param BufferSize      Size of raw buffer.\r
-  @param NumOfUpdates    Pointer to the number of update data.\r
-  @param UpdateArray     Pointer to the config of update data.\r
-\r
-  @retval EFI_NOT_FOUND         No config data is found.\r
-  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.\r
-  @retval EFI_SUCCESS           Parse the config file successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ParseUpdateDataFile (\r
-  IN      UINT8                         *DataBuffer,\r
-  IN      UINTN                         BufferSize,\r
-  IN OUT  UINTN                         *NumOfUpdates,\r
-  IN OUT  UPDATE_CONFIG_DATA            **UpdateArray\r
-  );\r
-\r
-/**\r
-  Update the whole FV image, and reinsall FVB protocol for the updated FV image.\r
-\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param ConfigData      Config data on updating driver.\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param ImageSize       Image size.\r
-\r
-  @retval EFI_INVALID_PARAMETER  Update type is not UpdateWholeFV.\r
-                                 Or Image size is not same to the size of whole FV.\r
-  @retval EFI_OUT_OF_RESOURCES   No enoug memory is allocated.\r
-  @retval EFI_SUCCESS            FV image is updated, and its FVB protocol is reinstalled.\r
-\r
-**/\r
-EFI_STATUS\r
-PerformUpdateOnWholeFv (\r
-  IN EFI_HANDLE                         FvbHandle,\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
-  IN UINT8                              *ImageBuffer,\r
-  IN UINTN                              ImageSize\r
-  );\r
-\r
-/**\r
-  Update certain file in the FV.\r
-\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param ConfigData      Config data on updating driver.\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param ImageSize       Image size.\r
-  @param FileType        FFS file type.\r
-  @param FileAttributes  FFS file attribute\r
-\r
-  @retval EFI_INVALID_PARAMETER  Update type is not UpdateFvFile.\r
-                                 Or Image size is not same to the size of whole FV.\r
-  @retval EFI_UNSUPPORTED        PEIM FFS is unsupported to be updated.\r
-  @retval EFI_SUCCESS            The FFS file is added into FV.\r
-\r
-**/\r
-EFI_STATUS\r
-PerformUpdateOnFvFile (\r
-  IN EFI_HANDLE                         FvbHandle,\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
-  IN UINT8                              *ImageBuffer,\r
-  IN UINTN                              ImageSize,\r
-  IN EFI_FV_FILETYPE                    FileType,\r
-  IN EFI_FV_FILE_ATTRIBUTES             FileAttributes\r
-  );\r
-\r
-/**\r
-  Update the buffer into flash area in fault tolerant write method.\r
-\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param SizeLeft        Size of the image buffer.\r
-  @param UpdatedSize     Size of the updated buffer.\r
-  @param ConfigData      Config data on updating driver.\r
-  @param FlashAddress    Flash address to be updated as start address.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-\r
-  @retval EFI_SUCCESS            Buffer data is updated into flash.\r
-  @retval EFI_INVALID_PARAMETER  Base flash address is not in FVB flash area.\r
-  @retval EFI_NOT_FOUND          FTW protocol doesn't exist.\r
-  @retval EFI_OUT_OF_RESOURCES   No enough backup space.\r
-  @retval EFI_ABORTED            Error happen when update flash area.\r
-\r
-**/\r
-EFI_STATUS\r
-FaultTolerantUpdateOnPartFv (\r
-  IN       UINT8                         *ImageBuffer,\r
-  IN       UINTN                         SizeLeft,\r
-  IN OUT   UINTN                         *UpdatedSize,\r
-  IN       UPDATE_CONFIG_DATA            *ConfigData,\r
-  IN       EFI_PHYSICAL_ADDRESS          FlashAddress,\r
-  IN       EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN       EFI_HANDLE                    FvbHandle\r
-  );\r
-\r
-/**\r
-  Directly update the buffer into flash area without fault tolerant write method.\r
-\r
-  @param ImageBuffer     Image buffer to be updated.\r
-  @param SizeLeft        Size of the image buffer.\r
-  @param UpdatedSize     Size of the updated buffer.\r
-  @param FlashAddress    Flash address to be updated as start address.\r
-  @param FvbProtocol     FVB protocol.\r
-  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
-\r
-  @retval EFI_SUCCESS            Buffer data is updated into flash.\r
-  @retval EFI_INVALID_PARAMETER  Base flash address is not in FVB flash area.\r
-  @retval EFI_OUT_OF_RESOURCES   No enough backup space.\r
-\r
-**/\r
-EFI_STATUS\r
-NonFaultTolerantUpdateOnPartFv (\r
-  IN      UINT8                         *ImageBuffer,\r
-  IN      UINTN                         SizeLeft,\r
-  IN OUT  UINTN                         *UpdatedSize,\r
-  IN      EFI_PHYSICAL_ADDRESS          FlashAddress,\r
-  IN      EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
-  IN      EFI_HANDLE                    FvbHandle\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxe.inf b/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxe.inf
deleted file mode 100644 (file)
index eaf62a0..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-## @file\r
-# Update Driver for Capulse update.\r
-#\r
-# This driver is intended to be put in a capsule (FV). If all goes well,\r
-# then it should be dispatched from the capsule FV, then find the image\r
-# in the same FV and program it in a target Firmware Volume device.\r
-#\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = UpdateDriverDxe\r
-  MODULE_UNI_FILE                = UpdateDriverDxe.uni\r
-  FILE_GUID                      = 0E84FC69-29CC-4C6D-92AC-6D476921850F\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializeUpdateDriver\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  UpdateDriver.h\r
-  UpdateStrings.uni\r
-  UpdateDispatcher.c\r
-  ParseUpdateProfile.c\r
-  FlashUpdate.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  PrintLib\r
-  HiiLib\r
-  DxeServicesTableLib\r
-  MemoryAllocationLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  UefiRuntimeServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  DevicePathLib\r
-\r
-[Guids]\r
-  gEfiConfigFileNameGuid                        ## CONSUMES ## File # FileName to store ConfigFile\r
-  gEfiUpdateDataFileGuid                        ## CONSUMES ## File # FileName to store Capsule Data.\r
-\r
-[Protocols]\r
-  gEfiFaultTolerantWriteProtocolGuid            ## CONSUMES\r
-  gEfiFirmwareVolume2ProtocolGuid               ## CONSUMES\r
-  gEfiFirmwareVolumeBlockProtocolGuid           ## CONSUMES\r
-  gEfiLoadedImageProtocolGuid                   ## CONSUMES\r
-\r
-[Depex]\r
-  gEfiFirmwareVolumeBlockProtocolGuid AND gEfiFaultTolerantWriteProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  UpdateDriverDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxe.uni b/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxe.uni
deleted file mode 100644 (file)
index de2204c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// Update Driver for Capulse update.\r
-//\r
-// This driver is intended to be put in a capsule (FV). If all goes well,\r
-// then it should be dispatched from the capsule FV, then find the image\r
-// in the same FV and program it in a target Firmware Volume device.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Update Driver for Capsule update"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This driver is intended to be put in a capsule (FV). If all goes correctly, it should be dispatched from the capsule FV, and then it finds the image in the same FV, and programs it in a target Firmware Volume device."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxeExtra.uni b/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriverDxeExtra.uni
deleted file mode 100644 (file)
index 7e22192..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// UpdateDriverDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Firmware Update DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateStrings.uni b/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateStrings.uni
deleted file mode 100644 (file)
index f0a808b..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/// @file\r
-//  String definitions for UpdateDispatcher formset.\r
-//\r
-//  Copyright (c) 2003 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-//  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-///\r
-\r
-/=#\r
-\r
-#langdef   en-US "English"\r
-\r
-#string UPDATE_PROCESS_DATA            #language en-US  "Update driver loaded, processing update image\n\r"\r
-#string UPDATE_DRIVER_DONE             #language en-US  "Done\n\r"\r
-#string UPDATE_FLASH_RANGE             #language en-US  "Updating flash area from %08LX to %08LX ...\n\r"\r
-#string UPDATE_DRIVER_ABORTED          #language en-US  "Aborted\n\r"\r
-#string UPDATE_FIRMWARE_VOLUME_FILE    #language en-US  "Update firmware volume file %g ..\n\r"\r
-#string UPDATE_FIRMWARE_VOLUME         #language en-US  "Updating whole firmware volume from %08LX to %08LX ..\n\r"\r
diff --git a/IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegion.c b/IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegion.c
deleted file mode 100644 (file)
index 00ddea5..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/** @file\r
-  Produces the Legacy Region Protocol.\r
-\r
-  This generic implementation of the Legacy Region Protocol does not actually\r
-  perform any lock/unlock operations.  This module may be used on platforms\r
-  that do not provide HW locking of the legacy memory regions.  It can also\r
-  be used as a template driver for implementing the Legacy Region Protocol on\r
-  a platform that does support HW locking of the legacy memory regions.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <Protocol/LegacyRegion.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-/**\r
-  Sets hardware to decode or not decode a region.\r
-\r
-  @param  This                  Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
-  @param  Start                 Start of region to decode.\r
-  @param  Length                Size in bytes of the region.\r
-  @param  On                    Decode/nondecode flag.\r
-\r
-  @retval EFI_SUCCESS           Decode range successfully changed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyRegionDecode (\r
-  IN EFI_LEGACY_REGION_PROTOCOL  *This,\r
-  IN UINT32                      Start,\r
-  IN UINT32                      Length,\r
-  IN BOOLEAN                     *On\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Sets a region to read only.\r
-\r
-  @param  This                  Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
-  @param  Start                 Start of region to lock.\r
-  @param  Length                Size in bytes of the region.\r
-  @param  Granularity           Lock attribute affects this granularity in bytes.\r
-\r
-  @retval EFI_SUCCESS           The region was made read only.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyRegionLock (\r
-  IN  EFI_LEGACY_REGION_PROTOCOL  *This,\r
-  IN  UINT32                      Start,\r
-  IN  UINT32                      Length,\r
-  OUT UINT32                      *Granularity OPTIONAL\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Sets a region to read only and ensures that flash is locked from being\r
-  inadvertently modified.\r
-\r
-  @param  This                  Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
-  @param  Start                 Start of region to lock.\r
-  @param  Length                Size in bytes of the region.\r
-  @param  Granularity           Lock attribute affects this granularity in bytes.\r
-\r
-  @retval EFI_SUCCESS           The region was made read only and flash is locked.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyRegionBootLock (\r
-  IN  EFI_LEGACY_REGION_PROTOCOL  *This,\r
-  IN  UINT32                      Start,\r
-  IN  UINT32                      Length,\r
-  OUT UINT32                      *Granularity OPTIONAL\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Sets a region to read-write.\r
-\r
-  @param  This                  Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
-  @param  Start                 Start of region to lock.\r
-  @param  Length                Size in bytes of the region.\r
-  @param  Granularity           Lock attribute affects this granularity in bytes.\r
-\r
-  @retval EFI_SUCCESS           The region was successfully made read-write.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyRegionUnlock (\r
-  IN  EFI_LEGACY_REGION_PROTOCOL  *This,\r
-  IN  UINT32                      Start,\r
-  IN  UINT32                      Length,\r
-  OUT UINT32                      *Granularity OPTIONAL\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// Module global for the handle the Legacy Region Protocol is installed\r
-//\r
-EFI_HANDLE                  mLegacyRegionHandle = NULL;\r
-\r
-//\r
-// Module global for the Legacy Region Protocol instance that is installed onto\r
-// mLegacyRegionHandle\r
-//\r
-EFI_LEGACY_REGION_PROTOCOL  mLegacyRegion = {\r
-  LegacyRegionDecode,\r
-  LegacyRegionLock,\r
-  LegacyRegionBootLock,\r
-  LegacyRegionUnlock\r
-};\r
-\r
-/**\r
-  The user Entry Point for module LegacyRegionDxe.  The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LegacyRegionInstall (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Make sure the Legacy Region Protocol is not already installed in the system\r
-  //\r
-  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiLegacyRegionProtocolGuid);\r
-\r
-  //\r
-  // Install the protocol on a new handle.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &mLegacyRegionHandle,\r
-                  &gEfiLegacyRegionProtocolGuid, &mLegacyRegion,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxe.inf b/IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxe.inf
deleted file mode 100644 (file)
index 84f5577..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-## @file\r
-#  Produces Framework Legacy Region Protocol.\r
-#\r
-#  This generic implementation of the Legacy Region Protocol does not actually\r
-#  perform any lock/unlock operations.  This module may be used on platforms\r
-#  that do not provide HW locking of the legacy memory regions.  It can also\r
-#  be used as a template driver for implementing the Legacy Region Protocol on\r
-#  a platform that does support HW locking of the legacy memory regions.\r
-#\r
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = LegacyRegionDxe\r
-  MODULE_UNI_FILE                = LegacyRegionDxe.uni\r
-  FILE_GUID                      = 8C439043-85CA-467a-96F1-CB14F4D0DCDA\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = LegacyRegionInstall\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  LegacyRegion.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  UefiBootServicesTableLib\r
-\r
-[Protocols]\r
-  gEfiLegacyRegionProtocolGuid                 ## PRODUCES\r
-\r
-[Depex]\r
-  TRUE\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  LegacyRegionDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxe.uni b/IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxe.uni
deleted file mode 100644 (file)
index 8f00bba..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// /** @file\r
-// Produces Framework Legacy Region Protocol.\r
-//\r
-// This generic implementation of the Legacy Region Protocol does not actually\r
-// perform any lock/unlock operations.  This module may be used on platforms\r
-// that do not provide HW locking of the legacy memory regions.  It can also\r
-// be used as a template driver for implementing the Legacy Region Protocol on\r
-// a platform that does support HW locking of the legacy memory regions.\r
-//\r
-// Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Produces Framework Legacy Region Protocol"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This generic implementation of the Legacy Region Protocol does not actually perform any lock/unlock operations.  This module may be used on platforms that do not provide HW locking of the legacy memory regions.  It can also be used as a template driver for implementing the Legacy Region Protocol on a platform that does support HW locking of the legacy memory regions."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxeExtra.uni b/IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegionDxeExtra.uni
deleted file mode 100644 (file)
index 6c0c396..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// LegacyRegionDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Legacy Region DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c b/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c
deleted file mode 100644 (file)
index 2dd3984..0000000
+++ /dev/null
@@ -1,1450 +0,0 @@
-/** @file\r
-  Section Extraction Protocol implementation.\r
-\r
-  Stream database is implemented as a linked list of section streams,\r
-  where each stream contains a linked list of children, which may be leaves or\r
-  encapsulations.\r
-\r
-  Children that are encapsulations generate new stream entries\r
-  when they are created.  Streams can also be created by calls to\r
-  SEP->OpenSectionStream().\r
-\r
-  The database is only created far enough to return the requested data from\r
-  any given stream, or to determine that the requested data is not found.\r
-\r
-  If a GUIDed encapsulation is encountered, there are three possiblilites.\r
-\r
-  1) A support protocol is found, in which the stream is simply processed with\r
-     the support protocol.\r
-\r
-  2) A support protocol is not found, but the data is available to be read\r
-     without processing.  In this case, the database is built up through the\r
-     recursions to return the data, and a RPN event is set that will enable\r
-     the stream in question to be refreshed if and when the required section\r
-     extraction protocol is published.This insures the AuthenticationStatus\r
-     does not become stale in the cache.\r
-\r
-  3) A support protocol is not found, and the data is not available to be read\r
-     without it.  This results in EFI_PROTOCOL_ERROR.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Protocol/Decompress.h>\r
-#include <Protocol/GuidedSectionExtraction.h>\r
-#include <Protocol/SectionExtraction.h>\r
-\r
-//\r
-// Local defines and typedefs\r
-//\r
-#define FRAMEWORK_SECTION_CHILD_SIGNATURE  SIGNATURE_32('S','X','F','S')\r
-#define CHILD_SECTION_NODE_FROM_LINK(Node) \\r
-  CR (Node, FRAMEWORK_SECTION_CHILD_NODE, Link, FRAMEWORK_SECTION_CHILD_SIGNATURE)\r
-\r
-typedef struct {\r
-  UINT32                      Signature;\r
-  LIST_ENTRY                  Link;\r
-  UINT32                      Type;\r
-  UINT32                      Size;\r
-  //\r
-  // StreamBase + OffsetInStream == pointer to section header in stream.  The\r
-  // stream base is always known when walking the sections within.\r
-  //\r
-  UINT32                      OffsetInStream;\r
-  //\r
-  // Then EncapsulatedStreamHandle below is always 0 if the section is NOT an\r
-  // encapsulating section.  Otherwise, it contains the stream handle\r
-  // of the encapsulated stream.  This handle is ALWAYS produced any time an\r
-  // encapsulating child is encountered, irrespective of whether the\r
-  // encapsulated stream is processed further.\r
-  //\r
-  UINTN                       EncapsulatedStreamHandle;\r
-  EFI_GUID                    *EncapsulationGuid;\r
-  //\r
-  // If the section REQUIRES an extraction protocol, register for RPN\r
-  // when the required GUIDed extraction protocol becomes available.\r
-  //\r
-  EFI_EVENT                   Event;\r
-} FRAMEWORK_SECTION_CHILD_NODE;\r
-\r
-#define FRAMEWORK_SECTION_STREAM_SIGNATURE SIGNATURE_32('S','X','S','S')\r
-#define STREAM_NODE_FROM_LINK(Node) \\r
-  CR (Node, FRAMEWORK_SECTION_STREAM_NODE, Link, FRAMEWORK_SECTION_STREAM_SIGNATURE)\r
-\r
-typedef struct {\r
-  UINT32                      Signature;\r
-  LIST_ENTRY                  Link;\r
-  UINTN                       StreamHandle;\r
-  UINT8                       *StreamBuffer;\r
-  UINTN                       StreamLength;\r
-  LIST_ENTRY                  Children;\r
-  //\r
-  // Authentication status is from GUIDed encapsulations.\r
-  //\r
-  UINT32                      AuthenticationStatus;\r
-} FRAMEWORK_SECTION_STREAM_NODE;\r
-\r
-#define NULL_STREAM_HANDLE    0\r
-\r
-typedef struct {\r
-  FRAMEWORK_SECTION_CHILD_NODE     *ChildNode;\r
-  FRAMEWORK_SECTION_STREAM_NODE    *ParentStream;\r
-  VOID                             *Registration;\r
-} RPN_EVENT_CONTEXT;\r
-\r
-/**\r
-  SEP member function.  This function creates and returns a new section stream\r
-  handle to represent the new section stream.\r
-\r
-  @param This                 Indicates the calling context.\r
-  @param SectionStreamLength  Size in bytes of the section stream.\r
-  @param SectionStream        Buffer containing the new section stream.\r
-  @param SectionStreamHandle  A pointer to a caller allocated UINTN that on output\r
-                              contains the new section stream handle.\r
-\r
-  @retval EFI_SUCCESS           Section wase opened successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  Memory allocation failed.\r
-  @retval EFI_INVALID_PARAMETER Section stream does not end concident with end of\r
-                                last section.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-OpenSectionStream (\r
-  IN     EFI_SECTION_EXTRACTION_PROTOCOL           *This,\r
-  IN     UINTN                                     SectionStreamLength,\r
-  IN     VOID                                      *SectionStream,\r
-     OUT UINTN                                     *SectionStreamHandle\r
-  )\r
-;\r
-\r
-/**\r
-  SEP member function.  Retrieves requested section from section stream.\r
-\r
-  @param This                  Pointer to SEP instance.\r
-  @param SectionStreamHandle   The section stream from which to extract the requested\r
-                               section.\r
-  @param SectionType           A pointer to the type of section to search for.\r
-  @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED, then\r
-                               SectionDefinitionGuid indicates which of these types\r
-                               of sections to search for.\r
-  @param SectionInstance       Indicates which instance of the requested section to\r
-                               return.\r
-  @param Buffer                Double indirection to buffer.  If *Buffer is non-null on\r
-                               input, then the buffer is caller allocated.  If\r
-                               *Buffer is NULL, then the buffer is callee allocated.\r
-                               In either case, the required buffer size is returned\r
-                               in *BufferSize.\r
-  @param BufferSize            On input, indicates the size of *Buffer if *Buffer is\r
-                               non-null on input.  On output, indicates the required\r
-                               size (allocated size if callee allocated) of *Buffer.\r
-  @param AuthenticationStatus  Indicates the authentication status of the retrieved\r
-                               section.\r
-\r
-\r
-  @retval EFI_SUCCESS           Section was retrieved successfully\r
-  @retval EFI_PROTOCOL_ERROR    A GUID defined section was encountered in the section\r
-                                stream with its EFI_GUIDED_SECTION_PROCESSING_REQUIRED\r
-                                bit set, but there was no corresponding GUIDed Section\r
-                                Extraction Protocol in the handle database.  *Buffer is\r
-                                unmodified.\r
-  @retval EFI_NOT_FOUND         An error was encountered when parsing the SectionStream.\r
-                                This indicates the SectionStream  is not correctly\r
-                                formatted.\r
-  @retval EFI_NOT_FOUND         The requested section does not exist.\r
-  @retval EFI_OUT_OF_RESOURCES  The system has insufficient resources to process the\r
-                                request.\r
-  @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.\r
-  @retval EFI_WARN_TOO_SMALL    The size of the caller allocated input buffer is\r
-                                insufficient to contain the requested section.  The\r
-                                input buffer is filled and contents are section contents\r
-                                are truncated.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GetSection (\r
-  IN EFI_SECTION_EXTRACTION_PROTOCOL                    *This,\r
-  IN UINTN                                              SectionStreamHandle,\r
-  IN EFI_SECTION_TYPE                                   *SectionType,\r
-  IN EFI_GUID                                           *SectionDefinitionGuid,\r
-  IN UINTN                                              SectionInstance,\r
-  IN VOID                                               **Buffer,\r
-  IN OUT UINTN                                          *BufferSize,\r
-  OUT UINT32                                            *AuthenticationStatus\r
-  )\r
-;\r
-\r
-/**\r
-  SEP member function.  Deletes an existing section stream\r
-\r
-  @param This                   Indicates the calling context.\r
-  @param StreamHandleToClose    Indicates the stream to close\r
-\r
-  @retval EFI_SUCCESS           Section stream was closed successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  Memory allocation failed.\r
-  @retval EFI_INVALID_PARAMETER Section stream does not end concident with end of\r
-                                last section.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CloseSectionStream (\r
-  IN  EFI_SECTION_EXTRACTION_PROTOCOL           *This,\r
-  IN  UINTN                                     StreamHandleToClose\r
-  )\r
-;\r
-\r
-//\r
-// Module globals\r
-//\r
-LIST_ENTRY mStreamRoot = INITIALIZE_LIST_HEAD_VARIABLE (mStreamRoot);\r
-\r
-EFI_HANDLE mSectionExtractionHandle = NULL;\r
-\r
-EFI_SECTION_EXTRACTION_PROTOCOL mSectionExtraction = {\r
-  OpenSectionStream,\r
-  GetSection,\r
-  CloseSectionStream\r
-};\r
-\r
-/**\r
-  Entry point of the section extraction code. Initializes an instance of the\r
-  section extraction interface and installs it on a new handle.\r
-\r
-  @param ImageHandle             A handle for the image that is initializing this driver\r
-  @param SystemTable             A pointer to the EFI system table\r
-\r
-  @retval EFI_SUCCESS            Driver initialized successfully\r
-  @retval EFI_OUT_OF_RESOURCES   Could not allocate needed resources\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SectionExtractionEntryPoint (\r
-  IN EFI_HANDLE                   ImageHandle,\r
-  IN EFI_SYSTEM_TABLE             *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS                         Status;\r
-\r
-  //\r
-  // Install SEP to a new handle\r
-  //\r
-  Status = gBS->InstallProtocolInterface (\r
-                  &mSectionExtractionHandle,\r
-                  &gEfiSectionExtractionProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &mSectionExtraction\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-\r
-  Check if a stream is valid.\r
-\r
-  @param SectionStream         The section stream to be checked\r
-  @param SectionStreamLength   The length of section stream\r
-\r
-  @return A boolean value indicating the validness of the section stream.\r
-\r
-**/\r
-BOOLEAN\r
-IsValidSectionStream (\r
-  IN  VOID              *SectionStream,\r
-  IN  UINTN             SectionStreamLength\r
-  )\r
-{\r
-  UINTN                       TotalLength;\r
-  UINTN                       SectionLength;\r
-  EFI_COMMON_SECTION_HEADER   *SectionHeader;\r
-  EFI_COMMON_SECTION_HEADER   *NextSectionHeader;\r
-\r
-  TotalLength = 0;\r
-  SectionHeader = (EFI_COMMON_SECTION_HEADER *)SectionStream;\r
-\r
-  while (TotalLength < SectionStreamLength) {\r
-    if (IS_SECTION2 (SectionHeader)) {\r
-      SectionLength = SECTION2_SIZE (SectionHeader);\r
-    } else {\r
-      SectionLength = SECTION_SIZE (SectionHeader);\r
-    }\r
-    TotalLength += SectionLength;\r
-\r
-    if (TotalLength == SectionStreamLength) {\r
-      return TRUE;\r
-    }\r
-\r
-    //\r
-    // Move to the next byte following the section...\r
-    //\r
-    SectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + SectionLength);\r
-\r
-    //\r
-    // Figure out where the next section begins\r
-    //\r
-    NextSectionHeader = ALIGN_POINTER(SectionHeader, 4);\r
-    TotalLength += (UINTN) NextSectionHeader - (UINTN) SectionHeader;\r
-    SectionHeader = NextSectionHeader;\r
-  }\r
-\r
-  ASSERT (FALSE);\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Worker function.  Constructor for section streams.\r
-\r
-  @param SectionStreamLength   Size in bytes of the section stream.\r
-  @param SectionStream         Buffer containing the new section stream.\r
-  @param AllocateBuffer        Indicates whether the stream buffer is to be copied\r
-                               or the input buffer is to be used in place.\r
-  @param AuthenticationStatus  Indicates the default authentication status for the\r
-                               new stream.\r
-  @param SectionStreamHandle   A pointer to a caller allocated section stream handle.\r
-\r
-  @retval EFI_SUCCESS           Stream was added to stream database.\r
-  @retval EFI_OUT_OF_RESOURCES  Memory allocation failed.\r
-\r
-**/\r
-EFI_STATUS\r
-OpenSectionStreamEx (\r
-  IN     UINTN                                     SectionStreamLength,\r
-  IN     VOID                                      *SectionStream,\r
-  IN     BOOLEAN                                   AllocateBuffer,\r
-  IN     UINT32                                    AuthenticationStatus,\r
-     OUT UINTN                                     *SectionStreamHandle\r
-  )\r
-{\r
-  FRAMEWORK_SECTION_STREAM_NODE    *NewStream;\r
-  EFI_TPL                          OldTpl;\r
-\r
-  //\r
-  // Allocate a new stream\r
-  //\r
-  NewStream = AllocatePool (sizeof (FRAMEWORK_SECTION_STREAM_NODE));\r
-  if (NewStream == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  if (AllocateBuffer) {\r
-    //\r
-    // if we're here, we're double buffering, allocate the buffer and copy the\r
-    // data in\r
-    //\r
-    if (SectionStreamLength > 0) {\r
-      NewStream->StreamBuffer = AllocatePool (SectionStreamLength);\r
-      if (NewStream->StreamBuffer == NULL) {\r
-        FreePool (NewStream);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-      //\r
-      // Copy in stream data\r
-      //\r
-      CopyMem (NewStream->StreamBuffer, SectionStream, SectionStreamLength);\r
-    } else {\r
-      //\r
-      // It's possible to have a zero length section stream.\r
-      //\r
-      NewStream->StreamBuffer = NULL;\r
-    }\r
-  } else {\r
-    //\r
-    // If were here, the caller has supplied the buffer (it's an internal call)\r
-    // so just assign the buffer.  This happens when we open section streams\r
-    // as a result of expanding an encapsulating section.\r
-    //\r
-    NewStream->StreamBuffer = SectionStream;\r
-  }\r
-\r
-  //\r
-  // Initialize the rest of the section stream\r
-  //\r
-  NewStream->Signature = FRAMEWORK_SECTION_STREAM_SIGNATURE;\r
-  NewStream->StreamHandle = (UINTN) NewStream;\r
-  NewStream->StreamLength = SectionStreamLength;\r
-  InitializeListHead (&NewStream->Children);\r
-  NewStream->AuthenticationStatus = AuthenticationStatus;\r
-\r
-  //\r
-  // Add new stream to stream list\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-  InsertTailList (&mStreamRoot, &NewStream->Link);\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  *SectionStreamHandle = NewStream->StreamHandle;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  SEP member function.  This function creates and returns a new section stream\r
-  handle to represent the new section stream.\r
-\r
-  @param This                 Indicates the calling context.\r
-  @param SectionStreamLength  Size in bytes of the section stream.\r
-  @param SectionStream        Buffer containing the new section stream.\r
-  @param SectionStreamHandle  A pointer to a caller allocated UINTN that on output\r
-                              contains the new section stream handle.\r
-\r
-  @retval EFI_SUCCESS           Section wase opened successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  Memory allocation failed.\r
-  @retval EFI_INVALID_PARAMETER Section stream does not end concident with end of\r
-                                last section.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-OpenSectionStream (\r
-  IN     EFI_SECTION_EXTRACTION_PROTOCOL           *This,\r
-  IN     UINTN                                     SectionStreamLength,\r
-  IN     VOID                                      *SectionStream,\r
-     OUT UINTN                                     *SectionStreamHandle\r
-  )\r
-{\r
-  //\r
-  // Check to see section stream looks good...\r
-  //\r
-  if (!IsValidSectionStream (SectionStream, SectionStreamLength)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return OpenSectionStreamEx (\r
-          SectionStreamLength,\r
-          SectionStream,\r
-          TRUE,\r
-          0,\r
-          SectionStreamHandle\r
-          );\r
-}\r
-\r
-/**\r
-  Worker function.  Determine if the input stream:child matches the input type.\r
-\r
-  @param Stream                 Indicates the section stream associated with the child\r
-  @param Child                  Indicates the child to check\r
-  @param SearchType             Indicates the type of section to check against for\r
-  @param SectionDefinitionGuid  Indicates the GUID to check against if the type is\r
-                                EFI_SECTION_GUID_DEFINED\r
-\r
-  @retval TRUE                  The child matches\r
-  @retval FALSE                 The child doesn't match\r
-\r
-**/\r
-BOOLEAN\r
-ChildIsType (\r
-  IN FRAMEWORK_SECTION_STREAM_NODE *Stream,\r
-  IN FRAMEWORK_SECTION_CHILD_NODE  *Child,\r
-  IN EFI_SECTION_TYPE              SearchType,\r
-  IN EFI_GUID                      *SectionDefinitionGuid\r
-  )\r
-{\r
-  EFI_GUID_DEFINED_SECTION    *GuidedSection;\r
-\r
-  if (SearchType == EFI_SECTION_ALL) {\r
-    return TRUE;\r
-  }\r
-  if (Child->Type != SearchType) {\r
-    return FALSE;\r
-  }\r
-  if ((SearchType != EFI_SECTION_GUID_DEFINED) || (SectionDefinitionGuid == NULL)) {\r
-    return TRUE;\r
-  }\r
-  GuidedSection = (EFI_GUID_DEFINED_SECTION * )(Stream->StreamBuffer + Child->OffsetInStream);\r
-  if (IS_SECTION2 (GuidedSection)) {\r
-    return CompareGuid (&(((EFI_GUID_DEFINED_SECTION2 *) GuidedSection)->SectionDefinitionGuid), SectionDefinitionGuid);\r
-  } else {\r
-    return CompareGuid (&GuidedSection->SectionDefinitionGuid, SectionDefinitionGuid);\r
-  }\r
-}\r
-\r
-/**\r
-  Create a protocol notification event and return it.\r
-\r
-  @param ProtocolGuid    Protocol to register notification event on.\r
-  @param NotifyTpl       Maximum TPL to signal the NotifyFunction.\r
-  @param NotifyFunction  EFI notification routine.\r
-  @param NotifyContext   Context passed into Event when it is created.\r
-  @param Registration    Registration key returned from RegisterProtocolNotify().\r
-  @param SignalFlag      Boolean value to decide whether kick the event after register or not.\r
-\r
-  @return The EFI_EVENT that has been registered to be signaled when a ProtocolGuid\r
-           is added to the system.\r
-\r
-**/\r
-EFI_EVENT\r
-CreateProtocolNotifyEvent (\r
-  IN EFI_GUID             *ProtocolGuid,\r
-  IN EFI_TPL              NotifyTpl,\r
-  IN EFI_EVENT_NOTIFY     NotifyFunction,\r
-  IN VOID                 *NotifyContext,\r
-  OUT VOID                **Registration,\r
-  IN  BOOLEAN             SignalFlag\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_EVENT               Event;\r
-\r
-  //\r
-  // Create the event\r
-  //\r
-\r
-  Status = gBS->CreateEvent (\r
-            EVT_NOTIFY_SIGNAL,\r
-            NotifyTpl,\r
-            NotifyFunction,\r
-            NotifyContext,\r
-           &Event\r
-            );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Register for protocol notifactions on this event\r
-  //\r
-\r
-  Status = gBS->RegisterProtocolNotify (\r
-            ProtocolGuid,\r
-            Event,\r
-            Registration\r
-            );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  if (SignalFlag) {\r
-    //\r
-    // Kick the event so we will perform an initial pass of\r
-    // current installed drivers\r
-    //\r
-    gBS->SignalEvent (Event);\r
-  }\r
-\r
-  return Event;\r
-}\r
-\r
-/**\r
-  Verify the Guided Section GUID by checking if there is the Guided Section GUID configuration table recorded the GUID itself.\r
-\r
-  @param GuidedSectionGuid          The Guided Section GUID.\r
-  @param GuidedSectionExtraction    A pointer to the pointer to the supported Guided Section Extraction Protocol\r
-                                    for the Guided Section.\r
-\r
-  @return TRUE      The GuidedSectionGuid could be identified, and the pointer to\r
-                    the Guided Section Extraction Protocol will be returned to *GuidedSectionExtraction.\r
-  @return FALSE     The GuidedSectionGuid could not be identified, or\r
-                    the Guided Section Extraction Protocol has not been installed yet.\r
-\r
-**/\r
-BOOLEAN\r
-VerifyGuidedSectionGuid (\r
-  IN  EFI_GUID                                  *GuidedSectionGuid,\r
-  OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL    **GuidedSectionExtraction\r
-  )\r
-{\r
-  EFI_GUID              *GuidRecorded;\r
-  VOID                  *Interface;\r
-  EFI_STATUS            Status;\r
-\r
-  //\r
-  // Check if there is the Guided Section GUID configuration table recorded the GUID itself.\r
-  //\r
-  Status = EfiGetSystemConfigurationTable (GuidedSectionGuid, (VOID **) &GuidRecorded);\r
-  if (Status == EFI_SUCCESS) {\r
-    if (CompareGuid (GuidRecorded, GuidedSectionGuid)) {\r
-      //\r
-      // Found the recorded GuidedSectionGuid.\r
-      //\r
-      Status = gBS->LocateProtocol (GuidedSectionGuid, NULL, (VOID **) &Interface);\r
-      if (!EFI_ERROR (Status) && Interface != NULL) {\r
-        //\r
-        // Found the supported Guided Section Extraction Porotocol for the Guided Section.\r
-        //\r
-        *GuidedSectionExtraction = (EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *) Interface;\r
-        return TRUE;\r
-      }\r
-      return FALSE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  RPN callback function.\r
-  1. Initialize the section stream when the GUIDED_SECTION_EXTRACTION_PROTOCOL is installed.\r
-  2. Removes a stale section stream and re-initializes it with an updated AuthenticationStatus.\r
-\r
-  @param Event               The event that fired\r
-  @param RpnContext          A pointer to the context that allows us to identify\r
-                             the relevent encapsulation.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-NotifyGuidedExtraction (\r
-  IN   EFI_EVENT   Event,\r
-  IN   VOID        *RpnContext\r
-  )\r
-{\r
-  EFI_STATUS                              Status;\r
-  EFI_GUID_DEFINED_SECTION                *GuidedHeader;\r
-  EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL  *GuidedExtraction;\r
-  VOID                                    *NewStreamBuffer;\r
-  UINTN                                   NewStreamBufferSize;\r
-  UINT32                                  AuthenticationStatus;\r
-  RPN_EVENT_CONTEXT                       *Context;\r
-\r
-  Context = RpnContext;\r
-  Status = EFI_SUCCESS;\r
-  if (Context->ChildNode->EncapsulatedStreamHandle != NULL_STREAM_HANDLE) {\r
-    Status = CloseSectionStream (&mSectionExtraction, Context->ChildNode->EncapsulatedStreamHandle);\r
-  }\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // The stream is not initialized, open it.\r
-    // Or the stream closed successfully, so re-open the stream with correct AuthenticationStatus.\r
-    //\r
-\r
-    GuidedHeader = (EFI_GUID_DEFINED_SECTION *)\r
-      (Context->ParentStream->StreamBuffer + Context->ChildNode->OffsetInStream);\r
-    ASSERT (GuidedHeader->CommonHeader.Type == EFI_SECTION_GUID_DEFINED);\r
-\r
-    if (!VerifyGuidedSectionGuid (Context->ChildNode->EncapsulationGuid, &GuidedExtraction)) {\r
-      return;\r
-    }\r
-\r
-    Status = GuidedExtraction->ExtractSection (\r
-                                 GuidedExtraction,\r
-                                 GuidedHeader,\r
-                                 &NewStreamBuffer,\r
-                                 &NewStreamBufferSize,\r
-                                 &AuthenticationStatus\r
-                                 );\r
-    ASSERT_EFI_ERROR (Status);\r
-    //\r
-    // OR in the parent stream's aggregate status.\r
-    //\r
-    AuthenticationStatus |= Context->ParentStream->AuthenticationStatus & EFI_AGGREGATE_AUTH_STATUS_ALL;\r
-    Status = OpenSectionStreamEx (\r
-               NewStreamBufferSize,\r
-               NewStreamBuffer,\r
-               FALSE,\r
-               AuthenticationStatus,\r
-               &Context->ChildNode->EncapsulatedStreamHandle\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  //\r
-  //  If above, the stream did not close successfully, it indicates it's\r
-  //  already been closed by someone, so just destroy the event and be done with\r
-  //  it.\r
-  //\r
-\r
-  gBS->CloseEvent (Event);\r
-  Context->ChildNode->Event = NULL;\r
-  FreePool (Context);\r
-}\r
-\r
-/**\r
-  Worker function.  Constructor for RPN event if needed to keep AuthenticationStatus\r
-  cache correct when a missing GUIDED_SECTION_EXTRACTION_PROTOCOL appears...\r
-\r
-  @param ParentStream        Indicates the parent of the ecnapsulation section (child)\r
-  @param ChildNode           Indicates the child node that is the encapsulation section.\r
-\r
-**/\r
-VOID\r
-CreateGuidedExtractionRpnEvent (\r
-  IN FRAMEWORK_SECTION_STREAM_NODE       *ParentStream,\r
-  IN FRAMEWORK_SECTION_CHILD_NODE        *ChildNode\r
-  )\r
-{\r
-  RPN_EVENT_CONTEXT *Context;\r
-\r
-  //\r
-  // Allocate new event structure and context\r
-  //\r
-  Context = AllocatePool (sizeof (RPN_EVENT_CONTEXT));\r
-  ASSERT (Context != NULL);\r
-\r
-  Context->ChildNode = ChildNode;\r
-  Context->ParentStream = ParentStream;\r
-\r
-  Context->ChildNode->Event = CreateProtocolNotifyEvent (\r
-                                Context->ChildNode->EncapsulationGuid,\r
-                                TPL_NOTIFY,\r
-                                NotifyGuidedExtraction,\r
-                                Context,\r
-                                &Context->Registration,\r
-                                FALSE\r
-                                );\r
-}\r
-\r
-/**\r
-  Worker function.  Constructor for new child nodes.\r
-\r
-  @param Stream                Indicates the section stream in which to add the child.\r
-  @param ChildOffset           Indicates the offset in Stream that is the beginning\r
-                               of the child section.\r
-  @param ChildNode             Indicates the Callee allocated and initialized child.\r
-\r
-  @retval EFI_SUCCESS          Child node was found and returned.\r
-  @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r
-  @retval EFI_PROTOCOL_ERROR   Encapsulation sections produce new stream handles when\r
-                               the child node is created.  If the section type is GUID\r
-                               defined, and the extraction GUID does not exist, and\r
-                               producing the stream requires the GUID, then a protocol\r
-                               error is generated and no child is produced.\r
-                               Values returned by OpenSectionStreamEx.\r
-\r
-**/\r
-EFI_STATUS\r
-CreateChildNode (\r
-  IN     FRAMEWORK_SECTION_STREAM_NODE              *Stream,\r
-  IN     UINT32                                     ChildOffset,\r
-  OUT    FRAMEWORK_SECTION_CHILD_NODE               **ChildNode\r
-  )\r
-{\r
-  EFI_STATUS                                   Status;\r
-  EFI_COMMON_SECTION_HEADER                    *SectionHeader;\r
-  EFI_COMPRESSION_SECTION                      *CompressionHeader;\r
-  EFI_GUID_DEFINED_SECTION                     *GuidedHeader;\r
-  EFI_DECOMPRESS_PROTOCOL                      *Decompress;\r
-  EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL       *GuidedExtraction;\r
-  VOID                                         *NewStreamBuffer;\r
-  VOID                                         *ScratchBuffer;\r
-  UINT32                                       ScratchSize;\r
-  UINTN                                        NewStreamBufferSize;\r
-  UINT32                                       AuthenticationStatus;\r
-  VOID                                         *CompressionSource;\r
-  UINT32                                       CompressionSourceSize;\r
-  UINT32                                       UncompressedLength;\r
-  UINT8                                        CompressionType;\r
-  UINT16                                       GuidedSectionAttributes;\r
-\r
-  FRAMEWORK_SECTION_CHILD_NODE                      *Node;\r
-\r
-  SectionHeader = (EFI_COMMON_SECTION_HEADER *) (Stream->StreamBuffer + ChildOffset);\r
-\r
-  //\r
-  // Allocate a new node\r
-  //\r
-  *ChildNode = AllocateZeroPool (sizeof (FRAMEWORK_SECTION_CHILD_NODE));\r
-  Node = *ChildNode;\r
-  if (Node == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Now initialize it\r
-  //\r
-  Node->Signature = FRAMEWORK_SECTION_CHILD_SIGNATURE;\r
-  Node->Type = SectionHeader->Type;\r
-  if (IS_SECTION2 (SectionHeader)) {\r
-    Node->Size = SECTION2_SIZE (SectionHeader);\r
-  } else {\r
-    Node->Size = SECTION_SIZE (SectionHeader);\r
-  }\r
-  Node->OffsetInStream = ChildOffset;\r
-  Node->EncapsulatedStreamHandle = NULL_STREAM_HANDLE;\r
-  Node->EncapsulationGuid = NULL;\r
-\r
-  //\r
-  // If it's an encapsulating section, then create the new section stream also\r
-  //\r
-  switch (Node->Type) {\r
-    case EFI_SECTION_COMPRESSION:\r
-      //\r
-      // Get the CompressionSectionHeader\r
-      //\r
-      if (Node->Size < sizeof (EFI_COMPRESSION_SECTION)) {\r
-        FreePool (Node);\r
-        return EFI_NOT_FOUND;\r
-      }\r
-\r
-      CompressionHeader = (EFI_COMPRESSION_SECTION *) SectionHeader;\r
-\r
-      if (IS_SECTION2 (CompressionHeader)) {\r
-        CompressionSource = (VOID *) ((UINT8 *) CompressionHeader + sizeof (EFI_COMPRESSION_SECTION2));\r
-        CompressionSourceSize = (UINT32) (SECTION2_SIZE (CompressionHeader) - sizeof (EFI_COMPRESSION_SECTION2));\r
-        UncompressedLength = ((EFI_COMPRESSION_SECTION2 *) CompressionHeader)->UncompressedLength;\r
-        CompressionType = ((EFI_COMPRESSION_SECTION2 *) CompressionHeader)->CompressionType;\r
-      } else {\r
-        CompressionSource = (VOID *) ((UINT8 *) CompressionHeader + sizeof (EFI_COMPRESSION_SECTION));\r
-        CompressionSourceSize = (UINT32) (SECTION_SIZE (CompressionHeader) - sizeof (EFI_COMPRESSION_SECTION));\r
-        UncompressedLength = CompressionHeader->UncompressedLength;\r
-        CompressionType = CompressionHeader->CompressionType;\r
-      }\r
-\r
-      //\r
-      // Allocate space for the new stream\r
-      //\r
-      if (UncompressedLength > 0) {\r
-        NewStreamBufferSize = UncompressedLength;\r
-        NewStreamBuffer = AllocatePool (NewStreamBufferSize);\r
-        if (NewStreamBuffer == NULL) {\r
-          FreePool (Node);\r
-          return EFI_OUT_OF_RESOURCES;\r
-        }\r
-\r
-        if (CompressionType == EFI_NOT_COMPRESSED) {\r
-          //\r
-          // stream is not actually compressed, just encapsulated.  So just copy it.\r
-          //\r
-          CopyMem (NewStreamBuffer, CompressionSource, NewStreamBufferSize);\r
-        } else if (CompressionType == EFI_STANDARD_COMPRESSION) {\r
-          //\r
-          // Only support the EFI_SATNDARD_COMPRESSION algorithm.\r
-          //\r
-\r
-          //\r
-          // Decompress the stream\r
-          //\r
-          Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **)&Decompress);\r
-\r
-          ASSERT_EFI_ERROR (Status);\r
-\r
-          Status = Decompress->GetInfo (\r
-                                 Decompress,\r
-                                 CompressionSource,\r
-                                 CompressionSourceSize,\r
-                                 (UINT32 *)&NewStreamBufferSize,\r
-                                 &ScratchSize\r
-                                 );\r
-          if (EFI_ERROR (Status) || (NewStreamBufferSize != UncompressedLength)) {\r
-            FreePool (Node);\r
-            FreePool (NewStreamBuffer);\r
-            if (!EFI_ERROR (Status)) {\r
-              Status = EFI_BAD_BUFFER_SIZE;\r
-            }\r
-            return Status;\r
-          }\r
-\r
-          ScratchBuffer = AllocatePool (ScratchSize);\r
-          if (ScratchBuffer == NULL) {\r
-            FreePool (Node);\r
-            FreePool (NewStreamBuffer);\r
-            return EFI_OUT_OF_RESOURCES;\r
-          }\r
-\r
-          Status = Decompress->Decompress (\r
-                                 Decompress,\r
-                                 CompressionSource,\r
-                                 CompressionSourceSize,\r
-                                 NewStreamBuffer,\r
-                                 (UINT32)NewStreamBufferSize,\r
-                                 ScratchBuffer,\r
-                                 ScratchSize\r
-                                 );\r
-          FreePool (ScratchBuffer);\r
-          if (EFI_ERROR (Status)) {\r
-            FreePool (Node);\r
-            FreePool (NewStreamBuffer);\r
-            return Status;\r
-          }\r
-        }\r
-      } else {\r
-        NewStreamBuffer = NULL;\r
-        NewStreamBufferSize = 0;\r
-      }\r
-\r
-      Status = OpenSectionStreamEx (\r
-                 NewStreamBufferSize,\r
-                 NewStreamBuffer,\r
-                 FALSE,\r
-                 Stream->AuthenticationStatus,\r
-                 &Node->EncapsulatedStreamHandle\r
-                 );\r
-      if (EFI_ERROR (Status)) {\r
-        FreePool (Node);\r
-        FreePool (NewStreamBuffer);\r
-        return Status;\r
-      }\r
-      break;\r
-\r
-    case EFI_SECTION_GUID_DEFINED:\r
-      GuidedHeader = (EFI_GUID_DEFINED_SECTION *) SectionHeader;\r
-      if (IS_SECTION2 (GuidedHeader)) {\r
-        Node->EncapsulationGuid = &(((EFI_GUID_DEFINED_SECTION2 *) GuidedHeader)->SectionDefinitionGuid);\r
-        GuidedSectionAttributes = ((EFI_GUID_DEFINED_SECTION2 *) GuidedHeader)->Attributes;\r
-      } else {\r
-        Node->EncapsulationGuid = &GuidedHeader->SectionDefinitionGuid;\r
-        GuidedSectionAttributes = GuidedHeader->Attributes;\r
-      }\r
-      if (VerifyGuidedSectionGuid (Node->EncapsulationGuid, &GuidedExtraction)) {\r
-        //\r
-        // NewStreamBuffer is always allocated by ExtractSection... No caller\r
-        // allocation here.\r
-        //\r
-        Status = GuidedExtraction->ExtractSection (\r
-                                     GuidedExtraction,\r
-                                     GuidedHeader,\r
-                                     &NewStreamBuffer,\r
-                                     &NewStreamBufferSize,\r
-                                     &AuthenticationStatus\r
-                                     );\r
-        if (EFI_ERROR (Status)) {\r
-          FreePool (*ChildNode);\r
-          return EFI_PROTOCOL_ERROR;\r
-        }\r
-\r
-        //\r
-        // Make sure we initialize the new stream with the correct\r
-        // authentication status for both aggregate and local status fields.\r
-        //\r
-        if ((GuidedSectionAttributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) == EFI_GUIDED_SECTION_AUTH_STATUS_VALID) {\r
-          //\r
-          // OR in the parent stream's aggregate status.\r
-          //\r
-          AuthenticationStatus |= Stream->AuthenticationStatus & EFI_AGGREGATE_AUTH_STATUS_ALL;\r
-        } else {\r
-          //\r
-          // since there's no authentication data contributed by the section,\r
-          // just inherit the full value from our immediate parent.\r
-          //\r
-          AuthenticationStatus = Stream->AuthenticationStatus;\r
-        }\r
-\r
-        Status = OpenSectionStreamEx (\r
-                   NewStreamBufferSize,\r
-                   NewStreamBuffer,\r
-                   FALSE,\r
-                   AuthenticationStatus,\r
-                   &Node->EncapsulatedStreamHandle\r
-                   );\r
-        if (EFI_ERROR (Status)) {\r
-          FreePool (*ChildNode);\r
-          FreePool (NewStreamBuffer);\r
-          return Status;\r
-        }\r
-      } else {\r
-        //\r
-        // There's no GUIDed section extraction protocol available.\r
-        //\r
-        if ((GuidedSectionAttributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == EFI_GUIDED_SECTION_PROCESSING_REQUIRED) {\r
-          //\r
-          // If the section REQUIRES an extraction protocol, register for RPN\r
-          // when the required GUIDed extraction protocol becomes available.\r
-          //\r
-          AuthenticationStatus = 0;\r
-          CreateGuidedExtractionRpnEvent (Stream, Node);\r
-        } else {\r
-          //\r
-          // Figure out the proper authentication status\r
-          //\r
-          AuthenticationStatus = Stream->AuthenticationStatus;\r
-          if ((GuidedSectionAttributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) == EFI_GUIDED_SECTION_AUTH_STATUS_VALID) {\r
-            //\r
-            //  The local status of the new stream is contained in\r
-            //  AuthenticaionStatus.  This value needs to be ORed into the\r
-            //  Aggregate bits also...\r
-            //\r
-\r
-            //\r
-            // Clear out and initialize the local status\r
-            //\r
-            AuthenticationStatus &= ~EFI_LOCAL_AUTH_STATUS_ALL;\r
-            AuthenticationStatus |= EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED | EFI_LOCAL_AUTH_STATUS_NOT_TESTED;\r
-            //\r
-            // OR local status into aggregate status\r
-            //\r
-            AuthenticationStatus |= AuthenticationStatus >> 16;\r
-          }\r
-\r
-          if (IS_SECTION2 (GuidedHeader)) {\r
-            Status = OpenSectionStreamEx (\r
-                       SECTION2_SIZE (GuidedHeader) - ((EFI_GUID_DEFINED_SECTION2 *) GuidedHeader)->DataOffset,\r
-                       (UINT8 *) GuidedHeader + ((EFI_GUID_DEFINED_SECTION2 *) GuidedHeader)->DataOffset,\r
-                       TRUE,\r
-                       AuthenticationStatus,\r
-                       &Node->EncapsulatedStreamHandle\r
-                       );\r
-          } else {\r
-            Status = OpenSectionStreamEx (\r
-                       SECTION_SIZE (GuidedHeader) - ((EFI_GUID_DEFINED_SECTION *) GuidedHeader)->DataOffset,\r
-                       (UINT8 *) GuidedHeader + ((EFI_GUID_DEFINED_SECTION *) GuidedHeader)->DataOffset,\r
-                       TRUE,\r
-                       AuthenticationStatus,\r
-                       &Node->EncapsulatedStreamHandle\r
-                       );\r
-          }\r
-          if (EFI_ERROR (Status)) {\r
-            FreePool (Node);\r
-            return Status;\r
-          }\r
-        }\r
-      }\r
-\r
-      if ((AuthenticationStatus & EFI_LOCAL_AUTH_STATUS_ALL) ==\r
-            (EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED | EFI_LOCAL_AUTH_STATUS_NOT_TESTED)) {\r
-        //\r
-        // Need to register for RPN for when the required GUIDed extraction\r
-        // protocol becomes available.  This will enable us to refresh the\r
-        // AuthenticationStatus cached in the Stream if it's ever requested\r
-        // again.\r
-        //\r
-        CreateGuidedExtractionRpnEvent (Stream, Node);\r
-      }\r
-\r
-      break;\r
-\r
-    default:\r
-\r
-      //\r
-      // Nothing to do if it's a leaf\r
-      //\r
-      break;\r
-  }\r
-\r
-  //\r
-  // Last, add the new child node to the stream\r
-  //\r
-  InsertTailList (&Stream->Children, &Node->Link);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Worker function  Recursively searches / builds section stream database\r
-  looking for requested section.\r
-\r
-\r
-  @param SourceStream          Indicates the section stream in which to do the search.\r
-  @param SearchType            Indicates the type of section to search for.\r
-  @param SectionInstance       Indicates which instance of section to find.  This is\r
-                               an in/out parameter to deal with recursions.\r
-  @param SectionDefinitionGuid Guid of section definition\r
-  @param FoundChild            Output indicating the child node that is found.\r
-  @param FoundStream           Output indicating which section stream the child was\r
-                               found in.  If this stream was generated as a result of\r
-                               an encapsulation section, the streamhandle is visible\r
-                               within the SEP driver only.\r
-  @param AuthenticationStatus  Indicates the authentication status of the found section.\r
-\r
-  @retval EFI_SUCCESS          Child node was found and returned.\r
-  @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r
-  @retval EFI_NOT_FOUND        Requested child node does not exist.\r
-  @retval EFI_PROTOCOL_ERROR   A required GUIDED section extraction protocol does not\r
-                               exist\r
-\r
-**/\r
-EFI_STATUS\r
-FindChildNode (\r
-  IN     FRAMEWORK_SECTION_STREAM_NODE                   *SourceStream,\r
-  IN     EFI_SECTION_TYPE                           SearchType,\r
-  IN OUT UINTN                                      *SectionInstance,\r
-  IN     EFI_GUID                                   *SectionDefinitionGuid,\r
-  OUT    FRAMEWORK_SECTION_CHILD_NODE                    **FoundChild,\r
-  OUT    FRAMEWORK_SECTION_STREAM_NODE                   **FoundStream,\r
-  OUT    UINT32                                     *AuthenticationStatus\r
-  )\r
-{\r
-  FRAMEWORK_SECTION_CHILD_NODE                       *CurrentChildNode;\r
-  FRAMEWORK_SECTION_CHILD_NODE                       *RecursedChildNode;\r
-  FRAMEWORK_SECTION_STREAM_NODE                      *RecursedFoundStream;\r
-  UINT32                                        NextChildOffset;\r
-  EFI_STATUS                                    ErrorStatus;\r
-  EFI_STATUS                                    Status;\r
-\r
-  CurrentChildNode = NULL;\r
-  ErrorStatus = EFI_NOT_FOUND;\r
-\r
-  if (SourceStream->StreamLength == 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if (IsListEmpty (&SourceStream->Children) &&\r
-                   SourceStream->StreamLength >= sizeof (EFI_COMMON_SECTION_HEADER)) {\r
-    //\r
-    // This occurs when a section stream exists, but no child sections\r
-    // have been parsed out yet.  Therefore, extract the first child and add it\r
-    // to the list of children so we can get started.\r
-    // Section stream may contain an array of zero or more bytes.\r
-    // So, its size should be >= the size of commen section header.\r
-    //\r
-    Status = CreateChildNode (SourceStream, 0, &CurrentChildNode);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  //\r
-  // At least one child has been parsed out of the section stream.  So, walk\r
-  // through the sections that have already been parsed out looking for the\r
-  // requested section, if necessary, continue parsing section stream and\r
-  // adding children until either the requested section is found, or we run\r
-  // out of data\r
-  //\r
-  CurrentChildNode = CHILD_SECTION_NODE_FROM_LINK (GetFirstNode(&SourceStream->Children));\r
-\r
-  for (;;) {\r
-    ASSERT (CurrentChildNode != NULL);\r
-    if (ChildIsType (SourceStream, CurrentChildNode, SearchType, SectionDefinitionGuid)) {\r
-      //\r
-      // The type matches, so check the instance count to see if it's the one we want\r
-      //\r
-      (*SectionInstance)--;\r
-      if (*SectionInstance == 0) {\r
-        //\r
-        // Got it!\r
-        //\r
-        *FoundChild = CurrentChildNode;\r
-        *FoundStream = SourceStream;\r
-        *AuthenticationStatus = SourceStream->AuthenticationStatus;\r
-        return EFI_SUCCESS;\r
-      }\r
-    }\r
-\r
-    if (CurrentChildNode->EncapsulatedStreamHandle != NULL_STREAM_HANDLE) {\r
-      //\r
-      // If the current node is an encapsulating node, recurse into it...\r
-      //\r
-      Status = FindChildNode (\r
-                (FRAMEWORK_SECTION_STREAM_NODE *)CurrentChildNode->EncapsulatedStreamHandle,\r
-                SearchType,\r
-                SectionInstance,\r
-                SectionDefinitionGuid,\r
-                &RecursedChildNode,\r
-                &RecursedFoundStream,\r
-                AuthenticationStatus\r
-                );\r
-      //\r
-      // If the status is not EFI_SUCCESS, just save the error code and continue\r
-      // to find the request child node in the rest stream.\r
-      //\r
-      if (*SectionInstance == 0) {\r
-        ASSERT_EFI_ERROR (Status);\r
-        *FoundChild = RecursedChildNode;\r
-        *FoundStream = RecursedFoundStream;\r
-        return EFI_SUCCESS;\r
-      } else {\r
-        ErrorStatus = Status;\r
-      }\r
-    } else if ((CurrentChildNode->Type == EFI_SECTION_GUID_DEFINED) && (SearchType != EFI_SECTION_GUID_DEFINED)) {\r
-      //\r
-      // When Node Type is GUIDED section, but Node has no encapsulated data, Node data should not be parsed\r
-      // because a required GUIDED section extraction protocol does not exist.\r
-      // If SearchType is not GUIDED section, EFI_PROTOCOL_ERROR should return.\r
-      //\r
-      ErrorStatus = EFI_PROTOCOL_ERROR;\r
-    }\r
-\r
-    if (!IsNodeAtEnd (&SourceStream->Children, &CurrentChildNode->Link)) {\r
-      //\r
-      // We haven't found the child node we're interested in yet, but there's\r
-      // still more nodes that have already been parsed so get the next one\r
-      // and continue searching..\r
-      //\r
-      CurrentChildNode = CHILD_SECTION_NODE_FROM_LINK (GetNextNode (&SourceStream->Children, &CurrentChildNode->Link));\r
-    } else {\r
-      //\r
-      // We've exhausted children that have already been parsed, so see if\r
-      // there's any more data and continue parsing out more children if there\r
-      // is.\r
-      //\r
-      NextChildOffset = CurrentChildNode->OffsetInStream + CurrentChildNode->Size;\r
-      //\r
-      // Round up to 4 byte boundary\r
-      //\r
-      NextChildOffset += 3;\r
-      NextChildOffset &= ~(UINTN)3;\r
-      if (NextChildOffset <= SourceStream->StreamLength - sizeof (EFI_COMMON_SECTION_HEADER)) {\r
-        //\r
-        // There's an unparsed child remaining in the stream, so create a new child node\r
-        //\r
-        Status = CreateChildNode (SourceStream, NextChildOffset, &CurrentChildNode);\r
-        if (EFI_ERROR (Status)) {\r
-          return Status;\r
-        }\r
-      } else {\r
-        ASSERT (EFI_ERROR (ErrorStatus));\r
-        return ErrorStatus;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Worker function.  Search stream database for requested stream handle.\r
-\r
-  @param SearchHandle        Indicates which stream to look for.\r
-  @param FoundStream         Output pointer to the found stream.\r
-\r
-  @retval EFI_SUCCESS        StreamHandle was found and *FoundStream contains\r
-                             the stream node.\r
-  @retval EFI_NOT_FOUND      SearchHandle was not found in the stream database.\r
-\r
-**/\r
-EFI_STATUS\r
-FindStreamNode (\r
-  IN  UINTN                                     SearchHandle,\r
-  OUT FRAMEWORK_SECTION_STREAM_NODE                  **FoundStream\r
-  )\r
-{\r
-  FRAMEWORK_SECTION_STREAM_NODE                      *StreamNode;\r
-\r
-  if (!IsListEmpty (&mStreamRoot)) {\r
-    StreamNode = STREAM_NODE_FROM_LINK (GetFirstNode (&mStreamRoot));\r
-    for (;;) {\r
-      if (StreamNode->StreamHandle == SearchHandle) {\r
-        *FoundStream = StreamNode;\r
-        return EFI_SUCCESS;\r
-      } else if (IsNodeAtEnd (&mStreamRoot, &StreamNode->Link)) {\r
-        break;\r
-      } else {\r
-        StreamNode = STREAM_NODE_FROM_LINK (GetNextNode (&mStreamRoot, &StreamNode->Link));\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  SEP member function.  Retrieves requested section from section stream.\r
-\r
-  @param This                  Pointer to SEP instance.\r
-  @param SectionStreamHandle   The section stream from which to extract the requested\r
-                               section.\r
-  @param SectionType           A pointer to the type of section to search for.\r
-  @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED, then\r
-                               SectionDefinitionGuid indicates which of these types\r
-                               of sections to search for.\r
-  @param SectionInstance       Indicates which instance of the requested section to\r
-                               return.\r
-  @param Buffer                Double indirection to buffer.  If *Buffer is non-null on\r
-                               input, then the buffer is caller allocated.  If\r
-                               *Buffer is NULL, then the buffer is callee allocated.\r
-                               In either case, the required buffer size is returned\r
-                               in *BufferSize.\r
-  @param BufferSize            On input, indicates the size of *Buffer if *Buffer is\r
-                               non-null on input.  On output, indicates the required\r
-                               size (allocated size if callee allocated) of *Buffer.\r
-  @param AuthenticationStatus  Indicates the authentication status of the retrieved\r
-                               section.\r
-\r
-\r
-  @retval EFI_SUCCESS           Section was retrieved successfully\r
-  @retval EFI_PROTOCOL_ERROR    A GUID defined section was encountered in the section\r
-                                stream with its EFI_GUIDED_SECTION_PROCESSING_REQUIRED\r
-                                bit set, but there was no corresponding GUIDed Section\r
-                                Extraction Protocol in the handle database.  *Buffer is\r
-                                unmodified.\r
-  @retval EFI_NOT_FOUND         An error was encountered when parsing the SectionStream.\r
-                                This indicates the SectionStream  is not correctly\r
-                                formatted.\r
-  @retval EFI_NOT_FOUND         The requested section does not exist.\r
-  @retval EFI_OUT_OF_RESOURCES  The system has insufficient resources to process the\r
-                                request.\r
-  @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.\r
-  @retval EFI_WARN_TOO_SMALL    The size of the caller allocated input buffer is\r
-                                insufficient to contain the requested section.  The\r
-                                input buffer is filled and contents are section contents\r
-                                are truncated.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GetSection (\r
-  IN EFI_SECTION_EXTRACTION_PROTOCOL                    *This,\r
-  IN UINTN                                              SectionStreamHandle,\r
-  IN EFI_SECTION_TYPE                                   *SectionType,\r
-  IN EFI_GUID                                           *SectionDefinitionGuid,\r
-  IN UINTN                                              SectionInstance,\r
-  IN VOID                                               **Buffer,\r
-  IN OUT UINTN                                          *BufferSize,\r
-  OUT UINT32                                            *AuthenticationStatus\r
-  )\r
-{\r
-  FRAMEWORK_SECTION_STREAM_NODE                         *StreamNode;\r
-  EFI_TPL                                               OldTpl;\r
-  EFI_STATUS                                            Status;\r
-  FRAMEWORK_SECTION_CHILD_NODE                          *ChildNode;\r
-  FRAMEWORK_SECTION_STREAM_NODE                         *ChildStreamNode;\r
-  UINTN                                                 CopySize;\r
-  UINT32                                                ExtractedAuthenticationStatus;\r
-  UINTN                                                 Instance;\r
-  UINT8                                                 *CopyBuffer;\r
-  UINTN                                                 SectionSize;\r
-  EFI_COMMON_SECTION_HEADER                             *Section;\r
-\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-  Instance = SectionInstance + 1;\r
-  ChildStreamNode = NULL;\r
-\r
-  //\r
-  // Locate target stream\r
-  //\r
-  Status = FindStreamNode (SectionStreamHandle, &StreamNode);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_INVALID_PARAMETER;\r
-    goto GetSection_Done;\r
-  }\r
-\r
-  //\r
-  // Found the stream, now locate and return the appropriate section\r
-  //\r
-  if (SectionType == NULL) {\r
-    //\r
-    // SectionType == NULL means return the WHOLE section stream...\r
-    //\r
-    CopySize = StreamNode->StreamLength;\r
-    CopyBuffer = StreamNode->StreamBuffer;\r
-    *AuthenticationStatus = StreamNode->AuthenticationStatus;\r
-  } else {\r
-    //\r
-    // There's a requested section type, so go find it and return it...\r
-    //\r
-    Status = FindChildNode (\r
-                      StreamNode,\r
-                      *SectionType,\r
-                      &Instance,\r
-                      SectionDefinitionGuid,\r
-                      &ChildNode,\r
-                      &ChildStreamNode,\r
-                      &ExtractedAuthenticationStatus\r
-                      );\r
-    if (EFI_ERROR (Status)) {\r
-      goto GetSection_Done;\r
-    }\r
-    ASSERT (ChildNode != NULL);\r
-    ASSERT (ChildStreamNode != NULL);\r
-    Section = (EFI_COMMON_SECTION_HEADER *) (ChildStreamNode->StreamBuffer + ChildNode->OffsetInStream);\r
-\r
-    if (IS_SECTION2 (Section)) {\r
-      CopySize = SECTION2_SIZE (Section) - sizeof (EFI_COMMON_SECTION_HEADER2);\r
-      CopyBuffer = (UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2);\r
-    } else {\r
-      CopySize = SECTION_SIZE (Section) - sizeof (EFI_COMMON_SECTION_HEADER);\r
-      CopyBuffer = (UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER);\r
-    }\r
-    *AuthenticationStatus = ExtractedAuthenticationStatus;\r
-  }\r
-\r
-  SectionSize = CopySize;\r
-  if (*Buffer != NULL) {\r
-    //\r
-    // Caller allocated buffer.  Fill to size and return required size...\r
-    //\r
-    if (*BufferSize < CopySize) {\r
-      Status = EFI_WARN_BUFFER_TOO_SMALL;\r
-      CopySize = *BufferSize;\r
-    }\r
-  } else {\r
-    //\r
-    // Callee allocated buffer.  Allocate buffer and return size.\r
-    //\r
-    *Buffer = AllocatePool (CopySize);\r
-    if (*Buffer == NULL) {\r
-      Status = EFI_OUT_OF_RESOURCES;\r
-      goto GetSection_Done;\r
-    }\r
-  }\r
-  CopyMem (*Buffer, CopyBuffer, CopySize);\r
-  *BufferSize = SectionSize;\r
-\r
-GetSection_Done:\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Worker function.  Destructor for child nodes.\r
-\r
-  @param ChildNode           Indicates the node to destroy\r
-\r
-**/\r
-VOID\r
-FreeChildNode (\r
-  IN  FRAMEWORK_SECTION_CHILD_NODE                   *ChildNode\r
-  )\r
-{\r
-  ASSERT (ChildNode->Signature == FRAMEWORK_SECTION_CHILD_SIGNATURE);\r
-  //\r
-  // Remove the child from it's list\r
-  //\r
-  RemoveEntryList (&ChildNode->Link);\r
-\r
-  if (ChildNode->EncapsulatedStreamHandle != NULL_STREAM_HANDLE) {\r
-    //\r
-    // If it's an encapsulating section, we close the resulting section stream.\r
-    // CloseSectionStream will free all memory associated with the stream.\r
-    //\r
-    CloseSectionStream (&mSectionExtraction, ChildNode->EncapsulatedStreamHandle);\r
-  }\r
-\r
-  if (ChildNode->Event != NULL) {\r
-    gBS->CloseEvent (ChildNode->Event);\r
-  }\r
-\r
-  //\r
-  // Last, free the child node itself\r
-  //\r
-  FreePool (ChildNode);\r
-}\r
-\r
-/**\r
-  SEP member function.  Deletes an existing section stream\r
-\r
-  @param This                   Indicates the calling context.\r
-  @param StreamHandleToClose    Indicates the stream to close\r
-\r
-  @retval EFI_SUCCESS           Section stream was closed successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  Memory allocation failed.\r
-  @retval EFI_INVALID_PARAMETER Section stream does not end concident with end of\r
-                                last section.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CloseSectionStream (\r
-  IN  EFI_SECTION_EXTRACTION_PROTOCOL           *This,\r
-  IN  UINTN                                     StreamHandleToClose\r
-  )\r
-{\r
-  FRAMEWORK_SECTION_STREAM_NODE                      *StreamNode;\r
-  EFI_TPL                                       OldTpl;\r
-  EFI_STATUS                                    Status;\r
-  LIST_ENTRY                                    *Link;\r
-  FRAMEWORK_SECTION_CHILD_NODE                       *ChildNode;\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  //\r
-  // Locate target stream\r
-  //\r
-  Status = FindStreamNode (StreamHandleToClose, &StreamNode);\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Found the stream, so close it\r
-    //\r
-    RemoveEntryList (&StreamNode->Link);\r
-    while (!IsListEmpty (&StreamNode->Children)) {\r
-      Link = GetFirstNode (&StreamNode->Children);\r
-      ChildNode = CHILD_SECTION_NODE_FROM_LINK (Link);\r
-      FreeChildNode (ChildNode);\r
-    }\r
-    FreePool (StreamNode->StreamBuffer);\r
-    FreePool (StreamNode);\r
-    Status = EFI_SUCCESS;\r
-  } else {\r
-    Status = EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.inf b/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.inf
deleted file mode 100644 (file)
index 16f3862..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-## @file\r
-#  Section Extraction Dxe Driver produces framework section extract protocol.\r
-#\r
-#  The section is implemented as a linked list of section streams,\r
-#  where each stream contains a linked list of children, which may be leaves or\r
-#  encapsulations. Encapsulation section will further generate new section stream entries.\r
-#\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = SectionExtractionDxe\r
-  MODULE_UNI_FILE                = SectionExtractionDxe.uni\r
-  FILE_GUID                      = 801ADCA0-815E-46a4-84F7-657F53621A57\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = SectionExtractionEntryPoint\r
-\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  SectionExtraction.c\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  DebugLib\r
-  BaseLib\r
-  BaseMemoryLib\r
-  UefiDriverEntryPoint\r
-  UefiLib\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-[Protocols]\r
-  gEfiSectionExtractionProtocolGuid    ## PRODUCES\r
-  gEfiDecompressProtocolGuid           ## SOMETIMES_CONSUMES\r
-\r
-[Depex]\r
-  gEfiDecompressProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  SectionExtractionDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.uni b/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxe.uni
deleted file mode 100644 (file)
index c1b376c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file\r
-// Section Extraction Dxe Driver produces framework section extract protocol.\r
-//\r
-// The section is implemented as a linked list of section streams,\r
-// where each stream contains a linked list of children, which may be leaves or\r
-// encapsulations. Encapsulation section will further generate new section stream entries.\r
-//\r
-// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Produces the framework section extract protocol"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "The section is implemented as a linked list of section streams, where each stream contains a linked list of children, which may be leaves or encapsulations. An encapsulation section will further generate new section of stream entries."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxeExtra.uni b/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtractionDxeExtra.uni
deleted file mode 100644 (file)
index 04ac18b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// SectionExtractionDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Firmware Storage Extraction DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DataHubStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DataHubStatusCodeWorker.c
deleted file mode 100644 (file)
index 82490a1..0000000
+++ /dev/null
@@ -1,370 +0,0 @@
-/** @file\r
-  Data Hub status code worker.\r
-\r
-  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "DatahubStatusCodeHandlerDxe.h"\r
-\r
-//\r
-// Initialize FIFO to cache records.\r
-//\r
-LIST_ENTRY                mRecordsFifo          = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo);\r
-LIST_ENTRY                mRecordsBuffer        = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer);\r
-UINT32                    mLogDataHubStatus     = 0;\r
-EFI_EVENT                 mLogDataHubEvent;\r
-//\r
-// Cache data hub protocol.\r
-//\r
-EFI_DATA_HUB_PROTOCOL     *mDataHubProtocol = NULL;\r
-\r
-\r
-/**\r
-  Retrieve one record of from free record buffer. This record is removed from\r
-  free record buffer.\r
-\r
-  This function retrieves one record from free record buffer.\r
-  If the pool has been exhausted, then new memory would be allocated for it.\r
-\r
-  @return  Pointer to the free record.\r
-           NULL means failure to allocate new memeory for free record buffer.\r
-\r
-**/\r
-DATA_HUB_STATUS_CODE_DATA_RECORD *\r
-AcquireRecordBuffer (\r
-  VOID\r
-  )\r
-{\r
-  DATAHUB_STATUSCODE_RECORD *Record;\r
-  EFI_TPL                   CurrentTpl;\r
-  LIST_ENTRY                *Node;\r
-  UINT32                    Index;\r
-\r
-  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  if (!IsListEmpty (&mRecordsBuffer)) {\r
-    //\r
-    // Strip one entry from free record buffer.\r
-    //\r
-    Node = GetFirstNode (&mRecordsBuffer);\r
-    RemoveEntryList (Node);\r
-\r
-    Record = BASE_CR (Node, DATAHUB_STATUSCODE_RECORD, Node);\r
-  } else {\r
-    if (CurrentTpl > TPL_NOTIFY) {\r
-      //\r
-      // Memory management should work at <=TPL_NOTIFY\r
-      //\r
-      gBS->RestoreTPL (CurrentTpl);\r
-      return NULL;\r
-    }\r
-\r
-    //\r
-    // If free record buffer is exhausted, then allocate 16 new records for it.\r
-    //\r
-    gBS->RestoreTPL (CurrentTpl);\r
-    Record   = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD) * 16);\r
-    if (Record == NULL) {\r
-      return NULL;\r
-    }\r
-\r
-    CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-    //\r
-    // Here we only insert 15 new records to the free record buffer, for the first record\r
-    // will be returned immediately.\r
-    //\r
-    for (Index = 1; Index < 16; Index++) {\r
-      InsertTailList (&mRecordsBuffer, &Record[Index].Node);\r
-    }\r
-  }\r
-\r
-  Record->Signature = DATAHUB_STATUS_CODE_SIGNATURE;\r
-  InsertTailList (&mRecordsFifo, &Record->Node);\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-\r
-  return (DATA_HUB_STATUS_CODE_DATA_RECORD *) (Record->Data);\r
-}\r
-\r
-\r
-/**\r
-  Retrieve one record from Records FIFO. The record would be removed from FIFO.\r
-\r
-  @return   Point to record, which is ready to be logged.\r
-            NULL means the FIFO of record is empty.\r
-\r
-**/\r
-DATA_HUB_STATUS_CODE_DATA_RECORD *\r
-RetrieveRecord (\r
-  VOID\r
-  )\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData;\r
-  DATAHUB_STATUSCODE_RECORD         *Record;\r
-  LIST_ENTRY                        *Node;\r
-  EFI_TPL                           CurrentTpl;\r
-\r
-  RecordData = NULL;\r
-\r
-  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  if (!IsListEmpty (&mRecordsFifo)) {\r
-    Node = GetFirstNode (&mRecordsFifo);\r
-    Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE);\r
-    ASSERT (Record != NULL);\r
-\r
-    RemoveEntryList (&Record->Node);\r
-    RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data;\r
-  }\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-\r
-  return RecordData;\r
-}\r
-\r
-/**\r
-  Release given record and return it to free record buffer.\r
-\r
-  @param RecordData  Pointer to the record to release.\r
-\r
-**/\r
-VOID\r
-ReleaseRecord (\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData\r
-  )\r
-{\r
-  DATAHUB_STATUSCODE_RECORD         *Record;\r
-  EFI_TPL                           CurrentTpl;\r
-\r
-  Record = CR (RecordData, DATAHUB_STATUSCODE_RECORD, Data[0], DATAHUB_STATUS_CODE_SIGNATURE);\r
-  ASSERT (Record != NULL);\r
-\r
-  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  InsertTailList (&mRecordsBuffer, &Record->Node);\r
-  Record->Signature = 0;\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-}\r
-\r
-/**\r
-  Report status code into DataHub.\r
-\r
-  @param  CodeType             Indicates the type of status code being reported.\r
-  @param  Value                Describes the current status of a hardware or software entity.\r
-                               This included information about the class and subclass that is used to\r
-                               classify the entity as well as an operation.\r
-  @param  Instance             The enumeration of a hardware or software entity within\r
-                               the system. Valid instance numbers start with 1.\r
-  @param  CallerId             This optional parameter may be used to identify the caller.\r
-                               This parameter allows the status code driver to apply different rules to\r
-                               different callers.\r
-  @param  Data                 This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS          The function completed successfully.\r
-  @retval EFI_DEVICE_ERROR     Function is reentered.\r
-  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
-  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DataHubStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId,\r
-  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  )\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
-  UINT32                            ErrorLevel;\r
-  BASE_LIST                         Marker;\r
-  CHAR8                             *Format;\r
-  UINTN                             CharCount;\r
-\r
-  //\r
-  // Use atom operation to avoid the reentant of report.\r
-  // If current status is not zero, then the function is reentrancy.\r
-  //\r
-  if (InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 0) == 1) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Record = AcquireRecordBuffer ();\r
-  if (Record == NULL) {\r
-    //\r
-    // There are no empty record buffer in private buffers\r
-    //\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Construct Data Hub Extended Data\r
-  //\r
-  Record->CodeType = CodeType;\r
-  Record->Value    = Value;\r
-  Record->Instance = Instance;\r
-\r
-  if (CallerId != NULL) {\r
-    CopyMem (&Record->CallerId, CallerId, sizeof (EFI_GUID));\r
-  }\r
-\r
-  if (Data != NULL) {\r
-    if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
-      CharCount = UnicodeBSPrintAsciiFormat (\r
-                    (CHAR16 *) (Record + 1),\r
-                    EFI_STATUS_CODE_DATA_MAX_SIZE,\r
-                    Format,\r
-                    Marker\r
-                    );\r
-      //\r
-      // Change record data type to DebugType.\r
-      //\r
-      CopyGuid (&Record->Data.Type, &gEfiStatusCodeDataTypeDebugGuid);\r
-      Record->Data.HeaderSize = Data->HeaderSize;\r
-      Record->Data.Size = (UINT16) ((CharCount + 1) * sizeof (CHAR16));\r
-    } else {\r
-      //\r
-      // Copy status code data header\r
-      //\r
-      CopyMem (&Record->Data, Data, sizeof (EFI_STATUS_CODE_DATA));\r
-\r
-      if (Data->Size > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
-        Record->Data.Size = EFI_STATUS_CODE_DATA_MAX_SIZE;\r
-      }\r
-      CopyMem ((VOID *) (Record + 1), Data + 1, Record->Data.Size);\r
-    }\r
-  }\r
-\r
-  gBS->SignalEvent (mLogDataHubEvent);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  The Event handler which will be notified to log data in Data Hub.\r
-\r
-  @param  Event       Instance of the EFI_EVENT to signal whenever data is\r
-                      available to be logged in the system.\r
-  @param  Context     Context of the event.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-LogDataHubEventCallBack (\r
-  IN  EFI_EVENT     Event,\r
-  IN  VOID          *Context\r
-  )\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
-  UINT32                            Size;\r
-  UINT64                            DataRecordClass;\r
-\r
-  //\r
-  // Use atom operation to avoid the reentant of report.\r
-  // If current status is not zero, then the function is reentrancy.\r
-  //\r
-  if (InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 1) == 1) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Log DataRecord in Data Hub.\r
-  // Journal records fifo to find all record entry.\r
-  //\r
-  while (TRUE) {\r
-    //\r
-    // Retrieve record from record FIFO until no more record can be retrieved.\r
-    //\r
-    Record = RetrieveRecord ();\r
-    if (Record == NULL) {\r
-      break;\r
-    }\r
-    //\r
-    // Add in the size of the header we added.\r
-    //\r
-    Size = sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD) + (UINT32) Record->Data.Size;\r
-\r
-    if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
-    } else if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_ERROR;\r
-    } else if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG;\r
-    } else {\r
-      //\r
-      // Should never get here.\r
-      //\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG |\r
-        EFI_DATA_RECORD_CLASS_ERROR |\r
-        EFI_DATA_RECORD_CLASS_DATA |\r
-        EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
-    }\r
-\r
-    //\r
-    // Log DataRecord in Data Hub\r
-    //\r
-    mDataHubProtocol->LogData (\r
-                        mDataHubProtocol,\r
-                        &gEfiDataHubStatusCodeRecordGuid,\r
-                        &gEfiStatusCodeRuntimeProtocolGuid,\r
-                        DataRecordClass,\r
-                        Record,\r
-                        Size\r
-                        );\r
-\r
-    ReleaseRecord (Record);\r
-  }\r
-\r
-  //\r
-  // Restore the nest status of report\r
-  //\r
-  InterlockedCompareExchange32 (&mLogDataHubStatus, 1, 0);\r
-}\r
-\r
-\r
-/**\r
-  Locate Data Hub Protocol and create event for logging data\r
-  as initialization for data hub status code worker.\r
-\r
-  @retval EFI_SUCCESS  Initialization is successful.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeInitializeWorker (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiDataHubProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &mDataHubProtocol\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    mDataHubProtocol = NULL;\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Create a Notify Event to log data in Data Hub\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  LogDataHubEventCallBack,\r
-                  NULL,\r
-                  &mLogDataHubEvent\r
-                  );\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.c b/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.c
deleted file mode 100644 (file)
index 5a82b99..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/** @file\r
-  Status Code Handler Driver which produces datahub handler and hook it\r
-  onto the DXE status code router.\r
-\r
-  Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "DatahubStatusCodeHandlerDxe.h"\r
-\r
-static EFI_EVENT          mExitBootServicesEvent     = NULL;\r
-EFI_RSC_HANDLER_PROTOCOL  *mRscHandlerProtocol       = NULL;\r
-\r
-/**\r
-  Unregister status code callback functions only available at boot time from\r
-  report status code router when exiting boot services.\r
-\r
-  @param  Event         Event whose notification function is being invoked.\r
-  @param  Context       Pointer to the notification function's context, which is\r
-                        always zero in current implementation.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-UnregisterBootTimeHandlers (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  mRscHandlerProtocol->Unregister (DataHubStatusCodeReportWorker);\r
-}\r
-\r
-/**\r
-  Entry point of DXE Status Code Driver.\r
-\r
-  This function is the entry point of this DXE Status Code Driver.\r
-  It initializes registers status code handlers, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
-\r
-  @param  ImageHandle       The firmware allocated handle for the EFI image.\r
-  @param  SystemTable       A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DatahubStatusCodeHandlerDxeEntry (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
-    Status = gBS->LocateProtocol (\r
-                    &gEfiRscHandlerProtocolGuid,\r
-                    NULL,\r
-                    (VOID **) &mRscHandlerProtocol\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Dispatch initialization request to supported devices\r
-    //\r
-    DataHubStatusCodeInitializeWorker ();\r
-\r
-    mRscHandlerProtocol->Register (DataHubStatusCodeReportWorker, TPL_HIGH_LEVEL);\r
-\r
-    Status = gBS->CreateEventEx (\r
-                    EVT_NOTIFY_SIGNAL,\r
-                    TPL_NOTIFY,\r
-                    UnregisterBootTimeHandlers,\r
-                    NULL,\r
-                    &gEfiEventExitBootServicesGuid,\r
-                    &mExitBootServicesEvent\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.h b/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.h
deleted file mode 100644 (file)
index 5d799af..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/** @file\r
-  Internal include file for Datahub Status Code Handler Driver.\r
-\r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __DATAHUB_STATUS_CODE_HANDLER_DXE_H__\r
-#define __DATAHUB_STATUS_CODE_HANDLER_DXE_H__\r
-\r
-#include <Protocol/ReportStatusCodeHandler.h>\r
-#include <Protocol/DataHub.h>\r
-#include <Protocol/StatusCode.h>\r
-\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Guid/DataHubStatusCodeRecord.h>\r
-#include <Guid/EventGroup.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/SynchronizationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-//\r
-// Data hub worker definition\r
-//\r
-#define DATAHUB_STATUS_CODE_SIGNATURE             SIGNATURE_32 ('B', 'D', 'H', 'S')\r
-\r
-typedef struct {\r
-  UINTN       Signature;\r
-  LIST_ENTRY  Node;\r
-  UINT8       Data[sizeof(DATA_HUB_STATUS_CODE_DATA_RECORD) + EFI_STATUS_CODE_DATA_MAX_SIZE];\r
-} DATAHUB_STATUSCODE_RECORD;\r
-\r
-/**\r
-  Report status code into DataHub.\r
-\r
-  @param  CodeType             Indicates the type of status code being reported.\r
-  @param  Value                Describes the current status of a hardware or software entity.\r
-                               This included information about the class and subclass that is used to\r
-                               classify the entity as well as an operation.\r
-  @param  Instance             The enumeration of a hardware or software entity within\r
-                               the system. Valid instance numbers start with 1.\r
-  @param  CallerId             This optional parameter may be used to identify the caller.\r
-                               This parameter allows the status code driver to apply different rules to\r
-                               different callers.\r
-  @param  Data                 This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS          The function completed successfully.\r
-  @retval EFI_DEVICE_ERROR     Function is reentered.\r
-  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
-  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DataHubStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId,\r
-  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  );\r
-\r
-/**\r
-  Locate Data Hub Protocol and create event for logging data\r
-  as initialization for data hub status code worker.\r
-\r
-  @retval EFI_SUCCESS  Initialization is successful.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeInitializeWorker (\r
-  VOID\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.inf b/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.inf
deleted file mode 100644 (file)
index a87b84d..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-## @file\r
-#  Status Code Handler Driver which produces datahub handler.\r
-#\r
-#  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DatahubStatusCodeHandlerDxe\r
-  MODULE_UNI_FILE                = DatahubStatusCodeHandlerDxe.uni\r
-  FILE_GUID                      = 863D214F-0920-437B-8CAD-88EA83A24E97\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = DatahubStatusCodeHandlerDxeEntry\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  DatahubStatusCodeHandlerDxe.h\r
-  DatahubStatusCodeHandlerDxe.c\r
-  DataHubStatusCodeWorker.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  MemoryAllocationLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  PcdLib\r
-  PrintLib\r
-  ReportStatusCodeLib\r
-  DebugLib\r
-  SynchronizationLib\r
-  BaseMemoryLib\r
-\r
-[Guids]\r
-  gEfiEventExitBootServicesGuid                 ## CONSUMES ## Event\r
-  gEfiDataHubStatusCodeRecordGuid               ## PRODUCES ## UNDEFINED # DataRecord Guid\r
-  gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_PRODUCES ## UNDEFINED # Record data type\r
-\r
-[Protocols]\r
-  gEfiRscHandlerProtocolGuid                    ## CONSUMES\r
-  gEfiDataHubProtocolGuid                       ## CONSUMES\r
-  gEfiStatusCodeRuntimeProtocolGuid             ## UNDEFINED\r
-\r
-[FeaturePcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseDataHub ## CONSUMES\r
-\r
-[Depex]\r
-  gEfiRscHandlerProtocolGuid AND\r
-  gEfiDataHubProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  DatahubStatusCodeHandlerDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.uni b/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxe.uni
deleted file mode 100644 (file)
index 69dee2a..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// Status Code Handler Driver which produces datahub handler.\r
-//\r
-// The Status Code Handler Driver which produces a datahub handler.\r
-//\r
-// Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Produces a datahub handler"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "The Status Code Handler Driver which produces a datahub handler."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxeExtra.uni b/IntelFrameworkModulePkg/Universal/StatusCode/DatahubStatusCodeHandlerDxe/DatahubStatusCodeHandlerDxeExtra.uni
deleted file mode 100644 (file)
index 4dfbc99..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// DatahubStatusCodeHandlerDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Data Hub Status Code DXE Driver"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c
deleted file mode 100644 (file)
index 051bef1..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/** @file\r
-  PEI memory status code worker.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "StatusCodePei.h"\r
-\r
-/**\r
-  Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r
-\r
-  @retval EFI_SUCCESS  The GUID'ed HOB is created successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-MemoryStatusCodeInitializeWorker (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Create memory status code GUID'ed HOB.\r
-  //\r
-  MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
-\r
-  //\r
-  // Build GUID'ed HOB with PCD defined size.\r
-  //\r
-  PacketHeader = BuildGuidHob (\r
-                   &gMemoryStatusCodeRecordGuid,\r
-                   PcdGet16 (PcdStatusCodeMemorySize) * 1024 + sizeof (MEMORY_STATUSCODE_PACKET_HEADER)\r
-                   );\r
-  ASSERT (PacketHeader != NULL);\r
-\r
-  PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
-  PacketHeader->PacketIndex      = 0;\r
-  PacketHeader->RecordIndex      = 0;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Report status code into GUID'ed HOB.\r
-\r
-  This function reports status code into GUID'ed HOB. If not all packets are full, then\r
-  write status code into available entry. Otherwise, create a new packet for it.\r
-\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or\r
-                           software entity. This includes information about the class and\r
-                           subclass that is used to classify the entity as well as an operation.\r
-                           For progress codes, the operation is the current activity.\r
-                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. A system may contain multiple entities that match a class/subclass\r
-                           pairing. The instance differentiates between them. An instance of 0 indicates\r
-                           that instance information is unavailable, not meaningful, or not relevant.\r
-                           Valid instance numbers start with 1.\r
-\r
-  @retval EFI_SUCCESS      The function always return EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-MemoryStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance\r
-  )\r
-{\r
-\r
-  EFI_PEI_HOB_POINTERS              Hob;\r
-  MEMORY_STATUSCODE_PACKET_HEADER   *PacketHeader;\r
-  MEMORY_STATUSCODE_RECORD          *Record;\r
-\r
-  //\r
-  // Find GUID'ed HOBs to locate current record buffer.\r
-  //\r
-  Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
-  ASSERT (Hob.Raw != NULL);\r
-\r
-  PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
-  Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
-  Record = &Record[PacketHeader->RecordIndex++];\r
-\r
-  //\r
-  // Save status code.\r
-  //\r
-  Record->CodeType = CodeType;\r
-  Record->Instance = Instance;\r
-  Record->Value    = Value;\r
-\r
-  //\r
-  // If record index equals to max record number, then wrap around record index to zero.\r
-  //\r
-  // The reader of status code should compare the number of records with max records number,\r
-  // If it is equal to or larger than the max number, then the wrap-around had happened,\r
-  // so the first record is pointed by record index.\r
-  // If it is less then max number, index of the first record is zero.\r
-  //\r
-  if (PacketHeader->RecordIndex == PacketHeader->MaxRecordsNumber) {\r
-    //\r
-    // Wrap around record index.\r
-    //\r
-    PacketHeader->RecordIndex = 0;\r
-    PacketHeader->PacketIndex ++;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c
deleted file mode 100644 (file)
index 560a785..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-/** @file\r
-  Serial I/O status code reporting worker.\r
-\r
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-**/\r
-\r
-#include "StatusCodePei.h"\r
-\r
-/**\r
-  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
-\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or\r
-                           software entity. This includes information about the class and\r
-                           subclass that is used to classify the entity as well as an operation.\r
-                           For progress codes, the operation is the current activity.\r
-                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. A system may contain multiple entities that match a class/subclass\r
-                           pairing. The instance differentiates between them. An instance of 0 indicates\r
-                           that instance information is unavailable, not meaningful, or not relevant.\r
-                           Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS      Status code reported to serial I/O successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-SerialStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE           CodeType,\r
-  IN EFI_STATUS_CODE_VALUE          Value,\r
-  IN UINT32                         Instance,\r
-  IN CONST EFI_GUID                 *CallerId,\r
-  IN CONST EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  )\r
-{\r
-  CHAR8           *Filename;\r
-  CHAR8           *Description;\r
-  CHAR8           *Format;\r
-  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
-  UINT32          ErrorLevel;\r
-  UINT32          LineNumber;\r
-  UINTN           CharCount;\r
-  BASE_LIST       Marker;\r
-\r
-  Buffer[0] = '\0';\r
-\r
-  if (Data != NULL &&\r
-      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
-    //\r
-    // Print ASSERT() information into output buffer.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "\n\rPEI_ASSERT!: %a (%d): %a\n\r",\r
-                  Filename,\r
-                  LineNumber,\r
-                  Description\r
-                  );\r
-  } else if (Data != NULL &&\r
-             ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
-    //\r
-    // Print DEBUG() information into output buffer.\r
-    //\r
-    CharCount = AsciiBSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  Format,\r
-                  Marker\r
-                  );\r
-  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
-    //\r
-    // Print ERROR information into output buffer.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "ERROR: C%08x:V%08x I%x",\r
-                  CodeType,\r
-                  Value,\r
-                  Instance\r
-                  );\r
-\r
-    if (CallerId != NULL) {\r
-      CharCount += AsciiSPrint (\r
-                     &Buffer[CharCount],\r
-                     (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
-                     " %g",\r
-                     CallerId\r
-                     );\r
-    }\r
-\r
-    if (Data != NULL) {\r
-      CharCount += AsciiSPrint (\r
-                     &Buffer[CharCount],\r
-                     (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
-                     " %x",\r
-                     Data\r
-                     );\r
-    }\r
-\r
-    CharCount += AsciiSPrint (\r
-                   &Buffer[CharCount],\r
-                   (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
-                   "\n\r"\r
-                   );\r
-  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
-    //\r
-    // Print PROGRESS information into output buffer.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "PROGRESS CODE: V%08x I%x\n\r",\r
-                  Value,\r
-                  Instance\r
-                  );\r
-  } else if (Data != NULL &&\r
-             CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) &&\r
-             ((EFI_STATUS_CODE_STRING_DATA *) Data)->StringType == EfiStringAscii) {\r
-    //\r
-    // EFI_STATUS_CODE_STRING_DATA\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "%a\n\r",\r
-                  ((EFI_STATUS_CODE_STRING_DATA *) Data)->String.Ascii\r
-                  );\r
-  } else {\r
-    //\r
-    // Code type is not defined.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "Undefined: C%08x:V%08x I%x\n\r",\r
-                  CodeType,\r
-                  Value,\r
-                  Instance\r
-                  );\r
-  }\r
-\r
-  //\r
-  // Call SerialPort Lib function to do print.\r
-  //\r
-  SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.c
deleted file mode 100644 (file)
index c266470..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/** @file\r
-  Status code PEIM which produces Status Code PPI.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "StatusCodePei.h"\r
-\r
-EFI_PEI_PROGRESS_CODE_PPI     mStatusCodePpi = {\r
-  ReportDispatcher\r
-  };\r
-\r
-EFI_PEI_PPI_DESCRIPTOR        mStatusCodePpiDescriptor = {\r
-  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
-  &gEfiPeiStatusCodePpiGuid,\r
-  &mStatusCodePpi\r
-  };\r
-\r
-/**\r
-  Publishes an interface that allows PEIMs to report status codes.\r
-\r
-  This function implements EFI_PEI_PROGRESS_CODE_PPI.ReportStatusCode().\r
-  It publishes an interface that allows PEIMs to report status codes.\r
-\r
-  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or\r
-                           software entity. This includes information about the class and\r
-                           subclass that is used to classify the entity as well as an operation.\r
-                           For progress codes, the operation is the current activity.\r
-                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. A system may contain multiple entities that match a class/subclass\r
-                           pairing. The instance differentiates between them. An instance of 0 indicates\r
-                           that instance information is unavailable, not meaningful, or not relevant.\r
-                           Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS      The function completed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportDispatcher (\r
-  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
-  IN EFI_STATUS_CODE_TYPE           CodeType,\r
-  IN EFI_STATUS_CODE_VALUE          Value,\r
-  IN UINT32                         Instance,\r
-  IN CONST EFI_GUID                 *CallerId OPTIONAL,\r
-  IN CONST EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  )\r
-{\r
-  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
-    SerialStatusCodeReportWorker (\r
-      CodeType,\r
-      Value,\r
-      Instance,\r
-      CallerId,\r
-      Data\r
-      );\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
-    MemoryStatusCodeReportWorker (\r
-      CodeType,\r
-      Value,\r
-      Instance\r
-      );\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
-    //\r
-    // Call OEM hook status code library API to report status code to OEM device\r
-    //\r
-    OemHookStatusCodeReport (\r
-      CodeType,\r
-      Value,\r
-      Instance,\r
-      (EFI_GUID *)CallerId,\r
-      (EFI_STATUS_CODE_DATA *)Data\r
-      );\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Entry point of Status Code PEIM.\r
-\r
-  This function is the entry point of this Status Code PEIM.\r
-  It initializes supported status code devices according to PCD settings,\r
-  and installs Status Code PPI.\r
-\r
-  @param  FileHandle  Handle of the file being invoked.\r
-  @param  PeiServices Describes the list of possible PEI Services.\r
-\r
-  @retval EFI_SUCESS  The entry point of DXE IPL PEIM executes successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiStatusCodeDriverEntry (\r
-  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r
-  IN CONST EFI_PEI_SERVICES     **PeiServices\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-\r
-  //\r
-  // Dispatch initialization request to sub-statuscode-devices.\r
-  // If enable UseSerial, then initialize serial port.\r
-  // if enable UseMemory, then initialize memory status code worker.\r
-  // if enable UseOEM, then initialize Oem status code.\r
-  //\r
-  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
-    Status = SerialPortInitialize();\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
-    Status = MemoryStatusCodeInitializeWorker ();\r
-    ASSERT_EFI_ERROR  (Status);\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
-    Status = OemHookStatusCodeInitialize ();\r
-    ASSERT_EFI_ERROR  (Status);\r
-  }\r
-\r
-  //\r
-  // Install Status Code PPI.\r
-  // It serves the PEI Service ReportStatusCode.\r
-  //\r
-  Status = PeiServicesInstallPpi (&mStatusCodePpiDescriptor);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.h b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.h
deleted file mode 100644 (file)
index d2d9a6b..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/** @file\r
-  Internal include file for Status Code PEIM.\r
-\r
-  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __PEI_STATUS_CODE_H__\r
-#define __PEI_STATUS_CODE_H__\r
-\r
-#include <FrameworkPei.h>\r
-\r
-#include <Guid/MemoryStatusCodeRecord.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Ppi/StatusCode.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/OemHookStatusCodeLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
-\r
-/**\r
-  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
-\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or\r
-                           software entity. This includes information about the class and\r
-                           subclass that is used to classify the entity as well as an operation.\r
-                           For progress codes, the operation is the current activity.\r
-                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. A system may contain multiple entities that match a class/subclass\r
-                           pairing. The instance differentiates between them. An instance of 0 indicates\r
-                           that instance information is unavailable, not meaningful, or not relevant.\r
-                           Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS      Status code reported to serial I/O successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-SerialStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE           CodeType,\r
-  IN EFI_STATUS_CODE_VALUE          Value,\r
-  IN UINT32                         Instance,\r
-  IN CONST EFI_GUID                 *CallerId,\r
-  IN CONST EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  );\r
-\r
-\r
-/**\r
-  Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r
-\r
-  @retval EFI_SUCCESS  The GUID'ed HOB is created successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-MemoryStatusCodeInitializeWorker (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Report status code into GUID'ed HOB.\r
-\r
-  This function reports status code into GUID'ed HOB. If not all packets are full, then\r
-  write status code into available entry. Otherwise, create a new packet for it.\r
-\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or\r
-                           software entity. This includes information about the class and\r
-                           subclass that is used to classify the entity as well as an operation.\r
-                           For progress codes, the operation is the current activity.\r
-                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. A system may contain multiple entities that match a class/subclass\r
-                           pairing. The instance differentiates between them. An instance of 0 indicates\r
-                           that instance information is unavailable, not meaningful, or not relevant.\r
-                           Valid instance numbers start with 1.\r
-\r
-  @retval EFI_SUCCESS      The function always return EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-MemoryStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance\r
-  );\r
-\r
-/**\r
-  Publishes an interface that allows PEIMs to report status codes.\r
-\r
-  This function implements EFI_PEI_PROGRESS_CODE_PPI.ReportStatusCode().\r
-  It publishes an interface that allows PEIMs to report status codes.\r
-\r
-  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or\r
-                           software entity. This includes information about the class and\r
-                           subclass that is used to classify the entity as well as an operation.\r
-                           For progress codes, the operation is the current activity.\r
-                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. A system may contain multiple entities that match a class/subclass\r
-                           pairing. The instance differentiates between them. An instance of 0 indicates\r
-                           that instance information is unavailable, not meaningful, or not relevant.\r
-                           Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS      The function completed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportDispatcher (\r
-  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
-  IN EFI_STATUS_CODE_TYPE           CodeType,\r
-  IN EFI_STATUS_CODE_VALUE          Value,\r
-  IN UINT32                         Instance,\r
-  IN CONST EFI_GUID                 *CallerId OPTIONAL,\r
-  IN CONST EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  );\r
-\r
-#endif\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
deleted file mode 100644 (file)
index ef316f5..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-## @file\r
-#  Status code PEIM which produces Status Code PPI.\r
-#\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = StatusCodePei\r
-  MODULE_UNI_FILE                = StatusCodePei.uni\r
-  FILE_GUID                      = 1EC0F53A-FDE0-4576-8F25-7A1A410F58EB\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = PeiStatusCodeDriverEntry\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  StatusCodePei.c\r
-  StatusCodePei.h\r
-  MemoryStausCodeWorker.c\r
-  SerialStatusCodeWorker.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PeimEntryPoint\r
-  OemHookStatusCodeLib\r
-  PeiServicesLib\r
-  PcdLib\r
-  HobLib\r
-  SerialPortLib\r
-  ReportStatusCodeLib\r
-  PrintLib\r
-  DebugLib\r
-  BaseLib\r
-\r
-\r
-[Guids]\r
-  gMemoryStatusCodeRecordGuid                   ## SOMETIMES_CONSUMES ## HOB\r
-  gEfiStatusCodeDataTypeStringGuid              ## SOMETIMES_CONSUMES ## UNDEFINED # String Data Type\r
-\r
-[Ppis]\r
-  gEfiPeiStatusCodePpiGuid                      ## PRODUCES\r
-\r
-\r
-[FeaturePcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseOEM ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial ## CONSUMES\r
-\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1|gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory  ## SOMETIMES_CONSUMES\r
-\r
-[Depex]\r
-  TRUE\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  StatusCodePeiExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.uni b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.uni
deleted file mode 100644 (file)
index 4ecbf23..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// Status code PEIM which produces Status Code PPI.\r
-//\r
-// The status code PEIM that produces a Status Code PPI.\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Produces a Status Code PPI"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "The status code PEIM that produces a Status Code PPI."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePeiExtra.uni b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePeiExtra.uni
deleted file mode 100644 (file)
index 7cbe35f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// StatusCodePei Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Status Code PEI Module"\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c
deleted file mode 100644 (file)
index ffa14e2..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-/** @file\r
-  Data Hub status code worker.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "StatusCodeRuntimeDxe.h"\r
-\r
-//\r
-// Initialize FIFO to cache records.\r
-//\r
-LIST_ENTRY                mRecordsFifo          = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo);\r
-LIST_ENTRY                mRecordsBuffer        = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer);\r
-UINT32                    mLogDataHubStatus     = 0;\r
-EFI_EVENT                 mLogDataHubEvent;\r
-//\r
-// Cache data hub protocol.\r
-//\r
-EFI_DATA_HUB_PROTOCOL     *mDataHubProtocol = NULL;\r
-\r
-\r
-/**\r
-  Retrieve one record of from free record buffer. This record is removed from\r
-  free record buffer.\r
-\r
-  This function retrieves one record from free record buffer.\r
-  If the pool has been exhausted, then new memory would be allocated for it.\r
-\r
-  @return  Pointer to the free record.\r
-           NULL means failure to allocate new memeory for free record buffer.\r
-\r
-**/\r
-DATA_HUB_STATUS_CODE_DATA_RECORD *\r
-AcquireRecordBuffer (\r
-  VOID\r
-  )\r
-{\r
-  DATAHUB_STATUSCODE_RECORD *Record;\r
-  EFI_TPL                   CurrentTpl;\r
-  LIST_ENTRY                *Node;\r
-  UINT32                    Index;\r
-\r
-  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  if (!IsListEmpty (&mRecordsBuffer)) {\r
-    //\r
-    // Strip one entry from free record buffer.\r
-    //\r
-    Node = GetFirstNode (&mRecordsBuffer);\r
-    RemoveEntryList (Node);\r
-\r
-    Record = BASE_CR (Node, DATAHUB_STATUSCODE_RECORD, Node);\r
-  } else {\r
-    if (CurrentTpl > TPL_NOTIFY) {\r
-      //\r
-      // Memory management should work at <=TPL_NOTIFY\r
-      //\r
-      gBS->RestoreTPL (CurrentTpl);\r
-      return NULL;\r
-    }\r
-\r
-    //\r
-    // If free record buffer is exhausted, then allocate 16 new records for it.\r
-    //\r
-    gBS->RestoreTPL (CurrentTpl);\r
-    Record   = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD) * 16);\r
-    if (Record == NULL) {\r
-      return NULL;\r
-    }\r
-\r
-    CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-    //\r
-    // Here we only insert 15 new records to the free record buffer, for the first record\r
-    // will be returned immediately.\r
-    //\r
-    for (Index = 1; Index < 16; Index++) {\r
-      InsertTailList (&mRecordsBuffer, &Record[Index].Node);\r
-    }\r
-  }\r
-\r
-  Record->Signature = DATAHUB_STATUS_CODE_SIGNATURE;\r
-  InsertTailList (&mRecordsFifo, &Record->Node);\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-\r
-  return (DATA_HUB_STATUS_CODE_DATA_RECORD *) (Record->Data);\r
-}\r
-\r
-\r
-/**\r
-  Retrieve one record from Records FIFO. The record would be removed from FIFO.\r
-\r
-  @return   Point to record, which is ready to be logged.\r
-            NULL means the FIFO of record is empty.\r
-\r
-**/\r
-DATA_HUB_STATUS_CODE_DATA_RECORD *\r
-RetrieveRecord (\r
-  VOID\r
-  )\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData;\r
-  DATAHUB_STATUSCODE_RECORD         *Record;\r
-  LIST_ENTRY                        *Node;\r
-  EFI_TPL                           CurrentTpl;\r
-\r
-  RecordData = NULL;\r
-\r
-  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  if (!IsListEmpty (&mRecordsFifo)) {\r
-    Node = GetFirstNode (&mRecordsFifo);\r
-    Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE);\r
-    ASSERT (Record != NULL);\r
-\r
-    RemoveEntryList (&Record->Node);\r
-    RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data;\r
-  }\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-\r
-  return RecordData;\r
-}\r
-\r
-/**\r
-  Release given record and return it to free record buffer.\r
-\r
-  @param RecordData  Pointer to the record to release.\r
-\r
-**/\r
-VOID\r
-ReleaseRecord (\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData\r
-  )\r
-{\r
-  DATAHUB_STATUSCODE_RECORD         *Record;\r
-  EFI_TPL                           CurrentTpl;\r
-\r
-  Record = CR (RecordData, DATAHUB_STATUSCODE_RECORD, Data[0], DATAHUB_STATUS_CODE_SIGNATURE);\r
-  ASSERT (Record != NULL);\r
-\r
-  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  InsertTailList (&mRecordsBuffer, &Record->Node);\r
-  Record->Signature = 0;\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-}\r
-\r
-/**\r
-  Report status code into DataHub.\r
-\r
-  @param  CodeType             Indicates the type of status code being reported.\r
-  @param  Value                Describes the current status of a hardware or software entity.\r
-                               This included information about the class and subclass that is used to\r
-                               classify the entity as well as an operation.\r
-  @param  Instance             The enumeration of a hardware or software entity within\r
-                               the system. Valid instance numbers start with 1.\r
-  @param  CallerId             This optional parameter may be used to identify the caller.\r
-                               This parameter allows the status code driver to apply different rules to\r
-                               different callers.\r
-  @param  Data                 This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS          The function completed successfully.\r
-  @retval EFI_DEVICE_ERROR     Function is reentered.\r
-  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
-  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId,\r
-  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  )\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
-  UINT32                            ErrorLevel;\r
-  BASE_LIST                         Marker;\r
-  CHAR8                             *Format;\r
-  UINTN                             CharCount;\r
-  EFI_STATUS                        Status;\r
-\r
-  //\r
-  // Use atom operation to avoid the reentant of report.\r
-  // If current status is not zero, then the function is reentrancy.\r
-  //\r
-  if (InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 0) == 1) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // See whether in runtime phase or not.\r
-  //\r
-  if (EfiAtRuntime ()) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (mDataHubProtocol == NULL) {\r
-    Status = DataHubStatusCodeInitializeWorker ();\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  Record = AcquireRecordBuffer ();\r
-  if (Record == NULL) {\r
-    //\r
-    // There are no empty record buffer in private buffers\r
-    //\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Construct Data Hub Extended Data\r
-  //\r
-  Record->CodeType = CodeType;\r
-  Record->Value    = Value;\r
-  Record->Instance = Instance;\r
-\r
-  if (CallerId != NULL) {\r
-    CopyMem (&Record->CallerId, CallerId, sizeof (EFI_GUID));\r
-  }\r
-\r
-  if (Data != NULL) {\r
-    if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
-      CharCount = UnicodeBSPrintAsciiFormat (\r
-                    (CHAR16 *) (Record + 1),\r
-                    EFI_STATUS_CODE_DATA_MAX_SIZE,\r
-                    Format,\r
-                    Marker\r
-                    );\r
-      //\r
-      // Change record data type to DebugType.\r
-      //\r
-      CopyGuid (&Record->Data.Type, &gEfiStatusCodeDataTypeDebugGuid);\r
-      Record->Data.HeaderSize = Data->HeaderSize;\r
-      Record->Data.Size = (UINT16) ((CharCount + 1) * sizeof (CHAR16));\r
-    } else {\r
-      //\r
-      // Copy status code data header\r
-      //\r
-      CopyMem (&Record->Data, Data, sizeof (EFI_STATUS_CODE_DATA));\r
-\r
-      if (Data->Size > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
-        Record->Data.Size = EFI_STATUS_CODE_DATA_MAX_SIZE;\r
-      }\r
-      CopyMem ((VOID *) (Record + 1), Data + 1, Record->Data.Size);\r
-    }\r
-  }\r
-\r
-  gBS->SignalEvent (mLogDataHubEvent);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  The Event handler which will be notified to log data in Data Hub.\r
-\r
-  @param  Event       Instance of the EFI_EVENT to signal whenever data is\r
-                      available to be logged in the system.\r
-  @param  Context     Context of the event.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-LogDataHubEventCallBack (\r
-  IN  EFI_EVENT     Event,\r
-  IN  VOID          *Context\r
-  )\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
-  UINT32                            Size;\r
-  UINT64                            DataRecordClass;\r
-\r
-  //\r
-  // Use atom operation to avoid the reentant of report.\r
-  // If current status is not zero, then the function is reentrancy.\r
-  //\r
-  if (InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 1) == 1) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Log DataRecord in Data Hub.\r
-  // Journal records fifo to find all record entry.\r
-  //\r
-  while (TRUE) {\r
-    //\r
-    // Retrieve record from record FIFO until no more record can be retrieved.\r
-    //\r
-    Record = RetrieveRecord ();\r
-    if (Record == NULL) {\r
-      break;\r
-    }\r
-    //\r
-    // Add in the size of the header we added.\r
-    //\r
-    Size = sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD) + (UINT32) Record->Data.Size;\r
-\r
-    if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
-    } else if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_ERROR;\r
-    } else if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG;\r
-    } else {\r
-      //\r
-      // Should never get here.\r
-      //\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG |\r
-        EFI_DATA_RECORD_CLASS_ERROR |\r
-        EFI_DATA_RECORD_CLASS_DATA |\r
-        EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
-    }\r
-\r
-    //\r
-    // Log DataRecord in Data Hub\r
-    //\r
-    mDataHubProtocol->LogData (\r
-                        mDataHubProtocol,\r
-                        &gEfiDataHubStatusCodeRecordGuid,\r
-                        &gEfiStatusCodeRuntimeProtocolGuid,\r
-                        DataRecordClass,\r
-                        Record,\r
-                        Size\r
-                        );\r
-\r
-    ReleaseRecord (Record);\r
-  }\r
-\r
-  //\r
-  // Restore the nest status of report\r
-  //\r
-  InterlockedCompareExchange32 (&mLogDataHubStatus, 1, 0);\r
-}\r
-\r
-\r
-/**\r
-  Locate Data Hub Protocol and create event for logging data\r
-  as initialization for data hub status code worker.\r
-\r
-  @retval EFI_SUCCESS  Initialization is successful.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeInitializeWorker (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiDataHubProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &mDataHubProtocol\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    mDataHubProtocol = NULL;\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Create a Notify Event to log data in Data Hub\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  LogDataHubEventCallBack,\r
-                  NULL,\r
-                  &mLogDataHubEvent\r
-                  );\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/RtMemoryStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/RtMemoryStatusCodeWorker.c
deleted file mode 100644 (file)
index 170b4d5..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/** @file\r
-  Runtime memory status code worker.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "StatusCodeRuntimeDxe.h"\r
-\r
-RUNTIME_MEMORY_STATUSCODE_HEADER  *mRtMemoryStatusCodeTable;\r
-\r
-/**\r
-  Initialize runtime memory status code table as initialization for runtime memory status code worker\r
-\r
-  @retval EFI_SUCCESS  Runtime memory status code table successfully initialized.\r
-\r
-**/\r
-EFI_STATUS\r
-RtMemoryStatusCodeInitializeWorker (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Allocate runtime memory status code pool.\r
-  //\r
-  mRtMemoryStatusCodeTable = AllocateRuntimePool (\r
-                               sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r
-                               PcdGet16 (PcdStatusCodeMemorySize) * 1024\r
-                               );\r
-  ASSERT (mRtMemoryStatusCodeTable != NULL);\r
-\r
-  mRtMemoryStatusCodeTable->RecordIndex      = 0;\r
-  mRtMemoryStatusCodeTable->NumberOfRecords  = 0;\r
-  mRtMemoryStatusCodeTable->MaxRecordsNumber =\r
-    (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Report status code into runtime memory. If the runtime pool is full, roll back to the\r
-  first record and overwrite it.\r
-\r
-  @param  CodeType                Indicates the type of status code being reported.\r
-  @param  Value                   Describes the current status of a hardware or software entity.\r
-                                  This included information about the class and subclass that is used to\r
-                                  classify the entity as well as an operation.\r
-  @param  Instance                The enumeration of a hardware or software entity within\r
-                                  the system. Valid instance numbers start with 1.\r
-\r
-  @retval EFI_SUCCESS             Status code successfully recorded in runtime memory status code table.\r
-\r
-**/\r
-EFI_STATUS\r
-RtMemoryStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE               CodeType,\r
-  IN EFI_STATUS_CODE_VALUE              Value,\r
-  IN UINT32                             Instance\r
-  )\r
-{\r
-  MEMORY_STATUSCODE_RECORD              *Record;\r
-\r
-  //\r
-  // Locate current record buffer.\r
-  //\r
-  Record = (MEMORY_STATUSCODE_RECORD *) (mRtMemoryStatusCodeTable + 1);\r
-  Record = &Record[mRtMemoryStatusCodeTable->RecordIndex++];\r
-\r
-  //\r
-  // Save status code.\r
-  //\r
-  Record->CodeType = CodeType;\r
-  Record->Value    = Value;\r
-  Record->Instance = Instance;\r
-\r
-  //\r
-  // If record index equals to max record number, then wrap around record index to zero.\r
-  //\r
-  // The reader of status code should compare the number of records with max records number,\r
-  // If it is equal to or larger than the max number, then the wrap-around had happened,\r
-  // so the first record is pointed by record index.\r
-  // If it is less then max number, index of the first record is zero.\r
-  //\r
-  mRtMemoryStatusCodeTable->NumberOfRecords++;\r
-  if (mRtMemoryStatusCodeTable->RecordIndex == mRtMemoryStatusCodeTable->MaxRecordsNumber) {\r
-    //\r
-    // Wrap around record index.\r
-    //\r
-    mRtMemoryStatusCodeTable->RecordIndex = 0;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/SerialStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/SerialStatusCodeWorker.c
deleted file mode 100644 (file)
index 2045fc8..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/** @file\r
-  Serial I/O status code reporting worker.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "StatusCodeRuntimeDxe.h"\r
-\r
-/**\r
-  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
-\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or software entity.\r
-                           This included information about the class and subclass that is used to\r
-                           classify the entity as well as an operation.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS      Status code reported to serial I/O successfully.\r
-  @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
-  @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
-\r
-**/\r
-EFI_STATUS\r
-SerialStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId,\r
-  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  )\r
-{\r
-  CHAR8           *Filename;\r
-  CHAR8           *Description;\r
-  CHAR8           *Format;\r
-  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
-  UINT32          ErrorLevel;\r
-  UINT32          LineNumber;\r
-  UINTN           CharCount;\r
-  BASE_LIST       Marker;\r
-\r
-  Buffer[0] = '\0';\r
-\r
-  if (Data != NULL &&\r
-      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
-    //\r
-    // Print ASSERT() information into output buffer.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "\n\rDXE_ASSERT!: %a (%d): %a\n\r",\r
-                  Filename,\r
-                  LineNumber,\r
-                  Description\r
-                  );\r
-  } else if (Data != NULL &&\r
-             ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
-    //\r
-    // Print DEBUG() information into output buffer.\r
-    //\r
-    CharCount = AsciiBSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  Format,\r
-                  Marker\r
-                  );\r
-  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
-    //\r
-    // Print ERROR information into output buffer.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "ERROR: C%08x:V%08x I%x",\r
-                  CodeType,\r
-                  Value,\r
-                  Instance\r
-                  );\r
-\r
-    if (CallerId != NULL) {\r
-      CharCount += AsciiSPrint (\r
-                     &Buffer[CharCount],\r
-                     (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
-                     " %g",\r
-                     CallerId\r
-                     );\r
-    }\r
-\r
-    if (Data != NULL) {\r
-      CharCount += AsciiSPrint (\r
-                     &Buffer[CharCount],\r
-                     (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
-                     " %x",\r
-                     Data\r
-                     );\r
-    }\r
-\r
-    CharCount += AsciiSPrint (\r
-                   &Buffer[CharCount],\r
-                   (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
-                   "\n\r"\r
-                   );\r
-  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
-    //\r
-    // Print PROGRESS information into output buffer.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "PROGRESS CODE: V%08x I%x\n\r",\r
-                  Value,\r
-                  Instance\r
-                  );\r
-  } else if (Data != NULL &&\r
-             CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) &&\r
-             ((EFI_STATUS_CODE_STRING_DATA *) Data)->StringType == EfiStringAscii) {\r
-    //\r
-    // EFI_STATUS_CODE_STRING_DATA\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "%a\n\r",\r
-                  ((EFI_STATUS_CODE_STRING_DATA *) Data)->String.Ascii\r
-                  );\r
-  } else {\r
-    //\r
-    // Code type is not defined.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  sizeof (Buffer),\r
-                  "Undefined: C%08x:V%08x I%x\n\r",\r
-                  CodeType,\r
-                  Value,\r
-                  Instance\r
-                  );\r
-  }\r
-\r
-  //\r
-  // Call SerialPort Lib function to do print.\r
-  //\r
-  SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c
deleted file mode 100644 (file)
index 03dc4cb..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/** @file\r
-  Status code driver for IA32/X64/EBC architecture.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "StatusCodeRuntimeDxe.h"\r
-\r
-EFI_EVENT    mVirtualAddressChangeEvent = NULL;\r
-EFI_HANDLE   mHandle = NULL;\r
-\r
-//\r
-// Declaration of status code protocol.\r
-//\r
-EFI_STATUS_CODE_PROTOCOL  mEfiStatusCodeProtocol  = {\r
-  ReportDispatcher\r
-};\r
-\r
-//\r
-// Report operation nest status.\r
-// If it is set, then the report operation has nested.\r
-//\r
-UINT32  mStatusCodeNestStatus = 0;\r
-\r
-/**\r
-  Entry point of DXE Status Code Driver.\r
-\r
-  This function is the entry point of this DXE Status Code Driver.\r
-  It installs Status Code Runtime Protocol, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
-\r
-  @param  ImageHandle       The firmware allocated handle for the EFI image.\r
-  @param  SystemTable       A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-StatusCodeRuntimeDxeEntry (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Dispatch initialization request to supported devices\r
-  //\r
-  InitializationDispatcherWorker ();\r
-\r
-  //\r
-  // Install Status Code Runtime Protocol implementation as defined in PI Specification.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &mHandle,\r
-                  &gEfiStatusCodeRuntimeProtocolGuid,\r
-                  &mEfiStatusCodeProtocol,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  VirtualAddressChangeCallBack,\r
-                  NULL,\r
-                  &gEfiEventVirtualAddressChangeGuid,\r
-                  &mVirtualAddressChangeEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Report status code to all supported device.\r
-\r
-  This function implements EFI_STATUS_CODE_PROTOCOL.ReportStatusCode().\r
-  It calls into the workers which dispatches the platform specific listeners.\r
-\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or software entity.\r
-                           This included information about the class and subclass that is used to\r
-                           classify the entity as well as an operation.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS      The function completed successfully\r
-  @retval EFI_DEVICE_ERROR The function should not be completed due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportDispatcher (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId  OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
-  )\r
-{\r
-  //\r
-  // Use atom operation to avoid the reentant of report.\r
-  // If current status is not zero, then the function is reentrancy.\r
-  //\r
-  if (InterlockedCompareExchange32 (&mStatusCodeNestStatus, 0, 1) == 1) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
-    SerialStatusCodeReportWorker (\r
-      CodeType,\r
-      Value,\r
-      Instance,\r
-      CallerId,\r
-      Data\r
-      );\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
-    RtMemoryStatusCodeReportWorker (\r
-      CodeType,\r
-      Value,\r
-      Instance\r
-      );\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
-    DataHubStatusCodeReportWorker (\r
-      CodeType,\r
-      Value,\r
-      Instance,\r
-      CallerId,\r
-      Data\r
-      );\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
-    //\r
-    // Call OEM hook status code library API to report status code to OEM device\r
-    //\r
-    OemHookStatusCodeReport (\r
-      CodeType,\r
-      Value,\r
-      Instance,\r
-      CallerId,\r
-      Data\r
-      );\r
-  }\r
-\r
-  //\r
-  // Restore the nest status of report\r
-  //\r
-  InterlockedCompareExchange32 (&mStatusCodeNestStatus, 1, 0);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Virtual address change notification call back. It converts global pointer\r
-  to virtual address.\r
-\r
-  @param  Event         Event whose notification function is being invoked.\r
-  @param  Context       Pointer to the notification function's context, which is\r
-                        always zero in current implementation.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-VirtualAddressChangeCallBack (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  //\r
-  // Convert memory status code table to virtual address;\r
-  //\r
-  EfiConvertPointer (\r
-    0,\r
-    (VOID **) &mRtMemoryStatusCodeTable\r
-    );\r
-}\r
-\r
-/**\r
-  Dispatch initialization request to sub status code devices based on\r
-  customized feature flags.\r
-\r
-**/\r
-VOID\r
-InitializationDispatcherWorker (\r
-  VOID\r
-  )\r
-{\r
-  EFI_PEI_HOB_POINTERS              Hob;\r
-  EFI_STATUS                        Status;\r
-  MEMORY_STATUSCODE_PACKET_HEADER   *PacketHeader;\r
-  MEMORY_STATUSCODE_RECORD          *Record;\r
-  UINTN                             Index;\r
-  UINTN                             MaxRecordNumber;\r
-\r
-  //\r
-  // If enable UseSerial, then initialize serial port.\r
-  // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r
-  // if enable UseDataHub, then initialize data hub status code worker.\r
-  //\r
-  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
-    //\r
-    // Call Serial Port Lib API to initialize serial port.\r
-    //\r
-    Status = SerialPortInitialize ();\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
-    Status = RtMemoryStatusCodeInitializeWorker ();\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
-    DataHubStatusCodeInitializeWorker ();\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
-    //\r
-    // Call OEM hook status code library API to initialize OEM device for status code.\r
-    //\r
-    Status = OemHookStatusCodeInitialize ();\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  //\r
-  // Replay Status code which saved in GUID'ed HOB to all supported devices.\r
-  //\r
-  if (FeaturePcdGet (PcdStatusCodeReplayIn)) {\r
-    //\r
-    // Journal GUID'ed HOBs to find all record entry, if found,\r
-    // then output record to support replay device.\r
-    //\r
-    Hob.Raw   = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
-    if (Hob.Raw != NULL) {\r
-      PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
-      Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
-      MaxRecordNumber = (UINTN) PacketHeader->RecordIndex;\r
-      if (PacketHeader->PacketIndex > 0) {\r
-        //\r
-        // Record has been wrapped around. So, record number has arrived at max number.\r
-        //\r
-        MaxRecordNumber = (UINTN) PacketHeader->MaxRecordsNumber;\r
-      }\r
-      for (Index = 0; Index < MaxRecordNumber; Index++) {\r
-        //\r
-        // Dispatch records to devices based on feature flag.\r
-        //\r
-        if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
-          SerialStatusCodeReportWorker (\r
-            Record[Index].CodeType,\r
-            Record[Index].Value,\r
-            Record[Index].Instance,\r
-            NULL,\r
-            NULL\r
-            );\r
-        }\r
-        if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
-          RtMemoryStatusCodeReportWorker (\r
-            Record[Index].CodeType,\r
-            Record[Index].Value,\r
-            Record[Index].Instance\r
-            );\r
-        }\r
-        if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
-          DataHubStatusCodeReportWorker (\r
-            Record[Index].CodeType,\r
-            Record[Index].Value,\r
-            Record[Index].Instance,\r
-            NULL,\r
-            NULL\r
-            );\r
-        }\r
-        if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
-          //\r
-          // Call OEM hook status code library API to report status code to OEM device\r
-          //\r
-          OemHookStatusCodeReport (\r
-            Record[Index].CodeType,\r
-            Record[Index].Value,\r
-            Record[Index].Instance,\r
-            NULL,\r
-            NULL\r
-            );\r
-        }\r
-      }\r
-    }\r
-  }\r
-}\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.h b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.h
deleted file mode 100644 (file)
index ef1711e..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/** @file\r
-  Internal include file of Status Code Runtime DXE Driver.\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __STATUS_CODE_RUNTIME_DXE_H__\r
-#define __STATUS_CODE_RUNTIME_DXE_H__\r
-\r
-\r
-#include <FrameworkDxe.h>\r
-#include <Guid/DataHubStatusCodeRecord.h>\r
-#include <Protocol/DataHub.h>\r
-#include <Guid/MemoryStatusCodeRecord.h>\r
-#include <Protocol/StatusCode.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Guid/EventGroup.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/SynchronizationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/OemHookStatusCodeLib.h>\r
-\r
-//\r
-// Data hub worker definition\r
-//\r
-#define DATAHUB_STATUS_CODE_SIGNATURE             SIGNATURE_32 ('B', 'D', 'H', 'S')\r
-\r
-typedef struct {\r
-  UINTN       Signature;\r
-  LIST_ENTRY  Node;\r
-  UINT8       Data[sizeof(DATA_HUB_STATUS_CODE_DATA_RECORD) + EFI_STATUS_CODE_DATA_MAX_SIZE];\r
-} DATAHUB_STATUSCODE_RECORD;\r
-\r
-\r
-extern RUNTIME_MEMORY_STATUSCODE_HEADER  *mRtMemoryStatusCodeTable;\r
-\r
-/**\r
-  Report status code to all supported device.\r
-\r
-  This function implements EFI_STATUS_CODE_PROTOCOL.ReportStatusCode().\r
-  It calls into the workers which dispatches the platform specific listeners.\r
-\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or software entity.\r
-                           This included information about the class and subclass that is used to\r
-                           classify the entity as well as an operation.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS      The function completed successfully\r
-  @retval EFI_DEVICE_ERROR The function should not be completed due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportDispatcher (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId  OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
-  );\r
-\r
-/**\r
-  Dispatch initialization request to sub status code devices based on\r
-  customized feature flags.\r
-\r
-**/\r
-VOID\r
-InitializationDispatcherWorker (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Locates Serial I/O Protocol as initialization for serial status code worker.\r
-\r
-  @retval EFI_SUCCESS  Serial I/O Protocol is successfully located.\r
-\r
-**/\r
-EFI_STATUS\r
-EfiSerialStatusCodeInitializeWorker (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
-\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or software entity.\r
-                           This included information about the class and subclass that is used to\r
-                           classify the entity as well as an operation.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS      Status code reported to serial I/O successfully.\r
-  @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
-  @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
-\r
-**/\r
-EFI_STATUS\r
-SerialStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId,\r
-  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  );\r
-\r
-/**\r
-  Initialize runtime memory status code table as initialization for runtime memory status code worker\r
-\r
-  @retval EFI_SUCCESS  Runtime memory status code table successfully initialized.\r
-\r
-**/\r
-EFI_STATUS\r
-RtMemoryStatusCodeInitializeWorker (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Report status code into runtime memory. If the runtime pool is full, roll back to the\r
-  first record and overwrite it.\r
-\r
-  @param  CodeType                Indicates the type of status code being reported.\r
-  @param  Value                   Describes the current status of a hardware or software entity.\r
-                                  This included information about the class and subclass that is used to\r
-                                  classify the entity as well as an operation.\r
-  @param  Instance                The enumeration of a hardware or software entity within\r
-                                  the system. Valid instance numbers start with 1.\r
-\r
-  @retval EFI_SUCCESS             Status code successfully recorded in runtime memory status code table.\r
-\r
-**/\r
-EFI_STATUS\r
-RtMemoryStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE               CodeType,\r
-  IN EFI_STATUS_CODE_VALUE              Value,\r
-  IN UINT32                             Instance\r
-  );\r
-\r
-/**\r
-  Locate Data Hub Protocol and create event for logging data\r
-  as initialization for data hub status code worker.\r
-\r
-  @retval EFI_SUCCESS  Initialization is successful.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeInitializeWorker (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Report status code into DataHub.\r
-\r
-  @param  CodeType             Indicates the type of status code being reported.\r
-  @param  Value                Describes the current status of a hardware or software entity.\r
-                               This included information about the class and subclass that is used to\r
-                               classify the entity as well as an operation.\r
-  @param  Instance             The enumeration of a hardware or software entity within\r
-                               the system. Valid instance numbers start with 1.\r
-  @param  CallerId             This optional parameter may be used to identify the caller.\r
-                               This parameter allows the status code driver to apply different rules to\r
-                               different callers.\r
-  @param  Data                 This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS          The function completed successfully.\r
-  @retval EFI_DEVICE_ERROR     Function is reentered.\r
-  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
-  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId,\r
-  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  );\r
-\r
-\r
-/**\r
-  Virtual address change notification call back. It converts global pointer\r
-  to virtual address.\r
-\r
-  @param  Event         Event whose notification function is being invoked.\r
-  @param  Context       Pointer to the notification function's context, which is\r
-                        always zero in current implementation.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-VirtualAddressChangeCallBack (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
deleted file mode 100644 (file)
index 2d1b465..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-## @file\r
-#  Status Code Runtime Dxe driver produces Status Code Runtime Protocol.\r
-#\r
-#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = StatusCodeRuntimeDxe\r
-  MODULE_UNI_FILE                = StatusCodeRuntimeDxe.uni\r
-  FILE_GUID                      = FEDE0A1B-BCA2-4A9F-BB2B-D9FD7DEC2E9F\r
-  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = StatusCodeRuntimeDxeEntry\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-#  VIRTUAL_ADDRESS_MAP_CALLBACK  =  VirtualAddressChangeCallBack\r
-#\r
-\r
-[Sources]\r
-  SerialStatusCodeWorker.c\r
-  RtMemoryStatusCodeWorker.c\r
-  DataHubStatusCodeWorker.c\r
-  StatusCodeRuntimeDxe.h\r
-  StatusCodeRuntimeDxe.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  OemHookStatusCodeLib\r
-  SerialPortLib\r
-  UefiRuntimeLib\r
-  MemoryAllocationLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  HobLib\r
-  PcdLib\r
-  PrintLib\r
-  ReportStatusCodeLib\r
-  DebugLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  SynchronizationLib\r
-\r
-\r
-[Guids]\r
-  gEfiDataHubStatusCodeRecordGuid               ## SOMETIMES_PRODUCES ## UNDEFINED # DataRecord Guid\r
-  gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_PRODUCES ## UNDEFINED # Record data type\r
-  gMemoryStatusCodeRecordGuid                   ## SOMETIMES_CONSUMES ## HOB\r
-  gEfiEventVirtualAddressChangeGuid             ## CONSUMES ## Event\r
-  gEfiStatusCodeDataTypeStringGuid              ## SOMETIMES_CONSUMES ## UNDEFINED\r
-\r
-[Protocols]\r
-  gEfiStatusCodeRuntimeProtocolGuid             ## PRODUCES\r
-  gEfiDataHubProtocolGuid                       ## SOMETIMES_CONSUMES # Needed if Data Hub is supported for status code\r
-\r
-[FeaturePcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeReplayIn              ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseOEM     ## CONSUMES\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseDataHub ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory             ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial             ## CONSUMES\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize |128| gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## SOMETIMES_CONSUMES\r
-\r
-[Depex]\r
-  TRUE\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  StatusCodeRuntimeDxeExtra.uni\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.uni b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.uni
deleted file mode 100644 (file)
index 7d6cb2e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file\r
-// Status Code Runtime Dxe driver produces Status Code Runtime Protocol.\r
-//\r
-// The Status Code Runtime DXE driver produces the Status Code Runtime Protocol.\r
-//\r
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Produces the Status Code Runtime Protocol"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "The Status Code Runtime DXE driver produces the Status Code Runtime Protocol."\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxeExtra.uni b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxeExtra.uni
deleted file mode 100644 (file)
index bd8a35b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file\r
-// StatusCodeRuntimeDxe Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// SPDX-License-Identifier: BSD-2-Clause-Patent\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Status Code Runtime DXE Driver"\r
-\r
-\r